[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33434] branches/soc-2008-mxcurioni: New feature edge selection criterion based on object groups.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Fri Dec 3 00:50:10 CET 2010


Revision: 33434
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33434
Author:   kjym3
Date:     2010-12-03 00:50:10 +0100 (Fri, 03 Dec 2010)

Log Message:
-----------
New feature edge selection criterion based on object groups.

The Freestyle tab in the Render buttons has a couple of new
options "Group" and "Group Negation".  The Group option specifies
a group of objects (defined through the Groups tab in the Object
buttons), while the Group Negation value is either INCLUSIVE or
EXCLUSIVE.  If INCLUSIVE, feature edges belonging to some object
in the group are selected.  Otherwise, those feature edges not
belonging to any object in the group are selected.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
    branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py
    branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c
    branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h
    branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c

Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py	2010-12-02 22:58:23 UTC (rev 33433)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py	2010-12-02 23:50:10 UTC (rev 33434)
@@ -299,6 +299,19 @@
         upred = bpred(upred, p)
     return upred
 
+class ObjectNamesUP1D(UnaryPredicate1D):
+    def __init__(self, names, negative):
+        UnaryPredicate1D.__init__(self)
+        self._names = names
+        self._negative = negative
+    def getName(self):
+        return "ObjectNamesUP1D"
+    def __call__(self, viewEdge):
+        found = viewEdge.viewShape().getName() in self._names
+        if self._negative:
+            return not found
+        return found
+
 # Stroke caps
 
 def iter_stroke_vertices(stroke):
@@ -506,6 +519,12 @@
             if lineset.edge_type_negation == "EXCLUSIVE":
                 upred = NotUP1D(upred)
             selection_criteria.append(upred)
+    # prepare selection criteria by group of objects
+    if lineset.select_by_group:
+        if lineset.group is not None and len(lineset.group.objects) > 0:
+            names = dict((ob.name, True) for ob in lineset.group.objects)
+            upred = ObjectNamesUP1D(names, lineset.group_negation == 'EXCLUSIVE')
+            selection_criteria.append(upred)
     # do feature edge selection
     upred = join_unary_predicates(selection_criteria, AndUP1D)
     if upred is None:

Modified: branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py	2010-12-02 22:58:23 UTC (rev 33433)
+++ branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py	2010-12-02 23:50:10 UTC (rev 33434)
@@ -220,20 +220,19 @@
 
             if lineset:
                 col.prop(lineset, "name")
+
                 col.prop(lineset, "select_by_visibility")
-                col.prop(lineset, "select_by_edge_types")
-
                 if lineset.select_by_visibility:
-                    col.label(text="Visibility:")
                     sub = col.row(align=True)
                     sub.prop(lineset, "visibility", expand=True)
                     if lineset.visibility == "RANGE":
                         sub = col.row(align=True)
                         sub.prop(lineset, "qi_start")
                         sub.prop(lineset, "qi_end")
+                    col.separator() # XXX
 
+                col.prop(lineset, "select_by_edge_types")
                 if lineset.select_by_edge_types:
-                    col.label(text="Edge Types:")
                     row = col.row()
                     row.prop(lineset, "edge_type_negation", expand=True)
                     row = col.row()
@@ -251,7 +250,14 @@
                     sub = row.column()
                     sub.prop(lineset, "select_contour")
                     sub.prop(lineset, "select_external_contour")
+                    col.separator() # XXX
 
+                col.prop(lineset, "select_by_group")
+                if lineset.select_by_group:
+                    col.prop(lineset, "group")
+                    row = col.row()
+                    row.prop(lineset, "group_negation", expand=True)
+
         else: # freestyle.mode == "SCRIPT"
 
             col.prop(freestyle, "use_smoothness")

Modified: branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c	2010-12-02 22:58:23 UTC (rev 33433)
+++ branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c	2010-12-02 23:50:10 UTC (rev 33434)
@@ -4243,6 +4243,7 @@
 				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);
+					fls->group= newlibadr_us(fd, sce->id.lib, fls->group);
 				}
 			}
 			/*Game Settings: Dome Warp Text*/

