This commit is contained in:
Andre Susano Pinto
2008-08-01 21:37:36 +00:00
parent 9e1ca2c1be
commit 289d875dfd
195 changed files with 4671 additions and 2058 deletions

View File

@@ -1469,6 +1469,8 @@ PyObject *Armature_Init(void)
PyConstant_NewInt("BONE_SELECTED", BONE_SELECTED));
PyModule_AddObject(module, "TIP_SELECTED",
PyConstant_NewInt("TIP_SELECTED", BONE_TIPSEL));
PyModule_AddObject(module, "LOCKED_EDIT",
PyConstant_NewInt("LOCKED_EDIT", BONE_EDITMODE_LOCKED));
PyModule_AddObject(module, "OCTAHEDRON",
PyConstant_NewInt("OCTAHEDRON", ARM_OCTA));

View File

@@ -368,6 +368,10 @@ static PyObject *EditBone_getOptions(BPy_EditBone *self, void *closure)
if (PyList_Append(list,
EXPP_GetModuleConstant("Blender.Armature", "TIP_SELECTED")) == -1)
goto RuntimeError;
if(self->editbone->flag & BONE_EDITMODE_LOCKED)
if (PyList_Append(list,
EXPP_GetModuleConstant("Blender.Armature", "LOCKED_EDIT")) == -1)
goto RuntimeError;
}else{
if(self->flag & BONE_CONNECTED)
if (PyList_Append(list,
@@ -401,6 +405,10 @@ static PyObject *EditBone_getOptions(BPy_EditBone *self, void *closure)
if (PyList_Append(list,
EXPP_GetModuleConstant("Blender.Armature", "TIP_SELECTED")) == -1)
goto RuntimeError;
if(self->flag & BONE_EDITMODE_LOCKED)
if (PyList_Append(list,
EXPP_GetModuleConstant("Blender.Armature", "LOCKED_EDIT")) == -1)
goto RuntimeError;
}
return list;
@@ -422,7 +430,7 @@ static int EditBone_CheckValidConstant(PyObject *constant)
return 0;
if (!STREQ3(PyString_AsString(name), "CONNECTED", "HINGE", "NO_DEFORM") &&
!STREQ3(PyString_AsString(name), "ROOT_SELECTED", "BONE_SELECTED", "TIP_SELECTED") &&
!STREQ2(PyString_AsString(name), "MULTIPLY", "HIDDEN_EDIT"))
!STREQ3(PyString_AsString(name), "MULTIPLY", "HIDDEN_EDIT", "LOCKED_EDIT"))
return 0;
else
return 1;

View File

@@ -60,6 +60,8 @@ PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
return PyInt_FromLong( (long)prop->data.val );
case IDP_FLOAT:
return PyFloat_FromDouble( (double)(*(float*)(&prop->data.val)) );
case IDP_DOUBLE:
return PyFloat_FromDouble( (*(double*)(&prop->data.val)) );
case IDP_GROUP:
/*blegh*/
{
@@ -128,7 +130,19 @@ int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject *value)
Py_XDECREF(value);
break;
}
case IDP_DOUBLE:
{
double dvalue;
if (!PyNumber_Check(value))
return EXPP_ReturnIntError(PyExc_TypeError, "expected a float!");
value = PyNumber_Float(value);
if (!value)
return EXPP_ReturnIntError(PyExc_TypeError, "expected a float!");
dvalue = (float) PyFloat_AsDouble(value);
*(double*)&self->prop->data.val = dvalue;
Py_XDECREF(value);
break;
}
default:
return EXPP_ReturnIntError(PyExc_AttributeError, "attempt to set read-only attribute!");
}
@@ -204,8 +218,8 @@ char *BPy_IDProperty_Map_ValidateAndCreate(char *name, IDProperty *group, PyObje
IDPropertyTemplate val = {0};
if (PyFloat_Check(ob)) {
val.f = (float) PyFloat_AsDouble(ob);
prop = IDP_New(IDP_FLOAT, val, name);
val.d = PyFloat_AsDouble(ob);
prop = IDP_New(IDP_DOUBLE, val, name);
} else if (PyInt_Check(ob)) {
val.i = (int) PyInt_AsLong(ob);
prop = IDP_New(IDP_INT, val, name);
@@ -223,7 +237,7 @@ char *BPy_IDProperty_Map_ValidateAndCreate(char *name, IDProperty *group, PyObje
val.array.len = PySequence_Length(ob);
for (i=0; i<val.array.len; i++) {
item = PySequence_GetItem(ob, i);
if (PyFloat_Check(item)) val.array.type = IDP_FLOAT;
if (PyFloat_Check(item)) val.array.type = IDP_DOUBLE;
else if (!PyInt_Check(item)) return "only floats and ints are allowed in ID property arrays";
Py_XDECREF(item);
}
@@ -236,7 +250,7 @@ char *BPy_IDProperty_Map_ValidateAndCreate(char *name, IDProperty *group, PyObje
((int*)prop->data.pointer)[i] = (int)PyInt_AsLong(item);
} else {
item = PyNumber_Float(item);
((float*)prop->data.pointer)[i] = (float)PyFloat_AsDouble(item);
((double*)prop->data.pointer)[i] = (float)PyFloat_AsDouble(item);
}
Py_XDECREF(item);
}
@@ -334,6 +348,9 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
case IDP_FLOAT:
return PyFloat_FromDouble(*((float*)&prop->data.val));
break;
case IDP_DOUBLE:
return PyFloat_FromDouble(*((double*)&prop->data.val));
break;
case IDP_INT:
return PyInt_FromLong( (long)prop->data.val );
break;
@@ -347,12 +364,15 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
"PyList_New() failed" );
for (i=0; i<prop->len; i++) {
if (prop->subtype == IDP_FLOAT)
if (prop->subtype == IDP_FLOAT) {
PyList_SetItem(seq, i,
PyFloat_FromDouble(((float*)prop->data.pointer)[i]));
else PyList_SetItem(seq, i,
PyInt_FromLong(((int*)prop->data.pointer)[i]));
} else if (prop->subtype == IDP_DOUBLE) {
PyList_SetItem(seq, i,
PyFloat_FromDouble(((double*)prop->data.pointer)[i]));
} else { PyList_SetItem(seq, i,
PyInt_FromLong(((int*)prop->data.pointer)[i]));
}
}
return seq;
}
@@ -451,7 +471,7 @@ PyObject *BPy_IDGroup_GetKeys(BPy_IDProperty *self)
/*set correct group length*/
self->prop->len = i;
/*free the old list*/
/*free the list*/
Py_DECREF(seq);
/*call self again*/
@@ -688,6 +708,9 @@ PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, int index)
case IDP_FLOAT:
return PyFloat_FromDouble( (double)(((float*)self->prop->data.pointer)[index]));
break;
case IDP_DOUBLE:
return PyFloat_FromDouble( (((double*)self->prop->data.pointer)[index]));
break;
case IDP_INT:
return PyInt_FromLong( (long)((int*)self->prop->data.pointer)[index] );
break;
@@ -700,7 +723,8 @@ int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *val)
{
int i;
float f;
double d;
if (index < 0 || index >= self->prop->len)
return EXPP_ReturnIntError( PyExc_RuntimeError,
"index out of range!");
@@ -717,6 +741,17 @@ int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *val)
((float*)self->prop->data.pointer)[index] = f;
Py_XDECREF(val);
break;
case IDP_DOUBLE:
if (!PyNumber_Check(val)) return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float");
val = PyNumber_Float(val);
if (!val) return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float");
d = (double) PyFloat_AsDouble(val);
((double*)self->prop->data.pointer)[index] = d;
Py_XDECREF(val);
break;
case IDP_INT:
if (!PyNumber_Check(val)) return EXPP_ReturnIntError( PyExc_TypeError,
"expected an int");

