Fix Cycles to mostly work with render layer / depsgraph changes.
[blender.git] / intern / cycles / blender / blender_python.cpp
index 17bf8ceef36876a667231cf4dd28882e1d481581..5c1181960c353a0f0075922ea88041a1fd8b7bc7 100644 (file)
@@ -280,13 +280,22 @@ static PyObject *free_func(PyObject * /*self*/, PyObject *value)
        Py_RETURN_NONE;
 }
 
-static PyObject *render_func(PyObject * /*self*/, PyObject *value)
+static PyObject *render_func(PyObject * /*self*/, PyObject *args)
 {
-       BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(value);
+       PyObject *pysession, *pydepsgraph;
+
+       if(!PyArg_ParseTuple(args, "OO", &pysession, &pydepsgraph))
+               return NULL;
+
+       BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
+
+       PointerRNA depsgraphptr;
+       RNA_pointer_create(NULL, &RNA_Depsgraph, (ID*)PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
+       BL::Depsgraph b_depsgraph(depsgraphptr);
 
        python_thread_state_save(&session->python_thread_state);
 
-       session->render();
+       session->render(b_depsgraph);
 
        python_thread_state_restore(&session->python_thread_state);
 
@@ -296,16 +305,20 @@ static PyObject *render_func(PyObject * /*self*/, PyObject *value)
 /* pixel_array and result passed as pointers */
 static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
 {
-       PyObject *pysession, *pyobject;
+       PyObject *pysession, *pydepsgraph, *pyobject;
        PyObject *pypixel_array, *pyresult;
        const char *pass_type;
        int num_pixels, depth, object_id, pass_filter;
 
-       if(!PyArg_ParseTuple(args, "OOsiiOiiO", &pysession, &pyobject, &pass_type, &pass_filter, &object_id, &pypixel_array, &num_pixels, &depth, &pyresult))
+       if(!PyArg_ParseTuple(args, "OOOsiiOiiO", &pysession, &pydepsgraph, &pyobject, &pass_type, &pass_filter, &object_id, &pypixel_array, &num_pixels, &depth, &pyresult))
                return NULL;
 
        BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
 
+       PointerRNA depsgraphptr;
+       RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
+       BL::Depsgraph b_depsgraph(depsgraphptr);
+
        PointerRNA objectptr;
        RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyobject), &objectptr);
        BL::Object b_object(objectptr);
@@ -318,7 +331,7 @@ static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
 
        python_thread_state_save(&session->python_thread_state);
 
-       session->bake(b_object, pass_type, pass_filter, object_id, b_bake_pixel, (size_t)num_pixels, depth, (float *)b_result);
+       session->bake(b_depsgraph, b_object, pass_type, pass_filter, object_id, b_bake_pixel, (size_t)num_pixels, depth, (float *)b_result);
 
        python_thread_state_restore(&session->python_thread_state);
 
@@ -371,13 +384,22 @@ static PyObject *reset_func(PyObject * /*self*/, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *sync_func(PyObject * /*self*/, PyObject *value)
+static PyObject *sync_func(PyObject * /*self*/, PyObject *args)
 {
-       BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(value);
+       PyObject *pysession, *pydepsgraph;
+
+       if(!PyArg_ParseTuple(args, "OO", &pysession, &pydepsgraph))
+               return NULL;
+
+       BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
+
+       PointerRNA depsgraphptr;
+       RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
+       BL::Depsgraph b_depsgraph(depsgraphptr);
 
        python_thread_state_save(&session->python_thread_state);
 
-       session->synchronize();
+       session->synchronize(b_depsgraph);
 
        python_thread_state_restore(&session->python_thread_state);
 
@@ -749,10 +771,10 @@ static PyMethodDef methods[] = {
        {"exit", exit_func, METH_VARARGS, ""},
        {"create", create_func, METH_VARARGS, ""},
        {"free", free_func, METH_O, ""},
-       {"render", render_func, METH_O, ""},
+       {"render", render_func, METH_VARARGS, ""},
        {"bake", bake_func, METH_VARARGS, ""},
        {"draw", draw_func, METH_VARARGS, ""},
-       {"sync", sync_func, METH_O, ""},
+       {"sync", sync_func, METH_VARARGS, ""},
        {"reset", reset_func, METH_VARARGS, ""},
 #ifdef WITH_OSL
        {"osl_update_node", osl_update_node_func, METH_VARARGS, ""},