diff options
Diffstat (limited to 'intern/cycles/blender/blender_python.cpp')
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 8e5a6c13f44..292af14c63a 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ #include <Python.h> @@ -73,8 +73,9 @@ static const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) static PyObject *init_func(PyObject *self, PyObject *args) { PyObject *path, *user_path; + int headless; - if(!PyArg_ParseTuple(args, "OO", &path, &user_path)) { + if(!PyArg_ParseTuple(args, "OOi", &path, &user_path, &headless)) { return NULL; } @@ -84,6 +85,8 @@ static PyObject *init_func(PyObject *self, PyObject *args) Py_XDECREF(path_coerce); Py_XDECREF(user_path_coerce); + BlenderSession::headless = headless; + Py_RETURN_NONE; } @@ -92,8 +95,11 @@ static PyObject *create_func(PyObject *self, PyObject *args) PyObject *pyengine, *pyuserpref, *pydata, *pyscene, *pyregion, *pyv3d, *pyrv3d; int preview_osl; - if(!PyArg_ParseTuple(args, "OOOOOOOi", &pyengine, &pyuserpref, &pydata, &pyscene, &pyregion, &pyv3d, &pyrv3d, &preview_osl)) + if(!PyArg_ParseTuple(args, "OOOOOOOi", &pyengine, &pyuserpref, &pydata, &pyscene, + &pyregion, &pyv3d, &pyrv3d, &preview_osl)) + { return NULL; + } /* RNA */ PointerRNA engineptr; @@ -105,7 +111,7 @@ static PyObject *create_func(PyObject *self, PyObject *args) BL::UserPreferences userpref(userprefptr); PointerRNA dataptr; - RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydata), &dataptr); + RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr); BL::BlendData data(dataptr); PointerRNA sceneptr; @@ -113,15 +119,15 @@ static PyObject *create_func(PyObject *self, PyObject *args) BL::Scene scene(sceneptr); PointerRNA regionptr; - RNA_id_pointer_create((ID*)pylong_as_voidptr_typesafe(pyregion), ®ionptr); + RNA_pointer_create(NULL, &RNA_Region, pylong_as_voidptr_typesafe(pyregion), ®ionptr); BL::Region region(regionptr); PointerRNA v3dptr; - RNA_id_pointer_create((ID*)pylong_as_voidptr_typesafe(pyv3d), &v3dptr); + RNA_pointer_create(NULL, &RNA_SpaceView3D, pylong_as_voidptr_typesafe(pyv3d), &v3dptr); BL::SpaceView3D v3d(v3dptr); PointerRNA rv3dptr; - RNA_id_pointer_create((ID*)pylong_as_voidptr_typesafe(pyrv3d), &rv3dptr); + RNA_pointer_create(NULL, &RNA_RegionView3D, pylong_as_voidptr_typesafe(pyrv3d), &rv3dptr); BL::RegionView3D rv3d(rv3dptr); /* create session */ @@ -196,7 +202,7 @@ static PyObject *bake_func(PyObject *self, PyObject *args) void *b_result = PyLong_AsVoidPtr(pyresult); PointerRNA bakepixelptr; - RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pypixel_array), &bakepixelptr); + RNA_pointer_create(NULL, &RNA_BakePixel, PyLong_AsVoidPtr(pypixel_array), &bakepixelptr); BL::BakePixel b_bake_pixel(bakepixelptr); python_thread_state_save(&session->python_thread_state); @@ -238,7 +244,7 @@ static PyObject *reset_func(PyObject *self, PyObject *args) BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession); PointerRNA dataptr; - RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydata), &dataptr); + RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr); BL::BlendData b_data(dataptr); PointerRNA sceneptr; @@ -385,13 +391,7 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args) /* find socket socket */ BL::NodeSocket b_sock(PointerRNA_NULL); if (param->isoutput) { -#if OSL_LIBRARY_VERSION_CODE < 10500 - b_sock = b_node.outputs[param->name]; -#else b_sock = b_node.outputs[param->name.string()]; -#endif - - /* remove if type no longer matches */ if(b_sock && b_sock.bl_idname() != socket_type) { b_node.outputs.remove(b_sock); @@ -399,12 +399,7 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args) } } else { -#if OSL_LIBRARY_VERSION_CODE < 10500 - b_sock = b_node.inputs[param->name]; -#else b_sock = b_node.inputs[param->name.string()]; -#endif - /* remove if type no longer matches */ if(b_sock && b_sock.bl_idname() != socket_type) { b_node.inputs.remove(b_sock); @@ -484,6 +479,12 @@ static PyObject *osl_compile_func(PyObject *self, PyObject *args) } #endif +static PyObject *system_info_func(PyObject *self, PyObject *value) +{ + string system_info = Device::device_capabilities(); + return PyUnicode_FromString(system_info.c_str()); +} + static PyMethodDef methods[] = { {"init", init_func, METH_VARARGS, ""}, {"create", create_func, METH_VARARGS, ""}, @@ -498,6 +499,7 @@ static PyMethodDef methods[] = { {"osl_compile", osl_compile_func, METH_VARARGS, ""}, #endif {"available_devices", available_devices_func, METH_NOARGS, ""}, + {"system_info", system_info_func, METH_NOARGS, ""}, {NULL, NULL, 0, NULL}, }; |