View File

@@ -89,6 +89,8 @@ Example::
@type BONE_SELECTED: Constant
@var TIP_SELECTED: Tip of the Bone is selected
@type TIP_SELECTED: Constant
@var LOCKED_EDIT: Prevents the bone from being transformed in editmode
@type LOCKED_EDIT: Constant
@var OCTAHEDRON: Bones drawn as octahedrons
@type OCTAHEDRON: Constant
@var STICK: Bones drawn as a line
@@ -286,6 +288,7 @@ class Bone:
- Armature.ROOT_SELECTED: Selection of root ball of bone
- Armature.BONE_SELECTED: Selection of bone
- Armature.TIP_SELECTED: Selection of tip ball of bone
- Armature.LOCKED_EDIT: Prevents the bone from being transformed in editmode
@type options: List of Constants
@ivar subdivision: The number of bone subdivisions.
@type subdivision: Int

View File

@@ -18,7 +18,9 @@ class IDGroup:
Note that for arrays, the array type defaults to int unless a float is found
while scanning the template list; if any floats are found, then the whole
array is float.
array is float. Note that double-precision floating point numbers are used for
python-created float ID properties and arrays (though the internal C api does
support single-precision floats, and the python code will read them).
You can also delete properties with the del operator. For example:

View File

@@ -250,7 +250,7 @@ class Ipo:
OfsZ, SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var,
Disp.
3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ,
dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ,
dRotX, dRotY, dRotZ, ScaleX, ScaleY, ScaleZ, dScaleX, dScaleY, dScaleZ,
Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFall, Damping,
RDamp, Perm.
4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaInt.
@@ -289,7 +289,7 @@ class Ipo:
OfsZ, SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var,
Disp.
3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ,
dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ,
dRotX, dRotY, dRotZ, ScaleX, ScaleY, ScaleZ, dScaleX, dScaleY, dScaleZ,
Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFall, Damping,
RDamp, Perm.
4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaInt.

