Cycles: svn merge -r41613:41627 ^/trunk/blender
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 7 Nov 2011 17:13:32 +0000 (17:13 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 7 Nov 2011 17:13:32 +0000 (17:13 +0000)
13 files changed:
1  2 
CMakeLists.txt
build_files/cmake/config/blender_lite.cmake
intern/cycles/blender/addon/engine.py
intern/cycles/blender/blender_python.cpp
source/blender/blenloader/intern/readfile.c
source/blender/editors/screen/area.c
source/blender/editors/space_node/drawnode.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_render.c
source/blender/makesrna/intern/rna_ui_api.c
source/blender/nodes/shader/nodes/node_shader_mapping.c
source/blender/python/intern/bpy_interface.c
source/creator/CMakeLists.txt

diff --cc CMakeLists.txt
index 83d99928dca69cf22e5bf30c0e3155bd751f7024,43f52eff0091d719be1ec1e0721ac9d9f97c6407..99a44efdb0d61d8682f4d3ab19ef8e03b2b3a141
@@@ -294,16 -284,6 +293,12 @@@ if(WITH_PYTHON_MODULE
        set(WITH_HEADLESS ON)
  endif()
  
- if(WITH_OPENIMAGEIO)
-       set(WITH_BOOST ON)
- endif()
 +# auto enable openimageio and boost for cycles
 +if(WITH_CYCLES)
 +      set(WITH_OPENIMAGEIO ON)
 +      set(WITH_BOOST ON)
 +endif()
 +
  TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
  
  # don't store paths to libs for portable distrobution
@@@ -1511,6 -1480,6 +1495,7 @@@ if(FIRST_RUN
        info_cfg_option(WITH_FFTW3)
        info_cfg_option(WITH_INTERNATIONAL)
        info_cfg_option(WITH_INPUT_NDOF)
++      info_cfg_option(WITH_CYCLES)
  
        info_cfg_text("Compiler Options:")
        info_cfg_option(WITH_BUILDINFO)
index 6791028a888eca3b3b37f2c0b851c252d5845202,0da28a943ebc3ed30fe71b16c0c274dbc7e89527..4f04960d5e347837a62756a621edc462c7b3f9fe
@@@ -12,7 -12,8 +12,9 @@@ set(WITH_BUILTIN_GLEW        OFF CACHE 
  set(WITH_BULLET              OFF CACHE FORCE BOOL)
  set(WITH_CODEC_FFMPEG        OFF CACHE FORCE BOOL)
  set(WITH_CODEC_SNDFILE       OFF CACHE FORCE BOOL)
++set(WITH_CYCLES              OFF CACHE FORCE BOOL)
  set(WITH_FFTW3               OFF CACHE FORCE BOOL)
+ set(WITH_LIBMV               OFF CACHE FORCE BOOL)
  set(WITH_GAMEENGINE          OFF CACHE FORCE BOOL)
  set(WITH_IK_ITASC            OFF CACHE FORCE BOOL)
  set(WITH_IMAGE_CINEON        OFF CACHE FORCE BOOL)
index 8cd7be567e6446b1ffa20a567e3e53a7ef54a610,0000000000000000000000000000000000000000..097909ca05818a3cebe481123b90b9687f8dbc99
mode 100644,000000..100644
--- /dev/null
@@@ -1,74 -1,0 +1,74 @@@
-     import libcycles_blender as lib
 +#
 +# Copyright 2011, Blender Foundation.
 +#
 +# This program is free software; you can redistribute it and/or
 +# modify it under the terms of the GNU General Public License
 +# as published by the Free Software Foundation; either version 2
 +# of the License, or (at your option) any later version.
 +#
 +# This program is distributed in the hope that it will be useful,
 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +# GNU General Public License for more details.
 +#
 +# You should have received a copy of the GNU General Public License
 +# along with this program; if not, write to the Free Software Foundation,
 +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 +#
 +
 +import bpy
 +
 +def init():
-     lib.init(path, user_path)
++    import bcycles
 +    import os.path
 +
 +    path = os.path.dirname(__file__)
 +    user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', '')))
 +
-     import libcycles_blender as lib
++    bcycles.init(path, user_path)
 +
 +def create(engine, data, scene, region = 0, v3d = 0, rv3d = 0):
-     engine.session = lib.create(engine.as_pointer(), data, scene, region, v3d, rv3d)
++    import bcycles
 +
 +    data = data.as_pointer()
 +    scene = scene.as_pointer()
 +    if region:
 +        region = region.as_pointer()
 +    if v3d:
 +        v3d = v3d.as_pointer()
 +    if rv3d:
 +        rv3d = rv3d.as_pointer()
 +
-             import libcycles_blender as lib
-             lib.free(engine.session)
++    engine.session = bcycles.create(engine.as_pointer(), data, scene, region, v3d, rv3d)
 +
 +def free(engine):
 +    if "session" in dir(engine):
 +        if engine.session:
-     import libcycles_blender as lib
-     lib.render(engine.session)
++            import bcycles
++            bcycles.free(engine.session)
 +        del engine.session
 +
 +def render(engine):
-     import libcycles_blender as lib
-     lib.sync(engine.session)
++    import bcycles
++    bcycles.render(engine.session)
 +
 +def update(engine, data, scene):
-     import libcycles_blender as lib
++    import bcycles
++    bcycles.sync(engine.session)
 +
 +def draw(engine, region, v3d, rv3d):
-     lib.draw(engine.session, v3d, rv3d)
++    import bcycles
 +    v3d = v3d.as_pointer()
 +    rv3d = rv3d.as_pointer()
 +
 +    # draw render image
-     import libcycles_blender as lib
-     return lib.available_devices()
++    bcycles.draw(engine.session, v3d, rv3d)
 +
 +def available_devices():
-     import libcycles_blender as lib
-     return lib.with_osl()
++    import bcycles
++    return bcycles.available_devices()
 +
 +def with_osl():
++    import bcycles
++    return bcycles.with_osl()
 +
index 1026d420c0242a7c6699fc566712c8c01e3d5d21,0000000000000000000000000000000000000000..58049bb8cbe9809a5aa3b559b27464458b981353
mode 100644,000000..100644
--- /dev/null
@@@ -1,212 -1,0 +1,212 @@@
-       "libcycles_blender",
-       "Blender RNA to render exporter",
 +/*
 + * Copyright 2011, Blender Foundation.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + */
 +
 +#include <Python.h>
 +
 +#include "blender_sync.h"
 +#include "blender_session.h"
 +
 +#include "util_opengl.h"
 +#include "util_path.h"
 +
 +CCL_NAMESPACE_BEGIN
 +
 +static PyObject *init_func(PyObject *self, PyObject *args)
 +{
 +      const char *path, *user_path;
 +
 +      if(!PyArg_ParseTuple(args, "ss", &path, &user_path))
 +              return NULL;
 +      
 +      path_init(path, user_path);
 +
 +      Py_INCREF(Py_None);
 +      return Py_None;
 +}
 +
 +static PyObject *create_func(PyObject *self, PyObject *args)
 +{
 +      PyObject *pyengine, *pydata, *pyscene, *pyregion, *pyv3d, *pyrv3d;
 +
 +      if(!PyArg_ParseTuple(args, "OOOOOO", &pyengine, &pydata, &pyscene, &pyregion, &pyv3d, &pyrv3d))
 +              return NULL;
 +
 +      /* RNA */
 +      PointerRNA engineptr;
 +      RNA_pointer_create(NULL, &RNA_RenderEngine, (void*)PyLong_AsVoidPtr(pyengine), &engineptr);
 +      BL::RenderEngine engine(engineptr);
 +
 +      PointerRNA dataptr;
 +      RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydata), &dataptr);
 +      BL::BlendData data(dataptr);
 +
 +      PointerRNA sceneptr;
 +      RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyscene), &sceneptr);
 +      BL::Scene scene(sceneptr);
 +
 +      PointerRNA regionptr;
 +      RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyregion), &regionptr);
 +      BL::Region region(regionptr);
 +
 +      PointerRNA v3dptr;
 +      RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyv3d), &v3dptr);
 +      BL::SpaceView3D v3d(v3dptr);
 +
 +      PointerRNA rv3dptr;
 +      RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyrv3d), &rv3dptr);
 +      BL::RegionView3D rv3d(rv3dptr);
 +
 +      /* create session */
 +      BlenderSession *session;
 +
 +      if(rv3d) {
 +              /* interactive session */
 +              int width = region.width();
 +              int height = region.height();
 +
 +              session = new BlenderSession(engine, data, scene, v3d, rv3d, width, height);
 +      }
 +      else {
 +              /* offline session */
 +              session = new BlenderSession(engine, data, scene);
 +      }
 +      
 +      return PyLong_FromVoidPtr(session);
 +}
 +
 +static PyObject *free_func(PyObject *self, PyObject *args)
 +{
 +      PyObject *pysession;
 +
 +      if(!PyArg_ParseTuple(args, "O", &pysession))
 +              return NULL;
 +
 +      delete (BlenderSession*)PyLong_AsVoidPtr(pysession);
 +
 +      Py_INCREF(Py_None);
 +      return Py_None;
 +}
 +
 +static PyObject *render_func(PyObject *self, PyObject *args)
 +{
 +      PyObject *pysession;
 +
 +      if(!PyArg_ParseTuple(args, "O", &pysession))
 +              return NULL;
 +      
 +      Py_BEGIN_ALLOW_THREADS
 +
 +      BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
 +      session->render();
 +
 +      Py_END_ALLOW_THREADS
 +
 +      Py_INCREF(Py_None);
 +      return Py_None;
 +}
 +
 +static PyObject *draw_func(PyObject *self, PyObject *args)
 +{
 +      PyObject *pysession, *pyv3d, *pyrv3d;
 +
 +      if(!PyArg_ParseTuple(args, "OOO", &pysession, &pyv3d, &pyrv3d))
 +              return NULL;
 +      
 +      BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
 +
 +      if(PyLong_AsVoidPtr(pyrv3d)) {
 +              /* 3d view drawing */
 +              int viewport[4];
 +              glGetIntegerv(GL_VIEWPORT, viewport);
 +
 +              session->draw(viewport[2], viewport[3]);
 +      }
 +
 +      Py_INCREF(Py_None);
 +      return Py_None;
 +}
 +
 +static PyObject *sync_func(PyObject *self, PyObject *args)
 +{
 +      PyObject *pysession;
 +
 +      if(!PyArg_ParseTuple(args, "O", &pysession))
 +              return NULL;
 +
 +      BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
 +      session->synchronize();
 +
 +      Py_INCREF(Py_None);
 +      return Py_None;
 +}
 +
 +static PyObject *available_devices_func(PyObject *self, PyObject *args)
 +{
 +      vector<DeviceType> types = Device::available_types();
 +
 +      PyObject *ret = PyTuple_New(types.size());
 +
 +      for(size_t i = 0; i < types.size(); i++) {
 +              string name = Device::string_from_type(types[i]);
 +              PyTuple_SetItem(ret, i, PyUnicode_FromString(name.c_str()));
 +      }
 +
 +      return ret;
 +}
 +
 +static PyObject *with_osl_func(PyObject *self, PyObject *args)
 +{
 +#ifdef WITH_OSL
 +      PyObject *ret = Py_True;
 +#else
 +      PyObject *ret = Py_False;
 +#endif
 +
 +      return Py_INCREF(ret), ret;
 +}
 +
 +static PyMethodDef methods[] = {
 +      {"init", init_func, METH_VARARGS, ""},
 +      {"create", create_func, METH_VARARGS, ""},
 +      {"free", free_func, METH_VARARGS, ""},
 +      {"render", render_func, METH_VARARGS, ""},
 +      {"draw", draw_func, METH_VARARGS, ""},
 +      {"sync", sync_func, METH_VARARGS, ""},
 +      {"available_devices", available_devices_func, METH_NOARGS, ""},
 +      {"with_osl", with_osl_func, METH_NOARGS, ""},
 +      {NULL, NULL, 0, NULL},
 +};
 +
 +static struct PyModuleDef module = {
 +      PyModuleDef_HEAD_INIT,
++      "bcycles",
++      "Blender cycles render integration",
 +      -1,
 +      methods,
 +      NULL, NULL, NULL, NULL
 +};
 +
 +CCL_NAMESPACE_END
 +
 +extern "C" PyObject *CYCLES_initPython();
 +
 +PyObject *CYCLES_initPython()
 +{
 +      return PyModule_Create(&ccl::module);
 +}
 +
