[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25705] trunk/blender: object.group_users, object.scene_users

Campbell Barton ideasman42 at gmail.com
Mon Jan 4 16:37:22 CET 2010


Revision: 25705
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25705
Author:   campbellbarton
Date:     2010-01-04 16:37:22 +0100 (Mon, 04 Jan 2010)

Log Message:
-----------
object.group_users, object.scene_users
utility functions to find the groups and scenes this object is used in.

button to set the group location from the cursor (UI is horrible but not any nice place to add?)

smarp project would fail if there were linked meshes in the scene, made ID.tag ignore the library, so you can tag linked data since its only for tools to use.

normalize the vertex normal before setting and use inline vector functions.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy_types.py
    trunk/blender/release/scripts/ui/properties_object.py
    trunk/blender/source/blender/makesrna/intern/rna_ID.c
    trunk/blender/source/blender/makesrna/intern/rna_mesh.c

Modified: trunk/blender/release/scripts/modules/bpy_types.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_types.py	2010-01-04 15:25:21 UTC (rev 25704)
+++ trunk/blender/release/scripts/modules/bpy_types.py	2010-01-04 15:37:22 UTC (rev 25705)
@@ -46,7 +46,20 @@
         import bpy
         return [child for child in bpy.data.objects if child.parent == self]
 
+    @property
+    def group_users(self):
+        """The groups this object is in"""
+        import bpy
+        name = self.name
+        return [group for group in bpy.data.groups if name in group.objects]
 
+    @property
+    def scene_users(self):
+        """The scenes this object is in"""
+        import bpy
+        name = self.name
+        return [scene for scene in bpy.data.scenes if name in scene.objects]
+
 class _GenericBone:
     """
     functions for bones, common between Armature/Pose/Edit bones.

Modified: trunk/blender/release/scripts/ui/properties_object.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_object.py	2010-01-04 15:25:21 UTC (rev 25704)
+++ trunk/blender/release/scripts/ui/properties_object.py	2010-01-04 15:37:22 UTC (rev 25705)
@@ -154,6 +154,8 @@
         else:
             layout.operator_menu_enum("object.group_add", "group")
 
+        index = 0
+        value = str(tuple(context.scene.cursor_location))
         for group in bpy.data.groups:
             if ob.name in group.objects:
                 col = layout.column(align=True)
@@ -172,6 +174,11 @@
                 if wide_ui:
                     col = split.column()
                 col.prop(group, "dupli_offset", text="")
+                
+                prop = col.operator("wm.context_set_value", text="From Cursor")
+                prop.path = "object.group_users[%d].dupli_offset" % index
+                prop.value = value
+                index += 1
 
 
 class OBJECT_PT_display(ObjectButtonsPanel):

Modified: trunk/blender/source/blender/makesrna/intern/rna_ID.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_ID.c	2010-01-04 15:25:21 UTC (rev 25704)
+++ trunk/blender/source/blender/makesrna/intern/rna_ID.c	2010-01-04 15:37:22 UTC (rev 25705)
@@ -380,6 +380,7 @@
 
 	prop= RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_DOIT);
+	RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
 	RNA_def_property_ui_text(prop, "Tag", "Tools can use this to tag data, (initial state is undefined).");
 
 	prop= RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE);

Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mesh.c	2010-01-04 15:25:21 UTC (rev 25704)
+++ trunk/blender/source/blender/makesrna/intern/rna_mesh.c	2010-01-04 15:37:22 UTC (rev 25705)
@@ -75,19 +75,17 @@
 static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
 {
 	MVert *mvert= (MVert*)ptr->data;
-
-	value[0]= mvert->no[0]/32767.0f;
-	value[1]= mvert->no[1]/32767.0f;
-	value[2]= mvert->no[2]/32767.0f;
+	normal_short_to_float_v3(value, mvert->no);
 }
 
-static void rna_MeshVertex_normal_set(PointerRNA *ptr, float *value)
+static void rna_MeshVertex_normal_set(PointerRNA *ptr, const float *value)
 {
 	MVert *mvert= (MVert*)ptr->data;
+	float no[3];
 
-	mvert->no[0] = (short) (value[0] * 32767.0f);
-	mvert->no[1] = (short) (value[1] * 32767.0f);
-	mvert->no[2] = (short) (value[2] * 32767.0f);
+	copy_v3_v3(no, value);
+	normalize_v3(no);
+	normal_float_to_short_v3(mvert->no, no);
 }
 
 static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr)





More information about the Bf-blender-cvs mailing list