View File

@@ -56,6 +56,7 @@ struct View3D; /* keep me up here */
#include "gen_utils.h"
#include "gen_library.h"
#include "../BPY_extern.h" /* for BPY_do_all_scripts() */
#include "Scene.h"
#include "Group.h"
@@ -469,19 +470,20 @@ PyObject *M_Render_EnableDispWin( PyObject * self )
PyObject *RenderData_Render( BPy_RenderData * self )
{
Scene *oldsce;
/* unlock to prevent a deadlock when there are pynodes: */
PyThreadState *tstate = NULL;
if (!G.background) {
oldsce = G.scene;
set_scene( self->scene );
tstate = PyEval_SaveThread();
BIF_do_render( 0 );
set_scene( oldsce );
}
else { /* background mode (blender -b file.blend -P script) */
int slink_flag = 0;
Render *re= RE_NewRender(G.scene->id.name);
int end_frame = G.scene->r.efra;
if (G.scene != self->scene)
@@ -490,11 +492,25 @@ PyObject *RenderData_Render( BPy_RenderData * self )
G.scene->r.efra = G.scene->r.sfra;
if (G.f & G_DOSCRIPTLINKS) {
BPY_do_all_scripts(SCRIPT_RENDER);
G.f &= ~G_DOSCRIPTLINKS; /* avoid FRAMECHANGED events*/
slink_flag = 1;
}
tstate = PyEval_SaveThread();
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
if (slink_flag) {
G.f |= G_DOSCRIPTLINKS;
BPY_do_all_scripts(SCRIPT_POSTRENDER);
}
G.scene->r.efra = end_frame;
}
PyEval_RestoreThread(tstate);
Py_RETURN_NONE;
}
@@ -565,10 +581,13 @@ PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args )
PyObject *RenderData_RenderAnim( BPy_RenderData * self )
{
Scene *oldsce;
/* unlock to prevent a deadlock when there are pynodes: */
PyThreadState *tstate = NULL;
if (!G.background) {
oldsce = G.scene;
set_scene( self->scene );
tstate = PyEval_SaveThread();
BIF_do_render( 1 );
set_scene( oldsce );
}
@@ -582,9 +601,18 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self )
if (G.scene->r.sfra > G.scene->r.efra)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"start frame must be less or equal to end frame");
if (G.f & G_DOSCRIPTLINKS)
BPY_do_all_scripts(SCRIPT_RENDER);
tstate = PyEval_SaveThread();
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
if (G.f & G_DOSCRIPTLINKS)
BPY_do_all_scripts(SCRIPT_POSTRENDER);
}
PyEval_RestoreThread(tstate);
Py_RETURN_NONE;
}