Merged changes in the trunk up to revision 35972.
This commit is contained in:
@@ -35,4 +35,4 @@ if env['BF_BUILDINFO']:
|
||||
defs.append('BUILD_DATE')
|
||||
|
||||
sources = env.Glob('intern/*.c')
|
||||
env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [361,160])
|
||||
env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core'], priority = [361])
|
||||
|
||||
@@ -55,6 +55,27 @@
|
||||
|
||||
static Main *bpy_import_main= NULL;
|
||||
|
||||
/* 'builtins' is most likely PyEval_GetBuiltins() */
|
||||
void bpy_import_init(PyObject *builtins)
|
||||
{
|
||||
PyObject *item;
|
||||
PyObject *mod;
|
||||
|
||||
PyDict_SetItemString(builtins, "__import__", item=PyCFunction_New(&bpy_import_meth, NULL)); Py_DECREF(item);
|
||||
|
||||
/* move reload here
|
||||
* XXX, use import hooks */
|
||||
mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0);
|
||||
if(mod) {
|
||||
PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
|
||||
Py_DECREF(mod);
|
||||
}
|
||||
else {
|
||||
BLI_assert(!"unable to load 'imp' module.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void free_compiled_text(Text *text)
|
||||
{
|
||||
if(text->compiled) {
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
|
||||
struct Text;
|
||||
|
||||
void bpy_import_init(PyObject *builtins);
|
||||
|
||||
PyObject* bpy_text_import(struct Text *text);
|
||||
PyObject* bpy_text_import_name(char *name, int *found);
|
||||
PyObject* bpy_text_reimport(PyObject *module, int *found);
|
||||
|
||||
@@ -226,8 +226,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
/* clamp angle between -360 and 360 in radians */
|
||||
angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2;
|
||||
angle= angle_wrap_rad(angle);
|
||||
|
||||
if(matSize != 2 && matSize != 3 && matSize != 4) {
|
||||
PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix");
|
||||
|
||||
@@ -861,7 +861,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
|
||||
return -1;
|
||||
}
|
||||
|
||||
angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2;
|
||||
angle= angle_wrap_rad(angle);
|
||||
|
||||
/* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */
|
||||
if( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
|
||||
@@ -955,7 +955,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
|
||||
case 2:
|
||||
if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1)
|
||||
return NULL;
|
||||
angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2; /* clamp because of precision issues */
|
||||
angle= angle_wrap_rad(angle); /* clamp because of precision issues */
|
||||
axis_angle_to_quat(quat, quat, angle);
|
||||
break;
|
||||
/* PyArg_ParseTuple assures no more then 2 */
|
||||
|
||||
@@ -552,7 +552,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < self->size; x++) {
|
||||
dot += self->vec[x] * tvec[x];
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(dot);
|
||||
@@ -591,8 +591,8 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < size; x++) {
|
||||
test_v1 += self->vec[x] * self->vec[x];
|
||||
test_v2 += tvec[x] * tvec[x];
|
||||
test_v1 += (double)(self->vec[x] * self->vec[x]);
|
||||
test_v2 += (double)(tvec[x] * tvec[x]);
|
||||
}
|
||||
if (!test_v1 || !test_v2){
|
||||
/* avoid exception */
|
||||
@@ -608,7 +608,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
|
||||
//dot product
|
||||
for(x = 0; x < self->size; x++) {
|
||||
dot += self->vec[x] * tvec[x];
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
}
|
||||
dot /= (sqrt(test_v1) * sqrt(test_v2));
|
||||
|
||||
@@ -679,13 +679,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
|
||||
|
||||
//get dot products
|
||||
for(x = 0; x < size; x++) {
|
||||
dot += self->vec[x] * tvec[x];
|
||||
dot2 += tvec[x] * tvec[x];
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
dot2 += (double)(tvec[x] * tvec[x]);
|
||||
}
|
||||
//projection
|
||||
dot /= dot2;
|
||||
for(x = 0; x < size; x++) {
|
||||
vec[x] = (float)(dot * tvec[x]);
|
||||
vec[x] = (float)dot * tvec[x];
|
||||
}
|
||||
return newVectorObject(vec, size, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
@@ -1034,7 +1034,7 @@ static int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject
|
||||
|
||||
for(x = 0; x < mat->col_size; x++) {
|
||||
for(y = 0; y < mat->row_size; y++) {
|
||||
dot += mat->matrix[y][x] * vec_cpy[y];
|
||||
dot += (double)(mat->matrix[y][x] * vec_cpy[y]);
|
||||
}
|
||||
rvec[z++] = (float)dot;
|
||||
dot = 0.0f;
|
||||
@@ -1079,7 +1079,7 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
|
||||
|
||||
/*dot product*/
|
||||
for(i = 0; i < vec1->size; i++) {
|
||||
dot += vec1->vec[i] * vec2->vec[i];
|
||||
dot += (double)(vec1->vec[i] * vec2->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(dot);
|
||||
}
|
||||
@@ -1257,7 +1257,7 @@ static double vec_magnitude_nosqrt(float *data, int size)
|
||||
int i;
|
||||
|
||||
for(i=0; i<size; i++){
|
||||
dot += data[i];
|
||||
dot += (double)data[i];
|
||||
}
|
||||
/*return (double)sqrt(dot);*/
|
||||
/* warning, line above removed because we are not using the length,
|
||||
@@ -1273,7 +1273,7 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
{
|
||||
VectorObject *vecA = NULL, *vecB = NULL;
|
||||
int result = 0;
|
||||
float epsilon = .000001f;
|
||||
double epsilon = .000001f;
|
||||
double lenA, lenB;
|
||||
|
||||
if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)){
|
||||
@@ -1499,7 +1499,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure))
|
||||
return NULL;
|
||||
|
||||
for(i = 0; i < self->size; i++){
|
||||
dot += (self->vec[i] * self->vec[i]);
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(sqrt(dot));
|
||||
}
|
||||
@@ -1517,17 +1517,17 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (param < 0.0f) {
|
||||
if (param < 0.0) {
|
||||
PyErr_SetString(PyExc_TypeError, "cannot set a vectors length to a negative value");
|
||||
return -1;
|
||||
}
|
||||
if (param == 0.0f) {
|
||||
if (param == 0.0) {
|
||||
fill_vn(self->vec, self->size, 0.0f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(i = 0; i < self->size; i++){
|
||||
dot += (self->vec[i] * self->vec[i]);
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
|
||||
if (!dot) /* cant sqrt zero */
|
||||
|
||||
@@ -59,6 +59,8 @@ static PyTypeObject BlenderAppType;
|
||||
static PyStructSequence_Field app_info_fields[]= {
|
||||
{(char *)"version", (char *)"The Blender version as a tuple of 3 numbers. eg. (2, 50, 11)"},
|
||||
{(char *)"version_string", (char *)"The Blender version formatted as a string"},
|
||||
{(char *)"version_char", (char *)"The Blender version character (for minor releases)"},
|
||||
{(char *)"version_cycle", (char *)"The release status of this build alpha/beta/rc/release"},
|
||||
{(char *)"binary_path", (char *)"The location of blenders executable, useful for utilities that spawn new instances"},
|
||||
{(char *)"background", (char *)"Boolean, True when blender is running without a user interface (started with -b)"},
|
||||
|
||||
@@ -103,6 +105,8 @@ static PyObject *make_app_info(void)
|
||||
|
||||
SetObjItem(Py_BuildValue("(iii)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION));
|
||||
SetObjItem(PyUnicode_FromFormat("%d.%02d (sub %d)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION));
|
||||
SetStrItem(STRINGIFY(BLENDER_VERSION_CHAR));
|
||||
SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
|
||||
SetStrItem(bprogname);
|
||||
SetObjItem(PyBool_FromLong(G.background));
|
||||
|
||||
|
||||
@@ -170,9 +170,13 @@ static void bpy_python_start_path(void)
|
||||
{
|
||||
char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL);
|
||||
|
||||
if(py_path_bundle==NULL)
|
||||
if(py_path_bundle==NULL) {
|
||||
/* Common enough to have bundled *nix python but complain on OSX/Win */
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n");
|
||||
#endif
|
||||
return;
|
||||
|
||||
}
|
||||
/* set the environment path */
|
||||
printf("found bundled python: %s\n", py_path_bundle);
|
||||
|
||||
@@ -272,27 +276,7 @@ void BPY_python_start(int argc, const char **argv)
|
||||
/* bpy.* and lets us import it */
|
||||
BPy_init_modules();
|
||||
|
||||
{ /* our own import and reload functions */
|
||||
PyObject *item;
|
||||
PyObject *mod;
|
||||
//PyObject *m= PyImport_AddModule("__builtin__");
|
||||
//PyObject *d= PyModule_GetDict(m);
|
||||
PyObject *d= PyEval_GetBuiltins();
|
||||
// PyDict_SetItemString(d, "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
|
||||
PyDict_SetItemString(d, "__import__", item=PyCFunction_New(&bpy_import_meth, NULL)); Py_DECREF(item);
|
||||
|
||||
/* move reload here
|
||||
* XXX, use import hooks */
|
||||
mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0);
|
||||
if(mod) {
|
||||
PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
|
||||
Py_DECREF(mod);
|
||||
}
|
||||
else {
|
||||
BLI_assert(!"unable to load 'imp' module.");
|
||||
}
|
||||
|
||||
}
|
||||
bpy_import_init(PyEval_GetBuiltins());
|
||||
|
||||
pyrna_alloc_types();
|
||||
|
||||
|
||||
@@ -225,18 +225,18 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash)
|
||||
|
||||
BLI_ghashIterator_init(&weakinfo_hash_iter, weakinfo_hash);
|
||||
|
||||
#ifdef DEBUG_RNA_WEAKREF
|
||||
#ifdef DEBUG_RNA_WEAKREF
|
||||
fprintf(stdout, "id_release_weakref: '%s', %d items\n", id->name, BLI_ghash_size(weakinfo_hash));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
while (!BLI_ghashIterator_isDone(&weakinfo_hash_iter)) {
|
||||
PyObject *weakref= (PyObject *)BLI_ghashIterator_getKey(&weakinfo_hash_iter);
|
||||
PyObject *item= PyWeakref_GET_OBJECT(weakref);
|
||||
if(item != Py_None) {
|
||||
|
||||
#ifdef DEBUG_RNA_WEAKREF
|
||||
#ifdef DEBUG_RNA_WEAKREF
|
||||
PyC_ObSpit("id_release_weakref item ", item);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
pyrna_invalidate((BPy_DummyPointerRNA *)item);
|
||||
}
|
||||
@@ -252,9 +252,9 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash)
|
||||
if(BLI_ghash_size(id_weakref_pool) == 0) {
|
||||
BLI_ghash_free(id_weakref_pool, NULL, NULL);
|
||||
id_weakref_pool= NULL;
|
||||
#ifdef DEBUG_RNA_WEAKREF
|
||||
#ifdef DEBUG_RNA_WEAKREF
|
||||
printf("id_release_weakref freeing pool\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,11 +275,13 @@ void BPY_id_release(struct ID *id)
|
||||
#endif
|
||||
|
||||
#ifdef USE_PYRNA_INVALIDATE_WEAKREF
|
||||
PyGILState_STATE gilstate= PyGILState_Ensure();
|
||||
if(id_weakref_pool) {
|
||||
PyGILState_STATE gilstate= PyGILState_Ensure();
|
||||
|
||||
id_release_weakref(id);
|
||||
id_release_weakref(id);
|
||||
|
||||
PyGILState_Release(gilstate);
|
||||
PyGILState_Release(gilstate);
|
||||
}
|
||||
#endif /* USE_PYRNA_INVALIDATE_WEAKREF */
|
||||
|
||||
(void)id;
|
||||
@@ -640,6 +642,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
|
||||
}
|
||||
break;
|
||||
case PROP_COLOR:
|
||||
case PROP_COLOR_GAMMA:
|
||||
if(len==3) { /* color */
|
||||
if(is_thick) {
|
||||
ret= newColorObject(NULL, Py_NEW, NULL); // TODO, get order from RNA
|
||||
@@ -6186,22 +6189,6 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* call classed register function () */
|
||||
py_cls_meth= PyObject_GetAttrString(py_class, "register");
|
||||
if(py_cls_meth == NULL) {
|
||||
PyErr_Clear();
|
||||
}
|
||||
else {
|
||||
PyObject *ret= PyObject_CallObject(py_cls_meth, NULL);
|
||||
if(ret) {
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* get the context, so register callback can do necessary refreshes */
|
||||
C= BPy_GetContext();
|
||||
|
||||
@@ -6235,6 +6222,21 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
|
||||
if(pyrna_deferred_register_class(srna_new, py_class)!=0)
|
||||
return NULL;
|
||||
|
||||
/* call classed register method () */
|
||||
py_cls_meth= PyObject_GetAttrString(py_class, "register");
|
||||
if(py_cls_meth == NULL) {
|
||||
PyErr_Clear();
|
||||
}
|
||||
else {
|
||||
PyObject *ret= PyObject_CallObject(py_cls_meth, NULL);
|
||||
if(ret) {
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -6296,7 +6298,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* call classed register function */
|
||||
/* call classed unregister method */
|
||||
py_cls_meth= PyObject_GetAttrString(py_class, "unregister");
|
||||
if(py_cls_meth == NULL) {
|
||||
PyErr_Clear();
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#endif
|
||||
/* --- end bpy build options --- */
|
||||
|
||||
struct ID;
|
||||
|
||||
extern PyTypeObject pyrna_struct_meta_idprop_Type;
|
||||
extern PyTypeObject pyrna_struct_Type;
|
||||
@@ -192,4 +193,6 @@ void BPY_modules_update(struct bContext *C); //XXX temp solution
|
||||
extern PyMethodDef meth_bpy_register_class;
|
||||
extern PyMethodDef meth_bpy_unregister_class;
|
||||
|
||||
void BPY_id_release(struct ID *id);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_util.h"
|
||||
#include "bpy_rna_anim.h"
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
Reference in New Issue
Block a user