[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19838] trunk/blender/source: Blender Python API
Campbell Barton
ideasman42 at gmail.com
Tue Apr 21 11:44:30 CEST 2009
Revision: 19838
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19838
Author: campbellbarton
Date: 2009-04-21 11:44:29 +0200 (Tue, 21 Apr 2009)
Log Message:
-----------
Blender Python API
- Removed the gen_utils.c dependency from Mathutils (since gen_utils wont go into 2.5 but mathutils will), repalced with python functions.
- removed Blender.Mathutils.Point, since it was not documented, the C api never used it, none of our scripts used it (and I never saw a script that used it).
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_scene.h
trunk/blender/source/blender/python/BPY_interface.c
trunk/blender/source/blender/python/api2_2x/Geometry.h
trunk/blender/source/blender/python/api2_2x/Group.c
trunk/blender/source/blender/python/api2_2x/Key.c
trunk/blender/source/blender/python/api2_2x/Mathutils.c
trunk/blender/source/blender/python/api2_2x/Mathutils.h
trunk/blender/source/blender/python/api2_2x/Node.c
trunk/blender/source/blender/python/api2_2x/Scene.c
trunk/blender/source/blender/python/api2_2x/Texture.c
trunk/blender/source/blender/python/api2_2x/Types.c
trunk/blender/source/blender/python/api2_2x/euler.c
trunk/blender/source/blender/python/api2_2x/gen_utils.c
trunk/blender/source/blender/python/api2_2x/gen_utils.h
trunk/blender/source/blender/python/api2_2x/matrix.c
trunk/blender/source/blender/python/api2_2x/quat.c
trunk/blender/source/blender/python/api2_2x/vector.c
trunk/blender/source/blender/python/api2_2x/vector.h
trunk/blender/source/blender/render/intern/source/convertblender.c
trunk/blender/source/gameengine/Ketsji/CMakeLists.txt
trunk/blender/source/gameengine/Ketsji/SConscript
Removed Paths:
-------------
trunk/blender/source/blender/python/api2_2x/point.c
trunk/blender/source/blender/python/api2_2x/point.h
Modified: trunk/blender/source/blender/blenkernel/BKE_scene.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_scene.h 2009-04-21 09:38:27 UTC (rev 19837)
+++ trunk/blender/source/blender/blenkernel/BKE_scene.h 2009-04-21 09:44:29 UTC (rev 19838)
@@ -35,6 +35,7 @@
struct Scene;
struct Object;
struct Base;
+struct Text;
struct AviCodecData;
struct QuicktimeCodecData;
struct SculptData;
Modified: trunk/blender/source/blender/python/BPY_interface.c
===================================================================
--- trunk/blender/source/blender/python/BPY_interface.c 2009-04-21 09:38:27 UTC (rev 19837)
+++ trunk/blender/source/blender/python/BPY_interface.c 2009-04-21 09:44:29 UTC (rev 19838)
@@ -70,6 +70,7 @@
#include "api2_2x/Object.h"
#include "api2_2x/Registry.h"
#include "api2_2x/Pose.h"
+#include "api2_2x/Mathutils.h"
#include "api2_2x/bpy.h" /* for the new "bpy" module */
#include "api2_2x/bpy_internal_import.h"
Modified: trunk/blender/source/blender/python/api2_2x/Geometry.h
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Geometry.h 2009-04-21 09:38:27 UTC (rev 19837)
+++ trunk/blender/source/blender/python/api2_2x/Geometry.h 2009-04-21 09:44:29 UTC (rev 19838)
@@ -32,7 +32,7 @@
#define EXPP_Geometry_H
#include <Python.h>
-#include "vector.h"
+#include "Mathutils.h"
PyObject *Geometry_Init( void );
Modified: trunk/blender/source/blender/python/api2_2x/Group.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Group.c 2009-04-21 09:38:27 UTC (rev 19837)
+++ trunk/blender/source/blender/python/api2_2x/Group.c 2009-04-21 09:44:29 UTC (rev 19838)
@@ -46,7 +46,7 @@
#include "gen_utils.h"
#include "gen_library.h"
-#include "vector.h"
+#include "Mathutils.h"
/* checks for the group being removed */
#define GROUP_DEL_CHECK_PY(bpy_group) if (!(bpy_group->group)) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "Group has been removed" ) )
Modified: trunk/blender/source/blender/python/api2_2x/Key.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Key.c 2009-04-21 09:38:27 UTC (rev 19837)
+++ trunk/blender/source/blender/python/api2_2x/Key.c 2009-04-21 09:44:29 UTC (rev 19838)
@@ -29,7 +29,7 @@
*/
#include "Key.h" /*This must come first*/
-#include "vector.h"
+#include "Mathutils.h"
#include "DNA_scene_types.h"
Modified: trunk/blender/source/blender/python/api2_2x/Mathutils.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Mathutils.c 2009-04-21 09:38:27 UTC (rev 19837)
+++ trunk/blender/source/blender/python/api2_2x/Mathutils.c 2009-04-21 09:44:29 UTC (rev 19838)
@@ -69,7 +69,6 @@
static char M_Mathutils_TriangleNormal_doc[] = "(v1, v2, v3) - returns the normal of the 3D triangle defined";
static char M_Mathutils_QuadNormal_doc[] = "(v1, v2, v3, v4) - returns the normal of the 3D quad defined";
static char M_Mathutils_LineIntersect_doc[] = "(v1, v2, v3, v4) - returns a tuple with the points on each line respectively closest to the other";
-static char M_Mathutils_Point_doc[] = "Creates a 2d or 3d point object";
//-----------------------METHOD DEFINITIONS ----------------------
struct PyMethodDef M_Mathutils_methods[] = {
{"Rand", (PyCFunction) M_Mathutils_Rand, METH_VARARGS, M_Mathutils_Rand_doc},
@@ -103,7 +102,6 @@
{"TriangleNormal", ( PyCFunction ) M_Mathutils_TriangleNormal, METH_VARARGS, M_Mathutils_TriangleNormal_doc},
{"QuadNormal", ( PyCFunction ) M_Mathutils_QuadNormal, METH_VARARGS, M_Mathutils_QuadNormal_doc},
{"LineIntersect", ( PyCFunction ) M_Mathutils_LineIntersect, METH_VARARGS, M_Mathutils_LineIntersect_doc},
- {"Point", (PyCFunction) M_Mathutils_Point, METH_VARARGS, M_Mathutils_Point_doc},
{NULL, NULL, 0, NULL}
};
/*----------------------------MODULE INIT-------------------------*/
@@ -184,36 +182,7 @@
}
return newVectorObject(vecNew, vec->size, Py_NEW);
}
-//This is a helper for point/matrix translation
-PyObject *column_point_multiplication(MatrixObject * mat, PointObject* pt)
-{
- float ptNew[4], ptCopy[4];
- double dot = 0.0f;
- int x, y, z = 0;
-
- if(mat->rowSize != pt->size){
- if(mat->rowSize == 4 && pt->size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "matrix * point: matrix row size and point size must be the same\n");
- }else{
- ptCopy[3] = 0.0f;
- }
- }
-
- for(x = 0; x < pt->size; x++){
- ptCopy[x] = pt->coord[x];
- }
-
- for(x = 0; x < mat->rowSize; x++) {
- for(y = 0; y < mat->colSize; y++) {
- dot += mat->matrix[x][y] * ptCopy[y];
- }
- ptNew[z++] = (float)dot;
- dot = 0.0f;
- }
- return newPointObject(ptNew, pt->size, Py_NEW);
-}
//-----------------row_vector_multiplication (internal)-----------
//ROW VECTOR Multiplication - Vector X Matrix
//[x][y][z] * [1][2][3]
@@ -249,36 +218,7 @@
}
return newVectorObject(vecNew, vec_size, Py_NEW);
}
-//This is a helper for the point class
-PyObject *row_point_multiplication(PointObject* pt, MatrixObject * mat)
-{
- float ptNew[4], ptCopy[4];
- double dot = 0.0f;
- int x, y, z = 0, size;
- if(mat->colSize != pt->size){
- if(mat->rowSize == 4 && pt->size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "point * matrix: matrix column size and the point size must be the same\n");
- }else{
- ptCopy[3] = 0.0f;
- }
- }
- size = pt->size;
- for(x = 0; x < pt->size; x++){
- ptCopy[x] = pt->coord[x];
- }
-
- //muliplication
- for(x = 0; x < mat->colSize; x++) {
- for(y = 0; y < mat->rowSize; y++) {
- dot += mat->matrix[y][x] * ptCopy[y];
- }
- ptNew[z++] = (float)dot;
- dot = 0.0f;
- }
- return newPointObject(ptNew, size, Py_NEW);
-}
//-----------------quat_rotation (internal)-----------
//This function multiplies a vector/point * quat or vice versa
//to rotate the point/vector by the quaternion
@@ -288,7 +228,6 @@
float rot[3];
QuaternionObject *quat = NULL;
VectorObject *vec = NULL;
- PointObject *pt = NULL;
if(QuaternionObject_Check(arg1)){
quat = (QuaternionObject*)arg1;
@@ -307,21 +246,6 @@
quat->quat[2]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[1]*vec->vec[1] -
quat->quat[1]*quat->quat[1]*vec->vec[2] + quat->quat[0]*quat->quat[0]*vec->vec[2];
return newVectorObject(rot, 3, Py_NEW);
- }else if(PointObject_Check(arg2)){
- pt = (PointObject*)arg2;
- rot[0] = quat->quat[0]*quat->quat[0]*pt->coord[0] + 2*quat->quat[2]*quat->quat[0]*pt->coord[2] -
- 2*quat->quat[3]*quat->quat[0]*pt->coord[1] + quat->quat[1]*quat->quat[1]*pt->coord[0] +
- 2*quat->quat[2]*quat->quat[1]*pt->coord[1] + 2*quat->quat[3]*quat->quat[1]*pt->coord[2] -
- quat->quat[3]*quat->quat[3]*pt->coord[0] - quat->quat[2]*quat->quat[2]*pt->coord[0];
- rot[1] = 2*quat->quat[1]*quat->quat[2]*pt->coord[0] + quat->quat[2]*quat->quat[2]*pt->coord[1] +
- 2*quat->quat[3]*quat->quat[2]*pt->coord[2] + 2*quat->quat[0]*quat->quat[3]*pt->coord[0] -
- quat->quat[3]*quat->quat[3]*pt->coord[1] + quat->quat[0]*quat->quat[0]*pt->coord[1] -
- 2*quat->quat[1]*quat->quat[0]*pt->coord[2] - quat->quat[1]*quat->quat[1]*pt->coord[1];
- rot[2] = 2*quat->quat[1]*quat->quat[3]*pt->coord[0] + 2*quat->quat[2]*quat->quat[3]*pt->coord[1] +
- quat->quat[3]*quat->quat[3]*pt->coord[2] - 2*quat->quat[0]*quat->quat[2]*pt->coord[0] -
- quat->quat[2]*quat->quat[2]*pt->coord[2] + 2*quat->quat[0]*quat->quat[1]*pt->coord[1] -
- quat->quat[1]*quat->quat[1]*pt->coord[2] + quat->quat[0]*quat->quat[0]*pt->coord[2];
- return newPointObject(rot, 3, Py_NEW);
}
}else if(VectorObject_Check(arg1)){
vec = (VectorObject*)arg1;
@@ -341,24 +265,6 @@
quat->quat[1]*quat->quat[1]*vec->vec[2] + quat->quat[0]*quat->quat[0]*vec->vec[2];
return newVectorObject(rot, 3, Py_NEW);
}
- }else if(PointObject_Check(arg1)){
- pt = (PointObject*)arg1;
- if(QuaternionObject_Check(arg2)){
- quat = (QuaternionObject*)arg2;
- rot[0] = quat->quat[0]*quat->quat[0]*pt->coord[0] + 2*quat->quat[2]*quat->quat[0]*pt->coord[2] -
- 2*quat->quat[3]*quat->quat[0]*pt->coord[1] + quat->quat[1]*quat->quat[1]*pt->coord[0] +
- 2*quat->quat[2]*quat->quat[1]*pt->coord[1] + 2*quat->quat[3]*quat->quat[1]*pt->coord[2] -
- quat->quat[3]*quat->quat[3]*pt->coord[0] - quat->quat[2]*quat->quat[2]*pt->coord[0];
- rot[1] = 2*quat->quat[1]*quat->quat[2]*pt->coord[0] + quat->quat[2]*quat->quat[2]*pt->coord[1] +
- 2*quat->quat[3]*quat->quat[2]*pt->coord[2] + 2*quat->quat[0]*quat->quat[3]*pt->coord[0] -
- quat->quat[3]*quat->quat[3]*pt->coord[1] + quat->quat[0]*quat->quat[0]*pt->coord[1] -
- 2*quat->quat[1]*quat->quat[0]*pt->coord[2] - quat->quat[1]*quat->quat[1]*pt->coord[1];
- rot[2] = 2*quat->quat[1]*quat->quat[3]*pt->coord[0] + 2*quat->quat[2]*quat->quat[3]*pt->coord[1] +
- quat->quat[3]*quat->quat[3]*pt->coord[2] - 2*quat->quat[0]*quat->quat[2]*pt->coord[0] -
- quat->quat[2]*quat->quat[2]*pt->coord[2] + 2*quat->quat[0]*quat->quat[1]*pt->coord[1] -
- quat->quat[1]*quat->quat[1]*pt->coord[2] + quat->quat[0]*quat->quat[0]*pt->coord[2];
- return newPointObject(rot, 3, Py_NEW);
- }
}
return (EXPP_ReturnPyObjError(PyExc_RuntimeError,
@@ -1329,60 +1235,7 @@
Py_DECREF(listObject);
return newEulerObject(eul, Py_NEW);
}
-//----------------------------------POINT FUNCTIONS---------------------
-//----------------------------------Mathutils.Point() ------------------
-PyObject *M_Mathutils_Point(PyObject * self, PyObject * args)
-{
- PyObject *listObject = NULL;
- int size, i;
- float point[3];
- PyObject *v, *f;
- size = PySequence_Length(args);
- if (size == 1) {
- listObject = PySequence_GetItem(args, 0);
- if (PySequence_Check(listObject)) {
- size = PySequence_Length(listObject);
- } else { // Single argument was not a sequence
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Point(): 2-3 floats or ints expected (optionally in a sequence)\n");
- }
- } else if (size == 0) {
- //returns a new empty 3d point
- return newPointObject(NULL, 3, Py_NEW);
- } else {
- listObject = EXPP_incr_ret(args);
- }
-
- if (size<2 || size>3) { // Invalid vector size
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list