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.
This commit is contained in:
@@ -1451,7 +1451,6 @@ static PyObject *Curve_getIter( BPy_Curve * self )
|
|||||||
|
|
||||||
static PyObject *Curve_iterNext( BPy_Curve * self )
|
static PyObject *Curve_iterNext( BPy_Curve * self )
|
||||||
{
|
{
|
||||||
PyObject *po; /* return value */
|
|
||||||
Nurb *pnurb;
|
Nurb *pnurb;
|
||||||
|
|
||||||
if( self->iter_pointer ) {
|
if( self->iter_pointer ) {
|
||||||
@@ -1500,7 +1499,6 @@ static int Curve_length( PyInstanceObject * inst )
|
|||||||
|
|
||||||
PyObject *Curve_getNurb( BPy_Curve * self, int n )
|
PyObject *Curve_getNurb( BPy_Curve * self, int n )
|
||||||
{
|
{
|
||||||
PyObject *pyo;
|
|
||||||
Nurb *pNurb;
|
Nurb *pNurb;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|||||||
@@ -1292,7 +1292,7 @@ static PyObject *SceneObSeq_add( BPy_SceneObSeq * self, PyObject *pyobj )
|
|||||||
static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
|
static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
|
||||||
{
|
{
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
int type;
|
short type;
|
||||||
struct Object *object;
|
struct Object *object;
|
||||||
Base *base;
|
Base *base;
|
||||||
PyObject *py_data;
|
PyObject *py_data;
|
||||||
@@ -1307,10 +1307,8 @@ static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
|
|||||||
if( !PyArg_ParseTuple( args, "O", &py_data ) )
|
if( !PyArg_ParseTuple( args, "O", &py_data ) )
|
||||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||||
"expected an object as argument" );
|
"expected an object as argument" );
|
||||||
|
if (py_data == Py_None) {
|
||||||
if( ArmatureObject_Check( py_data ) ) {
|
type = OB_EMPTY;
|
||||||
data = ( void * ) PyArmature_AsArmature((BPy_Armature*)py_data);
|
|
||||||
type = OB_ARMATURE;
|
|
||||||
} else if( Camera_CheckPyObject( py_data ) ) {
|
} else if( Camera_CheckPyObject( py_data ) ) {
|
||||||
data = ( void * ) Camera_FromPyObject( py_data );
|
data = ( void * ) Camera_FromPyObject( py_data );
|
||||||
type = OB_CAMERA;
|
type = OB_CAMERA;
|
||||||
@@ -1340,17 +1338,22 @@ static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* have we set data to something good? */
|
/* have we set data to something good? */
|
||||||
if( !data )
|
if( data ) {
|
||||||
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
((ID *)object->data)->us++;
|
||||||
"link argument type is not supported " );
|
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 = alloc_libblock( &( G.main->object ), ID_OB, ((ID *)data)->name + 2 );
|
|
||||||
object->data = data;
|
object->data = data;
|
||||||
((ID *)object->data)->us++;
|
|
||||||
|
|
||||||
object->flag = 0;
|
|
||||||
object->type = (short)type;
|
|
||||||
|
|
||||||
|
object->flag = SELECT;
|
||||||
|
object->type = type;
|
||||||
|
|
||||||
|
|
||||||
/* Object properties copied from M_Object_New */
|
/* 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->object = object; /* link object to the new base */
|
||||||
base->lay= object->lay = scene->lay; /* Layer, by default visible*/
|
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 */
|
object->id.us = 1; /* we will exist once in this scene */
|
||||||
|
|
||||||
BLI_addhead( &(scene->base), base ); /* finally, link new base to scene */
|
BLI_addhead( &(scene->base), base ); /* finally, link new base to scene */
|
||||||
|
|||||||
@@ -695,7 +695,6 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
|
|||||||
double dot = 0.0f;
|
double dot = 0.0f;
|
||||||
MatrixObject *mat1 = NULL, *mat2 = NULL;
|
MatrixObject *mat1 = NULL, *mat2 = NULL;
|
||||||
PyObject *f = NULL;
|
PyObject *f = NULL;
|
||||||
VectorObject *vec = NULL;
|
|
||||||
PointObject *pt = NULL;
|
PointObject *pt = NULL;
|
||||||
|
|
||||||
mat1 = (MatrixObject*)m1;
|
mat1 = (MatrixObject*)m1;
|
||||||
|
|||||||
@@ -111,18 +111,15 @@ PyObject *Vector_Normalize(VectorObject * self)
|
|||||||
resize the vector to x,y */
|
resize the vector to x,y */
|
||||||
PyObject *Vector_Resize2D(VectorObject * self)
|
PyObject *Vector_Resize2D(VectorObject * self)
|
||||||
{
|
{
|
||||||
if(self->data.blend_data){
|
if(self->wrapped==Py_WRAP)
|
||||||
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
||||||
"vector.resize2d(): cannot resize wrapped data - only python vectors\n");
|
"vector.resize2d(): cannot resize wrapped data - only python vectors\n");
|
||||||
}
|
|
||||||
|
|
||||||
self->data.py_data =
|
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2));
|
||||||
PyMem_Realloc(self->data.py_data, (sizeof(float) * 2));
|
if(self->vec == NULL)
|
||||||
if(self->data.py_data == NULL) {
|
|
||||||
return EXPP_ReturnPyObjError(PyExc_MemoryError,
|
return EXPP_ReturnPyObjError(PyExc_MemoryError,
|
||||||
"vector.resize2d(): problem allocating pointer space\n\n");
|
"vector.resize2d(): problem allocating pointer space\n\n");
|
||||||
}
|
|
||||||
self->vec = self->data.py_data; /*force*/
|
|
||||||
self->size = 2;
|
self->size = 2;
|
||||||
return EXPP_incr_ret((PyObject*)self);
|
return EXPP_incr_ret((PyObject*)self);
|
||||||
}
|
}
|
||||||
@@ -130,21 +127,18 @@ PyObject *Vector_Resize2D(VectorObject * self)
|
|||||||
resize the vector to x,y,z */
|
resize the vector to x,y,z */
|
||||||
PyObject *Vector_Resize3D(VectorObject * self)
|
PyObject *Vector_Resize3D(VectorObject * self)
|
||||||
{
|
{
|
||||||
if(self->data.blend_data){
|
if (self->wrapped==Py_WRAP)
|
||||||
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
||||||
"vector.resize3d(): cannot resize wrapped data - only python vectors\n");
|
"vector.resize3d(): cannot resize wrapped data - only python vectors\n");
|
||||||
}
|
|
||||||
|
|
||||||
self->data.py_data =
|
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3));
|
||||||
PyMem_Realloc(self->data.py_data, (sizeof(float) * 3));
|
if(self->vec == NULL)
|
||||||
if(self->data.py_data == NULL) {
|
|
||||||
return EXPP_ReturnPyObjError(PyExc_MemoryError,
|
return EXPP_ReturnPyObjError(PyExc_MemoryError,
|
||||||
"vector.resize3d(): problem allocating pointer space\n\n");
|
"vector.resize3d(): problem allocating pointer space\n\n");
|
||||||
}
|
|
||||||
self->vec = self->data.py_data; /*force*/
|
if(self->size == 2)
|
||||||
if(self->size == 2){
|
self->vec[2] = 0.0f;
|
||||||
self->data.py_data[2] = 0.0f;
|
|
||||||
}
|
|
||||||
self->size = 3;
|
self->size = 3;
|
||||||
return EXPP_incr_ret((PyObject*)self);
|
return EXPP_incr_ret((PyObject*)self);
|
||||||
}
|
}
|
||||||
@@ -152,23 +146,20 @@ PyObject *Vector_Resize3D(VectorObject * self)
|
|||||||
resize the vector to x,y,z,w */
|
resize the vector to x,y,z,w */
|
||||||
PyObject *Vector_Resize4D(VectorObject * self)
|
PyObject *Vector_Resize4D(VectorObject * self)
|
||||||
{
|
{
|
||||||
if(self->data.blend_data){
|
if(self->wrapped==Py_WRAP)
|
||||||
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
||||||
"vector.resize4d(): cannot resize wrapped data - only python vectors\n");
|
"vector.resize4d(): cannot resize wrapped data - only python vectors\n");
|
||||||
}
|
|
||||||
|
|
||||||
self->data.py_data =
|
self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4));
|
||||||
PyMem_Realloc(self->data.py_data, (sizeof(float) * 4));
|
if(self->vec == NULL)
|
||||||
if(self->data.py_data == NULL) {
|
|
||||||
return EXPP_ReturnPyObjError(PyExc_MemoryError,
|
return EXPP_ReturnPyObjError(PyExc_MemoryError,
|
||||||
"vector.resize4d(): problem allocating pointer space\n\n");
|
"vector.resize4d(): problem allocating pointer space\n\n");
|
||||||
}
|
|
||||||
self->vec = self->data.py_data; /*force*/
|
|
||||||
if(self->size == 2){
|
if(self->size == 2){
|
||||||
self->data.py_data[2] = 0.0f;
|
self->vec[2] = 0.0f;
|
||||||
self->data.py_data[3] = 1.0f;
|
self->vec[3] = 1.0f;
|
||||||
}else if(self->size == 3){
|
}else if(self->size == 3){
|
||||||
self->data.py_data[3] = 1.0f;
|
self->vec[3] = 1.0f;
|
||||||
}
|
}
|
||||||
self->size = 4;
|
self->size = 4;
|
||||||
return EXPP_incr_ret((PyObject*)self);
|
return EXPP_incr_ret((PyObject*)self);
|
||||||
@@ -296,9 +287,9 @@ PyObject *Vector_copy(VectorObject * self)
|
|||||||
free the py_object */
|
free the py_object */
|
||||||
static void Vector_dealloc(VectorObject * self)
|
static void Vector_dealloc(VectorObject * self)
|
||||||
{
|
{
|
||||||
/*only free py_data*/
|
/* only free non wrapped */
|
||||||
if(self->data.py_data){
|
if(self->wrapped != Py_WRAP){
|
||||||
PyMem_Free(self->data.py_data);
|
PyMem_Free(self->vec);
|
||||||
}
|
}
|
||||||
PyObject_DEL(self);
|
PyObject_DEL(self);
|
||||||
}
|
}
|
||||||
@@ -1223,19 +1214,15 @@ PyObject *newVectorObject(float *vec, int size, int type)
|
|||||||
int i;
|
int i;
|
||||||
VectorObject *self = PyObject_NEW(VectorObject, &vector_Type);
|
VectorObject *self = PyObject_NEW(VectorObject, &vector_Type);
|
||||||
|
|
||||||
self->data.blend_data = NULL;
|
|
||||||
self->data.py_data = NULL;
|
|
||||||
if(size > 4 || size < 2)
|
if(size > 4 || size < 2)
|
||||||
return NULL;
|
return NULL;
|
||||||
self->size = size;
|
self->size = size;
|
||||||
|
|
||||||
if(type == Py_WRAP){
|
if(type == Py_WRAP) {
|
||||||
self->data.blend_data = vec;
|
self->vec = vec;
|
||||||
self->vec = self->data.blend_data;
|
|
||||||
self->wrapped = Py_WRAP;
|
self->wrapped = Py_WRAP;
|
||||||
}else if (type == Py_NEW){
|
} else if (type == Py_NEW) {
|
||||||
self->data.py_data = PyMem_Malloc(size * sizeof(float));
|
self->vec = PyMem_Malloc(size * sizeof(float));
|
||||||
self->vec = self->data.py_data;
|
|
||||||
if(!vec) { /*new empty*/
|
if(!vec) { /*new empty*/
|
||||||
for(i = 0; i < size; i++){
|
for(i = 0; i < size; i++){
|
||||||
self->vec[i] = 0.0f;
|
self->vec[i] = 0.0f;
|
||||||
|
|||||||
@@ -41,22 +41,10 @@ extern PyTypeObject vector_Type;
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_VAR_HEAD
|
PyObject_VAR_HEAD
|
||||||
struct{
|
float *vec; /*1D array of data (alias), wrapped status depends on wrapped status */
|
||||||
float *py_data; //python managed
|
short size; /* vec size 2,3 or 4 */
|
||||||
float *blend_data; //blender managed
|
short wrapped; /* is wrapped data? */
|
||||||
}data;
|
|
||||||
float *vec; //1D array of data (alias)
|
|
||||||
int size;
|
|
||||||
int wrapped; //is wrapped data?
|
|
||||||
} VectorObject;
|
} 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
|
//prototypes
|
||||||
PyObject *Vector_Zero( VectorObject * self );
|
PyObject *Vector_Zero( VectorObject * self );
|
||||||
|
|||||||
Reference in New Issue
Block a user