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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-10-07 15:49:53 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-10-07 15:49:53 +0400
commitb3a48fe82efe1839f5702db93fdd2f20a68f9c4a (patch)
treee9d99d156eecd7c448c455a195564f2904dba9e4 /source
parent30d207e650333bf052faf003b405c1a9122e2aff (diff)
removed some unused vars from Curve and matrix
scn.objects.new(None) - adds a new empty - new objects are selected by default now further stripped down the vector struct, the wrapped state was being stored and 2 places.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Curve.c2
-rw-r--r--source/blender/python/api2_2x/Scene.c33
-rw-r--r--source/blender/python/api2_2x/matrix.c3
-rw-r--r--source/blender/python/api2_2x/vector.c63
-rw-r--r--source/blender/python/api2_2x/vector.h18
5 files changed, 47 insertions, 72 deletions
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c
index 9c25bd44a3d..75c8a3801a3 100644
--- a/source/blender/python/api2_2x/Curve.c
+++ b/source/blender/python/api2_2x/Curve.c
@@ -1451,7 +1451,6 @@ static PyObject *Curve_getIter( BPy_Curve * self )
static PyObject *Curve_iterNext( BPy_Curve * self )
{
- PyObject *po; /* return value */
Nurb *pnurb;
if( self->iter_pointer ) {
@@ -1500,7 +1499,6 @@ static int Curve_length( PyInstanceObject * inst )
PyObject *Curve_getNurb( BPy_Curve * self, int n )
{
- PyObject *pyo;
Nurb *pNurb;
int i;
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
index ed6eea6e4da..29911002b55 100644
--- a/source/blender/python/api2_2x/Scene.c
+++ b/source/blender/python/api2_2x/Scene.c
@@ -1292,7 +1292,7 @@ static PyObject *SceneObSeq_add( BPy_SceneObSeq * self, PyObject *pyobj )
static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
{
void *data = NULL;
- int type;
+ short type;
struct Object *object;
Base *base;
PyObject *py_data;
@@ -1307,10 +1307,8 @@ static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
if( !PyArg_ParseTuple( args, "O", &py_data ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected an object as argument" );
-
- if( ArmatureObject_Check( py_data ) ) {
- data = ( void * ) PyArmature_AsArmature((BPy_Armature*)py_data);
- type = OB_ARMATURE;
+ if (py_data == Py_None) {
+ type = OB_EMPTY;
} else if( Camera_CheckPyObject( py_data ) ) {
data = ( void * ) Camera_FromPyObject( py_data );
type = OB_CAMERA;
@@ -1340,17 +1338,22 @@ static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
}
/* have we set data to something good? */
- if( !data )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "link argument type is not supported " );
-
- object = alloc_libblock( &( G.main->object ), ID_OB, ((ID *)data)->name + 2 );
- object->data = data;
- ((ID *)object->data)->us++;
+ if( data ) {
+ ((ID *)object->data)->us++;
+ object = alloc_libblock( &( G.main->object ), ID_OB, ((ID *)data)->name + 2 );
+ } else {
+ if (type != OB_EMPTY) {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "objects.new() argument type is not supported" );
+ }
+
+ object = alloc_libblock( &( G.main->object ), ID_OB, "Empty" );
+ }
- object->flag = 0;
- object->type = (short)type;
+ object->data = data;
+ object->flag = SELECT;
+ object->type = type;
/* Object properties copied from M_Object_New */
@@ -1418,7 +1421,7 @@ static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
base->object = object; /* link object to the new base */
base->lay= object->lay = scene->lay; /* Layer, by default visible*/
- base->flag = 0;
+ base->flag = SELECT;
object->id.us = 1; /* we will exist once in this scene */
BLI_addhead( &(scene->base), base ); /* finally, link new base to scene */
diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c
index 5394ae14f81..ffdecc70361 100644
--- a/source/blender/python/api2_2x/matrix.c
+++ b/source/blender/python/api2_2x/matrix.c
@@ -695,7 +695,6 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
double dot = 0.0f;
MatrixObject *mat1 = NULL, *mat2 = NULL;
PyObject *f = NULL;
- VectorObject *vec = NULL;
PointObject *pt = NULL;
mat1 = (MatrixObject*)m1;
@@ -963,4 +962,4 @@ PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type)
return NULL;
}
return (PyObject *) self;
-} \ No newline at end of file
+}
diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c
index b0b76669e71..e6cce38dd11 100644
--- a/source/blender/python/api2_2x/vector.c
+++ b/source/blender/python/api2_2x/vector.c
@@ -111,18 +111,15 @@ PyObject *Vector_Normalize(VectorObject * self)
resize the vector to x,y */
PyObject *Vector_Resize2D(VectorObject * self)
{
- if(self->data.blend_data){
+ if(self->wrapped==Py_WRAP)
return EXPP_ReturnPyObjError(PyExc_TypeError,
"vector.resize2d(): cannot resize wrapped data - only python vectors\n");
- }
- self->data.py_data =
- PyMem_Realloc(self->data.py_data, (sizeof(float) * 2));
- if(self->data.py_data == NULL) {
+ self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2));
+ if(self->vec == NULL)
return EXPP_ReturnPyObjError(PyExc_MemoryError,
"vector.resize2d(): problem allocating pointer space\n\n");
- }
- self->vec = self->data.py_data; /*force*/
+
self->size = 2;
return EXPP_incr_ret((PyObject*)self);
}
@@ -130,21 +127,18 @@ PyObject *Vector_Resize2D(VectorObject * self)
resize the vector to x,y,z */
PyObject *Vector_Resize3D(VectorObject * self)
{
- if(self->data.blend_data){
+ if (self->wrapped==Py_WRAP)
return EXPP_ReturnPyObjError(PyExc_TypeError,
"vector.resize3d(): cannot resize wrapped data - only python vectors\n");
- }
- self->data.py_data =
- PyMem_Realloc(self->data.py_data, (sizeof(float) * 3));
- if(self->data.py_data == NULL) {
+ self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3));
+ if(self->vec == NULL)
return EXPP_ReturnPyObjError(PyExc_MemoryError,
"vector.resize3d(): problem allocating pointer space\n\n");
- }
- self->vec = self->data.py_data; /*force*/
- if(self->size == 2){
- self->data.py_data[2] = 0.0f;
- }
+
+ if(self->size == 2)
+ self->vec[2] = 0.0f;
+
self->size = 3;
return EXPP_incr_ret((PyObject*)self);
}
@@ -152,23 +146,20 @@ PyObject *Vector_Resize3D(VectorObject * self)
resize the vector to x,y,z,w */
PyObject *Vector_Resize4D(VectorObject * self)
{
- if(self->data.blend_data){
+ if(self->wrapped==Py_WRAP)
return EXPP_ReturnPyObjError(PyExc_TypeError,
"vector.resize4d(): cannot resize wrapped data - only python vectors\n");
- }
- self->data.py_data =
- PyMem_Realloc(self->data.py_data, (sizeof(float) * 4));
- if(self->data.py_data == NULL) {
+ self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4));
+ if(self->vec == NULL)
return EXPP_ReturnPyObjError(PyExc_MemoryError,
"vector.resize4d(): problem allocating pointer space\n\n");
- }
- self->vec = self->data.py_data; /*force*/
+
if(self->size == 2){
- self->data.py_data[2] = 0.0f;
- self->data.py_data[3] = 1.0f;
+ self->vec[2] = 0.0f;
+ self->vec[3] = 1.0f;
}else if(self->size == 3){
- self->data.py_data[3] = 1.0f;
+ self->vec[3] = 1.0f;
}
self->size = 4;
return EXPP_incr_ret((PyObject*)self);
@@ -296,9 +287,9 @@ PyObject *Vector_copy(VectorObject * self)
free the py_object */
static void Vector_dealloc(VectorObject * self)
{
- /*only free py_data*/
- if(self->data.py_data){
- PyMem_Free(self->data.py_data);
+ /* only free non wrapped */
+ if(self->wrapped != Py_WRAP){
+ PyMem_Free(self->vec);
}
PyObject_DEL(self);
}
@@ -1223,19 +1214,15 @@ PyObject *newVectorObject(float *vec, int size, int type)
int i;
VectorObject *self = PyObject_NEW(VectorObject, &vector_Type);
- self->data.blend_data = NULL;
- self->data.py_data = NULL;
if(size > 4 || size < 2)
return NULL;
self->size = size;
- if(type == Py_WRAP){
- self->data.blend_data = vec;
- self->vec = self->data.blend_data;
+ if(type == Py_WRAP) {
+ self->vec = vec;
self->wrapped = Py_WRAP;
- }else if (type == Py_NEW){
- self->data.py_data = PyMem_Malloc(size * sizeof(float));
- self->vec = self->data.py_data;
+ } else if (type == Py_NEW) {
+ self->vec = PyMem_Malloc(size * sizeof(float));
if(!vec) { /*new empty*/
for(i = 0; i < size; i++){
self->vec[i] = 0.0f;
diff --git a/source/blender/python/api2_2x/vector.h b/source/blender/python/api2_2x/vector.h
index 94ac10cac15..8f8dda99a7f 100644
--- a/source/blender/python/api2_2x/vector.h
+++ b/source/blender/python/api2_2x/vector.h
@@ -41,22 +41,10 @@ extern PyTypeObject vector_Type;
typedef struct {
PyObject_VAR_HEAD
- struct{
- float *py_data; //python managed
- float *blend_data; //blender managed
- }data;
- float *vec; //1D array of data (alias)
- int size;
- int wrapped; //is wrapped data?
+ float *vec; /*1D array of data (alias), wrapped status depends on wrapped status */
+ short size; /* vec size 2,3 or 4 */
+ short wrapped; /* is wrapped data? */
} VectorObject;
-/*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*/
//prototypes
PyObject *Vector_Zero( VectorObject * self );