Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-04-01 14:15:39 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-04-01 14:15:39 +0400
commit4f6493d1a7233d61ecce73caee5073d721d41e61 (patch)
tree6a80891735376844bce3377551e514b651075559 /source/blender/python/api2_2x
parent5c9a72973409f466172d751d6cb3202f2c846a1f (diff)
Fix for bug #8629: python object.boundingBox was not in worldspace
anymore for meshes due to a bugfix. The python code assumed ob->bb was in worldspace while it isn't, also meant metaball bounding boxes were wrong.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r--source/blender/python/api2_2x/Object.c98
1 files changed, 41 insertions, 57 deletions
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index a7a651e4465..311d13a18fa 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -1498,73 +1498,57 @@ static PyObject *Object_getBoundBox( BPy_Object * self )
default:
Py_RETURN_NONE;
}
+ } else { /* the ob bbox exists */
+ vec = ( float * ) self->object->bb->vec;
+ }
- { /* transform our obdata bbox by the obmat.
- the obmat is 4x4 homogeneous coords matrix.
- each bbox coord is xyz, so we make it homogenous
- by padding it with w=1.0 and doing the matrix mult.
- afterwards we divide by w to get back to xyz.
- */
- /* printmatrix4( "obmat", self->object->obmat); */
-
- float tmpvec[4]; /* tmp vector for homogenous coords math */
- int i;
- float *from;
-
- bbox = PyList_New( 8 );
- if( !bbox )
- return EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create pylist" );
- for( i = 0, from = vec; i < 8; i++, from += 3 ) {
- memcpy( tmpvec, from, 3 * sizeof( float ) );
- tmpvec[3] = 1.0f; /* set w coord */
- Mat4MulVec4fl( self->object->obmat, tmpvec );
- /* divide x,y,z by w */
- tmpvec[0] /= tmpvec[3];
- tmpvec[1] /= tmpvec[3];
- tmpvec[2] /= tmpvec[3];
-
-#if 0
- { /* debug print stuff */
- int i;
- printf( "\nobj bbox transformed\n" );
- for( i = 0; i < 4; ++i )
- printf( "%f ", tmpvec[i] );
+ { /* transform our obdata bbox by the obmat.
+ the obmat is 4x4 homogeneous coords matrix.
+ each bbox coord is xyz, so we make it homogenous
+ by padding it with w=1.0 and doing the matrix mult.
+ afterwards we divide by w to get back to xyz.
+ */
+ /* printmatrix4( "obmat", self->object->obmat); */
- printf( "\n" );
- }
-#endif
+ float tmpvec[4]; /* tmp vector for homogenous coords math */
+ int i;
+ float *from;
- /* because our bounding box is calculated and
- does not have its own memory,
- we must create vectors that allocate space */
+ bbox = PyList_New( 8 );
+ if( !bbox )
+ return EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create pylist" );
+ for( i = 0, from = vec; i < 8; i++, from += 3 ) {
+ memcpy( tmpvec, from, 3 * sizeof( float ) );
+ tmpvec[3] = 1.0f; /* set w coord */
+ Mat4MulVec4fl( self->object->obmat, tmpvec );
+ /* divide x,y,z by w */
+ tmpvec[0] /= tmpvec[3];
+ tmpvec[1] /= tmpvec[3];
+ tmpvec[2] /= tmpvec[3];
- vector = newVectorObject( NULL, 3, Py_NEW);
- memcpy( ( ( VectorObject * ) vector )->vec,
- tmpvec, 3 * sizeof( float ) );
- PyList_SET_ITEM( bbox, i, vector );
- }
- }
- } else { /* the ob bbox exists */
- vec = ( float * ) self->object->bb->vec;
+#if 0
+ { /* debug print stuff */
+ int i;
- if( !vec )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't retrieve bounding box data" );
+ printf( "\nobj bbox transformed\n" );
+ for( i = 0; i < 4; ++i )
+ printf( "%f ", tmpvec[i] );
- bbox = PyList_New( 8 );
+ printf( "\n" );
+ }
+#endif
- if( !bbox )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create pylist" );
+ /* because our bounding box is calculated and
+ does not have its own memory,
+ we must create vectors that allocate space */
- /* create vectors referencing object bounding box coords */
- for( i = 0; i < 8; i++ ) {
- vector = newVectorObject( vec, 3, Py_WRAP );
+ vector = newVectorObject( NULL, 3, Py_NEW);
+ memcpy( ( ( VectorObject * ) vector )->vec,
+ tmpvec, 3 * sizeof( float ) );
PyList_SET_ITEM( bbox, i, vector );
- vec += 3;
}
}