Addition to Mathutils

vec.normalized()
 mat.inverted()
 mat.transposed()
 made vec/float possible

 normalize/invert/transpose now return None because they modify the data in place.
 use the ...(ed) versions to return a modified copy.


Fixed Memory leaks from not decreffing PyFloat_AS_DOUBLE from these python functions...
(found when testing above functions)
  ob.rbMass
  ob.rbRadius
  matrix.determinant()
  quat*float
  vec*float
  matrix.transpose()
  EXPP_setModuleConstant

Checked all instances of PyFloat_AS_DOUBLE so I dont think there are any mroe leaks there.
This commit is contained in:
2006-07-27 01:18:21 +00:00
parent 4ee3515bf1
commit b227c98c44
7 changed files with 258 additions and 154 deletions

View File

@@ -43,14 +43,14 @@ typedef float **ptRow;
typedef struct _Matrix {
PyObject_VAR_HEAD
struct{
float *py_data; //python managed
float *blend_data; //blender managed
float *py_data; /*python managed*/
float *blend_data; /*blender managed*/
}data;
ptRow matrix; //ptr to the contigPtr (accessor)
float *contigPtr; //1D array of data (alias)
ptRow matrix; /*ptr to the contigPtr (accessor)*/
float *contigPtr; /*1D array of data (alias)*/
int rowSize;
int colSize;
int wrapped; //is wrapped data?
int wrapped; /*is wrapped data?*/
PyObject *coerced_object;
} MatrixObject;
/*coerced_object is a pointer to the object that it was
@@ -62,12 +62,14 @@ object uses. It can use either PyMem allocated data (which will
be stored in py_data) or be a wrapper for data allocated through
blender (stored in blend_data). This is an either/or struct not both*/
//prototypes
/*prototypes*/
PyObject *Matrix_Zero( MatrixObject * self );
PyObject *Matrix_Identity( MatrixObject * self );
PyObject *Matrix_Transpose( MatrixObject * self );
PyObject *Matrix_Transposed( MatrixObject * self );
PyObject *Matrix_Determinant( MatrixObject * self );
PyObject *Matrix_Invert( MatrixObject * self );
PyObject *Matrix_Inverted( MatrixObject * self );
PyObject *Matrix_TranslationPart( MatrixObject * self );
PyObject *Matrix_RotationPart( MatrixObject * self );
PyObject *Matrix_scalePart( MatrixObject * self );