index 7ce7e0291a2c25908ebc2816fc92fcc08bdbe049,ba1d333f44fa4cf871133e4a02b24b973fd18e85..b0f597ba47770bcd40ca28d80f2694411b92412e
@@@ -12516,15 -12318,8 +12516,15 @@@ static void do_versions(FileData *fd, L
                                        cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
                        }
                }
+       }
  
-               {
-                       bNodeTreeType *ntreetype= ntreeGetType(NTREE_SHADER);
++      if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 2)) {
++              bNodeTreeType *ntreetype= ntreeGetType(NTREE_SHADER);
 +
-                       if(ntreetype && ntreetype->foreach_nodetree)
-                               ntreetype->foreach_nodetree(main, NULL, do_version_ntree_tex_mapping_260);
-               }
++              if(ntreetype && ntreetype->foreach_nodetree)
++                      ntreetype->foreach_nodetree(main, NULL, do_version_ntree_tex_mapping_260);
 +      }
 +
        /* put compatibility code here until next subversion bump */
        {
                {
Simple merge
index 3c2de3f4711f6858cf3737a73a4105b611530364,b4d89e1365dcf28e73f438da90486ef9fd7c44cb..e6a219f4685b83b84d7a8ee1b9807c593edb1b2c
@@@ -946,12 -938,11 +946,12 @@@ static void node_shader_buts_material(u
  
  static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
  {
 +      PointerRNA mappingptr = RNA_pointer_get(ptr, "mapping");
        uiLayout *row;
        
-       uiItemL(layout, "Translation:", ICON_NONE);
+       uiItemL(layout, "Location:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
 -      uiItemR(row, ptr, "location", 0, "", ICON_NONE);
 +      uiItemR(row, &mappingptr, "location", 0, "", ICON_NONE);
        
        uiItemL(layout, "Rotation:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
        
        uiItemL(layout, "Scale:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
 -      uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
 +      uiItemR(row, &mappingptr, "scale", 0, "", ICON_NONE);
        
- #if 0
        row= uiLayoutRow(layout, 1);
 -      uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE);
 -      uiItemR(row, ptr, "min", 0, "", ICON_NONE);
 +      uiItemR(row, &mappingptr, "use_min", 0, "Min", ICON_NONE);
 +      uiItemR(row, &mappingptr, "min", 0, "", ICON_NONE);
        
        row= uiLayoutRow(layout, 1);
 -      uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE);
 -      uiItemR(row, ptr, "max", 0, "", ICON_NONE);
 -      
 +      uiItemR(row, &mappingptr, "use_max", 0, "Max", ICON_NONE);
 +      uiItemR(row, &mappingptr, "max", 0, "", ICON_NONE);
- #endif        
  }
  
  static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@@ -996,68 -986,6 +994,54 @@@ static void node_shader_buts_geometry(u
        }
  }
  
- /*static void node_layout_prop(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname)
- {
-       if(C && CTX_wm_space_node(C)) {
-               uiItemR(layout, ptr, propname, 0, NULL, ICON_NONE);
-       }
-       else {
-               uiLayout *split = uiLayoutSplit(layout, 0.35f, 0);
-               PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
-               uiItemL(uiLayoutColumn(split, 0), RNA_property_ui_name(prop), ICON_NONE);
-               uiItemR(uiLayoutColumn(split, 0), ptr, propname, 0, "", ICON_NONE);
-       }
- }*/
 +static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "attribute_name", 0, "Name", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
 +{
 +      //uiItemR(layout, ptr, "image", 0, "", ICON_NONE);
 +      uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
 +      uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "gradient_type", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
 +}
 +
  static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr)
  { 
        Main *bmain= CTX_data_main(C);
index 2eff74651effc7ee34d0afe76ae17fc68420dde1,862c52187dc30d2281daa12507c83c6994e290f6..2fa885dcdd3a3bf9f540775d4db48d37fa329824
@@@ -67,9 -67,9 +67,9 @@@ static void node_shader_exec_mapping(vo
  }
  
  
- static void node_shader_default_mapping(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+ static void node_shader_init_mapping(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
  {
 -      node->storage= add_mapping();
 +      node->storage= add_tex_mapping();
  }
  
  static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
@@@ -91,10 -91,10 +91,10 @@@ void register_node_type_sh_mapping(List
        static bNodeType ntype;
        
        node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, NODE_OPTIONS);
 -      node_type_compatibility(&ntype, NODE_OLD_SHADING);
 +      node_type_compatibility(&ntype, NODE_OLD_SHADING|NODE_NEW_SHADING);
        node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out);
        node_type_size(&ntype, 240, 160, 320);
-       node_type_init(&ntype, node_shader_default_mapping);
+       node_type_init(&ntype, node_shader_init_mapping);
        node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage);
        node_type_exec(&ntype, node_shader_exec_mapping);
        node_type_gpu(&ntype, gpu_shader_mapping);
index de2433c876672799ced0f6d883c2ec6be4727079,ffa9e5cc27c99f719efebe980f5a0cc7bf49867e..7dee2ce6fb4e1cab12054bcda9178b3abfbb4145
@@@ -185,9 -183,6 +185,9 @@@ static struct _inittab bpy_internal_mod
        {(char *)"blf", BPyInit_blf},
  #ifdef WITH_AUDASPACE
        {(char *)"aud", AUD_initPython},
-       {(char *)"libcycles_blender", CYCLES_initPython},
 +#endif
 +#ifdef WITH_CYCLES
++      {(char *)"bcycles", CYCLES_initPython},
  #endif
        {(char *)"gpu", GPU_initPython},
        {NULL, NULL}
index 0e0830f0fa2cf30a9dac1d71d36764db995133da,b0e5427500bda3d199f346412c0bdbd26d73c8b9..bb55d05cb280fd60ca8355406883003a3dfbd121
@@@ -864,15 -854,6 +864,13 @@@ endif(
                bf_blenfont
                bf_intern_audaspace
                bf_intern_mikktspace
-               extern_recastnavigation
-               bf_editor_util          # --- BAD LEVEL CALL HERE --- XXX, this should be removed before release!
 +              bf_intern_cycles
 +              cycles_render
 +              cycles_bvh
 +              cycles_device
 +              cycles_kernel
 +              cycles_util
 +              cycles_subd
        )
  
        if(WITH_LIBMV)