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:
authorJoseph Gilbert <ascotan@gmail.com>2005-05-20 23:28:04 +0400
committerJoseph Gilbert <ascotan@gmail.com>2005-05-20 23:28:04 +0400
commit7586eb28a14c1283fdac8d485edf46cabd6219ad (patch)
tree774a811c3dcb7a49113e062d91cf0eb047b2a7fb /source/blender/python/api2_2x/matrix.h
parentd99f64b82346da82f4f1a179c6f3b647f90d44ed (diff)
-rewrite and bugfixes
---------------------------------- Here's my changelog: -fixed Rand() so that it doesn't seed everytime and should generate better random numbers - changed a few error return types to something more appropriate - clean up of uninitialized variables & removal of unneccessary objects - NMesh returns wrapped vectors now - World returns wrapped matrices now - Object.getEuler() and Object.getBoundingBox() return Wrapped data when data is present - Object.getMatrix() returns wrapped data if it's worldspace, 'localspace' returns a new matrix - Vector, Euler, Mat, Quat, call all now internally wrap object without destroying internal datablocks - Removed memory allocation (unneeded) from all methods - Vector's resize methods are only applicable to new vectors not wrapped data. - Matrix(), Quat(), Euler(), Vector() now accepts ANY sequence list, including tuples, list, or a self object to copy - matrices accept multiple sequences - Fixed Slerp() so that it now works correctly values are clamped between 0 and 1 - Euler.rotate does internal rotation now - Slice assignment now works better for all types - Vector * Vector and Quat * Quat are defined and return the DOT product - Mat * Vec and Vec * Mat are defined now - Moved #includes to .c file from headers. Also fixed prototypes in mathutils - Added new helper functions for incref'ing to genutils - Major cleanup of header files includes - include Mathutils.h for access to math types - matrix.toQuat() and .toEuler() now fixed take appropriate matrix sizes - Matrix() with no parameters now returns an identity matrix by default not a zero matrix - printf() now prints with 6 digits instead of 4 - printf() now prints output with object descriptor - Matrices now support [x][y] assignment (e.g. matrix[x][y] = 5.4) - Matrix[index] = value now expectes a sequence not an integer. This will now set a ROW of the matrix through a sequence. index cannot go above the row size of the matrix. - slice operations on matrices work with sequences now (rows of the matrix) example: mymatrix[0:2] returns a list of 2 wrapped vectors with access to the matrix data. - slice assignment will no longer modify the data if the assignment operation fails - fixed error in matrix * scalar multiplication - euler.toMatrix(), toQuat() no longer causes "creep" from repeated use - Wrapped data will generate wrapped objects when toEuler(), toQuat(), toMatrix() is used - Quats can be created with angle/axis, axis/angle - 4x4 matrices can be multiplied by 3D vectors (by popular demand :)) - vec *quat / quat * vec is now defined - vec.magnitude alias for vec.length - all self, internal methods return a pointer to self now so you can do print vector.internalmethod() or vector.internalmethod().nextmethod() (no more print matrix.inverse() returning 'none') - these methods have been deprecated (still functioning but suggested to use the corrected functionality): * CopyVec() - replaced by Vector() functionality * CopyMat() - replaced by Matrix() functionality * CopyQuat() - replace by Quaternion() functionality * CopyEuler() - replaced by Euler() functionality * RotateEuler() - replaced by Euler.rotate() funtionality * MatMultVec() - replaced by matrix * vector * VecMultMat() - replaced by vector * matrix - New struct containers references to python object data or internally allocated blender data for wrapping * Explaination here: math structs now function as a 'simple wrapper' or a 'py_object' - data that is created on the fly will now be a 'py_object' with its memory managed by python * otherwise if the data is returned by blender's G.main then the math object is a 'simple wrapper' and data can be accessed directly from the struct just like other python objects.
Diffstat (limited to 'source/blender/python/api2_2x/matrix.h')
-rw-r--r--source/blender/python/api2_2x/matrix.h43
1 files changed, 19 insertions, 24 deletions
diff --git a/source/blender/python/api2_2x/matrix.h b/source/blender/python/api2_2x/matrix.h
index b40ec978159..9c114867786 100644
--- a/source/blender/python/api2_2x/matrix.h
+++ b/source/blender/python/api2_2x/matrix.h
@@ -33,37 +33,31 @@
#ifndef EXPP_matrix_h
#define EXPP_matrix_h
-#include "Python.h"
-#include "BLI_arithb.h"
-#include "vector.h"
-#include "gen_utils.h"
-#include "Types.h"
-#include "quat.h"
-#include "euler.h"
+#define MatrixObject_Check(v) ((v)->ob_type == &matrix_Type)
-#define Matrix_CheckPyObject(v) ((v)->ob_type == &matrix_Type)
-
-/*****************************/
-/* Matrix Python Object */
-/*****************************/
typedef float **ptRow;
-
typedef struct _Matrix {
- PyObject_VAR_HEAD /* standard python macro */
- ptRow matrix;
- float *contigPtr;
+ PyObject_VAR_HEAD
+ struct{
+ 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)
int rowSize;
int colSize;
- int flag;
- //0 - no coercion
- //1 - coerced from int
- //2 - coerced from float
+ PyObject *coerced_object;
} MatrixObject;
+/*coerced_object is a pointer to the object that it was
+coerced from when a dummy vector needs to be created from
+the coerce() function for numeric protocol operations*/
+
+/*struct data contains a pointer to the actual data that the
+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*/
-/*****************************************************************************/
-/* Python API function prototypes. */
-/*****************************************************************************/
-PyObject *newMatrixObject( float *mat, int rowSize, int colSize );
+//prototypes
PyObject *Matrix_Zero( MatrixObject * self );
PyObject *Matrix_Identity( MatrixObject * self );
PyObject *Matrix_Transpose( MatrixObject * self );
@@ -74,5 +68,6 @@ PyObject *Matrix_RotationPart( MatrixObject * self );
PyObject *Matrix_Resize4x4( MatrixObject * self );
PyObject *Matrix_toEuler( MatrixObject * self );
PyObject *Matrix_toQuat( MatrixObject * self );
+PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type);
#endif /* EXPP_matrix_H */