Page Menu
Home
Search
Configure Global Search
Log In
Files
F2419
patch-2230.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Ken Hughes (khughes)
Nov 13 2013, 1:04 PM
Size
4 KB
Subscribers
None
patch-2230.txt
View Options
Index: source/blender/python/api2_2x/Bone.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Bone.c,v
retrieving revision 1.27
diff -u -r1.27 Bone.c
--- source/blender/python/api2_2x/Bone.c 22 May 2005 17:40:00 -0000 1.27
+++ source/blender/python/api2_2x/Bone.c 12 Jun 2005 05:15:16 -0000
@@ -1672,6 +1672,7 @@
char *local = "worldspace";
char *bonespace = "bonespace";
char *worldspace = "worldspace";
+ char *parentspace = "parentspace";
PyObject *matrix;
float delta[3];
float root[3];
@@ -1681,40 +1682,59 @@
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string" ) );
- if( !BLI_streq( local, bonespace ) && !BLI_streq( local, worldspace ) )
+ if( !BLI_streq( local, bonespace ) && !BLI_streq( local, worldspace ) &&
+ !BLI_streq( local, parentspace ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected 'bonespace' or 'worldspace'" ) );
+ "expected 'bonespace', 'worldspace', or 'parentspace'" ) );
matrix = newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
- if( !self->bone ) { //test to see if linked to armature
- //use python vars
+ if( !self->bone ) { /* test to see if linked to armature */
+ /* use python vars */
if( BLI_streq( local, worldspace ) ) {
VecSubf( delta, self->tail->vec, self->head->vec );
make_boneMatrixvr( (float ( * )[4]) *( ( MatrixObject * ) matrix )->
matrix, delta, self->roll );
- } else if( BLI_streq( local, bonespace ) ) {
+ } else
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"bone not yet linked to an armature....'" ) );
- }
} else {
- //use bone datastruct
+ /* use bone datastruct */
if( BLI_streq( local, worldspace ) ) {
get_objectspace_bone_matrix( self->bone,
( float ( * )[4] ) *( ( MatrixObject * )
- matrix )->matrix, 1,
- 1 );
+ matrix )->matrix, 1, 1 );
} else if( BLI_streq( local, bonespace ) ) {
VecSubf( delta, self->bone->tail, self->bone->head );
make_boneMatrixvr( (float ( * )[4]) *( ( MatrixObject * ) matrix )->
matrix, delta, self->bone->roll );
if( self->bone->parent ) {
get_bone_root_pos( self->bone, root, 1 );
- get_bone_root_pos( self->bone->parent, p_root,
- 1 );
+ get_bone_root_pos( self->bone->parent, p_root, 1 );
VecSubf( delta, root, p_root );
- VECCOPY( ( ( MatrixObject * ) matrix )->
- matrix[3], delta );
+ VECCOPY( ( ( MatrixObject * ) matrix )->matrix[3], delta );
+ }
+ } else { /* must be 'parentspace' */
+ int i;
+
+ /* copy the current object matrix */
+
+ for (i = 0; i< 4; ++i )
+ VECCOPY( ( ( MatrixObject * ) matrix )->matrix[i],
+ self->bone->obmat[i] );
+ if( self->bone->parent ) {
+
+ /* get length of parent */
+
+ VecSubf ( root, self->bone->parent->tail,
+ self->bone->parent->head );
+ p_root[1] = VecLength ( root );
+ p_root[0] = p_root[2] = p_root[3] = 0;
+
+ /* add relative offset of this bone's head */
+
+ VecAddf ( delta, p_root, self->bone->head );
+ VECCOPY( ( ( MatrixObject * ) matrix )-> matrix[3], delta );
}
}
}
Index: source/blender/python/api2_2x/doc/Bone.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Bone.py,v
retrieving revision 1.3
diff -u -r1.3 Bone.py
--- source/blender/python/api2_2x/doc/Bone.py 8 Jun 2004 04:41:02 -0000 1.3
+++ source/blender/python/api2_2x/doc/Bone.py 12 Jun 2005 05:15:16 -0000
@@ -305,16 +305,21 @@
def getRestMatrix(locale = 'worldspace'):
"""
Return a matrix that represents the rotation and position of this bone.
- There are two types of matrices that can be returned:
+ There are three types of matrices that can be returned:
1. bonespace (in the coord. system of parent) or
2. worldspace (in the coord system of blender).
+ 3. parent (also in the coord system of parent).
- The rotation will be in either worldspace or bonespace. Translation vectors
- (row 4) will be the bone's head position (if worldspace) or the difference
- from this bone's head to the parent head (if bonespace).
+ The rotation will be in either worldspace, bonespace or parentspace.
+ Translation vectors (row 4) will be the bone's head position (if
+ worldspace), or the difference from this bone's head to the parent
+ head in blender's coordinate system (if bonespace), or
+ the difference from this bone's head to the parent
+ head in the parent's coordinate system (if parentspace).
@type locale: string. Values are:
@param locale: possible values are:
- worldspace (default)
- bonespace
+ - parentspace
@rtype: 4x4 PyMatrix
"""
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1b/f9/402e371b12a7335fec90bf6d60fe
Event Timeline
Log In to Comment