From 589b2b4ca8af8a3b260c0dd33ddfdb0cc8ee8376 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Jan 2010 15:37:22 +0000 Subject: [PATCH] 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. --- release/scripts/modules/bpy_types.py | 13 +++++++++++++ release/scripts/ui/properties_object.py | 7 +++++++ source/blender/makesrna/intern/rna_ID.c | 1 + source/blender/makesrna/intern/rna_mesh.c | 14 ++++++-------- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index d890882b77c..2a757f83208 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -46,6 +46,19 @@ class Object(bpy_types.ID): 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: """ diff --git a/release/scripts/ui/properties_object.py b/release/scripts/ui/properties_object.py index 716c0340e2d..f24dda2ce8b 100644 --- a/release/scripts/ui/properties_object.py +++ b/release/scripts/ui/properties_object.py @@ -154,6 +154,8 @@ class OBJECT_PT_groups(ObjectButtonsPanel): 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 @@ class OBJECT_PT_groups(ObjectButtonsPanel): 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): diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index a250f0a49b4..e931f08c3a3 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -380,6 +380,7 @@ static void rna_def_ID(BlenderRNA *brna) 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); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index f8bfa105c12..56a1b170979 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -75,19 +75,17 @@ void rna_Mesh_update_draw(Main *bmain, Scene *scene, PointerRNA *ptr) 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)