Revision: 24860
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24860
Author:   campbellbarton
Date:     2009-11-24 12:58:49 +0100 (Tue, 24 Nov 2009)

Log Message:
-----------
- use a generic bone class so all 3 bone types (Edit/Pose/Armature) - can have 
the same utility functions, length, parent_recursive, parent_index(), etc
- change the wiki url to avoid redirects (from Luka)
- removed pose prefix from pose_head/pose_tail/pose_matrix

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy_types.py
    trunk/blender/release/scripts/ui/space_info.py
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/makesrna/intern/rna_pose.c

Modified: trunk/blender/release/scripts/modules/bpy_types.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_types.py  2009-11-24 11:48:16 UTC 
(rev 24859)
+++ trunk/blender/release/scripts/modules/bpy_types.py  2009-11-24 11:58:49 UTC 
(rev 24860)
@@ -41,16 +41,22 @@
         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
@@ -58,12 +64,6 @@
         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 = []
         parent = self.parent
@@ -75,12 +75,19 @@
             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,13 +96,33 @@
         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):
     if i1<i2: return i1,i2
     return i2,i1

Modified: trunk/blender/release/scripts/ui/space_info.py
===================================================================
--- trunk/blender/release/scripts/ui/space_info.py      2009-11-24 11:48:16 UTC 
(rev 24859)
+++ trunk/blender/release/scripts/ui/space_info.py      2009-11-24 11:58:49 UTC 
(rev 24860)
@@ -298,7 +298,7 @@
     '''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):

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c      
2009-11-24 11:48:16 UTC (rev 24859)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c      
2009-11-24 11:58:49 UTC (rev 24860)
@@ -4329,7 +4329,7 @@
 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]; 

Modified: trunk/blender/source/blender/makesrna/intern/rna_pose.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_pose.c     2009-11-24 
11:48:16 UTC (rev 24859)
+++ trunk/blender/source/blender/makesrna/intern/rna_pose.c     2009-11-24 
11:58:49 UTC (rev 24860)
@@ -675,7 +675,7 @@
        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 @@
        */
        
        /* 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.");
        


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to