Page MenuHome

BoneSpace.patch

Authored By
alex mole (lordbosh)
Nov 13 2013, 12:59 PM
Size
4 KB
Subscribers
None

BoneSpace.patch

Index: Bone.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Bone.c,v
retrieving revision 1.25
diff -u -r1.25 Bone.c
--- Bone.c 9 Mar 2005 19:45:55 -0000 1.25
+++ Bone.c 7 Apr 2005 08:05:09 -0000
@@ -1672,26 +1672,29 @@
char *local = "worldspace";
char *bonespace = "bonespace";
char *worldspace = "worldspace";
+ const char *parentspace = "parentspace";
PyObject *matrix;
float delta[3];
float root[3];
float p_root[3];
+ float restmat[4][4];
if( !PyArg_ParseTuple( args, "|s", &local ) )
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 );
+ matrix = newMatrixObject( NULL, 4, 4 );
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 )->
+ make_boneMatrixvr( *( ( MatrixObject * ) matrix )->
matrix, delta, self->roll );
} else if( BLI_streq( local, bonespace ) ) {
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -1701,12 +1704,12 @@
//use bone datastruct
if( BLI_streq( local, worldspace ) ) {
get_objectspace_bone_matrix( self->bone,
- ( float ( * )[4] ) *( ( MatrixObject * )
+ *( ( MatrixObject * )
matrix )->matrix, 1,
1 );
} else if( BLI_streq( local, bonespace ) ) {
VecSubf( delta, self->bone->tail, self->bone->head );
- make_boneMatrixvr( (float ( * )[4]) *( ( MatrixObject * ) matrix )->
+ make_boneMatrixvr( *( ( MatrixObject * ) matrix )->
matrix, delta, self->bone->roll );
if( self->bone->parent ) {
get_bone_root_pos( self->bone, root, 1 );
@@ -1716,8 +1719,23 @@
VECCOPY( ( ( MatrixObject * ) matrix )->
matrix[3], delta );
}
+ } else if( BLI_streq( local, parentspace ) ) {
+ /* This is hugely unoptimal, but there doesn't seem to be a variant
+ * of get_objectspace_bone_matrix for just one bone, and I don't want
+ * to copy the code out of it, so here goes... */
+ VecSubf( delta, self->bone->tail, self->bone->head );
+ if( self->bone->parent ) {
+ get_objectspace_bone_matrix( self->bone, restmat, 1, 0 );
+ Mat4MulMat4( ((MatrixObject*)matrix)->contigPtr,
+ restmat, self->bone->parent->irestmat );
+ }
+ else
+ make_boneMatrixvr( *( ( MatrixObject * ) matrix )->matrix,
+ delta, self->bone->roll );
}
}
return matrix;
}
+
+
Index: 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
--- doc/Bone.py 8 Jun 2004 04:41:02 -0000 1.3
+++ doc/Bone.py 7 Apr 2005 08:05:09 -0000
@@ -305,16 +305,24 @@
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:
- 1. bonespace (in the coord. system of parent) or
- 2. worldspace (in the coord system of blender).
+ There are three types of matrix that can be returned:
+ 1. bonespace (in the coord. system of parent, except translation)
+ 2. worldspace (in the coord system of blender)
+ 3. parentspace (completely in the parent's coord. system)
+
+ The rotation will be in either worldspace or bonespace/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 (if bonespace), or the translation from the parent to the
+ bone, in the parent's space (if parentspace).
+
+ An alternative description of 'parentspace' is "the bone's world rest
+ matrix multiplied by the inverse of the parent's world rest matrix".
- 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).
@type locale: string. Values are:
@param locale: possible values are:
- worldspace (default)
- bonespace
+ - parentspace
@rtype: 4x4 PyMatrix
"""

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
3c/ff/afd481ef551efcd7c61c352f5854

Event Timeline