- use a generic bone class so all 3 bone types (Edit/Pose/Armature) - can have the...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 24 Nov 2009 11:58:49 +0000 (11:58 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 24 Nov 2009 11:58:49 +0000 (11:58 +0000)
- change the wiki url to avoid redirects (from Luka)
- removed pose prefix from pose_head/pose_tail/pose_matrix

release/scripts/modules/bpy_types.py
release/scripts/ui/space_info.py
source/blender/editors/space_view3d/drawobject.c
source/blender/makesrna/intern/rna_pose.c

index 43af9a4dc8549e25db1c1e4bc0e735e3b86c12fa..13d48f05d187083dcbd25e0f77832c49a21c0e31 100644 (file)
@@ -41,28 +41,28 @@ class Object(bpy_types.ID):
         return [child for child in bpy.data.objects if child.parent == self]
 
 
-class PoseBone(StructRNA):
-
+class _GenericBone:
+    '''
+    functions for bones, common between Armature/Pose/Edit bones.
+    internal subclassing use only.
+    '''
     def parent_index(self, parent_test):
         '''
         The same as 'bone in other_bone.parent_recursive' but saved generating a list.
         '''
+        # use the name so different types can be tested.
+        name = parent_test.name
+        
         parent = self.parent
         i = 1
         while parent:
-            if parent == parent_test:
+            if parent.name == name:
                 return i
             parent = parent.parent
             i += 1
         
         return 0
 
-    @property
-    def children(self):
-        import bpy
-        obj = self.id_data
-        return [child for child in obj.pose.bones if child.parent == self]
-
     @property
     def parent_recursive(self):
         parent_list = []
@@ -75,12 +75,19 @@ class PoseBone(StructRNA):
             parent = parent.parent
         
         return parent_list
-    
+
+    @property
+    def length(self):
+        return (self.head - self.tail).length
+
+    @property
+    def children(self):
+        return [child for child in self._other_bones if child.parent == self]
+
     @property
     def children_recursive(self):
-        obj = self.id_data
         bones_children = []
-        for bone in obj.pose.bones:
+        for bone in self._other_bones:
             index = bone.parent_index(self)
             if index:
                 bones_children.append((index, bone))
@@ -89,11 +96,31 @@ class PoseBone(StructRNA):
         bones_children.sort(key=lambda bone_pair: bone_pair[0])
         return [bone for index, bone in bones_children]
 
-
-class Bone(StructRNA):
     @property
-    def length(self):
-        return (self.head - self.tail).length
+    def _other_bones(self):
+        id_data = self.id_data
+        id_data_type = type(id_data)
+        
+        if id_data_type == bpy_types.Object:
+            bones = id_data.pose.bones
+        elif id_data_type == bpy_types.Armature:
+            bones = id_data.edit_bones
+            if not bones: # not in editmode
+                bones = id_data.bones
+        
+        return bones
+
+
+class PoseBone(StructRNA, _GenericBone):
+    pass
+
+
+class Bone(StructRNA, _GenericBone):
+    pass
+
+
+class EditBone(StructRNA, _GenericBone):
+    pass
 
 
 def ord_ind(i1,i2):
index 0142805ca296f5fa129ca6e6b756f3c30203acd8..5eea68728d628b70afc2a5e9ce480cb199378cdc 100644 (file)
@@ -298,7 +298,7 @@ class HELP_OT_manual(HelpOperator):
     '''The Blender Wiki manual'''
     bl_idname = "help.manual"
     bl_label = "Manual"
-    _url = 'http://wiki.blender.org/index.php/Manual'
+    _url = 'http://wiki.blender.org/index.php/Doc:Manual'
 
 
 class HELP_OT_release_logs(HelpOperator):
index 496af5ef1b846f66467b783db56c3a8bf09eac3c..41eab057d4029b5528c7c8080820ebb8a0295a33 100644 (file)
@@ -4329,7 +4329,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj
 static void draw_sb_motion(Scene *scene, Object *ob)
 {
        SoftBody *sb = 0;
-       if (sb= ob->soft){
+       if ((sb= ob->soft)){
                if(sb->solverflags & SBSO_MONITOR ||sb->solverflags & SBSO_ESTIMATEIPO){
                        /* draw com */ 
                float rt[3][3],sc[3][3],tr[3][3]; 
index 5b5b331fea8310575490c0cad33e2b2c0afb500b..5b1f4dc42eddda37936fc63bbf8031e7c0a9ffdb 100644 (file)
@@ -675,7 +675,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Channel Matrix", "4x4 matrix, before constraints.");
        
-       prop= RNA_def_property(srna, "pose_matrix", PROP_FLOAT, PROP_MATRIX);
+       prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
        RNA_def_property_float_sdna(prop, NULL, "pose_mat");
        RNA_def_property_array(prop, 16);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE); 
@@ -689,11 +689,13 @@ static void rna_def_pose_channel(BlenderRNA *brna)
        */
        
        /* Head/Tail Coordinates (in Pose Space) - Automatically calculated... */
-       prop= RNA_def_property(srna, "pose_head", PROP_FLOAT, PROP_TRANSLATION);
+       prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION);
+       RNA_def_property_float_sdna(prop, NULL, "pose_head");
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Pose Head Position", "Location of head of the channel's bone.");
 
-       prop= RNA_def_property(srna, "pose_tail", PROP_FLOAT, PROP_TRANSLATION);
+       prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION);
+       RNA_def_property_float_sdna(prop, NULL, "pose_tail");
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone.");