diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-09-07 11:55:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-09-07 11:55:36 +0400 |
commit | 8a11629602990a8c3a793d2509eb20ec6394d0e5 (patch) | |
tree | 46252cc7ed4e66259315b8237ebfb6bf74e2d03f /source/blender/python/api2_2x/Object.c | |
parent | 0ba5295404dd1c2ee04a9e7823eafc664562f4eb (diff) |
matrix to scale fixes from stable
Diffstat (limited to 'source/blender/python/api2_2x/Object.c')
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 0c2f9ed9634..b02a932aa39 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -1368,29 +1368,40 @@ static int Object_setParentBoneName( BPy_Object * self, PyObject *value ) static PyObject *Object_getSize( BPy_Object * self, PyObject * args ) { char *space = "localspace"; /* default to local */ - + PyObject *attr; if( !PyArg_ParseTuple( args, "|s", &space ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string or nothing" ); if( BLI_streq( space, "worldspace" ) ) { /* Worldspace matrix */ - float scale[3]; + float rot[3]; + float mat[3][3], imat[3][3], tmat[3][3]; disable_where_script( 1 ); where_is_object( self->object ); - Mat4ToSize(self->object->obmat, scale); - return Py_BuildValue( "fff", - self->object->size[0], - self->object->size[1], - self->object->size[2] ); + + Mat3CpyMat4(mat, self->object->obmat); + + /* functionality copied from editobject.c apply_obmat */ + Mat3ToEul(mat, rot); + EulToMat3(rot, tmat); + Mat3Inv(imat, tmat); + Mat3MulMat3(tmat, imat, mat); + + attr = Py_BuildValue( "fff", + tmat[0][0], + tmat[1][1], + tmat[2][2] ); disable_where_script( 0 ); } else if( BLI_streq( space, "localspace" ) ) { /* Localspace matrix */ - return Py_BuildValue( "fff", + attr = Py_BuildValue( "fff", self->object->size[0], self->object->size[1], self->object->size[2] ); - } - return EXPP_ReturnPyObjError( PyExc_ValueError, + } else { + return EXPP_ReturnPyObjError( PyExc_ValueError, "expected either nothing, 'localspace' (default) or 'worldspace'" ); + } + return attr; } static PyObject *Object_getTimeOffset( BPy_Object * self ) |