=bmesh= merge from trunk at r36529

This commit is contained in:
Joseph Eagar
2011-05-08 23:43:18 +00:00
623 changed files with 24039 additions and 22798 deletions

View File

@@ -513,15 +513,15 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
for (i=0; i<prop->len; i++) {
if (prop->subtype == IDP_FLOAT) {
PyList_SET_ITEM(seq, i,
PyFloat_FromDouble(((float*)prop->data.pointer)[i]));
PyFloat_FromDouble(((float*)prop->data.pointer)[i]));
}
else if (prop->subtype == IDP_DOUBLE) {
PyList_SET_ITEM(seq, i,
PyFloat_FromDouble(((double*)prop->data.pointer)[i]));
PyFloat_FromDouble(((double*)prop->data.pointer)[i]));
}
else {
PyList_SET_ITEM(seq, i,
PyLong_FromLong(((int*)prop->data.pointer)[i]));
PyLong_FromLong(((int*)prop->data.pointer)[i]));
}
}
return seq;
@@ -588,7 +588,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value)
/*ok something bad happened with the pyobject,
so don't remove the prop from the group. if pyform is
NULL, then it already should have raised an exception.*/
return NULL;
return NULL;
}
IDP_RemFromGroup(self->prop, idprop);

View File

@@ -132,16 +132,16 @@ static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
int BGL_typeSize(int type)
{
switch (type) {
case GL_BYTE:
return sizeof(char);
case GL_SHORT:
return sizeof(short);
case GL_INT:
return sizeof(int);
case GL_FLOAT:
return sizeof(float);
case GL_DOUBLE:
return sizeof(double);
case GL_BYTE:
return sizeof(char);
case GL_SHORT:
return sizeof(short);
case GL_INT:
return sizeof(int);
case GL_FLOAT:
return sizeof(float);
case GL_DOUBLE:
return sizeof(double);
}
return -1;
}
@@ -293,7 +293,7 @@ static PyObject *Buffer_item(PyObject *self, int i)
size= BGL_typeSize(buf->type);
newbuf= (Buffer *) PyObject_NEW(Buffer, &BGL_bufferType);
Py_INCREF(self);
newbuf->parent= self;
@@ -307,7 +307,7 @@ static PyObject *Buffer_item(PyObject *self, int i)
return (PyObject *) newbuf;
}
return NULL;
}
@@ -435,7 +435,7 @@ static PyObject *Buffer_dimensions(PyObject *self)
Buffer *buffer= (Buffer *) self;
PyObject *list= PyList_New(buffer->ndimensions);
int i;
for (i= 0; i<buffer->ndimensions; i++) {
PyList_SET_ITEM(list, i, PyLong_FromLong(buffer->dimensions[i]));
}
@@ -804,7 +804,7 @@ BGLU_Wrap(9, UnProject, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdo
* {"glAccum", Method_Accumfunc, METH_VARARGS} */
static struct PyMethodDef BGL_methods[] = {
{"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc},
{"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc},
/* #ifndef __APPLE__ */
MethodDef(Accum),
@@ -1641,7 +1641,7 @@ PyObject *BPyInit_bgl(void)
EXPP_ADDCONST(GL_TEXTURE_RESIDENT);
EXPP_ADDCONST(GL_TEXTURE_BINDING_1D);
EXPP_ADDCONST(GL_TEXTURE_BINDING_2D);
return submodule;
}

View File

@@ -132,7 +132,7 @@ PyObject *bpy_text_import(Text *text)
PyObject *bpy_text_import_name(char *name, int *found)
{
Text *text;
char txtname[22]; /* 21+NULL */
char txtname[MAX_ID_NAME-2];
int namelen= strlen(name);
//XXX Main *maggie= bpy_import_main ? bpy_import_main:G.main;
Main *maggie= bpy_import_main;
@@ -144,7 +144,7 @@ PyObject *bpy_text_import_name(char *name, int *found)
return NULL;
}
if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */
if (namelen >= (MAX_ID_NAME-2) - 3) return NULL; /* we know this cant be importable, the name is too long for blender! */
memcpy(txtname, name, namelen);
memcpy(&txtname[namelen], ".py", 4);
@@ -304,7 +304,7 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject * module)
}
else {
/* no blender text was found that could import the module
* rause the original error from PyImport_ImportModuleEx */
* reuse the original error from PyImport_ImportModuleEx */
PyErr_Restore(exception, err, tb);
}
@@ -326,8 +326,8 @@ PyMethodDef bpy_reload_meth= {"bpy_reload_meth", (PyCFunction)blender_reload, ME
* it wont reload scripts between loading different blend files or while making the game.
* - use 'clear_all' arg in this case.
*
* Since pythons bultins include a full path even for win32.
* even if we remove a python module a reimport will bring it back again.
* Since pythons built-ins include a full path even for win32.
* even if we remove a python module a re-import will bring it back again.
*/
#if 0 // not used anymore but may still come in handy later

View File

@@ -841,10 +841,10 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
vec_t1_tar->size != 3 ||
vec_t2_tar->size != 3 ||
vec_t3_tar->size != 3)
{
PyErr_SetString(PyExc_ValueError, "One of more of the vector arguments wasnt a 3D vector");
return NULL;
}
{
PyErr_SetString(PyExc_ValueError, "One of more of the vector arguments wasnt a 3D vector");
return NULL;
}
barycentric_transform(vec, vec_pt->vec,
vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec,

View File

@@ -30,6 +30,12 @@
#include "py_capi_utils.h"
#include "BKE_font.h" /* only for utf8towchar, should replace with py funcs but too late in release now */
#ifdef _WIN32 /* BLI_setenv */
#include "BLI_path_util.h"
#endif
#define PYC_INTERPRETER_ACTIVE (((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL)
/* for debugging */
@@ -284,6 +290,48 @@ void PyC_MainModule_Restore(PyObject *main_mod)
Py_XDECREF(main_mod);
}
/* must be called before Py_Initialize, expects output of BLI_get_folder(BLENDER_PYTHON, NULL) */
void PyC_SetHomePath(const char *py_path_bundle)
{
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);
#ifdef __APPLE__
/* OSX allow file/directory names to contain : character (represented as / in the Finder)
but current Python lib (release 3.1.1) doesn't handle these correctly */
if(strchr(py_path_bundle, ':'))
printf("Warning : Blender application is located in a path containing : or / chars\
\nThis may make python import function fail\n");
#endif
#ifdef _WIN32
/* cmake/MSVC debug build crashes without this, why only
in this case is unknown.. */
{
BLI_setenv("PYTHONPATH", py_path_bundle);
}
#endif
{
static wchar_t py_path_bundle_wchar[1024];
/* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */
/* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
utf8towchar(py_path_bundle_wchar, py_path_bundle);
Py_SetPythonHome(py_path_bundle_wchar);
// printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar);
}
}
/* Would be nice if python had this built in */
void PyC_RunQuicky(const char *filepath, int n, ...)
{

View File

@@ -48,4 +48,6 @@ void PyC_RunQuicky(const char *filepath, int n, ...);
void PyC_MainModule_Backup(PyObject **main_mod);
void PyC_MainModule_Restore(PyObject *main_mod);
void PyC_SetHomePath(const char *py_path_bundle);
#endif // PY_CAPI_UTILS_H