Many long standing memory leaks fixed in the BPY api.
Data from Armature.c and logic.c still leaks. Mostly todo with PyList_Append adding a refcount and the bpython api not decrefing. Also added some features needed to fix a bug in mesh_clean.py (ob.pinShape and ob.activeShape)
This commit is contained in:
@@ -877,6 +877,7 @@ int BPY_menu_do_python( short menutype, int event )
|
|||||||
|
|
||||||
if( !setup_armature_weakrefs()){
|
if( !setup_armature_weakrefs()){
|
||||||
printf("Oops - weakref dict\n");
|
printf("Oops - weakref dict\n");
|
||||||
|
MEM_freeN( buffer );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,17 +118,18 @@ static PyMethodDef BPy_BonesDict_methods[] = {
|
|||||||
//-----------------(internal)
|
//-----------------(internal)
|
||||||
static int BoneMapping_Init(PyObject *dictionary, ListBase *bones){
|
static int BoneMapping_Init(PyObject *dictionary, ListBase *bones){
|
||||||
Bone *bone = NULL;
|
Bone *bone = NULL;
|
||||||
PyObject *py_bone = NULL;
|
PyObject *py_bone = NULL, *str;
|
||||||
|
|
||||||
for (bone = bones->first; bone; bone = bone->next){
|
for (bone = bones->first; bone; bone = bone->next){
|
||||||
py_bone = PyBone_FromBone(bone);
|
py_bone = PyBone_FromBone(bone);
|
||||||
if (!py_bone)
|
if (!py_bone)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(PyDict_SetItem(dictionary,
|
str = PyString_FromString(bone->name);
|
||||||
PyString_FromString(bone->name), py_bone) == -1){
|
if(PyDict_SetItem(dictionary, str, py_bone) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
Py_DECREF(str);
|
||||||
Py_DECREF(py_bone);
|
Py_DECREF(py_bone);
|
||||||
if (bone->childbase.first)
|
if (bone->childbase.first)
|
||||||
BoneMapping_Init(dictionary, &bone->childbase);
|
BoneMapping_Init(dictionary, &bone->childbase);
|
||||||
@@ -138,17 +139,18 @@ static int BoneMapping_Init(PyObject *dictionary, ListBase *bones){
|
|||||||
//-----------------(internal)
|
//-----------------(internal)
|
||||||
static int EditBoneMapping_Init(PyObject *dictionary, ListBase *editbones){
|
static int EditBoneMapping_Init(PyObject *dictionary, ListBase *editbones){
|
||||||
EditBone *editbone = NULL;
|
EditBone *editbone = NULL;
|
||||||
PyObject *py_editbone = NULL;
|
PyObject *py_editbone = NULL, *str;
|
||||||
|
|
||||||
for (editbone = editbones->first; editbone; editbone = editbone->next){
|
for (editbone = editbones->first; editbone; editbone = editbone->next){
|
||||||
py_editbone = PyEditBone_FromEditBone(editbone);
|
py_editbone = PyEditBone_FromEditBone(editbone);
|
||||||
if (!py_editbone)
|
if (!py_editbone)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(PyDict_SetItem(dictionary,
|
str = PyString_FromString(editbone->name);
|
||||||
PyString_FromString(editbone->name), py_editbone) == -1){
|
if(PyDict_SetItem(dictionary, str, py_editbone) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
Py_DECREF(str);
|
||||||
Py_DECREF(py_editbone);
|
Py_DECREF(py_editbone);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -215,7 +217,7 @@ static void BonesDict_dealloc(BPy_BonesDict * self)
|
|||||||
Py_DECREF(self->bonesMap);
|
Py_DECREF(self->bonesMap);
|
||||||
Py_DECREF(self->editbonesMap);
|
Py_DECREF(self->editbonesMap);
|
||||||
BLI_freelistN(&self->editbones);
|
BLI_freelistN(&self->editbones);
|
||||||
BonesDict_Type.tp_free(self);
|
PyObject_DEL( self );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//------------------------mp_length
|
//------------------------mp_length
|
||||||
@@ -422,10 +424,7 @@ PyTypeObject BonesDict_Type = {
|
|||||||
//-----------------------PyBonesDict_FromPyArmature
|
//-----------------------PyBonesDict_FromPyArmature
|
||||||
static PyObject *PyBonesDict_FromPyArmature(BPy_Armature *py_armature)
|
static PyObject *PyBonesDict_FromPyArmature(BPy_Armature *py_armature)
|
||||||
{
|
{
|
||||||
BPy_BonesDict *py_BonesDict = NULL;
|
BPy_BonesDict *py_BonesDict = (BPy_BonesDict *)PyObject_NEW( BPy_BonesDict, &BonesDict_Type );
|
||||||
|
|
||||||
//create py object
|
|
||||||
py_BonesDict = (BPy_BonesDict *)BonesDict_Type.tp_alloc(&BonesDict_Type, 0);
|
|
||||||
if (!py_BonesDict)
|
if (!py_BonesDict)
|
||||||
goto RuntimeError;
|
goto RuntimeError;
|
||||||
|
|
||||||
@@ -1067,9 +1066,9 @@ static void Armature_dealloc(BPy_Armature * self)
|
|||||||
{
|
{
|
||||||
if (self->weaklist != NULL)
|
if (self->weaklist != NULL)
|
||||||
PyObject_ClearWeakRefs((PyObject *) self);
|
PyObject_ClearWeakRefs((PyObject *) self);
|
||||||
|
|
||||||
Py_DECREF(self->Bones);
|
Py_DECREF(self->Bones);
|
||||||
Armature_Type.tp_free(self);
|
PyObject_DEL( self );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
//------------------TYPE_OBECT DEFINITION--------------------------
|
//------------------TYPE_OBECT DEFINITION--------------------------
|
||||||
PyTypeObject Armature_Type = {
|
PyTypeObject Armature_Type = {
|
||||||
@@ -1291,8 +1290,12 @@ PyObject *Armature_RebuildBones(PyObject *pyarmature)
|
|||||||
{
|
{
|
||||||
return Armature_update((BPy_Armature*)pyarmature);
|
return Armature_update((BPy_Armature*)pyarmature);
|
||||||
}
|
}
|
||||||
//-----------------(internal)
|
/*-----------------(internal)
|
||||||
//Converts a bArmature to a PyArmature
|
* Converts a bArmature to a PyArmature
|
||||||
|
*
|
||||||
|
* WARNING!!! - MEMORY LEAK HERE, Run in a loop and loose your ram.
|
||||||
|
* cannot find out why but dosnt seam to be the weakref */
|
||||||
|
|
||||||
PyObject *Armature_CreatePyObject(struct bArmature *armature)
|
PyObject *Armature_CreatePyObject(struct bArmature *armature)
|
||||||
{
|
{
|
||||||
BPy_Armature *py_armature = NULL;
|
BPy_Armature *py_armature = NULL;
|
||||||
@@ -1300,15 +1303,16 @@ PyObject *Armature_CreatePyObject(struct bArmature *armature)
|
|||||||
PyObject *armlist = NULL; /* list of armature weak refs */
|
PyObject *armlist = NULL; /* list of armature weak refs */
|
||||||
char *list_name = ARM_WEAKREF_LIST_NAME;
|
char *list_name = ARM_WEAKREF_LIST_NAME;
|
||||||
|
|
||||||
//create armature type
|
/*create armature type*/
|
||||||
py_armature = (BPy_Armature*)Armature_Type.tp_alloc(&Armature_Type, 0); /*new*/
|
py_armature = PyObject_NEW( BPy_Armature, &Armature_Type );
|
||||||
|
|
||||||
if (!py_armature){
|
if (!py_armature){
|
||||||
printf("Oops - can't create py armature\n");
|
printf("Oops - can't create py armature\n");
|
||||||
goto RuntimeError;
|
goto RuntimeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
py_armature->weaklist = NULL; //init the weaklist
|
|
||||||
py_armature->armature = armature;
|
py_armature->armature = armature;
|
||||||
|
py_armature->weaklist = NULL; //init the weaklist
|
||||||
|
|
||||||
//create armature.bones
|
//create armature.bones
|
||||||
py_armature->Bones = (BPy_BonesDict*)PyBonesDict_FromPyArmature(py_armature);
|
py_armature->Bones = (BPy_BonesDict*)PyBonesDict_FromPyArmature(py_armature);
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ static PyObject *EditBone_hasParent(BPy_EditBone *self)
|
|||||||
{
|
{
|
||||||
if (self->editbone){
|
if (self->editbone){
|
||||||
if (self->editbone->parent)
|
if (self->editbone->parent)
|
||||||
return EXPP_incr_ret(Py_True);
|
Py_RETURN_TRUE;
|
||||||
else
|
else
|
||||||
return EXPP_incr_ret(Py_False);
|
Py_RETURN_FALSE;
|
||||||
}else{
|
}else{
|
||||||
goto AttributeError;
|
goto AttributeError;
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ static PyObject *EditBone_clearParent(BPy_EditBone *self)
|
|||||||
if (self->editbone){
|
if (self->editbone){
|
||||||
if (self->editbone->parent)
|
if (self->editbone->parent)
|
||||||
self->editbone->parent = NULL;
|
self->editbone->parent = NULL;
|
||||||
return EXPP_incr_ret(Py_None);
|
Py_RETURN_NONE;
|
||||||
}else{
|
}else{
|
||||||
goto AttributeError;
|
goto AttributeError;
|
||||||
}
|
}
|
||||||
@@ -406,9 +406,10 @@ static PyObject *EditBone_getOptions(BPy_EditBone *self, void *closure)
|
|||||||
goto RuntimeError;
|
goto RuntimeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXPP_incr_ret(list);
|
return list;
|
||||||
|
|
||||||
RuntimeError:
|
RuntimeError:
|
||||||
|
Py_XDECREF( list );
|
||||||
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
|
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
|
||||||
sEditBoneError, ".options: ", "Internal failure!");
|
sEditBoneError, ".options: ", "Internal failure!");
|
||||||
}
|
}
|
||||||
@@ -515,9 +516,9 @@ static PyObject *EditBone_getParent(BPy_EditBone *self, void *closure)
|
|||||||
if (self->editbone->parent)
|
if (self->editbone->parent)
|
||||||
return PyEditBone_FromEditBone(self->editbone->parent);
|
return PyEditBone_FromEditBone(self->editbone->parent);
|
||||||
else
|
else
|
||||||
return EXPP_incr_ret(Py_None);
|
Py_RETURN_NONE;
|
||||||
}else{
|
}else{
|
||||||
return EXPP_incr_ret(Py_None); //not in the list yet can't have a parent
|
Py_RETURN_NONE; //not in the list yet can't have a parent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//------------------------EditBone.parent (set)
|
//------------------------EditBone.parent (set)
|
||||||
@@ -880,43 +881,45 @@ static int PyBone_ChildrenAsList(PyObject *list, ListBase *bones){
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(PyList_Append(list, py_bone) == -1){
|
if(PyList_Append(list, py_bone) == -1){
|
||||||
goto RuntimeError;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Py_DECREF(py_bone);
|
||||||
if (bone->childbase.first)
|
if (bone->childbase.first)
|
||||||
PyBone_ChildrenAsList(list, &bone->childbase);
|
if (!PyBone_ChildrenAsList(list, &bone->childbase))
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
RuntimeError:
|
|
||||||
return EXPP_intError(PyExc_RuntimeError, "%s%s",
|
|
||||||
sBoneError, "Internal error trying to wrap blender bones!");
|
|
||||||
}
|
}
|
||||||
//-------------------------Bone.hasParent()
|
//-------------------------Bone.hasParent()
|
||||||
static PyObject *Bone_hasParent(BPy_Bone *self)
|
static PyObject *Bone_hasParent(BPy_Bone *self)
|
||||||
{
|
{
|
||||||
if (self->bone->parent)
|
if (self->bone->parent)
|
||||||
return EXPP_incr_ret(Py_True);
|
Py_RETURN_TRUE;
|
||||||
else
|
else
|
||||||
return EXPP_incr_ret(Py_False);
|
Py_RETURN_FALSE;
|
||||||
}
|
}
|
||||||
//-------------------------Bone.hasChildren()
|
//-------------------------Bone.hasChildren()
|
||||||
static PyObject *Bone_hasChildren(BPy_Bone *self)
|
static PyObject *Bone_hasChildren(BPy_Bone *self)
|
||||||
{
|
{
|
||||||
if (self->bone->childbase.first)
|
if (self->bone->childbase.first)
|
||||||
return EXPP_incr_ret(Py_True);
|
Py_RETURN_TRUE;
|
||||||
else
|
else
|
||||||
return EXPP_incr_ret(Py_False);
|
Py_RETURN_FALSE;
|
||||||
}
|
}
|
||||||
//-------------------------Bone.getAllChildren()
|
//-------------------------Bone.getAllChildren()
|
||||||
static PyObject *Bone_getAllChildren(BPy_Bone *self)
|
static PyObject *Bone_getAllChildren(BPy_Bone *self)
|
||||||
{
|
{
|
||||||
PyObject *list = PyList_New(0);
|
PyObject *list = PyList_New(0);
|
||||||
|
if (!self->bone->childbase.first) {
|
||||||
if (self->bone->childbase.first)
|
/* do nothing */
|
||||||
if (!PyBone_ChildrenAsList(list, &self->bone->childbase))
|
} else if (!PyBone_ChildrenAsList(list, &self->bone->childbase)) {
|
||||||
return NULL;
|
Py_XDECREF(list);
|
||||||
return EXPP_incr_ret(list);
|
EXPP_objError(PyExc_RuntimeError, "%s%s",
|
||||||
|
sBoneError, "Internal error trying to wrap blender bones!");
|
||||||
}
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------ATTRIBUTE IMPLEMENTATIONS-----------------------------
|
//------------------ATTRIBUTE IMPLEMENTATIONS-----------------------------
|
||||||
//------------------------Bone.name (get)
|
//------------------------Bone.name (get)
|
||||||
static PyObject *Bone_getName(BPy_Bone *self, void *closure)
|
static PyObject *Bone_getName(BPy_Bone *self, void *closure)
|
||||||
@@ -1044,9 +1047,10 @@ static PyObject *Bone_getOptions(BPy_Bone *self, void *closure)
|
|||||||
EXPP_GetModuleConstant("Blender.Armature", "TIP_SELECTED")) == -1)
|
EXPP_GetModuleConstant("Blender.Armature", "TIP_SELECTED")) == -1)
|
||||||
goto RuntimeError;
|
goto RuntimeError;
|
||||||
|
|
||||||
return EXPP_incr_ret(list);
|
return list;
|
||||||
|
|
||||||
RuntimeError:
|
RuntimeError:
|
||||||
|
Py_XDECREF(list);
|
||||||
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
|
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
|
||||||
sBoneError, "getOptions(): ", "Internal failure!");
|
sBoneError, "getOptions(): ", "Internal failure!");
|
||||||
}
|
}
|
||||||
@@ -1062,7 +1066,7 @@ static PyObject *Bone_getParent(BPy_Bone *self, void *closure)
|
|||||||
if (self->bone->parent)
|
if (self->bone->parent)
|
||||||
return PyBone_FromBone(self->bone->parent);
|
return PyBone_FromBone(self->bone->parent);
|
||||||
else
|
else
|
||||||
return EXPP_incr_ret(Py_None);
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
//------------------------Bone.parent (set)
|
//------------------------Bone.parent (set)
|
||||||
static int Bone_setParent(BPy_Bone *self, PyObject *value, void *closure)
|
static int Bone_setParent(BPy_Bone *self, PyObject *value, void *closure)
|
||||||
@@ -1081,15 +1085,17 @@ static PyObject *Bone_getChildren(BPy_Bone *self, void *closure)
|
|||||||
for (bone = self->bone->childbase.first; bone; bone = bone->next){
|
for (bone = self->bone->childbase.first; bone; bone = bone->next){
|
||||||
py_bone = PyBone_FromBone(bone);
|
py_bone = PyBone_FromBone(bone);
|
||||||
if (py_bone == NULL)
|
if (py_bone == NULL)
|
||||||
return 0;
|
|
||||||
if(PyList_Append(list, py_bone) == -1){
|
|
||||||
goto RuntimeError;
|
goto RuntimeError;
|
||||||
|
if (PyList_Append(list, py_bone) == -1)
|
||||||
|
goto RuntimeError;
|
||||||
|
Py_DECREF(py_bone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return list;
|
||||||
return EXPP_incr_ret(list);
|
|
||||||
|
|
||||||
RuntimeError:
|
RuntimeError:
|
||||||
|
Py_XDECREF(list);
|
||||||
|
Py_XDECREF(py_bone);
|
||||||
return EXPP_objError(PyExc_RuntimeError, "%s%s",
|
return EXPP_objError(PyExc_RuntimeError, "%s%s",
|
||||||
sBoneError, "Internal error trying to wrap blender bones!");
|
sBoneError, "Internal error trying to wrap blender bones!");
|
||||||
}
|
}
|
||||||
@@ -1309,19 +1315,11 @@ RuntimeError:
|
|||||||
//Converts a struct Bone to a BPy_Bone
|
//Converts a struct Bone to a BPy_Bone
|
||||||
PyObject *PyBone_FromBone(struct Bone *bone)
|
PyObject *PyBone_FromBone(struct Bone *bone)
|
||||||
{
|
{
|
||||||
BPy_Bone *py_Bone = NULL;
|
BPy_Bone *py_Bone = ( BPy_Bone * ) PyObject_NEW( BPy_Bone, &Bone_Type );
|
||||||
|
|
||||||
py_Bone = (BPy_Bone*)Bone_Type.tp_alloc(&Bone_Type, 0); //*new*
|
|
||||||
if (py_Bone == NULL)
|
|
||||||
goto RuntimeError;
|
|
||||||
|
|
||||||
py_Bone->bone = bone;
|
py_Bone->bone = bone;
|
||||||
|
|
||||||
return (PyObject *) py_Bone;
|
return (PyObject *) py_Bone;
|
||||||
|
|
||||||
RuntimeError:
|
|
||||||
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
|
|
||||||
sBoneError, "PyBone_FromBone: ", "Internal Error Ocurred");
|
|
||||||
}
|
}
|
||||||
//-----------------(internal)
|
//-----------------(internal)
|
||||||
//Converts a PyBone to a bBone
|
//Converts a PyBone to a bBone
|
||||||
|
|||||||
@@ -947,8 +947,7 @@ PyObject *CurNurb_pointAtIndex( Nurb * nurb, int index )
|
|||||||
|
|
||||||
for( i = 0; i < 4; i++ ) {
|
for( i = 0; i < 4; i++ ) {
|
||||||
PyList_SetItem( pyo, i,
|
PyList_SetItem( pyo, i,
|
||||||
PyFloat_FromDouble( nurb->bp[index].
|
PyFloat_FromDouble( nurb->bp[index].vec[i] ) );
|
||||||
vec[i] ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add Tilt only if curve is 3D */
|
/* add Tilt only if curve is 3D */
|
||||||
|
|||||||
@@ -1396,7 +1396,7 @@ static PyObject *M_Curve_Get( PyObject * self, PyObject * args )
|
|||||||
&Curve_Type );
|
&Curve_Type );
|
||||||
found_cur->curve = curv_iter;
|
found_cur->curve = curv_iter;
|
||||||
PyList_Append( curvlist, ( PyObject * ) found_cur );
|
PyList_Append( curvlist, ( PyObject * ) found_cur );
|
||||||
|
Py_DECREF(found_cur);
|
||||||
curv_iter = curv_iter->id.next;
|
curv_iter = curv_iter->id.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -787,9 +787,11 @@ static void exec_but_callback(void *pyobj, void *data)
|
|||||||
}
|
}
|
||||||
case BUT:
|
case BUT:
|
||||||
pyvalue = Py_None;
|
pyvalue = Py_None;
|
||||||
|
Py_INCREF(pyvalue);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pyvalue = Py_None;
|
pyvalue = Py_None;
|
||||||
|
Py_INCREF(pyvalue);
|
||||||
printf("Error, no button type matched.");
|
printf("Error, no button type matched.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,6 +804,7 @@ static void exec_but_callback(void *pyobj, void *data)
|
|||||||
|
|
||||||
result = PyObject_CallObject( callback, arg );
|
result = PyObject_CallObject( callback, arg );
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
Py_DECREF(pyvalue);
|
||||||
PyErr_Print( );
|
PyErr_Print( );
|
||||||
error( "Python script error: check console" );
|
error( "Python script error: check console" );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1494,7 +1494,7 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
|
|||||||
Effect *eff;
|
Effect *eff;
|
||||||
PartEff *paf;
|
PartEff *paf;
|
||||||
Particle *pa=0;
|
Particle *pa=0;
|
||||||
PyObject *list, *strand_list;
|
PyObject *list, *strand_list, *pyvec;
|
||||||
float p_time, c_time, vec[3], vec1[3], cfra, m_time, s_time;
|
float p_time, c_time, vec[3], vec1[3], cfra, m_time, s_time;
|
||||||
int a;
|
int a;
|
||||||
short disp=100 ;
|
short disp=100 ;
|
||||||
@@ -1545,12 +1545,17 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
|
|||||||
for(c_time= pa->time; c_time<m_time; c_time+=paf->staticstep) {
|
for(c_time= pa->time; c_time<m_time; c_time+=paf->staticstep) {
|
||||||
where_is_particle(paf, pa, c_time, vec);
|
where_is_particle(paf, pa, c_time, vec);
|
||||||
MTC_Mat4MulVecfl(ob->obmat, vec); /* make worldspace like the others */
|
MTC_Mat4MulVecfl(ob->obmat, vec); /* make worldspace like the others */
|
||||||
if( PyList_Append( strand_list, newVectorObject(vec, 3, Py_NEW)) < 0 ) {
|
pyvec = newVectorObject(vec, 3, Py_NEW);
|
||||||
|
if( PyList_Append( strand_list, pyvec) < 0 ) {
|
||||||
Py_DECREF( list );
|
Py_DECREF( list );
|
||||||
Py_DECREF( strand_list );
|
Py_DECREF( strand_list );
|
||||||
|
Py_XDECREF( pyvec );
|
||||||
|
|
||||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
"Couldn't append item to PyList" );
|
"Couldn't append item to PyList" );
|
||||||
}
|
}
|
||||||
|
Py_DECREF( pyvec );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( PyList_Append( list, strand_list) < 0 ) {
|
if( PyList_Append( list, strand_list) < 0 ) {
|
||||||
@@ -1589,12 +1594,14 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
|
|||||||
}
|
}
|
||||||
} else { /* not a vector */
|
} else { /* not a vector */
|
||||||
where_is_particle(paf, pa, c_time, vec);
|
where_is_particle(paf, pa, c_time, vec);
|
||||||
if( PyList_Append( list,
|
pyvec = newVectorObject(vec, 3, Py_NEW);
|
||||||
newVectorObject(vec, 3, Py_NEW)) < 0 ) {
|
if( PyList_Append( list, pyvec) < 0 ) {
|
||||||
Py_DECREF( list );
|
Py_DECREF( list );
|
||||||
|
Py_XDECREF( pyvec );
|
||||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
"Couldn't append item to PyList" );
|
"Couldn't append item to PyList" );
|
||||||
}
|
}
|
||||||
|
Py_DECREF( pyvec );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ static PyObject *Font_repr( BPy_Font * self )
|
|||||||
return PyString_FromFormat( "[Font \"%s\"]",
|
return PyString_FromFormat( "[Font \"%s\"]",
|
||||||
self->font->id.name+2 );
|
self->font->id.name+2 );
|
||||||
else
|
else
|
||||||
return PyString_FromString( "NULL" );
|
return PyString_FromString( "[Font - no data]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------- compare------------------------------------------*/
|
/*--------------- compare------------------------------------------*/
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ static PyGetSetDef BPy_Ipo_getseters[] = {
|
|||||||
(getter)Ipo_getBlocktype, (setter)NULL,
|
(getter)Ipo_getBlocktype, (setter)NULL,
|
||||||
"Ipo block type",
|
"Ipo block type",
|
||||||
NULL},
|
NULL},
|
||||||
{"rcft",
|
{"rctf",
|
||||||
(getter)Ipo_getRctf, (setter)Ipo_setRctf,
|
(getter)Ipo_getRctf, (setter)Ipo_setRctf,
|
||||||
"Ipo type",
|
"Ipo type",
|
||||||
NULL},
|
NULL},
|
||||||
@@ -830,11 +830,11 @@ static int Ipo_setBlocktype( BPy_Ipo * self, PyObject * args )
|
|||||||
|
|
||||||
static PyObject *Ipo_getRctf( BPy_Ipo * self )
|
static PyObject *Ipo_getRctf( BPy_Ipo * self )
|
||||||
{
|
{
|
||||||
PyObject *l = PyList_New( 0 );
|
PyObject *l = PyList_New( 4 );
|
||||||
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.xmin ) );
|
PyList_SET_ITEM( l, 0, PyFloat_FromDouble( self->ipo->cur.xmin ) );
|
||||||
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.xmax ) );
|
PyList_SET_ITEM( l, 1, PyFloat_FromDouble( self->ipo->cur.xmax ) );
|
||||||
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.ymin ) );
|
PyList_SET_ITEM( l, 2, PyFloat_FromDouble( self->ipo->cur.ymin ) );
|
||||||
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.ymax ) );
|
PyList_SET_ITEM( l, 3, PyFloat_FromDouble( self->ipo->cur.ymax ) );
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,12 +1018,14 @@ typeError:
|
|||||||
|
|
||||||
static PyObject *Ipo_getCurves( BPy_Ipo * self )
|
static PyObject *Ipo_getCurves( BPy_Ipo * self )
|
||||||
{
|
{
|
||||||
PyObject *attr = PyList_New( 0 );
|
PyObject *attr = PyList_New( 0 ), *pyipo;
|
||||||
IpoCurve *icu;
|
IpoCurve *icu;
|
||||||
|
|
||||||
for( icu = self->ipo->curve.first; icu; icu = icu->next )
|
for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
|
||||||
PyList_Append( attr, IpoCurve_CreatePyObject( icu ) );
|
pyipo = IpoCurve_CreatePyObject( icu );
|
||||||
|
PyList_Append( attr, pyipo );
|
||||||
|
Py_DECREF(pyipo);
|
||||||
|
}
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1110,14 +1112,16 @@ static PyObject *Ipo_getCurveNames( BPy_Ipo * self )
|
|||||||
/* find the ipo in the keylist */
|
/* find the ipo in the keylist */
|
||||||
for( key = G.main->key.first; key; key = key->id.next ) {
|
for( key = G.main->key.first; key; key = key->id.next ) {
|
||||||
if( key->ipo == self->ipo ) {
|
if( key->ipo == self->ipo ) {
|
||||||
|
PyObject *tmpstr;
|
||||||
KeyBlock *block = key->block.first;
|
KeyBlock *block = key->block.first;
|
||||||
attr = PyList_New( 0 );
|
attr = PyList_New( 0 );
|
||||||
|
|
||||||
/* add each name to the list */
|
/* add each name to the list */
|
||||||
for( block = key->block.first; block; block = block->next )
|
for( block = key->block.first; block; block = block->next ) {
|
||||||
PyList_Append( attr,
|
tmpstr = PyString_FromString( block->name );
|
||||||
PyString_FromString( block->name ) );
|
PyList_Append( attr, tmpstr);
|
||||||
|
Py_DECREF(tmpstr);
|
||||||
|
}
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1674,7 +1678,7 @@ static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
|
|||||||
struct BezTriple *ptrbt;
|
struct BezTriple *ptrbt;
|
||||||
int num = 0, pos, i, j;
|
int num = 0, pos, i, j;
|
||||||
IpoCurve *icu;
|
IpoCurve *icu;
|
||||||
PyObject *l = PyList_New( 0 );
|
PyObject *l = PyList_New( 0 ), *pyfloat;
|
||||||
|
|
||||||
if( !PyArg_ParseTuple( args, "ii", &num, &pos ) )
|
if( !PyArg_ParseTuple( args, "ii", &num, &pos ) )
|
||||||
return ( EXPP_ReturnPyObjError
|
return ( EXPP_ReturnPyObjError
|
||||||
@@ -1698,11 +1702,13 @@ static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
|
|||||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||||
"No bez triple" );
|
"No bez triple" );
|
||||||
|
|
||||||
for( i = 0; i < 3; i++ )
|
for( i = 0; i < 3; i++ ) {
|
||||||
for( j = 0; j < 3; j++ )
|
for( j = 0; j < 3; j++ ) {
|
||||||
PyList_Append( l,
|
pyfloat = PyFloat_FromDouble( ptrbt->vec[i][j] );
|
||||||
PyFloat_FromDouble( ptrbt->
|
PyList_Append( l, pyfloat );
|
||||||
vec[i][j] ) );
|
Py_DECREF(pyfloat);
|
||||||
|
}
|
||||||
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1823,8 +1829,7 @@ static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args )
|
|||||||
|
|
||||||
if( icu )
|
if( icu )
|
||||||
return PyFloat_FromDouble( icu->curval );
|
return PyFloat_FromDouble( icu->curval );
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
|
|
||||||
static int Key_compare( BPy_Key * a, BPy_Key * b );
|
static int Key_compare( BPy_Key * a, BPy_Key * b );
|
||||||
static PyObject *Key_repr( BPy_Key * self );
|
static PyObject *Key_repr( BPy_Key * self );
|
||||||
|
static void Key_dealloc( BPy_Key * self );
|
||||||
|
|
||||||
static PyObject *Key_getBlocks( BPy_Key * self );
|
static PyObject *Key_getBlocks( BPy_Key * self );
|
||||||
static PyObject *Key_getType( BPy_Key * self );
|
static PyObject *Key_getType( BPy_Key * self );
|
||||||
@@ -106,6 +107,10 @@ static int KeyBlock_setVgroup( BPy_KeyBlock *, PyObject * args );
|
|||||||
static int KeyBlock_setSlidermin( BPy_KeyBlock *, PyObject * args );
|
static int KeyBlock_setSlidermin( BPy_KeyBlock *, PyObject * args );
|
||||||
static int KeyBlock_setSlidermax( BPy_KeyBlock *, PyObject * args );
|
static int KeyBlock_setSlidermax( BPy_KeyBlock *, PyObject * args );
|
||||||
|
|
||||||
|
static void KeyBlock_dealloc( BPy_KeyBlock * self );
|
||||||
|
static int KeyBlock_compare( BPy_KeyBlock * a, BPy_KeyBlock * b );
|
||||||
|
static PyObject *KeyBlock_repr( BPy_KeyBlock * self );
|
||||||
|
|
||||||
static struct PyMethodDef KeyBlock_methods[] = {
|
static struct PyMethodDef KeyBlock_methods[] = {
|
||||||
{ "getData", (PyCFunction) KeyBlock_getData, METH_NOARGS,
|
{ "getData", (PyCFunction) KeyBlock_getData, METH_NOARGS,
|
||||||
"Get keyblock data" },
|
"Get keyblock data" },
|
||||||
@@ -136,7 +141,7 @@ PyTypeObject Key_Type = {
|
|||||||
sizeof( BPy_Key ), /*tp_basicsize */
|
sizeof( BPy_Key ), /*tp_basicsize */
|
||||||
0, /*tp_itemsize */
|
0, /*tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
NULL, /*tp_dealloc */
|
( destructor ) Key_dealloc,/* destructor tp_dealloc; */
|
||||||
( printfunc ) 0, /*tp_print */
|
( printfunc ) 0, /*tp_print */
|
||||||
( getattrfunc ) 0, /*tp_getattr */
|
( getattrfunc ) 0, /*tp_getattr */
|
||||||
( setattrfunc ) 0, /*tp_setattr */
|
( setattrfunc ) 0, /*tp_setattr */
|
||||||
@@ -213,12 +218,12 @@ PyTypeObject KeyBlock_Type = {
|
|||||||
sizeof( BPy_KeyBlock ), /*tp_basicsize */
|
sizeof( BPy_KeyBlock ), /*tp_basicsize */
|
||||||
0, /*tp_itemsize */
|
0, /*tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
NULL, /*tp_dealloc */
|
( destructor ) KeyBlock_dealloc,/* destructor tp_dealloc; */
|
||||||
NULL, /*tp_print */
|
( printfunc ) 0, /*tp_print */
|
||||||
NULL, /*tp_getattr */
|
( getattrfunc ) 0, /*tp_getattr */
|
||||||
NULL, /*tp_setattr */
|
( setattrfunc ) 0, /*tp_setattr */
|
||||||
NULL, /*tp_compare*/
|
( cmpfunc) KeyBlock_compare, /*tp_compare*/
|
||||||
NULL, /* tp_repr */
|
( reprfunc ) KeyBlock_repr, /* tp_repr */
|
||||||
/* Method suites for standard classes */
|
/* Method suites for standard classes */
|
||||||
|
|
||||||
NULL, /* PyNumberMethods *tp_as_number; */
|
NULL, /* PyNumberMethods *tp_as_number; */
|
||||||
@@ -303,6 +308,10 @@ PyObject *Key_CreatePyObject( Key * k )
|
|||||||
return ( PyObject * ) key;
|
return ( PyObject * ) key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Key_dealloc( BPy_Key * self )
|
||||||
|
{
|
||||||
|
PyObject_DEL( self );
|
||||||
|
}
|
||||||
|
|
||||||
static int Key_compare( BPy_Key * a, BPy_Key * b )
|
static int Key_compare( BPy_Key * a, BPy_Key * b )
|
||||||
{
|
{
|
||||||
@@ -378,13 +387,11 @@ static PyObject *Key_getBlocks( BPy_Key * self )
|
|||||||
{
|
{
|
||||||
Key *key = self->key;
|
Key *key = self->key;
|
||||||
KeyBlock *kb;
|
KeyBlock *kb;
|
||||||
PyObject *keyblock_object;
|
int i=0;
|
||||||
PyObject *l = PyList_New( 0 );
|
PyObject *l = PyList_New( BLI_countlist( &(key->block)) );
|
||||||
|
|
||||||
for (kb = key->block.first; kb; kb = kb->next) {
|
for (kb = key->block.first; kb; kb = kb->next, i++)
|
||||||
keyblock_object = KeyBlock_CreatePyObject( kb, key );
|
PyList_SET_ITEM( l, i, KeyBlock_CreatePyObject( kb, key ) );
|
||||||
PyList_Append( l, keyblock_object );
|
|
||||||
}
|
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
@@ -398,17 +405,11 @@ static PyObject *Key_getValue( BPy_Key * self )
|
|||||||
|
|
||||||
/* ------------ Key Block Functions -------------- */
|
/* ------------ Key Block Functions -------------- */
|
||||||
|
|
||||||
static PyObject *new_KeyBlock( KeyBlock * oldkeyBlock, Key *parentKey)
|
static PyObject *new_KeyBlock( KeyBlock * keyblock, Key *key)
|
||||||
{
|
{
|
||||||
BPy_KeyBlock *kb = PyObject_NEW( BPy_KeyBlock, &KeyBlock_Type );
|
BPy_KeyBlock *kb = PyObject_NEW( BPy_KeyBlock, &KeyBlock_Type );
|
||||||
|
kb->key = key;
|
||||||
kb->key = parentKey;
|
kb->keyblock = keyblock; /* keyblock maye be NULL, thats ok */
|
||||||
|
|
||||||
if( !oldkeyBlock ) {
|
|
||||||
kb->keyblock = 0;
|
|
||||||
} else {
|
|
||||||
kb->keyblock = oldkeyBlock;
|
|
||||||
}
|
|
||||||
return ( PyObject * ) kb;
|
return ( PyObject * ) kb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,6 +479,22 @@ static int KeyBlock_setSlidermax( BPy_KeyBlock * self, PyObject * args ){
|
|||||||
10.0f );
|
10.0f );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void KeyBlock_dealloc( BPy_KeyBlock * self )
|
||||||
|
{
|
||||||
|
PyObject_DEL( self );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int KeyBlock_compare( BPy_KeyBlock * a, BPy_KeyBlock * b )
|
||||||
|
{
|
||||||
|
return ( a->keyblock == b->keyblock ) ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *KeyBlock_repr( BPy_KeyBlock * self )
|
||||||
|
{
|
||||||
|
return PyString_FromFormat( "[KeyBlock \"%s\"]", self->keyblock->name );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Curve *find_curve( Key *key )
|
static Curve *find_curve( Key *key )
|
||||||
{
|
{
|
||||||
Curve *cu;
|
Curve *cu;
|
||||||
|
|||||||
@@ -166,11 +166,11 @@ static PyObject *M_Lattice_New( PyObject * self, PyObject * args )
|
|||||||
"expected string and int arguments (or nothing)" );
|
"expected string and int arguments (or nothing)" );
|
||||||
|
|
||||||
bl_Lattice = add_lattice( "Lattice" );
|
bl_Lattice = add_lattice( "Lattice" );
|
||||||
bl_Lattice->id.us = 0;
|
|
||||||
|
|
||||||
if( bl_Lattice )
|
if( bl_Lattice ) {
|
||||||
|
bl_Lattice->id.us = 0;
|
||||||
py_Lattice = Lattice_CreatePyObject( bl_Lattice );
|
py_Lattice = Lattice_CreatePyObject( bl_Lattice );
|
||||||
else
|
} else
|
||||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
"couldn't create Lattice Object in Blender" );
|
"couldn't create Lattice Object in Blender" );
|
||||||
if( !py_Lattice )
|
if( !py_Lattice )
|
||||||
|
|||||||
@@ -4972,15 +4972,15 @@ static PyObject *MFaceSeq_extend( BPy_MEdgeSeq * self, PyObject *args,
|
|||||||
|
|
||||||
tmpface->flag = ME_FACE_SEL;
|
tmpface->flag = ME_FACE_SEL;
|
||||||
|
|
||||||
if( return_list )
|
if( return_list ) {
|
||||||
PyList_Append( return_list,
|
tmp = PyInt_FromLong( mesh->totface );
|
||||||
PyInt_FromLong( mesh->totface ) );
|
PyList_Append( return_list, tmp );
|
||||||
|
Py_DECREF(tmp);
|
||||||
|
}
|
||||||
mesh->totface++;
|
mesh->totface++;
|
||||||
++tmpface;
|
++tmpface;
|
||||||
--good_faces;
|
--good_faces;
|
||||||
} else if( return_list ) {
|
} else if( return_list ) {
|
||||||
Py_INCREF( Py_None );
|
|
||||||
PyList_Append( return_list, Py_None );
|
PyList_Append( return_list, Py_None );
|
||||||
--good_faces;
|
--good_faces;
|
||||||
}
|
}
|
||||||
@@ -5385,9 +5385,44 @@ static PyObject *Mesh_vertexShade( BPy_Mesh * self )
|
|||||||
* force display list update
|
* force display list update
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PyObject *Mesh_Update( BPy_Mesh * self )
|
static PyObject *Mesh_Update( BPy_Mesh * self, PyObject *args, PyObject *kwd )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
char *blockname= NULL;
|
||||||
|
static char *kwlist[] = {"key", NULL};
|
||||||
|
|
||||||
|
if( !PyArg_ParseTupleAndKeywords(args, kwd, "|s", kwlist, &blockname) )
|
||||||
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||||
|
"Expected nothing or the name of a shapeKey");
|
||||||
|
|
||||||
|
if (blockname) {
|
||||||
|
Mesh *me = self->mesh;
|
||||||
|
MVert *mv = me->mvert;
|
||||||
|
Key *key= me->key;
|
||||||
|
KeyBlock *kb;
|
||||||
|
float (*co)[3];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
|
"Cannot update the key for this mesh, it has no shape keys");
|
||||||
|
|
||||||
|
for (kb = key->block.first; kb; kb=kb->next)
|
||||||
|
if (strcmp(blockname, kb->name))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!kb)
|
||||||
|
return EXPP_ReturnPyObjError( PyExc_ValueError,
|
||||||
|
"This requested key to update does not exist");
|
||||||
|
|
||||||
|
printf("KEYBLOCKNAME %s\n", kb->name);
|
||||||
|
|
||||||
|
for(i=0, co= kb->data; i<me->totvert; i++, mv++, co++)
|
||||||
|
VECCOPY(*co, mv->co);
|
||||||
|
} else {
|
||||||
|
/* Normal operation */
|
||||||
mesh_update( self->mesh );
|
mesh_update( self->mesh );
|
||||||
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5893,7 +5928,6 @@ static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * args )
|
|||||||
{
|
{
|
||||||
char *groupStr;
|
char *groupStr;
|
||||||
struct Object *object;
|
struct Object *object;
|
||||||
PyObject *tempStr;
|
|
||||||
|
|
||||||
if( !PyArg_ParseTuple( args, "s", &groupStr ) )
|
if( !PyArg_ParseTuple( args, "s", &groupStr ) )
|
||||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||||
@@ -5905,10 +5939,7 @@ static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * args )
|
|||||||
|
|
||||||
object = ( ( BPy_Mesh * ) self )->object;
|
object = ( ( BPy_Mesh * ) self )->object;
|
||||||
|
|
||||||
/*get clamped name*/
|
/* add_defgroup_name clamps the name to 32, make sure that dosnt change */
|
||||||
tempStr = PyString_FromStringAndSize( groupStr, 32 );
|
|
||||||
groupStr = PyString_AsString( tempStr );
|
|
||||||
|
|
||||||
add_defgroup_name( object, groupStr );
|
add_defgroup_name( object, groupStr );
|
||||||
|
|
||||||
EXPP_allqueue( REDRAWBUTSALL, 1 );
|
EXPP_allqueue( REDRAWBUTSALL, 1 );
|
||||||
@@ -6502,7 +6533,7 @@ static PyObject *Mesh_getLayerNames_internal( BPy_Mesh * self, int type )
|
|||||||
{
|
{
|
||||||
CustomData *data;
|
CustomData *data;
|
||||||
CustomDataLayer *layer;
|
CustomDataLayer *layer;
|
||||||
PyObject *list = PyList_New( 0 );
|
PyObject *str, *list = PyList_New( 0 );
|
||||||
Mesh *mesh = self->mesh;
|
Mesh *mesh = self->mesh;
|
||||||
int i;
|
int i;
|
||||||
data = &mesh->fdata;
|
data = &mesh->fdata;
|
||||||
@@ -6511,7 +6542,9 @@ static PyObject *Mesh_getLayerNames_internal( BPy_Mesh * self, int type )
|
|||||||
for(i=0; i<data->totlayer; i++) {
|
for(i=0; i<data->totlayer; i++) {
|
||||||
layer = &data->layers[i];
|
layer = &data->layers[i];
|
||||||
if(layer->type == type) {
|
if(layer->type == type) {
|
||||||
PyList_Append( list, PyString_FromString(layer->name) );
|
str = PyString_FromString(layer->name);
|
||||||
|
PyList_Append( list, str );
|
||||||
|
Py_DECREF(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@@ -6990,7 +7023,7 @@ static struct PyMethodDef BPy_Mesh_methods[] = {
|
|||||||
"find indices of an multiple edges in the mesh"},
|
"find indices of an multiple edges in the mesh"},
|
||||||
{"getFromObject", (PyCFunction)Mesh_getFromObject, METH_VARARGS,
|
{"getFromObject", (PyCFunction)Mesh_getFromObject, METH_VARARGS,
|
||||||
"Get a mesh by name"},
|
"Get a mesh by name"},
|
||||||
{"update", (PyCFunction)Mesh_Update, METH_NOARGS,
|
{"update", (PyCFunction)Mesh_Update, METH_VARARGS | METH_KEYWORDS,
|
||||||
"Update display lists after changes to mesh"},
|
"Update display lists after changes to mesh"},
|
||||||
{"transform", (PyCFunction)Mesh_transform, METH_VARARGS | METH_KEYWORDS,
|
{"transform", (PyCFunction)Mesh_transform, METH_VARARGS | METH_KEYWORDS,
|
||||||
"Applies a transformation matrix to mesh's vertices"},
|
"Applies a transformation matrix to mesh's vertices"},
|
||||||
|
|||||||
@@ -1278,7 +1278,7 @@ static PyObject *NMesh_getSelectedFaces( PyObject * self, PyObject * args )
|
|||||||
|
|
||||||
MTFace *tf;
|
MTFace *tf;
|
||||||
int i;
|
int i;
|
||||||
PyObject *l = PyList_New( 0 );
|
PyObject *l = PyList_New( 0 ), *pyval;
|
||||||
|
|
||||||
if( me == NULL )
|
if( me == NULL )
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1292,15 +1292,16 @@ static PyObject *NMesh_getSelectedFaces( PyObject * self, PyObject * args )
|
|||||||
|
|
||||||
if( flag ) {
|
if( flag ) {
|
||||||
for( i = 0; i < me->totface; i++ ) {
|
for( i = 0; i < me->totface; i++ ) {
|
||||||
if( tf[i].flag & TF_SELECT )
|
if( tf[i].flag & TF_SELECT ) {
|
||||||
PyList_Append( l, PyInt_FromLong( i ) );
|
pyval = PyInt_FromLong( i );
|
||||||
|
PyList_Append( l, pyval );
|
||||||
|
Py_DECREF(pyval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for( i = 0; i < me->totface; i++ ) {
|
for( i = 0; i < me->totface; i++ ) {
|
||||||
if( tf[i].flag & TF_SELECT )
|
if( tf[i].flag & TF_SELECT )
|
||||||
PyList_Append( l,
|
PyList_Append( l, PyList_GetItem( nm->faces, i ) );
|
||||||
PyList_GetItem( nm->faces,
|
|
||||||
i ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
@@ -2434,11 +2435,13 @@ static PyObject *M_NMesh_GetRaw( PyObject * self, PyObject * args )
|
|||||||
|
|
||||||
static PyObject *M_NMesh_GetNames(PyObject *self)
|
static PyObject *M_NMesh_GetNames(PyObject *self)
|
||||||
{
|
{
|
||||||
PyObject *names = PyList_New(0);
|
PyObject *names = PyList_New(0), *tmpstr;
|
||||||
Mesh *me = G.main->mesh.first;
|
Mesh *me = G.main->mesh.first;
|
||||||
|
|
||||||
while (me) {
|
while (me) {
|
||||||
PyList_Append(names, PyString_FromString(me->id.name+2));
|
tmpstr = PyString_FromString(me->id.name+2);
|
||||||
|
PyList_Append(names, tmpstr);
|
||||||
|
Py_DECREF(tmpstr);
|
||||||
me = me->id.next;
|
me = me->id.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4095,7 +4098,7 @@ static PyObject *NMesh_renameVertGroup( PyObject * self, PyObject * args )
|
|||||||
static PyObject *NMesh_getVertGroupNames( PyObject * self )
|
static PyObject *NMesh_getVertGroupNames( PyObject * self )
|
||||||
{
|
{
|
||||||
bDeformGroup *defGroup;
|
bDeformGroup *defGroup;
|
||||||
PyObject *list;
|
PyObject *list, *tmpstr;
|
||||||
|
|
||||||
if( !( ( BPy_NMesh * ) self )->object )
|
if( !( ( BPy_NMesh * ) self )->object )
|
||||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
@@ -4104,10 +4107,14 @@ static PyObject *NMesh_getVertGroupNames( PyObject * self )
|
|||||||
list = PyList_New( 0 );
|
list = PyList_New( 0 );
|
||||||
for( defGroup = ( ( ( BPy_NMesh * ) self )->object )->defbase.first;
|
for( defGroup = ( ( ( BPy_NMesh * ) self )->object )->defbase.first;
|
||||||
defGroup; defGroup = defGroup->next ) {
|
defGroup; defGroup = defGroup->next ) {
|
||||||
if( PyList_Append
|
|
||||||
( list, PyString_FromString( defGroup->name ) ) < 0 )
|
tmpstr = PyString_FromString( defGroup->name );
|
||||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
if( PyList_Append( list, tmpstr) < 0 ) {
|
||||||
"Couldn't add item to list" );
|
Py_XDECREF(list);
|
||||||
|
Py_XDECREF(tmpstr);
|
||||||
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError, "Couldn't add item to list" );
|
||||||
|
}
|
||||||
|
Py_XDECREF(tmpstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ struct rctf;
|
|||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
#include "DNA_object_force.h"
|
#include "DNA_object_force.h"
|
||||||
#include "DNA_userdef_types.h"
|
#include "DNA_userdef_types.h"
|
||||||
|
#include "DNA_key_types.h" /* for pinShape and activeShape */
|
||||||
|
|
||||||
#include "BKE_action.h"
|
#include "BKE_action.h"
|
||||||
#include "BKE_anim.h" /* used for dupli-objects */
|
#include "BKE_anim.h" /* used for dupli-objects */
|
||||||
@@ -68,6 +69,7 @@ struct rctf;
|
|||||||
#include "BKE_modifier.h"
|
#include "BKE_modifier.h"
|
||||||
#include "BKE_idprop.h"
|
#include "BKE_idprop.h"
|
||||||
#include "BKE_object.h"
|
#include "BKE_object.h"
|
||||||
|
#include "BKE_key.h" /* for setting the activeShape */
|
||||||
|
|
||||||
#include "BSE_editipo.h"
|
#include "BSE_editipo.h"
|
||||||
#include "BSE_edit.h"
|
#include "BSE_edit.h"
|
||||||
@@ -174,6 +176,7 @@ enum obj_consts {
|
|||||||
EXPP_OBJ_ATTR_PARENT_TYPE,
|
EXPP_OBJ_ATTR_PARENT_TYPE,
|
||||||
EXPP_OBJ_ATTR_PASSINDEX,
|
EXPP_OBJ_ATTR_PASSINDEX,
|
||||||
EXPP_OBJ_ATTR_ACT_MATERIAL,
|
EXPP_OBJ_ATTR_ACT_MATERIAL,
|
||||||
|
EXPP_OBJ_ATTR_ACT_SHAPE,
|
||||||
|
|
||||||
EXPP_OBJ_ATTR_PI_SURFACEDAMP, /* these need to stay together */
|
EXPP_OBJ_ATTR_PI_SURFACEDAMP, /* these need to stay together */
|
||||||
EXPP_OBJ_ATTR_PI_RANDOMDAMP, /* and in order */
|
EXPP_OBJ_ATTR_PI_RANDOMDAMP, /* and in order */
|
||||||
@@ -331,7 +334,6 @@ struct PyMethodDef M_Object_methods[] = {
|
|||||||
static int setupSB(Object* ob); /*Make sure Softbody Pointer is initialized */
|
static int setupSB(Object* ob); /*Make sure Softbody Pointer is initialized */
|
||||||
static int setupPI(Object* ob);
|
static int setupPI(Object* ob);
|
||||||
|
|
||||||
static PyObject *Object_GetProperties(BPy_Object * self);
|
|
||||||
static PyObject *Object_buildParts( BPy_Object * self );
|
static PyObject *Object_buildParts( BPy_Object * self );
|
||||||
static PyObject *Object_clearIpo( BPy_Object * self );
|
static PyObject *Object_clearIpo( BPy_Object * self );
|
||||||
static PyObject *Object_clrParent( BPy_Object * self, PyObject * args );
|
static PyObject *Object_clrParent( BPy_Object * self, PyObject * args );
|
||||||
@@ -756,8 +758,6 @@ works only if self and the object specified are of the same type."},
|
|||||||
"([s1<,s2,s3...>]) - Delete specified scriptlinks from this object."},
|
"([s1<,s2,s3...>]) - Delete specified scriptlinks from this object."},
|
||||||
{"insertShapeKey", ( PyCFunction ) Object_insertShapeKey, METH_NOARGS,
|
{"insertShapeKey", ( PyCFunction ) Object_insertShapeKey, METH_NOARGS,
|
||||||
"() - Insert a Shape Key in the current object"},
|
"() - Insert a Shape Key in the current object"},
|
||||||
{"getProperties", ( PyCFunction ) Object_GetProperties, METH_NOARGS,
|
|
||||||
"() return a reference to the ID properties associated with this object."},
|
|
||||||
{"__copy__", ( PyCFunction ) Object_copy, METH_NOARGS,
|
{"__copy__", ( PyCFunction ) Object_copy, METH_NOARGS,
|
||||||
"() - Return a copy of this object."},
|
"() - Return a copy of this object."},
|
||||||
{"copy", ( PyCFunction ) Object_copy, METH_NOARGS,
|
{"copy", ( PyCFunction ) Object_copy, METH_NOARGS,
|
||||||
@@ -1021,12 +1021,6 @@ static PyObject *M_Object_Duplicate( PyObject * self_unused,
|
|||||||
/* Python BPy_Object methods: */
|
/* Python BPy_Object methods: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static PyObject *Object_GetProperties(BPy_Object * self)
|
|
||||||
{
|
|
||||||
return BPy_Wrap_IDProperty( (ID*)self->object, IDP_GetProperties((ID*)self->object, 1), NULL );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *Object_buildParts( BPy_Object * self )
|
static PyObject *Object_buildParts( BPy_Object * self )
|
||||||
{
|
{
|
||||||
build_particle_system( self->object );
|
build_particle_system( self->object );
|
||||||
@@ -2733,14 +2727,16 @@ static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args )
|
|||||||
|
|
||||||
static PyObject *Object_getAllProperties( BPy_Object * self )
|
static PyObject *Object_getAllProperties( BPy_Object * self )
|
||||||
{
|
{
|
||||||
PyObject *prop_list;
|
PyObject *prop_list, *pyval;
|
||||||
bProperty *prop = NULL;
|
bProperty *prop = NULL;
|
||||||
|
|
||||||
prop_list = PyList_New( 0 );
|
prop_list = PyList_New( 0 );
|
||||||
|
|
||||||
prop = self->object->prop.first;
|
prop = self->object->prop.first;
|
||||||
while( prop ) {
|
while( prop ) {
|
||||||
PyList_Append( prop_list, Property_CreatePyObject( prop ) );
|
pyval = Property_CreatePyObject( prop );
|
||||||
|
PyList_Append( prop_list, pyval );
|
||||||
|
Py_DECREF(pyval);
|
||||||
prop = prop->next;
|
prop = prop->next;
|
||||||
}
|
}
|
||||||
return prop_list;
|
return prop_list;
|
||||||
@@ -3019,7 +3015,7 @@ static int Object_setDupliGroup( BPy_Object * self, PyObject * value )
|
|||||||
|
|
||||||
static PyObject *Object_getEffects( BPy_Object * self )
|
static PyObject *Object_getEffects( BPy_Object * self )
|
||||||
{
|
{
|
||||||
PyObject *effect_list;
|
PyObject *effect_list, *pyval;
|
||||||
Effect *eff;
|
Effect *eff;
|
||||||
|
|
||||||
effect_list = PyList_New( 0 );
|
effect_list = PyList_New( 0 );
|
||||||
@@ -3030,7 +3026,9 @@ static PyObject *Object_getEffects( BPy_Object * self )
|
|||||||
eff = self->object->effect.first;
|
eff = self->object->effect.first;
|
||||||
|
|
||||||
while( eff ) {
|
while( eff ) {
|
||||||
PyList_Append( effect_list, EffectCreatePyObject( eff, self->object ) );
|
pyval = EffectCreatePyObject( eff, self->object );
|
||||||
|
PyList_Append( effect_list, pyval );
|
||||||
|
Py_DECREF(pyval);
|
||||||
eff = eff->next;
|
eff = eff->next;
|
||||||
}
|
}
|
||||||
return effect_list;
|
return effect_list;
|
||||||
@@ -3571,6 +3569,9 @@ static PyObject *getIntAttr( BPy_Object *self, void *type )
|
|||||||
case EXPP_OBJ_ATTR_ACT_MATERIAL:
|
case EXPP_OBJ_ATTR_ACT_MATERIAL:
|
||||||
param = object->actcol;
|
param = object->actcol;
|
||||||
break;
|
break;
|
||||||
|
case EXPP_OBJ_ATTR_ACT_SHAPE:
|
||||||
|
param = object->shapenr;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
"undefined type in getIntAttr" );
|
"undefined type in getIntAttr" );
|
||||||
@@ -3632,6 +3633,20 @@ static int setIntAttrClamp( BPy_Object *self, PyObject *value, void *type )
|
|||||||
size = 'b'; /* in case max is later made > 128 */
|
size = 'b'; /* in case max is later made > 128 */
|
||||||
param = (void *)&object->actcol;
|
param = (void *)&object->actcol;
|
||||||
break;
|
break;
|
||||||
|
case EXPP_OBJ_ATTR_ACT_SHAPE:
|
||||||
|
{
|
||||||
|
Key *key= ob_get_key(object);
|
||||||
|
KeyBlock *kb;
|
||||||
|
min = 1;
|
||||||
|
max = 0;
|
||||||
|
if (key) {
|
||||||
|
max= 1;
|
||||||
|
for (kb = key->block.first; kb; kb=kb->next, max++);
|
||||||
|
}
|
||||||
|
size = 'h'; /* in case max is later made > 128 */
|
||||||
|
param = (void *)&object->shapenr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||||
"undefined type in setIntAttrClamp");
|
"undefined type in setIntAttrClamp");
|
||||||
@@ -4144,6 +4159,26 @@ static int setFloat3Attr( BPy_Object *self, PyObject *value, void *type )
|
|||||||
/* BPy_Object methods and attribute handlers */
|
/* BPy_Object methods and attribute handlers */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static PyObject *Object_getShapeFlag( BPy_Object *self, void *type )
|
||||||
|
{
|
||||||
|
if (self->object->shapeflag & (int)type)
|
||||||
|
Py_RETURN_TRUE;
|
||||||
|
else
|
||||||
|
Py_RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Object_setShapeFlag( BPy_Object *self, PyObject *value,
|
||||||
|
void *type )
|
||||||
|
{
|
||||||
|
if (PyObject_IsTrue(value) )
|
||||||
|
self->object->shapeflag |= (int)type;
|
||||||
|
else
|
||||||
|
self->object->shapeflag &= ~(int)type;
|
||||||
|
|
||||||
|
self->object->recalc |= OB_RECALC_OB;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *Object_getRestricted( BPy_Object *self, void *type )
|
static PyObject *Object_getRestricted( BPy_Object *self, void *type )
|
||||||
{
|
{
|
||||||
if (self->object->restrictflag & (int)type)
|
if (self->object->restrictflag & (int)type)
|
||||||
@@ -5013,8 +5048,16 @@ static PyGetSetDef BPy_Object_getseters[] = {
|
|||||||
"Toggle object restrictions",
|
"Toggle object restrictions",
|
||||||
(void *)OB_RESTRICT_RENDER},
|
(void *)OB_RESTRICT_RENDER},
|
||||||
|
|
||||||
{"properties", (getter)Object_GetProperties, (setter)NULL,
|
{"pinShape",
|
||||||
"Get the ID properties associated with this object"},
|
(getter)Object_getShapeFlag, (setter)Object_setShapeFlag,
|
||||||
|
"Set the state for pinning this object",
|
||||||
|
(void *)OB_SHAPE_LOCK},
|
||||||
|
{"activeShape",
|
||||||
|
(getter)getIntAttr, (setter)setIntAttrClamp,
|
||||||
|
"set the index for the active shape key",
|
||||||
|
(void *)EXPP_OBJ_ATTR_ACT_SHAPE},
|
||||||
|
|
||||||
|
|
||||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -452,6 +452,7 @@ static PyObject *Text_asLines( BPy_Text * self )
|
|||||||
while( line ) {
|
while( line ) {
|
||||||
ob = Py_BuildValue( "s", line->line );
|
ob = Py_BuildValue( "s", line->line );
|
||||||
PyList_Append( list, ob );
|
PyList_Append( list, ob );
|
||||||
|
Py_DECREF(ob);
|
||||||
line = line->next;
|
line = line->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ PyObject *M_Text3d_Get( PyObject * self, PyObject * args )
|
|||||||
&Text3d_Type );
|
&Text3d_Type );
|
||||||
found_text3d->curve = curv_iter;
|
found_text3d->curve = curv_iter;
|
||||||
PyList_Append( curvlist, ( PyObject * ) found_text3d );
|
PyList_Append( curvlist, ( PyObject * ) found_text3d );
|
||||||
|
Py_DECREF(found_text3d);
|
||||||
curv_iter = curv_iter->id.next;
|
curv_iter = curv_iter->id.next;
|
||||||
}
|
}
|
||||||
return ( curvlist );
|
return ( curvlist );
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ void types_InitAll( void )
|
|||||||
Text_Type.ob_type = &PyType_Type;
|
Text_Type.ob_type = &PyType_Type;
|
||||||
Text3d_Type.ob_type = &PyType_Type;
|
Text3d_Type.ob_type = &PyType_Type;
|
||||||
Texture_Type.ob_type = &PyType_Type;
|
Texture_Type.ob_type = &PyType_Type;
|
||||||
TimeLine_Type.ob_type = &PyType_Type;
|
//TimeLine_Type.ob_type = &PyType_Type;
|
||||||
World_Type.ob_type = &PyType_Type;
|
World_Type.ob_type = &PyType_Type;
|
||||||
buffer_Type.ob_type = &PyType_Type;
|
buffer_Type.ob_type = &PyType_Type;
|
||||||
constant_Type.ob_type = &PyType_Type;
|
constant_Type.ob_type = &PyType_Type;
|
||||||
|
|||||||
@@ -439,6 +439,7 @@ static PyObject *M_World_Get( PyObject * self, PyObject * args )
|
|||||||
&World_Type );
|
&World_Type );
|
||||||
found_world->world = world_iter;
|
found_world->world = world_iter;
|
||||||
PyList_Append( worldlist, ( PyObject * ) found_world );
|
PyList_Append( worldlist, ( PyObject * ) found_world );
|
||||||
|
Py_DECREF(found_world);
|
||||||
|
|
||||||
world_iter = world_iter->id.next;
|
world_iter = world_iter->id.next;
|
||||||
}
|
}
|
||||||
@@ -673,13 +674,13 @@ static PyObject *World_oldsetMistype( BPy_World * self, PyObject * args )
|
|||||||
|
|
||||||
static PyObject *World_getHor( BPy_World * self )
|
static PyObject *World_getHor( BPy_World * self )
|
||||||
{
|
{
|
||||||
PyObject *attr = PyList_New( 0 );
|
PyObject *attr = PyList_New( 3 );
|
||||||
if( !attr )
|
if( !attr )
|
||||||
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
"couldn't create list" ) );
|
"couldn't create list" ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->horr ) );
|
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->horr ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->horg ) );
|
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->horg ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->horb ) );
|
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->horb ) );
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,13 +706,13 @@ static PyObject *World_oldsetHor( BPy_World * self, PyObject * args )
|
|||||||
|
|
||||||
static PyObject *World_getZen( BPy_World * self )
|
static PyObject *World_getZen( BPy_World * self )
|
||||||
{
|
{
|
||||||
PyObject *attr = PyList_New( 0 );
|
PyObject *attr = PyList_New( 3 );
|
||||||
if( !attr )
|
if( !attr )
|
||||||
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
"couldn't create list" ) );
|
"couldn't create list" ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->zenr ) );
|
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->zenr ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->zeng ) );
|
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->zeng ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->zenb ) );
|
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->zenb ) );
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,13 +739,13 @@ static PyObject *World_oldsetZen( BPy_World * self, PyObject * args )
|
|||||||
|
|
||||||
static PyObject *World_getAmb( BPy_World * self )
|
static PyObject *World_getAmb( BPy_World * self )
|
||||||
{
|
{
|
||||||
PyObject *attr = PyList_New( 0 );
|
PyObject *attr = PyList_New( 3 );
|
||||||
if( !attr )
|
if( !attr )
|
||||||
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
"couldn't create list" ) );
|
"couldn't create list" ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->ambr ) );
|
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->ambr ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->ambg ) );
|
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->ambg ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->ambb ) );
|
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->ambb ) );
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,17 +771,17 @@ static PyObject *World_oldsetAmb( BPy_World * self, PyObject * args )
|
|||||||
|
|
||||||
static PyObject *World_getStar( BPy_World * self )
|
static PyObject *World_getStar( BPy_World * self )
|
||||||
{
|
{
|
||||||
PyObject *attr = PyList_New( 0 );
|
PyObject *attr = PyList_New( 7 );
|
||||||
if( !attr )
|
if( !attr )
|
||||||
return ( EXPP_ReturnPyObjError
|
return ( EXPP_ReturnPyObjError
|
||||||
( PyExc_RuntimeError, "couldn't create list" ) );
|
( PyExc_RuntimeError, "couldn't create list" ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->starr ) );
|
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->starr ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->starg ) );
|
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->starg ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->starb ) );
|
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->starb ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->starsize ) );
|
PyList_SET_ITEM( attr, 3, PyFloat_FromDouble( self->world->starsize ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->starmindist ) );
|
PyList_SET_ITEM( attr, 4, PyFloat_FromDouble( self->world->starmindist ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->stardist ) );
|
PyList_SET_ITEM( attr, 5, PyFloat_FromDouble( self->world->stardist ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->starcolnoise ) );
|
PyList_SET_ITEM( attr, 6, PyFloat_FromDouble( self->world->starcolnoise ) );
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,18 +816,17 @@ static PyObject *World_oldsetStar( BPy_World * self, PyObject * args )
|
|||||||
|
|
||||||
static PyObject *World_getMist( BPy_World * self )
|
static PyObject *World_getMist( BPy_World * self )
|
||||||
{
|
{
|
||||||
PyObject *attr = PyList_New( 0 );
|
PyObject *attr = PyList_New( 4 );
|
||||||
if( !attr )
|
if( !attr )
|
||||||
return ( EXPP_ReturnPyObjError
|
return ( EXPP_ReturnPyObjError
|
||||||
( PyExc_RuntimeError, "couldn't create list" ) );
|
( PyExc_RuntimeError, "couldn't create list" ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->misi ) );
|
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->misi ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->miststa ) );
|
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->miststa ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->mistdist ) );
|
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->mistdist ) );
|
||||||
PyList_Append( attr, PyFloat_FromDouble( self->world->misthi ) );
|
PyList_SET_ITEM( attr, 3, PyFloat_FromDouble( self->world->misthi ) );
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int World_setMist( BPy_World * self, PyObject * value )
|
static int World_setMist( BPy_World * self, PyObject * value )
|
||||||
{
|
{
|
||||||
if( !PyList_Check( value ) )
|
if( !PyList_Check( value ) )
|
||||||
|
|||||||
@@ -144,11 +144,13 @@ static PyObject *constant_getAttro(BPy_constant * self, PyObject *value)
|
|||||||
static PyObject *constant_repr(BPy_constant * self)
|
static PyObject *constant_repr(BPy_constant * self)
|
||||||
{
|
{
|
||||||
char str[4096];
|
char str[4096];
|
||||||
PyObject *key, *value;
|
PyObject *key, *value, *tempstr;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
BLI_strncpy(str,"[Constant: ",4096);
|
BLI_strncpy(str,"[Constant: ",4096);
|
||||||
value = PyDict_GetItem( self->dict, PyString_FromString("name") );
|
tempstr = PyString_FromString("name");
|
||||||
|
value = PyDict_GetItem( self->dict, tempstr );
|
||||||
|
Py_DECREF(tempstr);
|
||||||
if(value) {
|
if(value) {
|
||||||
strcat(str, PyString_AsString(value));
|
strcat(str, PyString_AsString(value));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -885,12 +885,20 @@ class Mesh:
|
|||||||
@param object: The Blender Object linked to the mesh.
|
@param object: The Blender Object linked to the mesh.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def update():
|
def update(key=None):
|
||||||
"""
|
"""
|
||||||
Update display lists after changes to mesh. B{Note}: with changes taking
|
Update display lists after changes to mesh. B{Note}: with changes taking
|
||||||
place for using a directed acyclic graph (DAG) for scene and object
|
place for using a directed acyclic graph (DAG) for scene and object
|
||||||
updating, this method may be only temporary and may be removed in future
|
updating, this method may be only temporary and may be removed in future
|
||||||
releases.
|
releases.
|
||||||
|
@type key: string
|
||||||
|
@param key: Use this optional argument to write the current vertex
|
||||||
|
locations to the a shape key. the name must match an existing shape key for this mesh
|
||||||
|
See L{Mesh.Mesh.key} and L{Key.Key.blocks} to get a list of the named shape keys, setting the active keys is
|
||||||
|
done from the object with L{Object.Object.pinShape}, L{Object.Object.activeShape}.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@warn: Since Blender 2.42 this function has changed; now it won't recalculate
|
@warn: Since Blender 2.42 this function has changed; now it won't recalculate
|
||||||
vertex normals (seen when faces are smooth). See L{Mesh.calcNormals()}.
|
vertex normals (seen when faces are smooth). See L{Mesh.calcNormals()}.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -465,6 +465,17 @@ class Object:
|
|||||||
|
|
||||||
Value is clamped to [1,len(ob.materials)]. - [0,0] when there is no materials applied to the object.
|
Value is clamped to [1,len(ob.materials)]. - [0,0] when there is no materials applied to the object.
|
||||||
@type activeMaterial: int
|
@type activeMaterial: int
|
||||||
|
@ivar activeShape: The active shape key index for this object.
|
||||||
|
|
||||||
|
The active index is used to select the material to edit in the material buttons,
|
||||||
|
new data created will also use the active material.
|
||||||
|
|
||||||
|
Value is clamped to [1,len(ob.data.key.blocks)]. - [0,0] when there are no keys.
|
||||||
|
|
||||||
|
@type activeShape: int
|
||||||
|
|
||||||
|
@ivar pinShape: If True, only the activeShape will be displayed.
|
||||||
|
@type pinShape: bool
|
||||||
@ivar drawSize: The size to display the Empty.
|
@ivar drawSize: The size to display the Empty.
|
||||||
Value clamped to [0.01,10.0].
|
Value clamped to [0.01,10.0].
|
||||||
@type drawSize: float
|
@type drawSize: float
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ void EXPP_allqueue(unsigned short event, short val)
|
|||||||
PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
|
PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
|
||||||
int is_scene )
|
int is_scene )
|
||||||
{
|
{
|
||||||
PyObject *list = NULL;
|
PyObject *list = NULL, *tmpstr;
|
||||||
char *eventname = NULL;
|
char *eventname = NULL;
|
||||||
int i, event = 0;
|
int i, event = 0;
|
||||||
|
|
||||||
@@ -414,15 +414,18 @@ PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
|
|||||||
event = SCRIPT_ONLOAD;
|
event = SCRIPT_ONLOAD;
|
||||||
else if( is_scene && !strcmp( eventname, "OnSave" ) )
|
else if( is_scene && !strcmp( eventname, "OnSave" ) )
|
||||||
event = SCRIPT_ONSAVE;
|
event = SCRIPT_ONSAVE;
|
||||||
else
|
else {
|
||||||
|
Py_XDECREF(list);
|
||||||
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
||||||
"invalid event name" );
|
"invalid event name" );
|
||||||
|
}
|
||||||
|
|
||||||
for( i = 0; i < slink->totscript; i++ ) {
|
for( i = 0; i < slink->totscript; i++ ) {
|
||||||
if( ( slink->flag[i] == event ) && slink->scripts[i] )
|
if( ( slink->flag[i] == event ) && slink->scripts[i] ) {
|
||||||
PyList_Append( list,
|
tmpstr =PyString_FromString( slink->scripts[i]->name + 2 );
|
||||||
PyString_FromString( slink->scripts[i]->
|
PyList_Append( list, tmpstr );
|
||||||
name + 2 ) );
|
Py_DECREF(tmpstr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ int updateProperyData( BPy_Property * self )
|
|||||||
static int checkValidData_ptr( BPy_Property * self )
|
static int checkValidData_ptr( BPy_Property * self )
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
//test pointer to see if data was removed (oops)
|
/* test pointer to see if data was removed (oops) */
|
||||||
|
/* WARNING!!! - MEMORY LEAK HERE, why not free this??? */
|
||||||
length = MEM_allocN_len( self->property );
|
length = MEM_allocN_len( self->property );
|
||||||
if( length != sizeof( bProperty ) ) { //data was freed
|
if( length != sizeof( bProperty ) ) { //data was freed
|
||||||
self->property = NULL;
|
self->property = NULL;
|
||||||
@@ -312,11 +313,9 @@ static int Property_compare( BPy_Property * a, BPy_Property * b )
|
|||||||
property->
|
property->
|
||||||
data ) ) );
|
data ) ) );
|
||||||
} else if( py_propB->property->type == PROP_STRING ) {
|
} else if( py_propB->property->type == PROP_STRING ) {
|
||||||
retval = PyObject_Compare( py_propA->data,
|
PyObject *tmpstr = PyString_FromString( py_propB->property->poin );
|
||||||
PyString_FromString
|
retval = PyObject_Compare( py_propA->data, tmpstr );
|
||||||
( py_propB->
|
Py_DECREF(tmpstr);
|
||||||
property->
|
|
||||||
poin ) );
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
retval = -1;
|
retval = -1;
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args) {
|
|||||||
|
|
||||||
PyObject *marker_dict= NULL;
|
PyObject *marker_dict= NULL;
|
||||||
TimeMarker *marker_it= NULL;
|
TimeMarker *marker_it= NULL;
|
||||||
PyObject *tmarker= NULL, *pyo= NULL;
|
PyObject *tmarker= NULL, *pyo= NULL, *tmpstr;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple (args, "|O", &tmarker))
|
if (!PyArg_ParseTuple (args, "|O", &tmarker))
|
||||||
return EXPP_ReturnPyObjError (PyExc_AttributeError,
|
return EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||||
@@ -196,13 +196,16 @@ static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args) {
|
|||||||
for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next){
|
for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next){
|
||||||
if (marker_it->frame==frm) {
|
if (marker_it->frame==frm) {
|
||||||
pyo= PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame));
|
pyo= PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame));
|
||||||
|
tmpstr = PyString_FromString(marker_it->name);
|
||||||
if (pyo) {
|
if (pyo) {
|
||||||
PyList_Append (pyo, PyString_FromString (marker_it->name));
|
PyList_Append (pyo, tmpstr);
|
||||||
Py_INCREF(pyo);
|
Py_INCREF(pyo);
|
||||||
}else{
|
}else{
|
||||||
pyo = PyList_New(0);
|
pyo = PyList_New(0);
|
||||||
PyList_Append (pyo, PyString_FromString (marker_it->name));
|
PyList_Append (pyo, tmpstr);
|
||||||
}
|
}
|
||||||
|
Py_DECREF(tmpstr);
|
||||||
|
|
||||||
PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo);
|
PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo);
|
||||||
if (pyo) {
|
if (pyo) {
|
||||||
Py_DECREF (pyo);
|
Py_DECREF (pyo);
|
||||||
@@ -216,13 +219,16 @@ static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args) {
|
|||||||
marker_dict= PyDict_New ();
|
marker_dict= PyDict_New ();
|
||||||
for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) {
|
for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) {
|
||||||
pyo=PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame));
|
pyo=PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame));
|
||||||
|
tmpstr = PyString_FromString(marker_it->name);
|
||||||
if (pyo) {
|
if (pyo) {
|
||||||
PyList_Append (pyo, PyString_FromString (marker_it->name));
|
PyList_Append (pyo, tmpstr);
|
||||||
Py_INCREF (pyo);
|
Py_INCREF (pyo);
|
||||||
}else{
|
}else{
|
||||||
pyo= PyList_New (0);
|
pyo= PyList_New (0);
|
||||||
PyList_Append (pyo, PyString_FromString (marker_it->name));
|
PyList_Append (pyo, tmpstr);
|
||||||
}
|
}
|
||||||
|
Py_DECREF(tmpstr);
|
||||||
|
|
||||||
PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo);
|
PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo);
|
||||||
if (pyo) {
|
if (pyo) {
|
||||||
Py_DECREF (pyo);
|
Py_DECREF (pyo);
|
||||||
|
|||||||
@@ -685,8 +685,7 @@ static PyObject *Theme_get( BPy_Theme * self, PyObject * args )
|
|||||||
|
|
||||||
while( type < EXPP_THEME_NUMBEROFTHEMES ) {
|
while( type < EXPP_THEME_NUMBEROFTHEMES ) {
|
||||||
PyList_SET_ITEM( ret, type,
|
PyList_SET_ITEM( ret, type,
|
||||||
PyString_FromString( themes_map[type].
|
PyString_FromString( themes_map[type].sval ) );
|
||||||
sval ) );
|
|
||||||
type++;
|
type++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user