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.
This commit is contained in:
Campbell Barton 2010-01-04 15:37:22 +00:00
parent 61a8f370f5
commit 589b2b4ca8
4 changed files with 27 additions and 8 deletions

@ -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:
"""

@ -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):

@ -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);

@ -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)