* Added some internal functions to the Material module
* Updated the Object module with some more functions. Only 1 function left to implement. * Removed the getDeformData function declaration.
This commit is contained in:
@@ -472,7 +472,7 @@ static void Material_Dealloc (BPy_Material *self)
|
|||||||
/* Description: This function will create a new BPy_Material from an existing*/
|
/* Description: This function will create a new BPy_Material from an existing*/
|
||||||
/* Blender material structure. */
|
/* Blender material structure. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *Material_CreatePyObject (Material *mat)
|
PyObject *Material_CreatePyObject (struct Material *mat)
|
||||||
{
|
{
|
||||||
BPy_Material *pymat;
|
BPy_Material *pymat;
|
||||||
float *col[3], *amb[3], *spec[3], *mir[3];
|
float *col[3], *amb[3], *spec[3], *mir[3];
|
||||||
@@ -1390,3 +1390,75 @@ Material **EXPP_newMaterialList(int len)
|
|||||||
|
|
||||||
return matlist;
|
return matlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int EXPP_releaseMaterialList (Material **matlist, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
Material * mat;
|
||||||
|
|
||||||
|
if ((len < 0) || (len > MAXMAT)) {
|
||||||
|
printf ("illegal matindex!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0 ; i<len ; i++) {
|
||||||
|
mat = matlist[i];
|
||||||
|
if (mat != NULL) {
|
||||||
|
if (((ID *)mat)->us > 0)
|
||||||
|
((ID *)mat)->us--;
|
||||||
|
else
|
||||||
|
printf ("FATAL: material usage=0: %s", ((ID *)mat)->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MEM_freeN (matlist);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** expands pointer array of length 'oldsize' to length 'newsize'.
|
||||||
|
* A pointer to the (void *) array must be passed as first argument
|
||||||
|
* The array pointer content can be NULL, in this case a new array of length
|
||||||
|
* 'newsize' is created.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int expandPtrArray(void **p, int oldsize, int newsize)
|
||||||
|
{
|
||||||
|
void *newarray;
|
||||||
|
|
||||||
|
if (newsize < oldsize) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
newarray = MEM_callocN(newsize * sizeof(void *), "PtrArray");
|
||||||
|
if (*p) {
|
||||||
|
memcpy(newarray, *p, oldsize);
|
||||||
|
MEM_freeN(*p);
|
||||||
|
}
|
||||||
|
*p = newarray;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EXPP_synchronizeMaterialLists (Object *object, void *data)
|
||||||
|
{
|
||||||
|
Material *** p_dataMaterials = give_matarar (object);
|
||||||
|
short * nmaterials = give_totcolp (object);
|
||||||
|
|
||||||
|
if (object->totcol > *nmaterials) {
|
||||||
|
/* More object mats than data mats */
|
||||||
|
*nmaterials = object->totcol;
|
||||||
|
return expandPtrArray ((void *) p_dataMaterials,
|
||||||
|
*nmaterials,
|
||||||
|
object->totcol);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (object->totcol < *nmaterials) {
|
||||||
|
/* More data mats than object mats */
|
||||||
|
object->totcol = *nmaterials;
|
||||||
|
return expandPtrArray ((void *) &object->mat,
|
||||||
|
object->totcol,
|
||||||
|
*nmaterials);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No synchronization is needed; they're of equal length */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@@ -82,7 +82,6 @@ struct PyMethodDef M_Object_methods[] = {
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Object_clrParent (BPy_Object *self, PyObject *args);
|
static PyObject *Object_clrParent (BPy_Object *self, PyObject *args);
|
||||||
static PyObject *Object_getData (BPy_Object *self);
|
static PyObject *Object_getData (BPy_Object *self);
|
||||||
static PyObject *Object_getDeformData (BPy_Object *self);
|
|
||||||
static PyObject *Object_getDeltaLocation (BPy_Object *self);
|
static PyObject *Object_getDeltaLocation (BPy_Object *self);
|
||||||
static PyObject *Object_getDrawMode (BPy_Object *self);
|
static PyObject *Object_getDrawMode (BPy_Object *self);
|
||||||
static PyObject *Object_getDrawType (BPy_Object *self);
|
static PyObject *Object_getDrawType (BPy_Object *self);
|
||||||
@@ -119,9 +118,6 @@ hierarchy (faster)"},
|
|||||||
{"getData", (PyCFunction)Object_getData, METH_NOARGS,
|
{"getData", (PyCFunction)Object_getData, METH_NOARGS,
|
||||||
"Returns the datablock object containing the object's data, \
|
"Returns the datablock object containing the object's data, \
|
||||||
e.g. Mesh"},
|
e.g. Mesh"},
|
||||||
{"getDeformData", (PyCFunction)Object_getDeformData, METH_NOARGS,
|
|
||||||
"Returns the datablock object containing the object's deformed \
|
|
||||||
data.\nCurrently, this is only supported for a Mesh"},
|
|
||||||
{"getDeltaLocation", (PyCFunction)Object_getDeltaLocation, METH_NOARGS,
|
{"getDeltaLocation", (PyCFunction)Object_getDeltaLocation, METH_NOARGS,
|
||||||
"Returns the object's delta location (x, y, z)"},
|
"Returns the object's delta location (x, y, z)"},
|
||||||
{"getDrawMode", (PyCFunction)Object_getDrawMode, METH_NOARGS,
|
{"getDrawMode", (PyCFunction)Object_getDrawMode, METH_NOARGS,
|
||||||
@@ -592,6 +588,7 @@ static PyObject *Object_getData (BPy_Object *self)
|
|||||||
data_object = Image_CreatePyObject (self->object->data);
|
data_object = Image_CreatePyObject (self->object->data);
|
||||||
break;
|
break;
|
||||||
case ID_IP:
|
case ID_IP:
|
||||||
|
data_object = Ipo_CreatePyObject (self->object->data);
|
||||||
break;
|
break;
|
||||||
case OB_LAMP://#ID_LA:
|
case OB_LAMP://#ID_LA:
|
||||||
data_object = Lamp_CreatePyObject (self->object->data);
|
data_object = Lamp_CreatePyObject (self->object->data);
|
||||||
@@ -607,6 +604,7 @@ static PyObject *Object_getData (BPy_Object *self)
|
|||||||
case ID_SCE:
|
case ID_SCE:
|
||||||
break;
|
break;
|
||||||
case ID_TXT:
|
case ID_TXT:
|
||||||
|
data_object = Text_CreatePyObject (self->object->data);
|
||||||
break;
|
break;
|
||||||
case ID_WO:
|
case ID_WO:
|
||||||
break;
|
break;
|
||||||
@@ -626,12 +624,6 @@ static PyObject *Object_getData (BPy_Object *self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Object_getDeformData (BPy_Object *self)
|
|
||||||
{
|
|
||||||
return (PythonReturnErrorObject (PyExc_NotImplementedError,
|
|
||||||
"getDeformData: not yet implemented"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *Object_getDeltaLocation (BPy_Object *self)
|
static PyObject *Object_getDeltaLocation (BPy_Object *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = Py_BuildValue ("fff",
|
PyObject *attr = Py_BuildValue ("fff",
|
||||||
@@ -704,9 +696,8 @@ static PyObject *Object_getLocation (BPy_Object *self, PyObject *args)
|
|||||||
|
|
||||||
static PyObject *Object_getMaterials (BPy_Object *self)
|
static PyObject *Object_getMaterials (BPy_Object *self)
|
||||||
{
|
{
|
||||||
/* TODO: Implement when the Material module is implemented. */
|
return (EXPP_PyList_fromMaterialList (self->object->mat,
|
||||||
return (PythonReturnErrorObject (PyExc_NotImplementedError,
|
self->object->totcol));
|
||||||
"getMaterials: not yet implemented"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Object_getMatrix (BPy_Object *self)
|
static PyObject *Object_getMatrix (BPy_Object *self)
|
||||||
@@ -1034,7 +1025,6 @@ static PyObject *Object_setLocation (BPy_Object *self, PyObject *args)
|
|||||||
|
|
||||||
static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args)
|
static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
PyObject * list;
|
PyObject * list;
|
||||||
int len;
|
int len;
|
||||||
int i;
|
int i;
|
||||||
@@ -1063,8 +1053,7 @@ static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args)
|
|||||||
|
|
||||||
if (self->object->mat)
|
if (self->object->mat)
|
||||||
{
|
{
|
||||||
/* TODO: create replacement function */
|
EXPP_releaseMaterialList (self->object->mat, len);
|
||||||
releaseMaterialList (self->object->mat, len);
|
|
||||||
}
|
}
|
||||||
/* Increase the user count on all materials */
|
/* Increase the user count on all materials */
|
||||||
for (i=0 ; i<len ; i++)
|
for (i=0 ; i<len ; i++)
|
||||||
@@ -1081,19 +1070,15 @@ static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args)
|
|||||||
case OB_FONT: /* fall through */
|
case OB_FONT: /* fall through */
|
||||||
case OB_MESH: /* fall through */
|
case OB_MESH: /* fall through */
|
||||||
case OB_MBALL: /* fall through */
|
case OB_MBALL: /* fall through */
|
||||||
case OB_SURF
|
case OB_SURF:
|
||||||
/* TODO: create replacement function */:
|
EXPP_synchronizeMaterialLists (self->object,
|
||||||
synchronizeMaterialLists (self->object, self->object->data);
|
self->object->data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (Py_None);
|
return (Py_None);
|
||||||
#endif
|
|
||||||
|
|
||||||
return (PythonReturnErrorObject (PyExc_NotImplementedError,
|
|
||||||
"setMaterials: not yet implemented"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Object_setName (BPy_Object *self, PyObject *args)
|
static PyObject *Object_setName (BPy_Object *self, PyObject *args)
|
||||||
|
@@ -103,10 +103,6 @@ class Object:
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getDeformData():
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
|
|
||||||
def getDeltaLocation():
|
def getDeltaLocation():
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
@@ -84,6 +84,13 @@ int NMesh_CheckPyObject (PyObject *pyobj);
|
|||||||
|
|
||||||
/* Material */
|
/* Material */
|
||||||
PyObject * Material_Init (void);
|
PyObject * Material_Init (void);
|
||||||
|
PyObject * Material_CreatePyObject (struct Material *mat);
|
||||||
|
int Material_CheckPyObject (PyObject *pyobj);
|
||||||
|
Material **EXPP_newMaterialList_fromPyList (PyObject *list);
|
||||||
|
Material **EXPP_newMaterialList(int len);
|
||||||
|
int EXPP_releaseMaterialList (Material **matlist, int len);
|
||||||
|
int EXPP_synchronizeMaterialLists (Object *object, void *data);
|
||||||
|
PyObject * EXPP_PyList_fromMaterialList(Material **matlist, int len);
|
||||||
|
|
||||||
/* Camera Data */
|
/* Camera Data */
|
||||||
PyObject * Camera_Init (void);
|
PyObject * Camera_Init (void);
|
||||||
|
Reference in New Issue
Block a user