Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-06-26 02:45:42 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-06-26 02:45:42 +0400
commitee61785384b9fa351d57b0803ab1ab44c8498016 (patch)
tree205be39142a6cca2205b2cdd1eb05e56ad7904aa
parent4d141cf80821fa0dc9533f24583fbf7e53eab5b4 (diff)
A step toward a new user-friendly GUI for manipulating line style parameters.
This commit is just meant to give the new GUI framework a concrete shape. There is no usefulness in newly introduced elements at the moment. Freestyle options in render layers now include a pull-down menu named Control Mode that allows you to choose either the Python Scripting or Parameter Editor mode. The Python Scripting mode is the conventional way of controlling Freestyle by directly using style modules written in Python. The Parameter Editor is a new control mode that is intended to be used by everyone without relying on Python programming. In the Parameter Editor mode, you can specify multiple line sets for each render layer. A line set defines feature edge selection criteria, as well as a line style for drawing the selected feature edges using specific line stylization parameters. Line style is a new datablock type, meaning that a line style can be shared by multiple line sets (possibly those in different render layers in different scenes). Much more additions are anticipated in subsequent commits to implement UI controls for specifying feature edge selection criteria and line stylization parameters.
-rw-r--r--release/scripts/ui/properties_render.py91
-rw-r--r--source/blender/blenkernel/BKE_linestyle.h42
-rw-r--r--source/blender/blenkernel/BKE_main.h1
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c7
-rw-r--r--source/blender/blenkernel/intern/library.c14
-rw-r--r--source/blender/blenkernel/intern/linestyle.c58
-rw-r--r--source/blender/blenkernel/intern/scene.c2
-rw-r--r--source/blender/blenloader/intern/readblenentry.c1
-rw-r--r--source/blender/blenloader/intern/readfile.c28
-rw-r--r--source/blender/blenloader/intern/writefile.c18
-rw-r--r--source/blender/editors/interface/interface_templates.c4
-rw-r--r--source/blender/editors/render/render_intern.h7
-rw-r--r--source/blender/editors/render/render_ops.c7
-rw-r--r--source/blender/editors/render/render_shading.c140
-rw-r--r--source/blender/freestyle/FRS_freestyle.h13
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp106
-rw-r--r--source/blender/makesdna/DNA_ID.h1
-rw-r--r--source/blender/makesdna/DNA_freestyle_types.h36
-rw-r--r--source/blender/makesrna/RNA_access.h3
-rw-r--r--source/blender/makesrna/RNA_types.h1
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt1
-rw-r--r--source/blender/makesrna/intern/SConscript1
-rw-r--r--source/blender/makesrna/intern/makesrna.c1
-rw-r--r--source/blender/makesrna/intern/rna_ID.c3
-rw-r--r--source/blender/makesrna/intern/rna_internal.h2
-rw-r--r--source/blender/makesrna/intern/rna_linestyle.c57
-rw-r--r--source/blender/makesrna/intern/rna_main.c7
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c41
-rw-r--r--source/blender/makesrna/intern/rna_scene.c102
29 files changed, 737 insertions, 58 deletions
diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py
index f18a93aee2c..ee98803bbfe 100644
--- a/release/scripts/ui/properties_render.py
+++ b/release/scripts/ui/properties_render.py
@@ -69,6 +69,27 @@ class RENDER_PT_render(RenderButtonsPanel):
layout.prop(rd, "display_mode", text="Display")
+class RENDER_PT_freestyle_linestyle(RenderButtonsPanel):
+ bl_label = "Freestyle Line Style"
+ COMPAT_ENGINES = {'BLENDER_RENDER'}
+
+ def poll(self, context):
+ rd = context.scene.render
+ rl = rd.layers[rd.active_layer_index]
+ return rl and rl.freestyle and rl.freestyle_settings.active_lineset
+
+ def draw(self, context):
+ layout = self.layout
+
+ rd = context.scene.render
+ rl = rd.layers[rd.active_layer_index]
+ linestyle = rl.freestyle_settings.active_lineset.linestyle
+
+ split = layout.split()
+ col = split.column()
+ col.prop(linestyle, "name")
+
+
class RENDER_PT_layers(RenderButtonsPanel):
bl_label = "Layers"
bl_default_closed = True
@@ -182,26 +203,55 @@ class RENDER_PT_layers(RenderButtonsPanel):
col = split.column()
col.label(text="Freestyle:")
freestyle = rl.freestyle_settings
- col.prop(freestyle, "crease_angle", text="Crease Angle")
- col.prop(freestyle, "sphere_radius", text="Sphere Radius")
- col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
- col.prop(freestyle, "suggestive_contours", text="Suggestive Contours")
- col.prop(freestyle, "material_boundaries", text="Material Boundaries")
- col.prop(freestyle, "dkr_epsilon", text="Dkr Epsilon")
-
- col.operator("scene.freestyle_module_add", text="Add Style Module")
-
- for i, module in enumerate(freestyle.modules):
- box = layout.box()
- box.set_context_pointer("freestyle_module", module)
- row = box.row(align=True)
- row.prop(module, "is_displayed", text="")
- row.prop(module, "module_path", text="")
- row.operator("scene.freestyle_module_remove", icon='X', text="")
- props = row.operator("scene.freestyle_module_move_up", icon='MOVE_UP_VEC', text="")
- props.active = (i > 0)
- props = row.operator("scene.freestyle_module_move_down", icon='MOVE_DOWN_VEC', text="")
- props.active = (i < len(freestyle.modules) - 1)
+ col.prop(freestyle, "mode", text="Control Mode")
+ if freestyle.mode == "EDITOR":
+
+ lineset = freestyle.active_lineset
+
+ col.label(text="Line Sets:")
+
+ row = col.row()
+ rows = 2
+ if lineset:
+ rows = 5
+ # FIXME: scrollbar does not work correctly
+ row.template_list(freestyle, "linesets", freestyle, "active_lineset_index", rows=rows)
+
+ sub = row.column()
+
+ subsub = sub.column(align=True)
+ subsub.operator("scene.freestyle_lineset_add", icon='ZOOMIN', text="")
+ subsub.operator("scene.freestyle_lineset_remove", icon='ZOOMOUT', text="")
+
+ if lineset:
+ sub.separator()
+
+ subsub = sub.column(align=True)
+ subsub.operator("scene.freestyle_lineset_move", icon='TRIA_UP', text="").direction = 'UP'
+ subsub.operator("scene.freestyle_lineset_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+
+ col.prop(lineset, "name")
+ col.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new")
+
+ else:
+ col.prop(freestyle, "crease_angle", text="Crease Angle")
+ col.prop(freestyle, "sphere_radius", text="Sphere Radius")
+ col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
+ col.prop(freestyle, "suggestive_contours", text="Suggestive Contours")
+ col.prop(freestyle, "material_boundaries", text="Material Boundaries")
+ col.prop(freestyle, "dkr_epsilon", text="Dkr Epsilon")
+
+ col.operator("scene.freestyle_module_add", text="Add Style Module")
+
+ for i, module in enumerate(freestyle.modules):
+ box = layout.box()
+ box.set_context_pointer("freestyle_module", module)
+ row = box.row(align=True)
+ row.prop(module, "is_displayed", text="")
+ row.prop(module, "module_path", text="")
+ row.operator("scene.freestyle_module_remove", icon='X', text="")
+ row.operator("scene.freestyle_module_move", icon='TRIA_UP', text="").direction = 'UP'
+ row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
class RENDER_PT_shading(RenderButtonsPanel):
@@ -706,6 +756,7 @@ classes = [
RENDER_MT_ffmpeg_presets,
RENDER_PT_render,
RENDER_PT_layers,
+ RENDER_PT_freestyle_linestyle,
RENDER_PT_dimensions,
RENDER_PT_antialiasing,
RENDER_PT_motion_blur,
diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h
new file mode 100644
index 00000000000..df7808c1a2b
--- /dev/null
+++ b/source/blender/blenkernel/BKE_linestyle.h
@@ -0,0 +1,42 @@
+/* BKE_linestyle.h
+ *
+ *
+ * $Id: BKE_particle.h 29187 2010-06-03 15:39:02Z kjym3 $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2010 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BKE_LINESTYLE_H
+#define BKE_LINESTYLE_H
+
+#include "DNA_freestyle_types.h"
+
+struct Main;
+
+FreestyleLineStyle *FRS_new_linestyle(char *name, struct Main *main);
+void FRS_free_linestyle(FreestyleLineStyle *linestyle);
+
+#endif
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index d4d76b2e6e1..d576556f13c 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -78,6 +78,7 @@ typedef struct Main {
ListBase particle;
ListBase wm;
ListBase gpencil;
+ ListBase linestyle;
} Main;
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 10c2c1801cb..28eed5a27e8 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -466,6 +466,7 @@ void BKE_animdata_main_cb (Main *main, ID_AnimData_Edit_Callback func, void *use
ANIMDATA_IDS_CB(main->particle.first); /* particles */
ANIMDATA_IDS_CB(main->object.first); /* objects */
ANIMDATA_IDS_CB(main->world.first); /* worlds */
+ ANIMDATA_IDS_CB(main->linestyle.first); /* linestyles */
/* scenes */
for (id= main->scene.first; id; id= id->next) {
@@ -542,6 +543,9 @@ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newNa
/* worlds */
RENAMEFIX_ANIM_IDS(mainptr->world.first);
+ /* linestyles */
+ RENAMEFIX_ANIM_IDS(mainptr->linestyle.first);
+
/* scenes */
for (id= mainptr->scene.first; id; id= id->next) {
AnimData *adt= BKE_animdata_from_id(id);
@@ -1890,6 +1894,9 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
/* particles */
EVAL_ANIM_IDS(main->particle.first, ADT_RECALC_ANIM);
+ /* linestyles */
+ EVAL_ANIM_IDS(main->linestyle.first, ADT_RECALC_ANIM);
+
/* objects */
/* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets
* this tagged by Depsgraph on framechange. This optimisation means that objects
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 5931bf973af..02118d4a3ef 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -99,6 +99,7 @@
#include "BKE_particle.h"
#include "BKE_gpencil.h"
#include "BKE_fcurve.h"
+#include "BKE_linestyle.h"
#define MAX_IDPUP 60 /* was 24 */
@@ -226,6 +227,8 @@ int id_make_local(ID *id, int test)
return 0; /* can't be linked */
case ID_GD:
return 0; /* not implemented */
+ case ID_LS:
+ return 0; /* not implemented */
}
return 0;
@@ -315,6 +318,8 @@ int id_copy(ID *id, ID **newid, int test)
return 0; /* can't be copied from here */
case ID_GD:
return 0; /* not implemented */
+ case ID_LS:
+ return 0; /* not implemented */
}
return 0;
@@ -413,6 +418,8 @@ ListBase *which_libbase(Main *mainlib, short type)
return &(mainlib->wm);
case ID_GD:
return &(mainlib->gpencil);
+ case ID_LS:
+ return &(mainlib->linestyle);
}
return 0;
}
@@ -493,6 +500,7 @@ int set_listbasepointers(Main *main, ListBase **lb)
lb[a++]= &(main->library);
lb[a++]= &(main->wm);
lb[a++]= &(main->gpencil);
+ lb[a++]= &(main->linestyle);
lb[a]= NULL;
@@ -601,6 +609,9 @@ static ID *alloc_libblock_notest(short type)
case ID_GD:
id = MEM_callocN(sizeof(bGPdata), "Grease Pencil");
break;
+ case ID_LS:
+ id = MEM_callocN(sizeof(FreestyleLineStyle), "Freestyle Line Style");
+ break;
}
return id;
}
@@ -806,6 +817,9 @@ void free_libblock(ListBase *lb, void *idv)
case ID_GD:
free_gpencil_data((bGPdata *)id);
break;
+ case ID_LS:
+ FRS_free_linestyle((FreestyleLineStyle *)id);
+ break;
}
if (id->properties) {
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
new file mode 100644
index 00000000000..0abf83fe422
--- /dev/null
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -0,0 +1,58 @@
+/* linestyle.c
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2010 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_linestyle.h"
+#include "BKE_main.h"
+
+FreestyleLineStyle *FRS_new_linestyle(char *name, struct Main *main)
+{
+ FreestyleLineStyle *linestyle;
+
+ if (!main)
+ main = G.main;
+
+ linestyle = (FreestyleLineStyle *)alloc_libblock(&main->linestyle, ID_LS, name);
+
+ /* todo: default parameter settings */
+
+ return linestyle;
+}
+
+void FRS_free_linestyle(FreestyleLineStyle *linestyle)
+{
+
+}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index c85276cd2a2..6d195dc0838 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -266,7 +266,7 @@ void free_scene(Scene *sce)
}
for(srl= sce->r.layers.first; srl; srl= srl->next) {
- BLI_freelistN( &srl->freestyleConfig.modules);
+ FRS_free_freestyle_config(srl);
}
BLI_freelistN(&sce->markers);
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 38e9a584952..30eb09c0b61 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -91,6 +91,7 @@ static IDType idtypes[]= {
{ ID_KE, "Key", "keys", 0},
{ ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE},
{ ID_LI, "Library", "libraries", 0},
+ { ID_LS, "FreestyleLineStyle", "linestyles", 0},
{ ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE},
{ ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE},
{ ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE},
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3fb20f16acf..5cc2676d80e 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4132,6 +4132,7 @@ static void lib_link_scene(FileData *fd, Main *main)
Base *base, *next;
Sequence *seq;
SceneRenderLayer *srl;
+ FreestyleLineSet *fls;
TimeMarker *marker;
sce= main->scene.first;
@@ -4213,6 +4214,9 @@ static void lib_link_scene(FileData *fd, Main *main)
for(srl= sce->r.layers.first; srl; srl= srl->next) {
srl->mat_override= newlibadr_us(fd, sce->id.lib, srl->mat_override);
srl->light_override= newlibadr_us(fd, sce->id.lib, srl->light_override);
+ for(fls=srl->freestyleConfig.linesets.first; fls; fls= fls->next) {
+ fls->linestyle= newlibadr_us(fd, sce->id.lib, fls->linestyle);
+ }
}
/*Game Settings: Dome Warp Text*/
sce->gm.dome.warptext= newlibadr(fd, sce->id.lib, sce->gm.dome.warptext);
@@ -4433,6 +4437,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
for(srl= sce->r.layers.first; srl; srl= srl->next) {
link_list(fd, &(srl->freestyleConfig.modules));
}
+ for(srl= sce->r.layers.first; srl; srl= srl->next) {
+ link_list(fd, &(srl->freestyleConfig.linesets));
+ }
sce->nodetree= newdataadr(fd, sce->nodetree);
if(sce->nodetree)
@@ -5362,6 +5369,14 @@ static void lib_link_group(FileData *fd, Main *main)
}
}
+/* ************ READ LINE STYLE ***************** */
+
+static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
+{
+
+}
+
+
/* ************** GENERAL & MAIN ******************** */
@@ -5395,6 +5410,7 @@ static char *dataname(short id_code)
case ID_BR: return "Data from BR";
case ID_PA: return "Data from PA";
case ID_GD: return "Data from GD";
+ case ID_LS: return "Data from LS";
}
return "Data from Lib Block";
@@ -5561,6 +5577,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
case ID_GD:
direct_link_gpencil(fd, (bGPdata *)id);
break;
+ case ID_LS:
+ direct_link_linestyle(fd, (FreestyleLineStyle *)id);
+ break;
}
/*link direct data of ID properties*/
@@ -11878,6 +11897,11 @@ static void expand_sound(FileData *fd, Main *mainvar, bSound *snd)
expand_doit(fd, mainvar, snd->ipo); // XXX depreceated - old animation system
}
+static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *linestyle)
+{
+
+}
+
static void expand_main(FileData *fd, Main *mainvar)
{
@@ -11958,6 +11982,10 @@ static void expand_main(FileData *fd, Main *mainvar)
break;
case ID_PA:
expand_particlesettings(fd, mainvar, (ParticleSettings *)id);
+ break;
+ case ID_LS:
+ expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id);
+ break;
}
doit= 1;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index af9ae820c73..faa6a131e8f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1787,6 +1787,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
TransformOrientation *ts;
SceneRenderLayer *srl;
FreestyleModuleConfig *fmc;
+ FreestyleLineSet *fls;
ToolSettings *tos;
sce= scebase->first;
@@ -1918,6 +1919,11 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
writestruct(wd, DATA, "FreestyleModuleConfig", 1, fmc);
}
+ for(fls= srl->freestyleConfig.linesets.first; fls; fls = fls->next) {
+ writestruct(wd, DATA, "FreestyleLineSet", 1, fls);
+ writestruct(wd, DATA, "FreestyleLineStyle", 1, fls->linestyle);
+ }
+
}
if(sce->nodetree) {
@@ -2368,6 +2374,17 @@ static void write_scripts(WriteData *wd, ListBase *idbase)
}
}
+static void write_linestyles(WriteData *wd, ListBase *idbase)
+{
+ FreestyleLineStyle *linestyle;
+
+ for(linestyle=idbase->first; linestyle; linestyle= linestyle->id.next) {
+ if(linestyle->id.us>0 || wd->current) {
+ writestruct(wd, ID_LS, "FreestyleLineStyle", 1, linestyle);
+ }
+ }
+}
+
/* context is usually defined by WM, two cases where no WM is available:
* - for forward compatibility, curscreen has to be saved
* - for undofile, curscene needs to be saved */
@@ -2457,6 +2474,7 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
write_brushes (wd, &mainvar->brush);
write_scripts (wd, &mainvar->script);
write_gpencils (wd, &mainvar->gpencil);
+ write_linestyles(wd, &mainvar->linestyle);
write_libraries(wd, mainvar->next);
if (write_user_block) {
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index fb515d55854..93529d31fcf 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -116,6 +116,8 @@ void uiTemplateDopeSheetFilter(uiLayout *layout, bContext *C, PointerRNA *ptr)
uiItemR(row, ptr, "display_armature", 0, "", 0);
if (mainptr && mainptr->particle.first)
uiItemR(row, ptr, "display_particle", 0, "", 0);
+ if (mainptr && mainptr->linestyle.first)
+ uiItemR(row, ptr, "display_linestyle", 0, "", 0);
/* group-based filtering (only when groups are available */
if (mainptr && mainptr->group.first) {
@@ -2137,7 +2139,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
uiBlockSetEmboss(block, UI_EMBOSS);
uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, ptr, "use_textures", i, 0, 0, 0, 0, NULL);
}
- else if(RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer)) {
+ else if(RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer) || itemptr->type == &RNA_FreestyleLineSet) {
uiItemL(sub, name, icon);
uiBlockSetEmboss(block, UI_EMBOSS);
uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "enabled", 0, 0, 0, 0, 0, NULL);
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h
index 11c2ff6e6f4..2f0ce71a4e5 100644
--- a/source/blender/editors/render/render_intern.h
+++ b/source/blender/editors/render/render_intern.h
@@ -52,8 +52,11 @@ void SCENE_OT_render_layer_add(struct wmOperatorType *ot);
void SCENE_OT_render_layer_remove(struct wmOperatorType *ot);
void SCENE_OT_freestyle_module_add(struct wmOperatorType *ot);
void SCENE_OT_freestyle_module_remove(struct wmOperatorType *ot);
-void SCENE_OT_freestyle_module_move_up(struct wmOperatorType *ot);
-void SCENE_OT_freestyle_module_move_down(struct wmOperatorType *ot);
+void SCENE_OT_freestyle_module_move(struct wmOperatorType *ot);
+void SCENE_OT_freestyle_lineset_add(struct wmOperatorType *ot);
+void SCENE_OT_freestyle_lineset_remove(struct wmOperatorType *ot);
+void SCENE_OT_freestyle_lineset_move(struct wmOperatorType *ot);
+void SCENE_OT_freestyle_linestyle_new(struct wmOperatorType *ot);
void TEXTURE_OT_slot_copy(struct wmOperatorType *ot);
diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c
index b3375bcc371..5a228ba5242 100644
--- a/source/blender/editors/render/render_ops.c
+++ b/source/blender/editors/render/render_ops.c
@@ -59,8 +59,11 @@ void ED_operatortypes_render(void)
WM_operatortype_append(SCENE_OT_freestyle_module_add);
WM_operatortype_append(SCENE_OT_freestyle_module_remove);
- WM_operatortype_append(SCENE_OT_freestyle_module_move_up);
- WM_operatortype_append(SCENE_OT_freestyle_module_move_down);
+ WM_operatortype_append(SCENE_OT_freestyle_module_move);
+ WM_operatortype_append(SCENE_OT_freestyle_lineset_add);
+ WM_operatortype_append(SCENE_OT_freestyle_lineset_remove);
+ WM_operatortype_append(SCENE_OT_freestyle_lineset_move);
+ WM_operatortype_append(SCENE_OT_freestyle_linestyle_new);
#if (defined(WITH_QUICKTIME) && !defined(USE_QTKIT))
WM_operatortype_append(SCENE_OT_render_data_set_quicktime_codec);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index e96eae49f33..36a62919b5a 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -761,70 +761,164 @@ void SCENE_OT_freestyle_module_remove(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int freestyle_module_move_up_exec(bContext *C, wmOperator *op)
+static int freestyle_module_move_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
FreestyleModuleConfig *module= ptr.data;
- int active = RNA_boolean_get(op->ptr, "active");
-
- if(active)
- FRS_move_up_module(&srl->freestyleConfig, module);
+ int dir= RNA_enum_get(op->ptr, "direction");
+ if (dir == 1) {
+ FRS_move_module_up(&srl->freestyleConfig, module);
+ } else {
+ FRS_move_module_down(&srl->freestyleConfig, module);
+ }
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
return OPERATOR_FINISHED;
}
-void SCENE_OT_freestyle_module_move_up(wmOperatorType *ot)
+void SCENE_OT_freestyle_module_move(wmOperatorType *ot)
{
+ static EnumPropertyItem direction_items[] = {
+ {1, "UP", 0, "Up", ""},
+ {-1, "DOWN", 0, "Down", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
/* identifiers */
- ot->name= "Move Up Freestyle Module";
- ot->idname= "SCENE_OT_freestyle_module_move_up";
- ot->description="Move the style module up in the stack.";
+ ot->name= "Move Freestyle Module";
+ ot->idname= "SCENE_OT_freestyle_module_move";
+ ot->description="Change the position of the style module within in the list of style modules.";
/* api callbacks */
- ot->exec= freestyle_module_move_up_exec;
+ ot->exec= freestyle_module_move_exec;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
- RNA_def_boolean(ot->srna, "active", 0, "Active", "True if the operator is enabled.");
+ RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN");
}
-static int freestyle_module_move_down_exec(bContext *C, wmOperator *op)
+static int freestyle_lineset_add_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
+
+ FRS_add_lineset(&srl->freestyleConfig);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Add Line Set";
+ ot->idname= "SCENE_OT_freestyle_lineset_add";
+ ot->description="Add a line set into the list of line sets.";
+
+ /* api callbacks */
+ ot->exec= freestyle_lineset_add_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int freestyle_lineset_remove_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
- PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
- FreestyleModuleConfig *module= ptr.data;
- int active = RNA_boolean_get(op->ptr, "active");
- if(active)
- FRS_move_down_module(&srl->freestyleConfig, module);
+ FRS_delete_active_lineset(&srl->freestyleConfig);
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
return OPERATOR_FINISHED;
}
-void SCENE_OT_freestyle_module_move_down(wmOperatorType *ot)
+void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Move Down Freestyle Module";
- ot->idname= "SCENE_OT_freestyle_module_move_down";
- ot->description="Move the style module down in the stack.";
+ ot->name= "Remove Line Set";
+ ot->idname= "SCENE_OT_freestyle_lineset_remove";
+ ot->description="Remove the active line set from the list of line sets.";
/* api callbacks */
- ot->exec= freestyle_module_move_down_exec;
+ ot->exec= freestyle_lineset_remove_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int freestyle_lineset_move_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
+ int dir= RNA_enum_get(op->ptr, "direction");
+
+ if (dir == 1) {
+ FRS_move_active_lineset_up(&srl->freestyleConfig);
+ } else {
+ FRS_move_active_lineset_down(&srl->freestyleConfig);
+ }
+ WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot)
+{
+ static EnumPropertyItem direction_items[] = {
+ {1, "UP", 0, "Up", ""},
+ {-1, "DOWN", 0, "Down", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name= "Move Line Set";
+ ot->idname= "SCENE_OT_freestyle_lineset_move";
+ ot->description="Change the position of the active line set within the list of line sets.";
+
+ /* api callbacks */
+ ot->exec= freestyle_lineset_move_exec;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
- RNA_def_boolean(ot->srna, "active", 0, "Active", "True if the operator is enabled.");
+ RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN");
+}
+
+static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
+ FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig);
+
+ lineset->linestyle->id.us--;
+ lineset->linestyle = FRS_new_linestyle("LineStyle", NULL);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_linestyle_new(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "New Line Style";
+ ot->idname= "SCENE_OT_freestyle_linestyle_new";
+ ot->description="Create a new line style, reusable by multiple line sets.";
+
+ /* api callbacks */
+ ot->exec= freestyle_linestyle_new_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int texture_slot_move(bContext *C, wmOperator *op)
diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h
index cd07d2dfc11..98f7f820715 100644
--- a/source/blender/freestyle/FRS_freestyle.h
+++ b/source/blender/freestyle/FRS_freestyle.h
@@ -28,9 +28,18 @@ extern "C" {
// Panel configuration
void FRS_add_module(FreestyleConfig *config);
void FRS_delete_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
- void FRS_move_up_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
- void FRS_move_down_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
+ void FRS_move_module_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
+ void FRS_move_module_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
+ void FRS_add_lineset(FreestyleConfig *config);
+ void FRS_delete_active_lineset(FreestyleConfig *config);
+ void FRS_move_active_lineset_up(FreestyleConfig *config);
+ void FRS_move_active_lineset_down(FreestyleConfig *config);
+
+ FreestyleLineSet *FRS_get_active_lineset(FreestyleConfig *config);
+ short FRS_get_active_lineset_index(FreestyleConfig *config);
+ void FRS_set_active_lineset_index(FreestyleConfig *config, short index);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 5af350e3ad0..3aa399f4af3 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -17,6 +17,9 @@ extern "C" {
#include "DNA_camera_types.h"
#include "DNA_freestyle_types.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_linestyle.h"
#include "BKE_main.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
@@ -310,15 +313,26 @@ extern "C" {
{
FreestyleConfig* config = &srl->freestyleConfig;
+ config->mode = FREESTYLE_CONTROL_SCRIPT_MODE;
+
config->modules.first = config->modules.last = NULL;
config->flags = 0;
config->sphere_radius = 1.0;
config->dkr_epsilon = 0.001;
config->crease_angle = 134.43;
+
+ config->linesets.first = config->linesets.last = NULL;
}
void FRS_free_freestyle_config( SceneRenderLayer* srl )
{
+ FreestyleLineSet *lineset;
+
+ for(lineset=(FreestyleLineSet *)srl->freestyleConfig.linesets.first; lineset; lineset=lineset->next) {
+ lineset->linestyle->id.us--;
+ lineset->linestyle = NULL;
+ }
+ BLI_freelistN( &srl->freestyleConfig.linesets );
BLI_freelistN( &srl->freestyleConfig.modules );
}
@@ -336,16 +350,100 @@ extern "C" {
BLI_freelinkN(&config->modules, module_conf);
}
- void FRS_move_up_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
+ void FRS_move_module_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
{
BLI_remlink(&config->modules, module_conf);
- BLI_insertlink(&config->modules, module_conf->prev->prev, module_conf);
+ BLI_insertlinkbefore(&config->modules, module_conf->prev, module_conf);
}
- void FRS_move_down_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
+ void FRS_move_module_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
{
BLI_remlink(&config->modules, module_conf);
- BLI_insertlink(&config->modules, module_conf->next, module_conf);
+ BLI_insertlinkafter(&config->modules, module_conf->next, module_conf);
+ }
+
+ void FRS_add_lineset(FreestyleConfig *config)
+ {
+ int lineset_index = BLI_countlist(&config->linesets);
+
+ FreestyleLineSet *lineset = (FreestyleLineSet *) MEM_callocN( sizeof(FreestyleLineSet), "Freestyle line set");
+ BLI_addtail(&config->linesets, (void *) lineset);
+ FRS_set_active_lineset_index(config, lineset_index);
+
+ lineset->linestyle = FRS_new_linestyle("LineStyle", NULL);
+ lineset->flags |= FREESTYLE_LINESET_ENABLED;
+ if (lineset_index > 0)
+ sprintf(lineset->name, "LineSet %i", lineset_index+1);
+ else
+ strcpy(lineset->name, "LineSet");
+ BLI_uniquename(&config->linesets, lineset, "FreestyleLineSet", '.', offsetof(FreestyleLineSet, name), sizeof(lineset->name));
+ }
+
+ void FRS_delete_active_lineset(FreestyleConfig *config)
+ {
+ FreestyleLineSet *lineset = FRS_get_active_lineset(config);
+
+ if (lineset) {
+ lineset->linestyle->id.us--;
+ lineset->linestyle = NULL;
+ BLI_remlink(&config->linesets, lineset);
+ MEM_freeN(lineset);
+ FRS_set_active_lineset_index(config, 0);
+ }
+ }
+
+ void FRS_move_active_lineset_up(FreestyleConfig *config)
+ {
+ FreestyleLineSet *lineset = FRS_get_active_lineset(config);
+
+ if (lineset) {
+ BLI_remlink(&config->linesets, lineset);
+ BLI_insertlinkbefore(&config->linesets, lineset->prev, lineset);
+ }
+ }
+
+ void FRS_move_active_lineset_down(FreestyleConfig *config)
+ {
+ FreestyleLineSet *lineset = FRS_get_active_lineset(config);
+
+ if (lineset) {
+ BLI_remlink(&config->linesets, lineset);
+ BLI_insertlinkafter(&config->linesets, lineset->next, lineset);
+ }
+ }
+
+ FreestyleLineSet *FRS_get_active_lineset(FreestyleConfig *config)
+ {
+ FreestyleLineSet *lineset;
+
+ for(lineset=(FreestyleLineSet *)config->linesets.first; lineset; lineset=lineset->next)
+ if(lineset->flags & FREESTYLE_LINESET_CURRENT)
+ return lineset;
+ return NULL;
+ }
+
+ short FRS_get_active_lineset_index(FreestyleConfig *config)
+ {
+ FreestyleLineSet *lineset;
+ short i;
+
+ for(lineset=(FreestyleLineSet *)config->linesets.first, i=0; lineset; lineset=lineset->next, i++)
+ if(lineset->flags & FREESTYLE_LINESET_CURRENT)
+ return i;
+ return 0;
+ }
+
+ void FRS_set_active_lineset_index(FreestyleConfig *config, short index)
+ {
+ FreestyleLineSet *lineset;
+ short i;
+
+ for(lineset=(FreestyleLineSet *)config->linesets.first, i=0; lineset; lineset=lineset->next, i++) {
+ if(i == index)
+ lineset->flags |= FREESTYLE_LINESET_CURRENT;
+ else
+ lineset->flags &= ~FREESTYLE_LINESET_CURRENT;
+ }
}
#ifdef __cplusplus
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 7c3641db379..b8b35c6ba10 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -186,6 +186,7 @@ typedef struct PreviewImage {
#define ID_PA MAKE_ID2('P', 'A') /* ParticleSettings */
#define ID_GD MAKE_ID2('G', 'D') /* GreasePencil */
#define ID_WM MAKE_ID2('W', 'M') /* WindowManager */
+#define ID_LS MAKE_ID2('L', 'S') /* FreestyleLineStyle */
/* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
#define ID_SEQ MAKE_ID2('S', 'Q')
diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h
index c49a47fc22a..8444f6bd29a 100644
--- a/source/blender/makesdna/DNA_freestyle_types.h
+++ b/source/blender/makesdna/DNA_freestyle_types.h
@@ -2,11 +2,39 @@
#define DNA_FREESTYLE_TYPES_H
#include "DNA_listBase.h"
+#include "DNA_ID.h"
+/* FreestyleConfig::flags */
#define FREESTYLE_SUGGESTIVE_CONTOURS_FLAG 1
#define FREESTYLE_RIDGES_AND_VALLEYS_FLAG 2
#define FREESTYLE_MATERIAL_BOUNDARIES_FLAG 4
+/* FreestyleConfig::mode */
+#define FREESTYLE_CONTROL_SCRIPT_MODE 1
+#define FREESTYLE_CONTROL_EDITOR_MODE 2
+
+/* FreestyleLineSet::flags */
+#define FREESTYLE_LINESET_CURRENT 1
+#define FREESTYLE_LINESET_ENABLED 2
+
+typedef struct FreestyleLineStyle {
+ ID id;
+
+} FreestyleLineStyle;
+
+typedef struct FreestyleLineSet {
+ struct FreestyleLineSet *next, *prev;
+
+ char name[32]; /* line set name */
+ int flags;
+ int pad;
+
+ FreestyleLineStyle *linestyle; /* line style */
+
+ ListBase objects; /* target objects on which stylized lines are drawn */
+
+} FreestyleLineSet;
+
typedef struct FreestyleModuleConfig {
struct FreestyleModuleConfig *next, *prev;
@@ -19,14 +47,16 @@ typedef struct FreestyleModuleConfig {
typedef struct FreestyleConfig {
ListBase modules;
- int flags;
+ int mode; /* scripting, editor */
+ int flags; /* suggestive contours, ridges/valleys, material boundaries */
float sphere_radius;
float dkr_epsilon;
float crease_angle;
+ int pad;
-} FreestyleConfig;
-
+ ListBase linesets;
+} FreestyleConfig;
#endif
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 82f9fcad788..8e12ad588d0 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -219,7 +219,10 @@ extern StructRNA RNA_FModifierNoise;
extern StructRNA RNA_FModifierPython;
extern StructRNA RNA_FModifierStepped;
extern StructRNA RNA_FollowPathConstraint;
+extern StructRNA RNA_FreestyleLineStyle;
+extern StructRNA RNA_FreestyleLineSet;
extern StructRNA RNA_FreestyleModuleSettings;
+extern StructRNA RNA_FreestyleSettings;
extern StructRNA RNA_Function;
extern StructRNA RNA_GameBooleanProperty;
extern StructRNA RNA_GameFloatProperty;
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 88058769f4b..1f08f76661c 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -343,6 +343,7 @@ typedef struct ExtensionRNA {
#define MainLamps Main
#define MainLattices Main
#define MainLibraries Main
+#define MainLineStyles Main
#define MainMaterials Main
#define MainMeshes Main
#define MainMetaBalls Main
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 9b824279d8d..3af93f70572 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -52,6 +52,7 @@ INCLUDE_DIRECTORIES(
../../gpu
../../imbuf
../../render/extern/include
+ ../../freestyle
. )
FILE(GLOB INC_FILES ../*.h ../../makesdna/*.h)
diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript
index 6b50daa5486..5bf0762466f 100644
--- a/source/blender/makesrna/intern/SConscript
+++ b/source/blender/makesrna/intern/SConscript
@@ -33,6 +33,7 @@ incs = '#/intern/guardedalloc ../../blenlib ../../blenkernel'
incs += ' ../../imbuf ../../makesdna ../../makesrna ../../ikplugin'
incs += ' ../../windowmanager ../../editors/include'
incs += ' ../../render/extern/include'
+incs += ' ../../freestyle'
incs += ' #/intern/audaspace/intern'
if env['WITH_BF_OPENEXR']:
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 2914bc96a70..386ae0c10c2 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2256,6 +2256,7 @@ RNAProcessItem PROCESS_ITEMS[]= {
{"rna_key.c", NULL, RNA_def_key},
{"rna_lamp.c", NULL, RNA_def_lamp},
{"rna_lattice.c", NULL, RNA_def_lattice},
+ {"rna_linestyle.c", NULL, RNA_def_linestyle},
{"rna_main.c", "rna_main_api.c", RNA_def_main},
{"rna_material.c", "rna_material_api.c", RNA_def_material},
{"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh},
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 009afec2ded..d07432c96fa 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -50,6 +50,7 @@ EnumPropertyItem id_type_items[] = {
{ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""},
{ID_LA, "LAMP", ICON_LAMP_DATA, "Lamp", ""},
{ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""},
+ {ID_LS, "LINESTYLE", ICON_PARTICLE_DATA, "FreestyleLineStyle", ""}, /* FIXME proper icon */
{ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""},
{ID_MA, "MATERIAL", ICON_MATERIAL_DATA, "Material", ""},
{ID_MB, "META", ICON_META_DATA, "MetaBall", ""},
@@ -117,6 +118,7 @@ short RNA_type_to_ID_code(StructRNA *type)
if(RNA_struct_is_a(type, &RNA_Key)) return ID_KE;
if(RNA_struct_is_a(type, &RNA_Lamp)) return ID_LA;
if(RNA_struct_is_a(type, &RNA_Library)) return ID_LI;
+ if(RNA_struct_is_a(type, &RNA_FreestyleLineStyle)) return ID_LS;
if(RNA_struct_is_a(type, &RNA_Lattice)) return ID_LT;
if(RNA_struct_is_a(type, &RNA_Material)) return ID_MA;
if(RNA_struct_is_a(type, &RNA_MetaBall)) return ID_MB;
@@ -150,6 +152,7 @@ StructRNA *ID_code_to_RNA_type(short idcode)
case ID_KE: return &RNA_Key;
case ID_LA: return &RNA_Lamp;
case ID_LI: return &RNA_Library;
+ case ID_LS: return &RNA_FreestyleLineStyle;
case ID_LT: return &RNA_Lattice;
case ID_MA: return &RNA_Material;
case ID_MB: return &RNA_MetaBall;
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 3f2bb60fba1..899902683bd 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -141,6 +141,7 @@ void RNA_def_image(struct BlenderRNA *brna);
void RNA_def_key(struct BlenderRNA *brna);
void RNA_def_lamp(struct BlenderRNA *brna);
void RNA_def_lattice(struct BlenderRNA *brna);
+void RNA_def_linestyle(struct BlenderRNA *brna);
void RNA_def_main(struct BlenderRNA *brna);
void RNA_def_material(struct BlenderRNA *brna);
void RNA_def_mesh(struct BlenderRNA *brna);
@@ -262,6 +263,7 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop);
+void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop);
/* ID Properties */
diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c
new file mode 100644
index 00000000000..f686d0cecda
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_linestyle.c
@@ -0,0 +1,57 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "RNA_define.h"
+
+#include "rna_internal.h"
+
+#include "DNA_freestyle_types.h"
+
+#include "WM_types.h"
+#include "WM_api.h"
+
+#ifdef RNA_RUNTIME
+
+#else
+
+static void rna_def_linestyle(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna= RNA_def_struct(brna, "FreestyleLineStyle", "ID");
+ RNA_def_struct_ui_text(srna, "Freestyle Line Style", "Freestyle line style, reusable by multiple line sets");
+
+}
+
+void RNA_def_linestyle(BlenderRNA *brna)
+{
+ rna_def_linestyle(brna);
+}
+
+#endif
+
diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c
index 052c9fb3453..c2f3953e627 100644
--- a/source/blender/makesrna/intern/rna_main.c
+++ b/source/blender/makesrna/intern/rna_main.c
@@ -239,6 +239,12 @@ static void rna_Main_wm_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
rna_iterator_listbase_begin(iter, &bmain->wm, NULL);
}
+static void rna_Main_linestyle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ Main *bmain= (Main*)ptr->data;
+ rna_iterator_listbase_begin(iter, &bmain->linestyle, NULL);
+}
+
#ifdef UNIT_TEST
static PointerRNA rna_Test_test_get(PointerRNA *ptr)
@@ -300,6 +306,7 @@ void RNA_def_main(BlenderRNA *brna)
{"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks.", RNA_def_main_actions},
{"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks.", RNA_def_main_particles},
{"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks.", RNA_def_main_gpencil},
+ {"linestyles", "FreestyleLineStyle", "rna_Main_linestyle_begin", "Line Styles", "Line Style datablocks.", RNA_def_main_linestyles},
{NULL, NULL, NULL, NULL, NULL, NULL}};
int i;
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 0dbaaa87a99..9e8f60af439 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -57,6 +57,7 @@
#include "BKE_particle.h"
#include "BKE_font.h"
#include "BKE_node.h"
+#include "BKE_linestyle.h"
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
@@ -452,6 +453,22 @@ void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSetting
/* XXX python now has invalid pointer? */
}
+FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, char* name)
+{
+ FreestyleLineStyle *linestyle = FRS_new_linestyle(name, bmain);
+ linestyle->id.us--;
+ return linestyle;
+}
+void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineStyle *linestyle)
+{
+ if(ID_REAL_USERS(linestyle) <= 0)
+ free_libblock(&bmain->linestyle, linestyle);
+ else
+ BKE_reportf(reports, RPT_ERROR, "Line style \"%s\" must have zero users to be removed, found %d.", linestyle->id.name+2, ID_REAL_USERS(linestyle));
+
+ /* XXX python now has invalid pointer? */
+}
+
#else
void RNA_api_main(StructRNA *srna)
@@ -1015,6 +1032,30 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
{
}
+void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "MainLineStyles");
+ srna= RNA_def_struct(brna, "MainLineStyles", NULL);
+ RNA_def_struct_ui_text(srna, "Main Line Styles", "Collection of line styles");
+
+ func= RNA_def_function(srna, "new", "rna_Main_linestyles_new");
+ RNA_def_function_ui_description(func, "Add a new line style instance to the main database");
+ parm= RNA_def_string(func, "name", "FreestyleLineStyle", 0, "", "New name for the datablock.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* return type */
+ parm= RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "New line style datablock.");
+ RNA_def_function_return(func, parm);
+
+ func= RNA_def_function(srna, "remove", "rna_Main_linestyles_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove a line style instance from the current blendfile.");
+ parm= RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "Line style to remove.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+}
#endif
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 56fd8de2250..3859ac5b834 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -173,6 +173,8 @@ EnumPropertyItem image_type_items[] = {
#include "RE_pipeline.h"
+#include "FRS_freestyle.h"
+
static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
@@ -904,6 +906,49 @@ static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *m
MEM_freeN(marker);
}
+static PointerRNA rna_FreestyleLineSet_linestyle_get(PointerRNA *ptr)
+{
+ FreestyleLineSet *lineset= (FreestyleLineSet *)ptr->data;
+
+ return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineStyle, lineset->linestyle);
+}
+
+static void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value)
+{
+ FreestyleLineSet *lineset= (FreestyleLineSet*)ptr->data;
+
+ lineset->linestyle->id.us--;
+ lineset->linestyle = (FreestyleLineStyle *)value.data;
+ lineset->linestyle->id.us++;
+}
+
+static PointerRNA rna_FreestyleSettings_active_lineset_get(PointerRNA *ptr)
+{
+ FreestyleConfig *config= (FreestyleConfig *)ptr->data;
+ FreestyleLineSet *lineset= FRS_get_active_lineset(config);
+ return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineSet, lineset);
+}
+
+static void rna_FreestyleSettings_active_lineset_index_range(PointerRNA *ptr, int *min, int *max)
+{
+ FreestyleConfig *config= (FreestyleConfig *)ptr->data;
+ *min= 0;
+ *max= BLI_countlist(&config->linesets)-1;
+ *max= MAX2(0, *max);
+}
+
+static int rna_FreestyleSettings_active_lineset_index_get(PointerRNA *ptr)
+{
+ FreestyleConfig *config= (FreestyleConfig *)ptr->data;
+ return FRS_get_active_lineset_index(config);
+}
+
+static void rna_FreestyleSettings_active_lineset_index_set(PointerRNA *ptr, int value)
+{
+ FreestyleConfig *config= (FreestyleConfig *)ptr->data;
+ FRS_set_active_lineset_index(config, value);
+}
+
#else
static void rna_def_transform_orientation(BlenderRNA *brna)
@@ -1490,6 +1535,41 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem freestyle_ui_mode_items[] = {
+ {FREESTYLE_CONTROL_SCRIPT_MODE, "SCRIPT", 0, "Python Scripting Mode", "Advanced mode for using style modules in Python"},
+ {FREESTYLE_CONTROL_EDITOR_MODE, "EDITOR", 0, "Parameter Editor Mode", "Basic mode for interactive style parameter editing"},
+ {0, NULL, 0, NULL, NULL}};
+
+ /* FreestyleLineSet */
+
+ srna= RNA_def_struct(brna, "FreestyleLineSet", NULL);
+ RNA_def_struct_ui_text(srna, "Freestyle Line Set", "Line set for associating lines and style parameters.");
+
+ /* access to line style settings is redirected through functions */
+ /* to allow proper id-buttons functionality */
+ prop= RNA_def_property(srna, "linestyle", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "FreestyleLineStyle");
+ RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL);
+ RNA_def_property_pointer_funcs(prop, "rna_FreestyleLineSet_linestyle_get", "rna_FreestyleLineSet_linestyle_set", NULL);
+ RNA_def_property_ui_text(prop, "Line Style", "Line style settings");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Line Set Name", "Line set name");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+ RNA_def_struct_name_property(srna, prop);
+
+ prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_LINESET_ENABLED);
+ RNA_def_property_ui_text(prop, "Enabled", "Enable or disable the line set.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "objects", NULL);
+ RNA_def_property_struct_type(prop, "Object");
+ RNA_def_property_ui_text(prop, "Target objects", "A list of objects on which stylized lines are drawn.");
+
/* FreestyleModuleSettings */
srna= RNA_def_struct(brna, "FreestyleModuleSettings", NULL);
@@ -1518,6 +1598,12 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "FreestyleModuleSettings");
RNA_def_property_ui_text(prop, "Style modules", "A list of style modules (to be applied from top to bottom).");
+ prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, freestyle_ui_mode_items);
+ RNA_def_property_ui_text(prop, "Control Mode", "Select the Freestyle control mode");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
prop= RNA_def_property(srna, "suggestive_contours", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_SUGGESTIVE_CONTOURS_FLAG);
RNA_def_property_ui_text(prop, "Suggestive Contours", "Enable suggestive contours.");
@@ -1550,6 +1636,22 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 180.0);
RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold in degrees (between 0 and 180) for detecting crease edges.");
RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "linesets", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "linesets", NULL);
+ RNA_def_property_struct_type(prop, "FreestyleLineSet");
+ RNA_def_property_ui_text(prop, "Line Sets", "Line sets for associating lines and style parameters");
+
+ prop= RNA_def_property(srna, "active_lineset", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "FreestyleLineSet");
+ RNA_def_property_pointer_funcs(prop, "rna_FreestyleSettings_active_lineset_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Active Line Set", "Active line set being displayed");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "active_lineset_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_funcs(prop, "rna_FreestyleSettings_active_lineset_index_get", "rna_FreestyleSettings_active_lineset_index_set", "rna_FreestyleSettings_active_lineset_index_range");
+ RNA_def_property_ui_text(prop, "Active Line Set Index", "Index of active line set slot");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
}
static void rna_def_scene_game_data(BlenderRNA *brna)