Modified: branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c	2010-12-02 22:58:23 UTC (rev 33433)
+++ branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c	2010-12-02 23:50:10 UTC (rev 33434)
@@ -1895,6 +1895,7 @@
 			for(fls= srl->freestyleConfig.linesets.first; fls; fls = fls->next) {
 				writestruct(wd, DATA, "FreestyleLineSet", 1, fls);
 				writestruct(wd, DATA, "FreestyleLineStyle", 1, fls->linestyle);
+				writestruct(wd, DATA, "Group", 1, fls->group);
 			}
 
 		}

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2010-12-02 22:58:23 UTC (rev 33433)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2010-12-02 23:50:10 UTC (rev 33434)
@@ -444,7 +444,7 @@
 		lineset->qi_start = 0;
 		lineset->qi_end = 100;
 		lineset->edge_types = 0;
-		lineset->objects.first = lineset->objects.last = NULL;
+		lineset->group = NULL;
 		if (lineset_index > 0)
 			sprintf(lineset->name, "LineSet %i", lineset_index+1);
 		else

Modified: branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h	2010-12-02 22:58:23 UTC (rev 33433)
+++ branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h	2010-12-02 23:50:10 UTC (rev 33434)
@@ -50,10 +50,12 @@
 #define FREESTYLE_LINESET_ENABLED  2
 #define FREESTYLE_LINESET_FE_NOT   4
 #define FREESTYLE_LINESET_FE_AND   8
+#define FREESTYLE_LINESET_GR_NOT   16
 
 /* FreestyleLineSet::selection */
 #define FREESTYLE_SEL_VISIBILITY  1
 #define FREESTYLE_SEL_EDGE_TYPES  2
+#define FREESTYLE_SEL_GROUP       4
 
 /* FreestyleLineSet::fedge_types */
 #define FREESTYLE_FE_SILHOUETTE          1
@@ -82,11 +84,10 @@
 	short pad1;
 	int qi_start, qi_end;
 	int edge_types; /* feature edge types */
+	struct Group *group; /* group of target objects */
 
 	struct FreestyleLineStyle *linestyle;
 
-	ListBase objects; /* target objects on which stylized lines are drawn */
-
 } FreestyleLineSet;
 
 typedef struct FreestyleModuleConfig {

Modified: branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c	2010-12-02 22:58:23 UTC (rev 33433)
+++ branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c	2010-12-02 23:50:10 UTC (rev 33434)
@@ -1641,16 +1641,21 @@
 	StructRNA *srna;
 	PropertyRNA *prop;
 
-	static EnumPropertyItem negation_items[] = {
+	static EnumPropertyItem edge_type_negation_items[] = {
 		{0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given edge type conditions."},
 		{FREESTYLE_LINESET_FE_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not satisfying the given edge type conditions."},
 		{0, NULL, 0, NULL, NULL}};
 
-	static EnumPropertyItem combination_items[] = {
+	static EnumPropertyItem edge_type_combination_items[] = {
 		{0, "OR", 0, "Logical OR", "Combine feature edge type conditions by logical OR (logical disjunction)."},
 		{FREESTYLE_LINESET_FE_AND, "AND", 0, "Logical AND", "Combine feature edge type conditions by logical AND (logical conjunction)."},
 		{0, NULL, 0, NULL, NULL}};
 
+	static EnumPropertyItem group_negation_items[] = {
+		{0, "INCLUSIVE", 0, "Inclusive", "Select feature edges belonging to some object in the group."},
+		{FREESTYLE_LINESET_GR_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not belonging to any object in the group."},
+		{0, NULL, 0, NULL, NULL}};
+
 	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"},
@@ -1697,23 +1702,36 @@
 	RNA_def_property_ui_text(prop, "Selection by Edge Types", "Select feature edges based on edge types.");
 	RNA_def_property_update(prop, NC_SCENE, NULL);
 
+	prop= RNA_def_property(srna, "select_by_group", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_GROUP);
+	RNA_def_property_ui_text(prop, "Selection by Group", "Select feature edges based on a group of objects.");
+	RNA_def_property_update(prop, NC_SCENE, NULL);
+
 	prop= RNA_def_property(srna, "edge_type_negation", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
-	RNA_def_property_enum_items(prop, negation_items);
+	RNA_def_property_enum_items(prop, edge_type_negation_items);
 	RNA_def_property_ui_text(prop, "Edge Type Negation", "Set the negation operation for conditions on feature edge types.");
 	RNA_def_property_update(prop, NC_SCENE, NULL);
 
 	prop= RNA_def_property(srna, "edge_type_combination", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
-	RNA_def_property_enum_items(prop, combination_items);
+	RNA_def_property_enum_items(prop, edge_type_combination_items);
 	RNA_def_property_ui_text(prop, "Edge Type Combination", "Set the combination operation for conditions on feature edge types.");
 	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.");
+	prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "group");
+	RNA_def_property_struct_type(prop, "Group");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list