Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 1 Jun 2016 12:34:11 +0000 (14:34 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 1 Jun 2016 12:34:11 +0000 (14:34 +0200)
Conflicts:
intern/cycles/blender/blender_curves.cpp
intern/cycles/blender/blender_particles.cpp
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/depsgraph/intern/depsgraph_build.cc

238 files changed:
CMakeLists.txt
build_files/buildbot/slave_compile.py
build_files/cmake/macros.cmake
extern/Eigen3/README.blender [new file with mode: 0644]
extern/binreloc/README.blender [new file with mode: 0644]
extern/carve/README.blender [new file with mode: 0644]
extern/libopenjpeg/README.blender [new file with mode: 0644]
extern/rangetree/README.blender [new file with mode: 0644]
extern/xdnd/README.blender [new file with mode: 0644]
intern/cycles/app/cycles_xml.cpp
intern/cycles/blender/blender_camera.cpp
intern/cycles/blender/blender_curves.cpp
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/blender/blender_util.h
intern/cycles/bvh/bvh.cpp
intern/cycles/bvh/bvh_build.cpp
intern/cycles/bvh/bvh_split.cpp
intern/cycles/device/device_cpu.cpp
intern/cycles/device/device_cuda.cpp
intern/cycles/device/device_multi.cpp
intern/cycles/device/device_network.cpp
intern/cycles/device/device_opencl.cpp
intern/cycles/graph/node.cpp
intern/cycles/graph/node.h
intern/cycles/graph/node_type.cpp
intern/cycles/graph/node_type.h
intern/cycles/graph/node_xml.cpp
intern/cycles/kernel/geom/geom_bvh.h
intern/cycles/kernel/geom/geom_bvh_traversal.h
intern/cycles/kernel/geom/geom_qbvh_traversal.h
intern/cycles/kernel/kernel_bake.h
intern/cycles/kernel/kernel_globals.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_path_branched.h
intern/cycles/kernel/kernel_shadow.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/kernels/cpu/kernel.cpp
intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
intern/cycles/kernel/shaders/node_brick_texture.osl
intern/cycles/kernel/shaders/node_convert_from_color.osl
intern/cycles/kernel/shaders/node_convert_from_float.osl
intern/cycles/kernel/shaders/node_convert_from_int.osl
intern/cycles/kernel/shaders/node_convert_from_normal.osl
intern/cycles/kernel/shaders/node_convert_from_point.osl
intern/cycles/kernel/shaders/node_convert_from_string.osl
intern/cycles/kernel/shaders/node_convert_from_vector.osl
intern/cycles/kernel/shaders/node_gradient_texture.osl
intern/cycles/kernel/shaders/node_image_texture.osl
intern/cycles/kernel/shaders/node_magic_texture.osl
intern/cycles/kernel/shaders/node_math.osl
intern/cycles/kernel/shaders/node_mix.osl
intern/cycles/kernel/shaders/node_musgrave_texture.osl
intern/cycles/kernel/shaders/node_normal.osl
intern/cycles/kernel/shaders/node_rgb_ramp.osl
intern/cycles/kernel/shaders/node_subsurface_scattering.osl
intern/cycles/kernel/shaders/node_voronoi_texture.osl
intern/cycles/kernel/shaders/node_wave_texture.osl
intern/cycles/kernel/svm/svm_closure.h
intern/cycles/kernel/svm/svm_image.h
intern/cycles/kernel/svm/svm_types.h
intern/cycles/render/attribute.cpp
intern/cycles/render/attribute.h
intern/cycles/render/background.cpp
intern/cycles/render/background.h
intern/cycles/render/bake.cpp
intern/cycles/render/camera.cpp
intern/cycles/render/camera.h
intern/cycles/render/curves.h
intern/cycles/render/film.cpp
intern/cycles/render/graph.cpp
intern/cycles/render/graph.h
intern/cycles/render/image.cpp
intern/cycles/render/image.h
intern/cycles/render/integrator.cpp
intern/cycles/render/integrator.h
intern/cycles/render/light.cpp
intern/cycles/render/mesh.cpp
intern/cycles/render/mesh.h
intern/cycles/render/mesh_displace.cpp
intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h
intern/cycles/render/object.cpp
intern/cycles/render/object.h
intern/cycles/render/osl.cpp
intern/cycles/render/osl.h
intern/cycles/render/particles.cpp
intern/cycles/render/particles.h
intern/cycles/render/scene.cpp
intern/cycles/render/scene.h
intern/cycles/render/session.cpp
intern/cycles/render/shader.cpp
intern/cycles/render/svm.cpp
intern/cycles/render/svm.h
intern/cycles/subd/subd_dice.cpp
intern/cycles/subd/subd_dice.h
intern/cycles/util/util_string.cpp
intern/cycles/util/util_string.h
intern/cycles/util/util_texture.h
intern/ghost/intern/GHOST_NDOFManager.cpp
intern/ghost/intern/GHOST_NDOFManager.h
intern/opencolorio/gpu_shader_display_transform.glsl
intern/opensubdiv/gpu_shader_opensubd_display.glsl
release/scripts/modules/bpy_types.py
release/scripts/presets/interface_theme/blender_24x.xml
release/scripts/presets/keyconfig/maya.py
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenlib/BLI_array_store.h [new file with mode: 0644]
source/blender/blenlib/BLI_stackdefines.h
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/intern/BLI_ghash.c
source/blender/blenlib/intern/BLI_mempool.c
source/blender/blenlib/intern/array_store.c [new file with mode: 0644]
source/blender/blenlib/intern/noise.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/ArmatureExporter.h
source/blender/collada/ArmatureImporter.cpp
source/blender/collada/ArmatureImporter.h
source/blender/collada/ExportSettings.h
source/blender/collada/ExtraTags.cpp
source/blender/collada/ExtraTags.h
source/blender/collada/MeshImporter.cpp
source/blender/collada/collada.cpp
source/blender/collada/collada.h
source/blender/collada/collada_utils.cpp
source/blender/collada/collada_utils.h
source/blender/depsgraph/CMakeLists.txt
source/blender/depsgraph/DEG_depsgraph.h
source/blender/depsgraph/DEG_depsgraph_build.h
source/blender/depsgraph/DEG_depsgraph_debug.h
source/blender/depsgraph/DEG_depsgraph_query.h
source/blender/depsgraph/intern/builder/deg_builder.cc [new file with mode: 0644]
source/blender/depsgraph/intern/builder/deg_builder.h [new file with mode: 0644]
source/blender/depsgraph/intern/builder/deg_builder_cycle.cc [moved from source/blender/depsgraph/util/depsgraph_util_cycle.cc with 80% similarity]
source/blender/depsgraph/intern/builder/deg_builder_cycle.h [moved from source/blender/depsgraph/util/depsgraph_util_cycle.h with 86% similarity]
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc [moved from source/blender/depsgraph/intern/depsgraph_build_nodes.cc with 97% similarity]
source/blender/depsgraph/intern/builder/deg_builder_nodes.h [new file with mode: 0644]
source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc [moved from source/blender/depsgraph/util/depsgraph_util_pchanmap.cc with 83% similarity]
source/blender/depsgraph/intern/builder/deg_builder_pchanmap.h [moved from source/blender/depsgraph/util/depsgraph_util_pchanmap.h with 88% similarity]
source/blender/depsgraph/intern/builder/deg_builder_relations.cc [moved from source/blender/depsgraph/intern/depsgraph_build_relations.cc with 97% similarity]
source/blender/depsgraph/intern/builder/deg_builder_relations.h [moved from source/blender/depsgraph/intern/depsgraph_build.h with 63% similarity]
source/blender/depsgraph/intern/builder/deg_builder_transitive.cc [moved from source/blender/depsgraph/util/depsgraph_util_transitive.cc with 72% similarity]
source/blender/depsgraph/intern/builder/deg_builder_transitive.h [moved from source/blender/depsgraph/util/depsgraph_util_transitive.h with 85% similarity]
source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc [new file with mode: 0644]
source/blender/depsgraph/intern/depsgraph.cc
source/blender/depsgraph/intern/depsgraph.h
source/blender/depsgraph/intern/depsgraph_build.cc
source/blender/depsgraph/intern/depsgraph_debug.cc
source/blender/depsgraph/intern/depsgraph_eval.cc
source/blender/depsgraph/intern/depsgraph_intern.h
source/blender/depsgraph/intern/depsgraph_query.cc
source/blender/depsgraph/intern/depsgraph_queue.cc [deleted file]
source/blender/depsgraph/intern/depsgraph_queue.h [deleted file]
source/blender/depsgraph/intern/depsgraph_tag.cc
source/blender/depsgraph/intern/depsgraph_type_defines.cc
source/blender/depsgraph/intern/depsgraph_types.h
source/blender/depsgraph/intern/depsnode_opcodes.h [deleted file]
source/blender/depsgraph/intern/eval/deg_eval.cc [new file with mode: 0644]
source/blender/depsgraph/intern/eval/deg_eval.h [new file with mode: 0644]
source/blender/depsgraph/intern/eval/deg_eval_debug.cc [new file with mode: 0644]
source/blender/depsgraph/intern/eval/deg_eval_debug.h [moved from source/blender/depsgraph/intern/depsgraph_debug.h with 87% similarity]
source/blender/depsgraph/intern/eval/deg_eval_flush.cc [new file with mode: 0644]
source/blender/depsgraph/intern/eval/deg_eval_flush.h [new file with mode: 0644]
source/blender/depsgraph/intern/nodes/deg_node.cc [moved from source/blender/depsgraph/intern/depsnode.cc with 68% similarity]
source/blender/depsgraph/intern/nodes/deg_node.h [moved from source/blender/depsgraph/intern/depsnode.h with 84% similarity]
source/blender/depsgraph/intern/nodes/deg_node_component.cc [moved from source/blender/depsgraph/intern/depsnode_component.cc with 61% similarity]
source/blender/depsgraph/intern/nodes/deg_node_component.h [moved from source/blender/depsgraph/intern/depsnode_component.h with 76% similarity]
source/blender/depsgraph/intern/nodes/deg_node_operation.cc [moved from source/blender/depsgraph/intern/depsnode_operation.cc with 78% similarity]
source/blender/depsgraph/intern/nodes/deg_node_operation.h [moved from source/blender/depsgraph/intern/depsnode_operation.h with 70% similarity]
source/blender/depsgraph/util/deg_util_foreach.h [new file with mode: 0644]
source/blender/depsgraph/util/deg_util_function.h [moved from source/blender/depsgraph/util/depsgraph_util_function.h with 93% similarity]
source/blender/depsgraph/util/deg_util_hash.h [moved from source/blender/depsgraph/util/depsgraph_util_set.h with 50% similarity]
source/blender/depsgraph/util/depsgraph_util_hash.h [deleted file]
source/blender/depsgraph/util/depsgraph_util_map.h [deleted file]
source/blender/editors/animation/anim_deps.c
source/blender/editors/animation/drivers.c
source/blender/editors/animation/keyframing.c
source/blender/editors/armature/armature_utils.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/io/io_collada.c
source/blender/editors/mesh/CMakeLists.txt
source/blender/editors/mesh/editmesh_undo.c [new file with mode: 0644]
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_snap.c
source/blender/gpu/GPU_buffers.h
source/blender/gpu/GPU_shader.h
source/blender/gpu/intern/gpu_buffers.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_framebuffer.c
source/blender/gpu/intern/gpu_material.c
source/blender/gpu/shaders/gpu_shader_basic_frag.glsl
source/blender/gpu/shaders/gpu_shader_basic_geom.glsl
source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl
source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl
source/blender/gpu/shaders/gpu_shader_fx_dof_vert.glsl
source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl
source/blender/gpu/shaders/gpu_shader_geometry.glsl
source/blender/gpu/shaders/gpu_shader_material.glsl
source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl
source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl
source/blender/gpu/shaders/gpu_shader_vertex.glsl
source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl
source/blender/imbuf/intern/IMB_anim.h
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_camera.c
source/blender/makesrna/intern/rna_curve.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/makesrna/intern/rna_sequencer.c
source/blender/modifiers/intern/MOD_screw.c
source/blender/nodes/shader/nodes/node_shader_camera.c
source/blender/nodes/shader/nodes/node_shader_normal_map.c
source/blender/nodes/shader/nodes/node_shader_tex_image.c
source/blender/python/intern/bpy_rna.c
source/blender/python/mathutils/mathutils_Matrix.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/wm_event_types.h
source/blenderplayer/bad_level_call_stubs/stubs.c
tests/gtests/blenlib/BLI_array_store_test.cc [new file with mode: 0644]
tests/gtests/blenlib/BLI_ghash_performance_test.cc
tests/gtests/blenlib/CMakeLists.txt

index 2b40b9268fcac07b3d03fb2484ffdbf4e4865baa..b558fe1482049f9e509876a30c44deef2f240e3a 100644 (file)
@@ -1959,7 +1959,7 @@ elseif(WIN32)
                set(OPENAL ${LIBDIR}/openal)
                set(OPENALDIR ${LIBDIR}/openal)
                set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
-               if(MSVC12)
+               if(MSVC)
                        set(OPENAL_LIBRARY openal32)
                else()
                        set(OPENAL_LIBRARY wrap_oal)
index 5e25d9f3f0422e7dfc47b48fabb49a194ec64c1d..9a874e92c80439e744ca2015939e558a3665ca3c 100644 (file)
@@ -75,11 +75,18 @@ if 'cmake' in builder:
         cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/bin/nvcc')
 
     elif builder.startswith('win'):
+      if builder.endswith('_vc2015'):
         if builder.startswith('win64'):
-            cmake_options.append(['-G', '"Visual Studio 12 2013 Win64"'])
+            cmake_options.extend(['-G', 'Visual Studio 14 2015 Win64'])
         elif builder.startswith('win32'):
             bits = 32
-            cmake_options.append(['-G', '"Visual Studio 12 2013"'])
+            cmake_options.extend(['-G', 'Visual Studio 14 2015'])
+      else:
+        if builder.startswith('win64'):
+            cmake_options.extend(['-G', 'Visual Studio 12 2013 Win64'])
+        elif builder.startswith('win32'):
+            bits = 32
+            cmake_options.extend(['-G', 'Visual Studio 12 2013'])
 
     elif builder.startswith('linux'):
         tokens = builder.split("_")
index 47fc86c4f20b531e5d28d9d9e8b728d738fcb903..d34b55e14e03a217f73048e1756c65aa09caae4e 100644 (file)
@@ -879,8 +879,16 @@ macro(TEST_SHARED_PTR_SUPPORT)
        # otherwise it's assumed to be defined in std namespace.
 
        include(CheckIncludeFileCXX)
+       include(CheckCXXSourceCompiles)
        set(SHARED_PTR_FOUND FALSE)
-       CHECK_INCLUDE_FILE_CXX(memory HAVE_STD_MEMORY_HEADER)
+       # Workaround for newer GCC (6.x+) where C++11 was enabled by default, which lead us
+       # to a situation when there is <unordered_map> include but which can't be used uless
+       # C++11 is enabled.
+       if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
+               set(HAVE_STD_MEMORY_HEADER False)
+       else()
+               CHECK_INCLUDE_FILE_CXX(memory HAVE_STD_MEMORY_HEADER)
+       endif()
        if(HAVE_STD_MEMORY_HEADER)
                # Finding the memory header doesn't mean that shared_ptr is in std
                # namespace.
@@ -888,7 +896,6 @@ macro(TEST_SHARED_PTR_SUPPORT)
                # In particular, MSVC 2008 has shared_ptr declared in std::tr1.  In
                # order to support this, we do an extra check to see which namespace
                # should be used.
-               include(CheckCXXSourceCompiles)
                CHECK_CXX_SOURCE_COMPILES("#include <memory>
                                           int main() {
                                             std::shared_ptr<int> int_ptr;
diff --git a/extern/Eigen3/README.blender b/extern/Eigen3/README.blender
new file mode 100644 (file)
index 0000000..8ccc46a
--- /dev/null
@@ -0,0 +1,6 @@
+Project: Eigen, template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms
+URL: http://eigen.tuxfamily.org/index.php?title=Main_Page
+License: GPLv3+
+Upstream version: 3.2.7
+Local modifications:
+- OpenMP fix for MSVC2015, see http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1131
diff --git a/extern/binreloc/README.blender b/extern/binreloc/README.blender
new file mode 100644 (file)
index 0000000..a90b442
--- /dev/null
@@ -0,0 +1,6 @@
+Project: AutoPackage
+URL: http://autopackage.org/docs/binreloc (original, defunct)
+     http://alien.cern.ch/cache/autopackage-1.0/site/docs/binreloc/ (cache)
+License: Public Domain
+Upstream version: Unknown (Last Release)
+Local modifications: None
diff --git a/extern/carve/README.blender b/extern/carve/README.blender
new file mode 100644 (file)
index 0000000..80be40a
--- /dev/null
@@ -0,0 +1,4 @@
+Project: Carve, CSG library
+URL: https://code.google.com/archive/p/carve/
+Upstream version 9a85d733a43d
+Local modifications: See patches/ folder
diff --git a/extern/libopenjpeg/README.blender b/extern/libopenjpeg/README.blender
new file mode 100644 (file)
index 0000000..5aa213c
--- /dev/null
@@ -0,0 +1,5 @@
+Project: OpenJPEG
+URL: http://www.openjpeg.org
+License: BSD 2-Clause
+Upstream version: 1.5.2
+Local modifications:
diff --git a/extern/rangetree/README.blender b/extern/rangetree/README.blender
new file mode 100644 (file)
index 0000000..cb59671
--- /dev/null
@@ -0,0 +1,5 @@
+Project: RangeTree
+URL: https://github.com/nicholasbishop/RangeTree
+License: GPLv2+
+Upstream version: c4ecf6bb7dfd
+Local modifications: None
diff --git a/extern/xdnd/README.blender b/extern/xdnd/README.blender
new file mode 100644 (file)
index 0000000..05afe56
--- /dev/null
@@ -0,0 +1,8 @@
+Project: X Drag and Drop
+URL: http://www.newplanetsoftware.com/xdnd/ (defunct)
+     https://freedesktop.org/wiki/Specifications/XDND/ (cache)
+License: GPLv2+
+Upstream version: 2000-08-08
+Local modifications:
+* Fix T33192
+  Opening Blender breaks drag-and-drop support on the KDE desktop.
index f734d01f71d8a39cb01ad8d677c503b7fcb28205..9f967a4bde909e9316710bfdc21d7c9f3218d8cf 100644 (file)
@@ -31,6 +31,7 @@
 #include "mesh.h"
 #include "nodes.h"
 #include "object.h"
+#include "osl.h"
 #include "shader.h"
 #include "scene.h"
 
@@ -214,25 +215,7 @@ static bool xml_equal_string(pugi::xml_node node, const char *name, const char *
        return false;
 }
 
-static bool xml_read_enum(ustring *str, ShaderEnum& enm, pugi::xml_node node, const char *name)
-{
-       pugi::xml_attribute attr = node.attribute(name);
-
-       if(attr) {
-               ustring ustr(attr.value());
-
-               if(enm.exists(ustr)) {
-                       *str = ustr;
-                       return true;
-               }
-               else
-                       fprintf(stderr, "Unknown value \"%s\" for attribute \"%s\".\n", ustr.c_str(), name);
-       }
-
-       return false;
-}
-
-static bool xml_read_enum_value(int *value, ShaderEnum& enm, pugi::xml_node node, const char *name)
+static bool xml_read_enum_value(int *value, NodeEnum& enm, pugi::xml_node node, const char *name)
 {
        pugi::xml_attribute attr = node.attribute(name);
 
@@ -250,77 +233,16 @@ static bool xml_read_enum_value(int *value, ShaderEnum& enm, pugi::xml_node node
        return false;
 }
 
-static ShaderSocketType xml_read_socket_type(pugi::xml_node node, const char *name)
-{
-       pugi::xml_attribute attr = node.attribute(name);
-
-       if(attr) {
-               string value = attr.value();
-               if(string_iequals(value, "float"))
-                       return SHADER_SOCKET_FLOAT;
-               else if(string_iequals(value, "int"))
-                       return SHADER_SOCKET_INT;
-               else if(string_iequals(value, "color"))
-                       return SHADER_SOCKET_COLOR;
-               else if(string_iequals(value, "vector"))
-                       return SHADER_SOCKET_VECTOR;
-               else if(string_iequals(value, "point"))
-                       return SHADER_SOCKET_POINT;
-               else if(string_iequals(value, "normal"))
-                       return SHADER_SOCKET_NORMAL;
-               else if(string_iequals(value, "closure color"))
-                       return SHADER_SOCKET_CLOSURE;
-               else if(string_iequals(value, "string"))
-                       return SHADER_SOCKET_STRING;
-               else
-                       fprintf(stderr, "Unknown shader socket type \"%s\" for attribute \"%s\".\n", value.c_str(), name);
-       }
-       
-       return SHADER_SOCKET_UNDEFINED;
-}
-
 /* Camera */
 
-static void xml_read_camera(const XMLReadState& state, pugi::xml_node node)
+static void xml_read_camera(XMLReadState& state, pugi::xml_node node)
 {
        Camera *cam = state.scene->camera;
 
        xml_read_int(&cam->width, node, "width");
        xml_read_int(&cam->height, node, "height");
 
-       if(xml_read_float(&cam->fov, node, "fov"))
-               cam->fov = DEG2RADF(cam->fov);
-
-       xml_read_float(&cam->nearclip, node, "nearclip");
-       xml_read_float(&cam->farclip, node, "farclip");
-       xml_read_float(&cam->aperturesize, node, "aperturesize"); // 0.5*focallength/fstop
-       xml_read_float(&cam->focaldistance, node, "focaldistance");
-       xml_read_float(&cam->shuttertime, node, "shuttertime");
-       xml_read_float(&cam->aperture_ratio, node, "aperture_ratio");
-
-       if(xml_equal_string(node, "type", "orthographic"))
-               cam->type = CAMERA_ORTHOGRAPHIC;
-       else if(xml_equal_string(node, "type", "perspective"))
-               cam->type = CAMERA_PERSPECTIVE;
-       else if(xml_equal_string(node, "type", "panorama"))
-               cam->type = CAMERA_PANORAMA;
-
-       if(xml_equal_string(node, "panorama_type", "equirectangular"))
-               cam->panorama_type = PANORAMA_EQUIRECTANGULAR;
-       else if(xml_equal_string(node, "panorama_type", "fisheye_equidistant"))
-               cam->panorama_type = PANORAMA_FISHEYE_EQUIDISTANT;
-       else if(xml_equal_string(node, "panorama_type", "fisheye_equisolid"))
-               cam->panorama_type = PANORAMA_FISHEYE_EQUISOLID;
-
-       xml_read_float(&cam->fisheye_fov, node, "fisheye_fov");
-       xml_read_float(&cam->fisheye_lens, node, "fisheye_lens");
-
-       xml_read_bool(&cam->use_spherical_stereo, node, "use_spherical_stereo");
-       xml_read_float(&cam->interocular_distance, node, "interocular_distance");
-       xml_read_float(&cam->convergence_distance, node, "convergence_distance");
-
-       xml_read_float(&cam->sensorwidth, node, "sensorwidth");
-       xml_read_float(&cam->sensorheight, node, "sensorheight");
+       xml_read_node(state, cam, node);
 
        cam->matrix = state.tfm;
 
@@ -345,6 +267,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
 {
        xml_read_node(state, shader, graph_node);
 
+       ShaderManager *manager = state.scene->shader_manager;
        ShaderGraph *graph = new ShaderGraph();
 
        map<string, ShaderNode*> nodemap;
@@ -364,8 +287,8 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                        xml_read_string(&img->filename, node, "src");
                        img->filename = path_join(state.base, img->filename);
                        
-                       xml_read_enum(&img->color_space, ImageTextureNode::color_space_enum, node, "color_space");
-                       xml_read_enum(&img->projection, ImageTextureNode::projection_enum, node, "projection");
+                       xml_read_enum_value((int*)&img->color_space, ImageTextureNode::color_space_enum, node, "color_space");
+                       xml_read_enum_value((int*)&img->projection, ImageTextureNode::projection_enum, node, "projection");
                        xml_read_float(&img->projection_blend, node, "projection_blend");
 
                        /* ToDo: Interpolation */
@@ -378,56 +301,40 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                        xml_read_string(&env->filename, node, "src");
                        env->filename = path_join(state.base, env->filename);
                        
-                       xml_read_enum(&env->color_space, EnvironmentTextureNode::color_space_enum, node, "color_space");
-                       xml_read_enum(&env->projection, EnvironmentTextureNode::projection_enum, node, "projection");
+                       xml_read_enum_value((int*)&env->color_space, EnvironmentTextureNode::color_space_enum, node, "color_space");
+                       xml_read_enum_value((int*)&env->projection, EnvironmentTextureNode::projection_enum, node, "projection");
 
                        snode = env;
                }
+#ifdef WITH_OSL
                else if(string_iequals(node.name(), "osl_shader")) {
-                       OSLScriptNode *osl = new OSLScriptNode();
+                       if(manager->use_osl()) {
+                               std::string filepath;
 
-                       /* Source */
-                       xml_read_string(&osl->filepath, node, "src");
-                       if(path_is_relative(osl->filepath)) {
-                               osl->filepath = path_join(state.base, osl->filepath);
-                       }
+                               if(xml_read_string(&filepath, node, "src")) {
+                                       if(path_is_relative(filepath)) {
+                                               filepath = path_join(state.base, filepath);
+                                       }
 
-                       /* Generate inputs/outputs from node sockets
-                        *
-                        * Note: ShaderInput/ShaderOutput store shallow string copies only!
-                        * So we register them as ustring to ensure the pointer stays valid. */
-                       /* read input values */
-                       for(pugi::xml_node param = node.first_child(); param; param = param.next_sibling()) {
-                               if(string_iequals(param.name(), "input")) {
-                                       string name;
-                                       if(!xml_read_string(&name, param, "name"))
-                                               continue;
-                                       
-                                       ShaderSocketType type = xml_read_socket_type(param, "type");
-                                       if(type == SHADER_SOCKET_UNDEFINED)
-                                               continue;
-                                       
-                                       osl->add_input(ustring(name).c_str(), type);
+                                       snode = ((OSLShaderManager*)manager)->osl_node(filepath);
+
+                                       if(!snode) {
+                                               fprintf(stderr, "Failed to create OSL node from \"%s\".\n", filepath.c_str());
+                                       }
                                }
-                               else if(string_iequals(param.name(), "output")) {
-                                       string name;
-                                       if(!xml_read_string(&name, param, "name"))
-                                               continue;
-                                       
-                                       ShaderSocketType type = xml_read_socket_type(param, "type");
-                                       if(type == SHADER_SOCKET_UNDEFINED)
-                                               continue;
-                                       
-                                       osl->add_output(ustring(name).c_str(), type);
+                               else {
+                                       fprintf(stderr, "OSL node missing \"src\" attribute.\n");
                                }
                        }
-                       
-                       snode = osl;
+                       else {
+                               fprintf(stderr, "OSL node without using --shadingsys osl.\n");
+                       }
                }
+#endif
                else if(string_iequals(node.name(), "sky_texture")) {
                        SkyTextureNode *sky = new SkyTextureNode();
                        
-                       xml_read_enum(&sky->type, SkyTextureNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&sky->type, SkyTextureNode::type_enum, node, "type");
                        xml_read_float3(&sky->sun_direction, node, "sun_direction");
                        xml_read_float(&sky->turbidity, node, "turbidity");
                        xml_read_float(&sky->ground_albedo, node, "ground_albedo");
@@ -452,17 +359,17 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                }
                else if(string_iequals(node.name(), "gradient_texture")) {
                        GradientTextureNode *blend = new GradientTextureNode();
-                       xml_read_enum(&blend->type, GradientTextureNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&blend->type, GradientTextureNode::type_enum, node, "type");
                        snode = blend;
                }
                else if(string_iequals(node.name(), "voronoi_texture")) {
                        VoronoiTextureNode *voronoi = new VoronoiTextureNode();
-                       xml_read_enum(&voronoi->coloring, VoronoiTextureNode::coloring_enum, node, "coloring");
+                       xml_read_enum_value((int*)&voronoi->coloring, VoronoiTextureNode::coloring_enum, node, "coloring");
                        snode = voronoi;
                }
                else if(string_iequals(node.name(), "musgrave_texture")) {
                        MusgraveTextureNode *musgrave = new MusgraveTextureNode();
-                       xml_read_enum(&musgrave->type, MusgraveTextureNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&musgrave->type, MusgraveTextureNode::type_enum, node, "type");
                        snode = musgrave;
                }
                else if(string_iequals(node.name(), "magic_texture")) {
@@ -472,8 +379,8 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                }
                else if(string_iequals(node.name(), "wave_texture")) {
                        WaveTextureNode *wave = new WaveTextureNode();
-                       xml_read_enum(&wave->type, WaveTextureNode::type_enum, node, "type");
-                       xml_read_enum(&wave->profile, WaveTextureNode::profile_enum, node, "profile");
+                       xml_read_enum_value((int*)&wave->type, WaveTextureNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&wave->profile, WaveTextureNode::profile_enum, node, "profile");
                        snode = wave;
                }
                else if(string_iequals(node.name(), "normal")) {
@@ -508,7 +415,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                }
                else if(string_iequals(node.name(), "anisotropic_bsdf")) {
                        AnisotropicBsdfNode *aniso = new AnisotropicBsdfNode();
-                       xml_read_enum(&aniso->distribution, AnisotropicBsdfNode::distribution_enum, node, "distribution");
+                       xml_read_enum_value((int*)&aniso->distribution, AnisotropicBsdfNode::distribution_enum, node, "distribution");
                        snode = aniso;
                }
                else if(string_iequals(node.name(), "diffuse_bsdf")) {
@@ -525,27 +432,27 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                }
                else if(string_iequals(node.name(), "toon_bsdf")) {
                        ToonBsdfNode *toon = new ToonBsdfNode();
-                       xml_read_enum(&toon->component, ToonBsdfNode::component_enum, node, "component");
+                       xml_read_enum_value((int*)&toon->component, ToonBsdfNode::component_enum, node, "component");
                        snode = toon;
                }
                else if(string_iequals(node.name(), "glossy_bsdf")) {
                        GlossyBsdfNode *glossy = new GlossyBsdfNode();
-                       xml_read_enum(&glossy->distribution, GlossyBsdfNode::distribution_enum, node, "distribution");
+                       xml_read_enum_value((int*)&glossy->distribution, GlossyBsdfNode::distribution_enum, node, "distribution");
                        snode = glossy;
                }
                else if(string_iequals(node.name(), "glass_bsdf")) {
                        GlassBsdfNode *diel = new GlassBsdfNode();
-                       xml_read_enum(&diel->distribution, GlassBsdfNode::distribution_enum, node, "distribution");
+                       xml_read_enum_value((int*)&diel->distribution, GlassBsdfNode::distribution_enum, node, "distribution");
                        snode = diel;
                }
                else if(string_iequals(node.name(), "refraction_bsdf")) {
                        RefractionBsdfNode *diel = new RefractionBsdfNode();
-                       xml_read_enum(&diel->distribution, RefractionBsdfNode::distribution_enum, node, "distribution");
+                       xml_read_enum_value((int*)&diel->distribution, RefractionBsdfNode::distribution_enum, node, "distribution");
                        snode = diel;
                }
                else if(string_iequals(node.name(), "hair_bsdf")) {
                        HairBsdfNode *hair = new HairBsdfNode();
-                       xml_read_enum(&hair->component, HairBsdfNode::component_enum, node, "component");
+                       xml_read_enum_value((int*)&hair->component, HairBsdfNode::component_enum, node, "component");
                        snode = hair;
                }
                else if(string_iequals(node.name(), "emission")) {
@@ -623,7 +530,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                else if(string_iequals(node.name(), "mix")) {
                        /* ToDo: Tag Mix case for optimization */
                        MixNode *mix = new MixNode();
-                       xml_read_enum(&mix->type, MixNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&mix->type, MixNode::type_enum, node, "type");
                        xml_read_bool(&mix->use_clamp, node, "use_clamp");
                        snode = mix;
                }
@@ -687,32 +594,32 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                else if(string_iequals(node.name(), "normal_map")) {
                        NormalMapNode *nmap = new NormalMapNode;
                        xml_read_ustring(&nmap->attribute, node, "attribute");
-                       xml_read_enum(&nmap->space, NormalMapNode::space_enum, node, "space");
+                       xml_read_enum_value((int*)&nmap->space, NormalMapNode::space_enum, node, "space");
                        snode = nmap;
                }
                else if(string_iequals(node.name(), "tangent")) {
                        TangentNode *tangent = new TangentNode;
                        xml_read_ustring(&tangent->attribute, node, "attribute");
-                       xml_read_enum(&tangent->direction_type, TangentNode::direction_type_enum, node, "direction_type");
-                       xml_read_enum(&tangent->axis, TangentNode::axis_enum, node, "axis");
+                       xml_read_enum_value((int*)&tangent->direction_type, TangentNode::direction_type_enum, node, "direction_type");
+                       xml_read_enum_value((int*)&tangent->axis, TangentNode::axis_enum, node, "axis");
                        snode = tangent;
                }
                else if(string_iequals(node.name(), "math")) {
                        MathNode *math = new MathNode();
-                       xml_read_enum(&math->type, MathNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&math->type, MathNode::type_enum, node, "type");
                        xml_read_bool(&math->use_clamp, node, "use_clamp");
                        snode = math;
                }
                else if(string_iequals(node.name(), "vector_math")) {
                        VectorMathNode *vmath = new VectorMathNode();
-                       xml_read_enum(&vmath->type, VectorMathNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&vmath->type, VectorMathNode::type_enum, node, "type");
                        snode = vmath;
                }
                else if(string_iequals(node.name(), "vector_transform")) {
                        VectorTransformNode *vtransform = new VectorTransformNode();
-                       xml_read_enum(&vtransform->type, VectorTransformNode::type_enum, node, "type");
-                       xml_read_enum(&vtransform->convert_from, VectorTransformNode::convert_space_enum, node, "convert_from");
-                       xml_read_enum(&vtransform->convert_to, VectorTransformNode::convert_space_enum, node, "convert_to");
+                       xml_read_enum_value((int*)&vtransform->type, VectorTransformNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&vtransform->convert_from, VectorTransformNode::convert_space_enum, node, "convert_from");
+                       xml_read_enum_value((int*)&vtransform->convert_to, VectorTransformNode::convert_space_enum, node, "convert_to");
                        snode = vtransform;
                }
                else if(string_iequals(node.name(), "connect")) {
@@ -731,7 +638,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                                        ShaderNode *fromnode = nodemap[from_tokens[0]];
 
                                        foreach(ShaderOutput *out, fromnode->outputs)
-                                               if(string_iequals(xml_socket_name(out->name), from_tokens[1]))
+                                               if(string_iequals(xml_socket_name(out->name().c_str()), from_tokens[1]))
                                                        output = out;
 
                                        if(!output)
@@ -744,7 +651,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                                        ShaderNode *tonode = nodemap[to_tokens[0]];
 
                                        foreach(ShaderInput *in, tonode->inputs)
-                                               if(string_iequals(xml_socket_name(in->name), to_tokens[1]))
+                                               if(string_iequals(xml_socket_name(in->name().c_str()), to_tokens[1]))
                                                        input = in;
 
                                        if(!input)
@@ -776,20 +683,20 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                        /* read input values */
                        for(pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute()) {
                                foreach(ShaderInput *in, snode->inputs) {
-                                       if(string_iequals(in->name, attr.name())) {
-                                               switch(in->type) {
-                                                       case SHADER_SOCKET_FLOAT:
-                                                       case SHADER_SOCKET_INT:
-                                                               xml_read_float(&in->value.x, node, attr.name());
+                                       if(string_iequals(in->name().c_str(), attr.name())) {
+                                               switch(in->type()) {
+                                                       case SocketType::FLOAT:
+                                                       case SocketType::INT:
+                                                               xml_read_float(&in->value_float(), node, attr.name());
                                                                break;
-                                                       case SHADER_SOCKET_COLOR:
-                                                       case SHADER_SOCKET_VECTOR:
-                                                       case SHADER_SOCKET_POINT:
-                                                       case SHADER_SOCKET_NORMAL:
-                                                               xml_read_float3(&in->value, node, attr.name());
+                                                       case SocketType::COLOR:
+                                                       case SocketType::VECTOR:
+                                                       case SocketType::POINT:
+                                                       case SocketType::NORMAL:
+                                                               xml_read_float3(&in->value(), node, attr.name());
                                                                break;
-                                                       case SHADER_SOCKET_STRING:
-                                                               xml_read_ustring( &in->value_string, node, attr.name() );
+                                                       case SocketType::STRING:
+                                                               xml_read_ustring( &in->value_string(), node, attr.name() );
                                                                break;
                                                        default:
                                                                break;
@@ -908,6 +815,11 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
                /* create vertices */
                mesh->verts = P;
 
+               size_t num_triangles = 0;
+               for(size_t i = 0; i < nverts.size(); i++)
+                       num_triangles += nverts[i]-2;
+               mesh->reserve_mesh(mesh->verts.size(), num_triangles);
+
                /* create triangles */
                int index_offset = 0;
 
index 9dec489ce336485a34fca368c47b08eb6ef88fe5..f02fc55390896964631f963d42035949be526790 100644 (file)
@@ -37,7 +37,7 @@ struct BlenderCamera {
        float lens;
        float shuttertime;
        Camera::MotionPosition motion_position;
-       float shutter_curve[RAMP_TABLE_SIZE];
+       array<float> shutter_curve;
 
        Camera::RollingShutterType rolling_shutter_type;
        float rolling_shutter_duration;
@@ -108,10 +108,6 @@ static void blender_camera_init(BlenderCamera *bcam,
        /* render resolution */
        bcam->full_width = render_resolution_x(b_render);
        bcam->full_height = render_resolution_y(b_render);
-
-       /* pixel aspect */
-       bcam->pixelaspect.x = b_render.pixel_aspect_x();
-       bcam->pixelaspect.y = b_render.pixel_aspect_y();
 }
 
 static float blender_camera_focal_distance(BL::RenderEngine& b_engine,
@@ -464,7 +460,7 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
        cam->rolling_shutter_type = bcam->rolling_shutter_type;
        cam->rolling_shutter_duration = bcam->rolling_shutter_duration;
 
-       memcpy(cam->shutter_curve, bcam->shutter_curve, sizeof(cam->shutter_curve));
+       cam->shutter_curve = bcam->shutter_curve;
 
        /* border */
        cam->border = bcam->border;
@@ -563,6 +559,10 @@ void BlenderSync::sync_camera_motion(BL::RenderSettings& b_render,
                float aspectratio, sensor_size;
                blender_camera_init(&bcam, b_render);
 
+               /* TODO(sergey): Consider making it a part of blender_camera_init(). */
+               bcam.pixelaspect.x = b_render.pixel_aspect_x();
+               bcam.pixelaspect.y = b_render.pixel_aspect_y();
+
                blender_camera_from_object(&bcam, b_engine, b_ob);
                blender_camera_viewplane(&bcam,
                                         width, height,
index 39521c841d133d05b92542eb80a07cb7691ef0c2..7b9d4f2ecdfe88e1d9cd721a88f1301df816d2fe 100644 (file)
@@ -134,10 +134,7 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
                }
        }
 
-       mesh->verts.reserve(mesh->verts.size() + numverts);
-       mesh->triangles.reserve(mesh->triangles.size() + numtris);
-       mesh->shader.reserve(mesh->shader.size() + numtris);
-       mesh->smooth.reserve(mesh->smooth.size() + numtris);
+       mesh->reserve_mesh(mesh->verts.size() + numverts, mesh->num_triangles() + numtris);
 
        /* actually export */
        for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
@@ -157,8 +154,8 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
                                xbasis = normalize(cross(RotCam - ickey_loc, v1));
                        float3 ickey_loc_shfl = ickey_loc - radius * xbasis;
                        float3 ickey_loc_shfr = ickey_loc + radius * xbasis;
-                       mesh->verts.push_back(ickey_loc_shfl);
-                       mesh->verts.push_back(ickey_loc_shfr);
+                       mesh->add_vertex(ickey_loc_shfl);
+                       mesh->add_vertex(ickey_loc_shfr);
                        vertexindex += 2;
 
                        for(int curvekey = CData->curve_firstkey[curve] + 1; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; curvekey++) {
@@ -184,8 +181,8 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
                                        xbasis = normalize(cross(RotCam - ickey_loc, v1));
                                float3 ickey_loc_shfl = ickey_loc - radius * xbasis;
                                float3 ickey_loc_shfr = ickey_loc + radius * xbasis;
-                               mesh->verts.push_back(ickey_loc_shfl);
-                               mesh->verts.push_back(ickey_loc_shfr);
+                               mesh->add_vertex(ickey_loc_shfl);
+                               mesh->add_vertex(ickey_loc_shfr);
                                mesh->add_triangle(vertexindex-2, vertexindex, vertexindex-1, CData->psys_shader[sys], true);
                                mesh->add_triangle(vertexindex+1, vertexindex-1, vertexindex, CData->psys_shader[sys], true);
                                vertexindex += 2;
@@ -193,7 +190,6 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
                }
        }
 
-       mesh->reserve(mesh->verts.size(), mesh->triangles.size(), 0, 0);
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
        mesh->add_face_normals();
@@ -220,10 +216,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol
                }
        }
 
-       mesh->verts.reserve(mesh->verts.size() + numverts);
-       mesh->triangles.reserve(mesh->triangles.size() + numtris);
-       mesh->shader.reserve(mesh->shader.size() + numtris);
-       mesh->smooth.reserve(mesh->smooth.size() + numtris);
+       mesh->reserve_mesh(mesh->verts.size() + numverts, mesh->num_triangles() + numtris);
 
        /* actually export */
        for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
@@ -312,7 +305,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol
                                        float angle = M_2PI_F / (float)resolution;
                                        for(int section = 0; section < resolution; section++) {
                                                float3 ickey_loc_shf = ickey_loc + radius * (cosf(angle * section) * xbasis + sinf(angle * section) * ybasis);
-                                               mesh->verts.push_back(ickey_loc_shf);
+                                               mesh->add_vertex(ickey_loc_shf);
                                        }
 
                                        if(subv != 0) {
@@ -329,7 +322,6 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol
                }
        }
 
-       mesh->reserve(mesh->verts.size(), mesh->triangles.size(), 0, 0);
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
        mesh->add_face_normals();
@@ -344,7 +336,7 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
        int num_keys = 0;
        int num_curves = 0;
 
-       if(!(mesh->curves.empty() && mesh->curve_keys.empty()))
+       if(mesh->num_curves())
                return;
 
        Attribute *attr_intercept = NULL;
@@ -367,8 +359,7 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
                VLOG(1) << "Exporting curve segments for mesh " << mesh->name;
        }
 
-       mesh->curve_keys.reserve(mesh->curve_keys.size() + num_keys);
-       mesh->curves.reserve(mesh->curves.size() + num_curves);
+       mesh->reserve_curves(mesh->num_curves() + num_curves, mesh->curve_keys.size() + num_keys);
 
        num_keys = 0;
        num_curves = 0;
@@ -396,18 +387,16 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
                                num_curve_keys++;
                        }
 
-                       mesh->add_curve(num_keys, num_curve_keys, CData->psys_shader[sys]);
+                       mesh->add_curve(num_keys, CData->psys_shader[sys]);
                        num_keys += num_curve_keys;
                        num_curves++;
                }
        }
 
        /* check allocation */
-       if((mesh->curve_keys.size() != num_keys) || (mesh->curves.size() != num_curves)) {
+       if((mesh->curve_keys.size() != num_keys) || (mesh->num_curves() != num_curves)) {
                VLOG(1) << "Allocation failed, clearing data";
-               mesh->curve_keys.clear();
-               mesh->curves.clear();
-               mesh->curve_attributes.clear();
+               mesh->clear();
        }
 }
 
@@ -450,13 +439,16 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
                                        if(CData->psys_closetip[sys] && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1))
                                                radius = 0.0f;
 
+                                       /* curve motion keys store both position and radius in float4 */
                                        mP[i] = float3_to_float4(ickey_loc);
                                        mP[i].w = radius;
 
                                        /* unlike mesh coordinates, these tend to be slightly different
                                         * between frames due to particle transforms into/out of object
                                         * space, so we use an epsilon to detect actual changes */
-                                       if(len_squared(mP[i] - mesh->curve_keys[i]) > 1e-5f*1e-5f)
+                                       float4 curve_key = float3_to_float4(mesh->curve_keys[i]);
+                                       curve_key.w = mesh->curve_radius[i];
+                                       if(len_squared(mP[i] - curve_key) > 1e-5f*1e-5f)
                                                have_motion = true;
                                }
 
@@ -480,8 +472,10 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
                        for(int step = 0; step < time_index; step++) {
                                float4 *mP = attr_mP->data_float4() + step*numkeys;
 
-                               for(int key = 0; key < numkeys; key++)
-                                       mP[key] = mesh->curve_keys[key];
+                               for(int key = 0; key < numkeys; key++) {
+                                       mP[key] = float3_to_float4(mesh->curve_keys[key]);
+                                       mP[key].w = mesh->curve_radius[key];
+                               }
                        }
                }
        }
@@ -641,7 +635,9 @@ void BlenderSync::sync_curves(Mesh *mesh,
        if(!motion) {
                /* Clear stored curve data */
                mesh->curve_keys.clear();
-               mesh->curves.clear();
+               mesh->curve_radius.clear();
+               mesh->curve_first_key.clear();
+               mesh->curve_shader.clear();
                mesh->curve_attributes.clear();
        }
 
@@ -658,7 +654,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
        int triangle_method = scene->curve_system_manager->triangle_method;
        int resolution = scene->curve_system_manager->resolution;
        size_t vert_num = mesh->verts.size();
-       size_t tri_num = mesh->triangles.size();
+       size_t tri_num = mesh->num_triangles();
        int used_res = 1;
 
        /* extract particle hair data - should be combined with connecting to mesh later*/
@@ -714,11 +710,10 @@ void BlenderSync::sync_curves(Mesh *mesh,
                        else {
                                Attribute *attr_generated = mesh->curve_attributes.add(ATTR_STD_GENERATED);
                                float3 *generated = attr_generated->data_float3();
-                               size_t i = 0;
 
-                               foreach(Mesh::Curve& curve, mesh->curves) {
-                                       float3 co = float4_to_float3(mesh->curve_keys[curve.first_key]);
-                                       generated[i++] = co*size - loc;
+                               for(size_t i = 0; i < mesh->num_curves(); i++) {
+                                       float3 co = mesh->curve_keys[mesh->get_curve(i).first_key];
+                                       generated[i] = co*size - loc;
                                }
                        }
                }
index 4a0ad79f3ae6960be7b06c92eaa374c5e4389faf..80db51148e613fa6ddd612e364bab85080d20082 100644 (file)
@@ -548,13 +548,12 @@ static void create_mesh(Scene *scene,
                numtris += (vi[3] == 0)? 1: 2;
        }
 
-       /* reserve memory */
-       mesh->reserve(numverts, numtris, 0, 0);
+       /* allocate memory */
+       mesh->reserve_mesh(numverts, numtris);
 
        /* create vertex coordinates and normals */
-       int i = 0;
-       for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++i)
-               mesh->verts[i] = get_float3(v->co());
+       for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
+               mesh->add_vertex(get_float3(v->co()));
 
        Attribute *attr_N = mesh->attributes.add(ATTR_STD_VERTEX_NORMAL);
        float3 *N = attr_N->data_float3();
@@ -583,7 +582,7 @@ static void create_mesh(Scene *scene,
        /* create faces */
        vector<int> nverts(numfaces);
        vector<int> face_flags(numfaces, FACE_FLAG_NONE);
-       int fi = 0, ti = 0;
+       int fi = 0;
 
        for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f, ++fi) {
                int4 vi = get_int4(f->vertices_raw());
@@ -618,18 +617,18 @@ static void create_mesh(Scene *scene,
                           is_zero(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - mesh->verts[vi[0]])))
                        {
                                // TODO(mai): order here is probably wrong
-                               mesh->set_triangle(ti++, vi[0], vi[1], vi[3], shader, smooth, true);
-                               mesh->set_triangle(ti++, vi[2], vi[3], vi[1], shader, smooth, true);
+                               mesh->add_triangle(vi[0], vi[1], vi[3], shader, smooth, true);
+                               mesh->add_triangle(vi[2], vi[3], vi[1], shader, smooth, true);
                                face_flags[fi] |= FACE_FLAG_DIVIDE_24;
                        }
                        else {
-                               mesh->set_triangle(ti++, vi[0], vi[1], vi[2], shader, smooth, true);
-                               mesh->set_triangle(ti++, vi[0], vi[2], vi[3], shader, smooth, true);
+                               mesh->add_triangle(vi[0], vi[1], vi[2], shader, smooth, true);
+                               mesh->add_triangle(vi[0], vi[2], vi[3], shader, smooth, true);
                                face_flags[fi] |= FACE_FLAG_DIVIDE_13;
                        }
                }
                else
-                       mesh->set_triangle(ti++, vi[0], vi[1], vi[2], shader, smooth, false);
+                       mesh->add_triangle(vi[0], vi[1], vi[2], shader, smooth, false);
 
                nverts[fi] = n;
        }
@@ -759,11 +758,12 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
        /* create derived mesh */
        PointerRNA cmesh = RNA_pointer_get(&b_ob_data.ptr, "cycles");
 
-       vector<Mesh::Triangle> oldtriangle = mesh->triangles;
+       array<int> oldtriangle = mesh->triangles;
        
        /* compares curve_keys rather than strands in order to handle quick hair
         * adjustments in dynamic BVH - other methods could probably do this better*/
-       vector<float4> oldcurve_keys = mesh->curve_keys;
+       array<float3> oldcurve_keys = mesh->curve_keys;
+       array<float> oldcurve_radius = mesh->curve_radius;
 
        mesh->clear();
        mesh->used_shaders = used_shaders;
@@ -827,14 +827,21 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
        if(oldtriangle.size() != mesh->triangles.size())
                rebuild = true;
        else if(oldtriangle.size()) {
-               if(memcmp(&oldtriangle[0], &mesh->triangles[0], sizeof(Mesh::Triangle)*oldtriangle.size()) != 0)
+               if(memcmp(&oldtriangle[0], &mesh->triangles[0], sizeof(int)*oldtriangle.size()) != 0)
                        rebuild = true;
        }
 
        if(oldcurve_keys.size() != mesh->curve_keys.size())
                rebuild = true;
        else if(oldcurve_keys.size()) {
-               if(memcmp(&oldcurve_keys[0], &mesh->curve_keys[0], sizeof(float4)*oldcurve_keys.size()) != 0)
+               if(memcmp(&oldcurve_keys[0], &mesh->curve_keys[0], sizeof(float3)*oldcurve_keys.size()) != 0)
+                       rebuild = true;
+       }
+
+       if(oldcurve_radius.size() != mesh->curve_radius.size())
+               rebuild = true;
+       else if(oldcurve_radius.size()) {
+               if(memcmp(&oldcurve_radius[0], &mesh->curve_radius[0], sizeof(float)*oldcurve_radius.size()) != 0)
                        rebuild = true;
        }
        
@@ -931,8 +938,8 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
                        Attribute *attr_mP = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
 
                        if(attr_mP) {
-                               float4 *keys = &mesh->curve_keys[0];
-                               memcpy(attr_mP->data_float4() + time_index*numkeys, keys, sizeof(float4)*numkeys);
+                               float3 *keys = &mesh->curve_keys[0];
+                               memcpy(attr_mP->data_float3() + time_index*numkeys, keys, sizeof(float3)*numkeys);
                        }
                }
 
index a56c2e75e4e94b4bc7f7017f90bec92e8c3f682c..7a13641a312036be310a8fda13d64ecc720e81dc 100644 (file)
@@ -127,82 +127,57 @@ static float3 get_node_output_vector(BL::Node& b_node, const string& name)
        return make_float3(value[0], value[1], value[2]);
 }
 
-static ShaderSocketType convert_socket_type(BL::NodeSocket& b_socket)
+static SocketType::Type convert_socket_type(BL::NodeSocket& b_socket)
 {
        switch(b_socket.type()) {
                case BL::NodeSocket::type_VALUE:
-                       return SHADER_SOCKET_FLOAT;
+                       return SocketType::FLOAT;
                case BL::NodeSocket::type_INT:
-                       return SHADER_SOCKET_INT;
+                       return SocketType::INT;
                case BL::NodeSocket::type_VECTOR:
-                       return SHADER_SOCKET_VECTOR;
+                       return SocketType::VECTOR;
                case BL::NodeSocket::type_RGBA:
-                       return SHADER_SOCKET_COLOR;
+                       return SocketType::COLOR;
                case BL::NodeSocket::type_STRING:
-                       return SHADER_SOCKET_STRING;
+                       return SocketType::STRING;
                case BL::NodeSocket::type_SHADER:
-                       return SHADER_SOCKET_CLOSURE;
+                       return SocketType::CLOSURE;
                
                default:
-                       return SHADER_SOCKET_UNDEFINED;
+                       return SocketType::UNDEFINED;
        }
 }
 
-#ifdef WITH_OSL
-static ShaderSocketType convert_osl_socket_type(OSL::OSLQuery& query,
-                                                BL::NodeSocket& b_socket)
-{
-       ShaderSocketType socket_type = convert_socket_type(b_socket);
-       if(socket_type == SHADER_SOCKET_VECTOR) {
-               /* TODO(sergey): Do we need compatible_name() here? */
-               const OSL::OSLQuery::Parameter *param = query.getparam(b_socket.name());
-               assert(param != NULL);
-               if(param != NULL) {
-                       if(param->type.vecsemantics == TypeDesc::POINT) {
-                               socket_type = SHADER_SOCKET_POINT;
-                       }
-                       else if(param->type.vecsemantics == TypeDesc::NORMAL) {
-                               socket_type = SHADER_SOCKET_NORMAL;
-                       }
-               }
-       }
-
-       return socket_type;
-}
-#endif  /* WITH_OSL */
-
 static void set_default_value(ShaderInput *input,
                               BL::NodeSocket& b_sock,
                               BL::BlendData& b_data,
                               BL::ID& b_id)
 {
        /* copy values for non linked inputs */
-       switch(input->type) {
-               case SHADER_SOCKET_FLOAT: {
+       switch(input->type()) {
+               case SocketType::FLOAT: {
                        input->set(get_float(b_sock.ptr, "default_value"));
                        break;
                }
-               case SHADER_SOCKET_INT: {
-                       input->set((float)get_int(b_sock.ptr, "default_value"));
+               case SocketType::INT: {
+                       input->set(get_int(b_sock.ptr, "default_value"));
                        break;
                }
-               case SHADER_SOCKET_COLOR: {
+               case SocketType::COLOR: {
                        input->set(float4_to_float3(get_float4(b_sock.ptr, "default_value")));
                        break;
                }
-               case SHADER_SOCKET_NORMAL:
-               case SHADER_SOCKET_POINT:
-               case SHADER_SOCKET_VECTOR: {
+               case SocketType::NORMAL:
+               case SocketType::POINT:
+               case SocketType::VECTOR: {
                        input->set(get_float3(b_sock.ptr, "default_value"));
                        break;
                }
-               case SHADER_SOCKET_STRING: {
+               case SocketType::STRING: {
                        input->set((ustring)blender_absolute_path(b_data, b_id, get_string(b_sock.ptr, "default_value")));
                        break;
                }
-
-               case SHADER_SOCKET_CLOSURE:
-               case SHADER_SOCKET_UNDEFINED:
+               default:
                        break;
        }
 }
@@ -315,7 +290,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeMixRGB)) {
                BL::ShaderNodeMixRGB b_mix_node(b_node);
                MixNode *mix = new MixNode();
-               mix->type = MixNode::type_enum[b_mix_node.blend_type()];
+               mix->type = (NodeMix)b_mix_node.blend_type();
                mix->use_clamp = b_mix_node.use_clamp();
                node = mix;
        }
@@ -341,27 +316,27 @@ static ShaderNode *add_node(Scene *scene,
                node = new HSVNode();
        }
        else if(b_node.is_a(&RNA_ShaderNodeRGBToBW)) {
-               node = new ConvertNode(SHADER_SOCKET_COLOR, SHADER_SOCKET_FLOAT);
+               node = new RGBToBWNode();
        }
        else if(b_node.is_a(&RNA_ShaderNodeMath)) {
                BL::ShaderNodeMath b_math_node(b_node);
                MathNode *math = new MathNode();
-               math->type = MathNode::type_enum[b_math_node.operation()];
+               math->type = (NodeMath)b_math_node.operation();
                math->use_clamp = b_math_node.use_clamp();
                node = math;
        }
        else if(b_node.is_a(&RNA_ShaderNodeVectorMath)) {
                BL::ShaderNodeVectorMath b_vector_math_node(b_node);
                VectorMathNode *vmath = new VectorMathNode();
-               vmath->type = VectorMathNode::type_enum[b_vector_math_node.operation()];
+               vmath->type = (NodeVectorMath)b_vector_math_node.operation();
                node = vmath;
        }
        else if(b_node.is_a(&RNA_ShaderNodeVectorTransform)) {
                BL::ShaderNodeVectorTransform b_vector_transform_node(b_node);
                VectorTransformNode *vtransform = new VectorTransformNode();
-               vtransform->type = VectorTransformNode::type_enum[b_vector_transform_node.vector_type()];
-               vtransform->convert_from = VectorTransformNode::convert_space_enum[b_vector_transform_node.convert_from()];
-               vtransform->convert_to = VectorTransformNode::convert_space_enum[b_vector_transform_node.convert_to()];
+               vtransform->type = (NodeVectorTransformType)b_vector_transform_node.vector_type();
+               vtransform->convert_from = (NodeVectorTransformConvertSpace)b_vector_transform_node.convert_from();
+               vtransform->convert_to = (NodeVectorTransformConvertSpace)b_vector_transform_node.convert_to();
                node = vtransform;
        }
        else if(b_node.is_a(&RNA_ShaderNodeNormal)) {
@@ -410,13 +385,13 @@ static ShaderNode *add_node(Scene *scene,
 
                switch(b_aniso_node.distribution()) {
                        case BL::ShaderNodeBsdfAnisotropic::distribution_BECKMANN:
-                               aniso->distribution = ustring("Beckmann");
+                               aniso->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID;
                                break;
                        case BL::ShaderNodeBsdfAnisotropic::distribution_GGX:
-                               aniso->distribution = ustring("GGX");
+                               aniso->distribution = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID;
                                break;
                        case BL::ShaderNodeBsdfAnisotropic::distribution_ASHIKHMIN_SHIRLEY:
-                               aniso->distribution = ustring("Ashikhmin-Shirley");
+                               aniso->distribution = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID;
                                break;
                }
 
@@ -432,13 +407,13 @@ static ShaderNode *add_node(Scene *scene,
 
                switch(b_subsurface_node.falloff()) {
                        case BL::ShaderNodeSubsurfaceScattering::falloff_CUBIC:
-                               subsurface->closure = CLOSURE_BSSRDF_CUBIC_ID;
+                               subsurface->falloff = CLOSURE_BSSRDF_CUBIC_ID;
                                break;
                        case BL::ShaderNodeSubsurfaceScattering::falloff_GAUSSIAN:
-                               subsurface->closure = CLOSURE_BSSRDF_GAUSSIAN_ID;
+                               subsurface->falloff = CLOSURE_BSSRDF_GAUSSIAN_ID;
                                break;
                        case BL::ShaderNodeSubsurfaceScattering::falloff_BURLEY:
-                               subsurface->closure = CLOSURE_BSSRDF_BURLEY_ID;
+                               subsurface->falloff = CLOSURE_BSSRDF_BURLEY_ID;
                                break;
                }
 
@@ -450,16 +425,16 @@ static ShaderNode *add_node(Scene *scene,
                
                switch(b_glossy_node.distribution()) {
                        case BL::ShaderNodeBsdfGlossy::distribution_SHARP:
-                               glossy->distribution = ustring("Sharp");
+                               glossy->distribution = CLOSURE_BSDF_REFLECTION_ID;
                                break;
                        case BL::ShaderNodeBsdfGlossy::distribution_BECKMANN:
-                               glossy->distribution = ustring("Beckmann");
+                               glossy->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_ID;
                                break;
                        case BL::ShaderNodeBsdfGlossy::distribution_GGX:
-                               glossy->distribution = ustring("GGX");
+                               glossy->distribution = CLOSURE_BSDF_MICROFACET_GGX_ID;
                                break;
                        case BL::ShaderNodeBsdfGlossy::distribution_ASHIKHMIN_SHIRLEY:
-                               glossy->distribution = ustring("Ashikhmin-Shirley");
+                               glossy->distribution = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID;
                                break;
                }
                node = glossy;
@@ -469,13 +444,13 @@ static ShaderNode *add_node(Scene *scene,
                GlassBsdfNode *glass = new GlassBsdfNode();
                switch(b_glass_node.distribution()) {
                        case BL::ShaderNodeBsdfGlass::distribution_SHARP:
-                               glass->distribution = ustring("Sharp");
+                               glass->distribution = CLOSURE_BSDF_SHARP_GLASS_ID;
                                break;
                        case BL::ShaderNodeBsdfGlass::distribution_BECKMANN:
-                               glass->distribution = ustring("Beckmann");
+                               glass->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID;
                                break;
                        case BL::ShaderNodeBsdfGlass::distribution_GGX:
-                               glass->distribution = ustring("GGX");
+                               glass->distribution = CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID;
                                break;
                }
                node = glass;
@@ -485,13 +460,13 @@ static ShaderNode *add_node(Scene *scene,
                RefractionBsdfNode *refraction = new RefractionBsdfNode();
                switch(b_refraction_node.distribution()) {
                        case BL::ShaderNodeBsdfRefraction::distribution_SHARP:
-                               refraction->distribution = ustring("Sharp");
+                               refraction->distribution = CLOSURE_BSDF_REFRACTION_ID;
                                break;
                        case BL::ShaderNodeBsdfRefraction::distribution_BECKMANN:
-                               refraction->distribution = ustring("Beckmann");
+                               refraction->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
                                break;
                        case BL::ShaderNodeBsdfRefraction::distribution_GGX:
-                               refraction->distribution = ustring("GGX");
+                               refraction->distribution = CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
                                break;
                }
                node = refraction;
@@ -501,10 +476,10 @@ static ShaderNode *add_node(Scene *scene,
                ToonBsdfNode *toon = new ToonBsdfNode();
                switch(b_toon_node.component()) {
                        case BL::ShaderNodeBsdfToon::component_DIFFUSE:
-                               toon->component = ustring("Diffuse");
+                               toon->component = CLOSURE_BSDF_DIFFUSE_TOON_ID;
                                break;
                        case BL::ShaderNodeBsdfToon::component_GLOSSY:
-                               toon->component = ustring("Glossy");
+                               toon->component = CLOSURE_BSDF_GLOSSY_TOON_ID;
                                break;
                }
                node = toon;
@@ -514,10 +489,10 @@ static ShaderNode *add_node(Scene *scene,
                HairBsdfNode *hair = new HairBsdfNode();
                switch(b_hair_node.component()) {
                        case BL::ShaderNodeBsdfHair::component_Reflection:
-                               hair->component = ustring("Reflection");
+                               hair->component = CLOSURE_BSDF_HAIR_REFLECTION_ID;
                                break;
                        case BL::ShaderNodeBsdfHair::component_Transmission:
-                               hair->component = ustring("Transmission");
+                               hair->component = CLOSURE_BSDF_HAIR_TRANSMISSION_ID;
                                break;
                }
                node = hair;
@@ -584,62 +559,17 @@ static ShaderNode *add_node(Scene *scene,
                if(scene->shader_manager->use_osl()) {
                        /* create script node */
                        BL::ShaderNodeScript b_script_node(b_node);
-                       OSLScriptNode *script_node = new OSLScriptNode();
 
                        OSLShaderManager *manager = (OSLShaderManager*)scene->shader_manager;
                        string bytecode_hash = b_script_node.bytecode_hash();
 
-                       /* Gather additional information from the shader, such as
-                        * input/output type info needed for proper node construction.
-                        */
-                       OSL::OSLQuery query;
-                       string absolute_filepath;
-
-                       if(!bytecode_hash.empty()) {
-                               query.open_bytecode(b_script_node.bytecode());
-                       }
-                       else {
-                               absolute_filepath = blender_absolute_path(b_data, b_ntree, b_script_node.filepath());
-                               OSLShaderManager::osl_query(query, absolute_filepath);
-                       }
-                       /* TODO(sergey): Add proper query info error parsing. */
-
-                       /* Generate inputs/outputs from node sockets
-                        *
-                        * Note: the node sockets are generated from OSL parameters,
-                        * so the names match those of the corresponding parameters exactly.
-                        *
-                        * Note 2: ShaderInput/ShaderOutput store shallow string copies only!
-                        * So we register them as ustring to ensure the pointer stays valid. */
-                       BL::Node::inputs_iterator b_input;
-
-                       for(b_script_node.inputs.begin(b_input); b_input != b_script_node.inputs.end(); ++b_input) {
-                               ShaderInput *input = script_node->add_input(ustring(b_input->name()).c_str(),
-                                                                           convert_osl_socket_type(query, *b_input));
-                               set_default_value(input, *b_input, b_data, b_ntree);
-                       }
-
-                       BL::Node::outputs_iterator b_output;
-
-                       for(b_script_node.outputs.begin(b_output); b_output != b_script_node.outputs.end(); ++b_output) {
-                               script_node->add_output(ustring(b_output->name()).c_str(),
-                                                       convert_osl_socket_type(query, *b_output));
-                       }
-
-                       /* load bytecode or filepath */
                        if(!bytecode_hash.empty()) {
-                               /* loaded bytecode if not already done */
-                               if(!manager->shader_test_loaded(bytecode_hash))
-                                       manager->shader_load_bytecode(bytecode_hash, b_script_node.bytecode());
-
-                               script_node->bytecode_hash = bytecode_hash;
+                               node = manager->osl_node("", bytecode_hash, b_script_node.bytecode());
                        }
                        else {
-                               /* set filepath */
-                               script_node->filepath = absolute_filepath;
+                               string absolute_filepath = blender_absolute_path(b_data, b_ntree, b_script_node.filepath());
+                               node = manager->osl_node(absolute_filepath, "");
                        }
-
-                       node = script_node;
                }
 #else
                (void)b_data;
@@ -692,8 +622,8 @@ static ShaderNode *add_node(Scene *scene,
                                        get_image_extension(b_image_node));
                        }
                }
-               image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
-               image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
+               image->color_space = (NodeImageColorSpace)b_image_node.color_space();
+               image->projection = (NodeImageProjection)b_image_node.projection();
                image->interpolation = get_image_interpolation(b_image_node);
                image->extension = get_image_extension(b_image_node);
                image->projection_blend = b_image_node.projection_blend();
@@ -738,9 +668,9 @@ static ShaderNode *add_node(Scene *scene,
                                        EXTENSION_REPEAT);
                        }
                }
-               env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
+               env->color_space = (NodeImageColorSpace)b_env_node.color_space();
                env->interpolation = get_image_interpolation(b_env_node);
-               env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()];
+               env->projection = (NodeEnvironmentProjection)b_env_node.projection();
                BL::TexMapping b_texture_mapping(b_env_node.texture_mapping());
                get_tex_mapping(&env->tex_mapping, b_texture_mapping);
                node = env;
@@ -748,7 +678,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexGradient)) {
                BL::ShaderNodeTexGradient b_gradient_node(b_node);
                GradientTextureNode *gradient = new GradientTextureNode();
-               gradient->type = GradientTextureNode::type_enum[(int)b_gradient_node.gradient_type()];
+               gradient->type = (NodeGradientType)b_gradient_node.gradient_type();
                BL::TexMapping b_texture_mapping(b_gradient_node.texture_mapping());
                get_tex_mapping(&gradient->tex_mapping, b_texture_mapping);
                node = gradient;
@@ -756,7 +686,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexVoronoi)) {
                BL::ShaderNodeTexVoronoi b_voronoi_node(b_node);
                VoronoiTextureNode *voronoi = new VoronoiTextureNode();
-               voronoi->coloring = VoronoiTextureNode::coloring_enum[(int)b_voronoi_node.coloring()];
+               voronoi->coloring = (NodeVoronoiColoring)b_voronoi_node.coloring();
                BL::TexMapping b_texture_mapping(b_voronoi_node.texture_mapping());
                get_tex_mapping(&voronoi->tex_mapping, b_texture_mapping);
                node = voronoi;
@@ -772,8 +702,8 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexWave)) {
                BL::ShaderNodeTexWave b_wave_node(b_node);
                WaveTextureNode *wave = new WaveTextureNode();
-               wave->type = WaveTextureNode::type_enum[(int)b_wave_node.wave_type()];
-               wave->profile = WaveTextureNode::profile_enum[(int)b_wave_node.wave_profile()];
+               wave->type = (NodeWaveType)b_wave_node.wave_type();
+               wave->profile = (NodeWaveProfile)b_wave_node.wave_profile();
                BL::TexMapping b_texture_mapping(b_wave_node.texture_mapping());
                get_tex_mapping(&wave->tex_mapping, b_texture_mapping);
                node = wave;
@@ -806,7 +736,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexMusgrave)) {
                BL::ShaderNodeTexMusgrave b_musgrave_node(b_node);
                MusgraveTextureNode *musgrave = new MusgraveTextureNode();
-               musgrave->type = MusgraveTextureNode::type_enum[(int)b_musgrave_node.musgrave_type()];
+               musgrave->type = (NodeMusgraveType)b_musgrave_node.musgrave_type();
                BL::TexMapping b_texture_mapping(b_musgrave_node.texture_mapping());
                get_tex_mapping(&musgrave->tex_mapping, b_texture_mapping);
                node = musgrave;
@@ -824,7 +754,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexSky)) {
                BL::ShaderNodeTexSky b_sky_node(b_node);
                SkyTextureNode *sky = new SkyTextureNode();
-               sky->type = SkyTextureNode::type_enum[(int)b_sky_node.sky_type()];
+               sky->type = (NodeSkyType)b_sky_node.sky_type();
                sky->sun_direction = normalize(get_float3(b_sky_node.sun_direction()));
                sky->turbidity = b_sky_node.turbidity();
                sky->ground_albedo = b_sky_node.ground_albedo();
@@ -835,15 +765,15 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeNormalMap)) {
                BL::ShaderNodeNormalMap b_normal_map_node(b_node);
                NormalMapNode *nmap = new NormalMapNode();
-               nmap->space = NormalMapNode::space_enum[(int)b_normal_map_node.space()];
+               nmap->space = (NodeNormalMapSpace)b_normal_map_node.space();
                nmap->attribute = b_normal_map_node.uv_map();
                node = nmap;
        }
        else if(b_node.is_a(&RNA_ShaderNodeTangent)) {
                BL::ShaderNodeTangent b_tangent_node(b_node);
                TangentNode *tangent = new TangentNode();
-               tangent->direction_type = TangentNode::direction_type_enum[(int)b_tangent_node.direction_type()];
-               tangent->axis = TangentNode::axis_enum[(int)b_tangent_node.axis()];
+               tangent->direction_type = (NodeTangentDirectionType)b_tangent_node.direction_type();
+               tangent->axis = (NodeTangentAxis)b_tangent_node.axis();
                tangent->attribute = b_tangent_node.uv_map();
                node = tangent;
        }
@@ -858,8 +788,7 @@ static ShaderNode *add_node(Scene *scene,
                BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
                PointDensityTextureNode *point_density = new PointDensityTextureNode();
                point_density->filename = b_point_density_node.name();
-               point_density->space =
-                       PointDensityTextureNode::space_enum[(int)b_point_density_node.space()];
+               point_density->space = (NodeTexVoxelSpace)b_point_density_node.space();
                point_density->interpolation = get_image_interpolation(b_point_density_node);
                point_density->builtin_data = b_point_density_node.ptr.data;
 
@@ -1020,7 +949,7 @@ static void add_nodes(Scene *scene,
                        BL::Node::internal_links_iterator b_link;
                        for(b_node->internal_links.begin(b_link); b_link != b_node->internal_links.end(); ++b_link) {
                                BL::NodeSocket to_socket(b_link->to_socket());
-                               ShaderSocketType to_socket_type = convert_socket_type(to_socket);
+                               SocketType::Type to_socket_type = convert_socket_type(to_socket);
                                ConvertNode *proxy = new ConvertNode(to_socket_type, to_socket_type, true);
 
                                input_map[b_link->from_socket().ptr.data] = proxy->inputs[0];
@@ -1043,7 +972,7 @@ static void add_nodes(Scene *scene,
                         * so that links have something to connect to and assert won't fail.
                         */
                        for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
-                               ShaderSocketType input_type = convert_socket_type(*b_input);
+                               SocketType::Type input_type = convert_socket_type(*b_input);
                                ConvertNode *proxy = new ConvertNode(input_type, input_type, true);
                                graph->add(proxy);
 
@@ -1055,7 +984,7 @@ static void add_nodes(Scene *scene,
                                set_default_value(proxy->inputs[0], *b_input, b_data, b_ntree);
                        }
                        for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
-                               ShaderSocketType output_type = convert_socket_type(*b_output);
+                               SocketType::Type output_type = convert_socket_type(*b_output);
                                ConvertNode *proxy = new ConvertNode(output_type, output_type, true);
                                graph->add(proxy);
 
@@ -1227,7 +1156,7 @@ void BlenderSync::sync_materials(bool update_all)
                                ShaderNode *closure, *out;
 
                                closure = graph->add(new DiffuseBsdfNode());
-                               closure->input("Color")->value = get_float3(b_mat->diffuse_color());
+                               closure->input("Color")->set(get_float3(b_mat->diffuse_color()));
                                out = graph->output();
 
                                graph->connect(closure->output("BSDF"), out->input("Surface"));
@@ -1276,7 +1205,7 @@ void BlenderSync::sync_world(bool update_all)
                        ShaderNode *closure, *out;
 
                        closure = graph->add(new BackgroundNode());
-                       closure->input("Color")->value = get_float3(b_world.horizon_color());
+                       closure->input("Color")->set(get_float3(b_world.horizon_color()));
                        out = graph->output();
 
                        graph->connect(closure->output("Background"), out->input("Surface"));
@@ -1369,8 +1298,8 @@ void BlenderSync::sync_lamps(bool update_all)
                                }
 
                                closure = graph->add(new EmissionNode());
-                               closure->input("Color")->value = get_float3(b_lamp->color());
-                               closure->input("Strength")->value.x = strength;
+                               closure->input("Color")->set(get_float3(b_lamp->color()));
+                               closure->input("Strength")->set(strength);
                                out = graph->output();
 
                                graph->connect(closure->output("Emission"), out->input("Surface"));
index 3e8856c8de6f4201189a903e1514bdca2c55b618..89a53a1deca75f6b54962f843456710fc59401d7 100644 (file)
@@ -98,11 +98,12 @@ static inline void curvemapping_minmax(/*const*/ BL::CurveMapping& cumap,
 }
 
 static inline void curvemapping_to_array(BL::CurveMapping& cumap,
-                                         float *data,
+                                         array<float>& data,
                                          int size)
 {
        cumap.update();
        BL::CurveMap curve = cumap.curves[0];
+       data.resize(size);
        for(int i = 0; i < size; i++) {
                float t = (float)i/(float)(size-1);
                data[i] = curve.evaluate(t);
index 5c474c8c3e9c19b4648b96e45926e09c198b5296..fa2b9ae7279c9f746b613894345fc675ba48bc72 100644 (file)
@@ -128,11 +128,11 @@ void BVH::pack_triangle(int idx, float4 storage[3])
        const Mesh *mesh = objects[tob]->mesh;
 
        int tidx = pack.prim_index[idx];
-       const int *vidx = mesh->triangles[tidx].v;
+       Mesh::Triangle t = mesh->get_triangle(tidx);
        const float3* vpos = &mesh->verts[0];
-       float3 v0 = vpos[vidx[0]];
-       float3 v1 = vpos[vidx[1]];
-       float3 v2 = vpos[vidx[2]];
+       float3 v0 = vpos[t.v[0]];
+       float3 v1 = vpos[t.v[1]];
+       float3 v2 = vpos[t.v[2]];
 
        storage[0] = float3_to_float4(v0);
        storage[1] = float3_to_float4(v1);
@@ -506,10 +506,10 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
                                if(pack.prim_type[prim] & PRIMITIVE_ALL_CURVE) {
                                        /* curves */
                                        int str_offset = (params.top_level)? mesh->curve_offset: 0;
-                                       const Mesh::Curve& curve = mesh->curves[pidx - str_offset];
+                                       Mesh::Curve curve = mesh->get_curve(pidx - str_offset);
                                        int k = PRIMITIVE_UNPACK_SEGMENT(pack.prim_type[prim]);
 
-                                       curve.bounds_grow(k, &mesh->curve_keys[0], bbox);
+                                       curve.bounds_grow(k, &mesh->curve_keys[0], &mesh->curve_radius[0], bbox);
 
                                        visibility |= PATH_RAY_CURVE;
 
@@ -520,17 +520,17 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
                                                if(attr) {
                                                        size_t mesh_size = mesh->curve_keys.size();
                                                        size_t steps = mesh->motion_steps - 1;
-                                                       float4 *key_steps = attr->data_float4();
+                                                       float3 *key_steps = attr->data_float3();
 
                                                        for(size_t i = 0; i < steps; i++)
-                                                               curve.bounds_grow(k, key_steps + i*mesh_size, bbox);
+                                                               curve.bounds_grow(k, key_steps + i*mesh_size, &mesh->curve_radius[0], bbox);
                                                }
                                        }
                                }
                                else {
                                        /* triangles */
                                        int tri_offset = (params.top_level)? mesh->tri_offset: 0;
-                                       const Mesh::Triangle& triangle = mesh->triangles[pidx - tri_offset];
+                                       Mesh::Triangle triangle = mesh->get_triangle(pidx - tri_offset);
                                        const float3 *vpos = &mesh->verts[0];
 
                                        triangle.bounds_grow(vpos, bbox);
@@ -770,10 +770,10 @@ void QBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
                                if(pack.prim_type[prim] & PRIMITIVE_ALL_CURVE) {
                                        /* Curves. */
                                        int str_offset = (params.top_level)? mesh->curve_offset: 0;
-                                       const Mesh::Curve& curve = mesh->curves[pidx - str_offset];
+                                       Mesh::Curve curve = mesh->get_curve(pidx - str_offset);
                                        int k = PRIMITIVE_UNPACK_SEGMENT(pack.prim_type[prim]);
 
-                                       curve.bounds_grow(k, &mesh->curve_keys[0], bbox);
+                                       curve.bounds_grow(k, &mesh->curve_keys[0], &mesh->curve_radius[0], bbox);
 
                                        visibility |= PATH_RAY_CURVE;
 
@@ -784,17 +784,17 @@ void QBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
                                                if(attr) {
                                                        size_t mesh_size = mesh->curve_keys.size();
                                                        size_t steps = mesh->motion_steps - 1;
-                                                       float4 *key_steps = attr->data_float4();
+                                                       float3 *key_steps = attr->data_float3();
 
                                                        for(size_t i = 0; i < steps; i++)
-                                                               curve.bounds_grow(k, key_steps + i*mesh_size, bbox);
+                                                               curve.bounds_grow(k, key_steps + i*mesh_size, &mesh->curve_radius[0], bbox);
                                                }
                                        }
                                }
                                else {
                                        /* Triangles. */
                                        int tri_offset = (params.top_level)? mesh->tri_offset: 0;
-                                       const Mesh::Triangle& triangle = mesh->triangles[pidx - tri_offset];
+                                       Mesh::Triangle triangle = mesh->get_triangle(pidx - tri_offset);
                                        const float3 *vpos = &mesh->verts[0];
 
                                        triangle.bounds_grow(vpos, bbox);
index 76a1bfa2bfe13e22047c84e231c1de2916ebaf11..87a889955fe0ac9000b5a39eaf52a1b16a5deef7 100644 (file)
@@ -117,8 +117,9 @@ void BVHBuild::add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh,
        if(mesh->has_motion_blur())
                attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
 
-       for(uint j = 0; j < mesh->triangles.size(); j++) {
-               Mesh::Triangle t = mesh->triangles[j];
+       size_t num_triangles = mesh->num_triangles();
+       for(uint j = 0; j < num_triangles; j++) {
+               Mesh::Triangle t = mesh->get_triangle(j);
                BoundBox bounds = BoundBox::empty;
                PrimitiveType type = PRIMITIVE_TRIANGLE;
 
@@ -148,22 +149,23 @@ void BVHBuild::add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh,
        if(mesh->has_motion_blur())
                curve_attr_mP = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
 
-       for(uint j = 0; j < mesh->curves.size(); j++) {
-               Mesh::Curve curve = mesh->curves[j];
+       size_t num_curves = mesh->num_curves();
+       for(uint j = 0; j < num_curves; j++) {
+               Mesh::Curve curve = mesh->get_curve(j);
                PrimitiveType type = PRIMITIVE_CURVE;
 
                for(int k = 0; k < curve.num_keys - 1; k++) {
                        BoundBox bounds = BoundBox::empty;
-                       curve.bounds_grow(k, &mesh->curve_keys[0], bounds);
+                       curve.bounds_grow(k, &mesh->curve_keys[0], &mesh->curve_radius[0], bounds);
 
                        /* motion curve */
                        if(curve_attr_mP) {
                                size_t mesh_size = mesh->curve_keys.size();
                                size_t steps = mesh->motion_steps - 1;
-                               float4 *key_steps = curve_attr_mP->data_float4();
+                               float3 *key_steps = curve_attr_mP->data_float3();
 
                                for(size_t i = 0; i < steps; i++)
-                                       curve.bounds_grow(k, key_steps + i*mesh_size, bounds);
+                                       curve.bounds_grow(k, key_steps + i*mesh_size, &mesh->curve_radius[0], bounds);
 
                                type = PRIMITIVE_MOTION_CURVE;
                        }
@@ -188,10 +190,10 @@ void BVHBuild::add_reference_object(BoundBox& root, BoundBox& center, Object *ob
 
 static size_t count_curve_segments(Mesh *mesh)
 {
-       size_t num = 0, num_curves = mesh->curves.size();
+       size_t num = 0, num_curves = mesh->num_curves();
 
        for(size_t i = 0; i < num_curves; i++)
-               num += mesh->curves[i].num_keys - 1;
+               num += mesh->get_curve(i).num_keys - 1;
        
        return num;
 }
@@ -204,14 +206,14 @@ void BVHBuild::add_references(BVHRange& root)
        foreach(Object *ob, objects) {
                if(params.top_level) {
                        if(!ob->mesh->is_instanced()) {
-                               num_alloc_references += ob->mesh->triangles.size();
+                               num_alloc_references += ob->mesh->num_triangles();
                                num_alloc_references += count_curve_segments(ob->mesh);
                        }
                        else
                                num_alloc_references++;
                }
                else {
-                       num_alloc_references += ob->mesh->triangles.size();
+                       num_alloc_references += ob->mesh->num_triangles();
                        num_alloc_references += count_curve_segments(ob->mesh);
                }
        }
@@ -326,11 +328,11 @@ BVHNode* BVHBuild::run()
                        VLOG(1) << "BVH build statistics:\n"
                                << "  Build time: " << time_dt() - build_start_time << "\n"
                                << "  Total number of nodes: "
-                               << rootnode->getSubtreeSize(BVH_STAT_NODE_COUNT) << "\n"
+                               << string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_NODE_COUNT)) << "\n"
                                << "  Number of inner nodes: "
-                               << rootnode->getSubtreeSize(BVH_STAT_INNER_COUNT)  << "\n"
+                               << string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_INNER_COUNT)) << "\n"
                                << "  Number of leaf nodes: "
-                               << rootnode->getSubtreeSize(BVH_STAT_LEAF_COUNT)  << "\n"
+                               << string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_LEAF_COUNT)) << "\n"
                                << "  Allocation slop factor: "
                                       << ((prim_type.capacity() != 0)
                                               ? (float)prim_type.size() / prim_type.capacity()
index 8084975565e4f4c7ea1ca2d51aad628bbfc19203..3665fb42bc2f836fc128f9ec9ef97ed842e74771 100644 (file)
@@ -292,13 +292,13 @@ void BVHSpatialSplit::split_triangle_primitive(const Mesh *mesh,
                                                BoundBox& left_bounds,
                                                BoundBox& right_bounds)
 {
-       const int *inds = mesh->triangles[prim_index].v;
+       Mesh::Triangle t = mesh->get_triangle(prim_index);
        const float3 *verts = &mesh->verts[0];
-       float3 v1 = tfm ? transform_point(tfm, verts[inds[2]]) : verts[inds[2]];
+       float3 v1 = tfm ? transform_point(tfm, verts[t.v[2]]) : verts[t.v[2]];
 
        for(int i = 0; i < 3; i++) {
                float3 v0 = v1;
-               int vindex = inds[i];
+               int vindex = t.v[i];
                v1 = tfm ? transform_point(tfm, verts[vindex]) : verts[vindex];
                float v0p = v0[dim];
                float v1p = v1[dim];
@@ -329,12 +329,11 @@ void BVHSpatialSplit::split_curve_primitive(const Mesh *mesh,
                                             BoundBox& right_bounds)
 {
        /* curve split: NOTE - Currently ignores curve width and needs to be fixed.*/
-       const int k0 = mesh->curves[prim_index].first_key + segment_index;
+       Mesh::Curve curve = mesh->get_curve(prim_index);
+       const int k0 = curve.first_key + segment_index;
        const int k1 = k0 + 1;
-       const float4& key0 = mesh->curve_keys[k0];
-       const float4& key1 = mesh->curve_keys[k1];
-       float3 v0 = float4_to_float3(key0);
-       float3 v1 = float4_to_float3(key1);
+       float3 v0 = mesh->curve_keys[k0];
+       float3 v1 = mesh->curve_keys[k1];
 
        if(tfm != NULL) {
                v0 = transform_point(tfm, v0);
@@ -414,8 +413,8 @@ void BVHSpatialSplit::split_object_reference(const Object *object,
                                         left_bounds,
                                         right_bounds);
        }
-       for(int curve_idx = 0; curve_idx < mesh->curves.size(); ++curve_idx) {
-               Mesh::Curve &curve = mesh->curves[curve_idx];
+       for(int curve_idx = 0; curve_idx < mesh->num_curves(); ++curve_idx) {
+               Mesh::Curve curve = mesh->get_curve(curve_idx);
                for(int segment_idx = 0;
                    segment_idx < curve.num_keys - 1;
                    ++segment_idx)
index 275ee028eb4bd087240cd893b643b73e816486b7..aed86d8d85377c2825484188099689aa0b4c88cf 100644 (file)
@@ -155,7 +155,9 @@ public:
                       InterpolationType interpolation,
                       ExtensionType extension)
        {
-               VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
+               VLOG(1) << "Texture allocate: " << name << ", "
+                       << string_human_readable_number(mem.memory_size()) << " bytes. ("
+                       << string_human_readable_size(mem.memory_size()) << ")";
                kernel_tex_copy(&kernel_globals,
                                name,
                                mem.data_pointer,
index 9a78d05558079073da4e59e1cbe42341e569e359..d7ed7b4f853475edd2f0ae6844242c2316650909 100644 (file)
@@ -493,7 +493,9 @@ public:
                       InterpolationType interpolation,
                       ExtensionType extension)
        {
-               VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
+               VLOG(1) << "Texture allocate: " << name << ", "
+                       << string_human_readable_number(mem.memory_size()) << " bytes. ("
+                       << string_human_readable_size(mem.memory_size()) << ")";
 
                /* Check if we are on sm_30 or above.
                 * We use arrays and bindles textures for storage there */
index 434d0085d39333377d0c1ec94769794c783a1e90..c4f8d9e16e0f526fd3a69aef3688ffba0e867043 100644 (file)
@@ -175,7 +175,9 @@ public:
                       interpolation,
                       ExtensionType extension)
        {
-               VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
+               VLOG(1) << "Texture allocate: " << name << ", "
+                       << string_human_readable_number(mem.memory_size()) << " bytes. ("
+                       << string_human_readable_size(mem.memory_size()) << ")";
 
                foreach(SubDevice& sub, devices) {
                        mem.device_pointer = 0;
index cf4a05de8fc35f321b33fda81549432a202f3fe4..3eb5ad2d2dbb63f8aa7ea9439b4c14681d601f41 100644 (file)
@@ -168,7 +168,9 @@ public:
                       InterpolationType interpolation,
                       ExtensionType extension)
        {
-               VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
+               VLOG(1) << "Texture allocate: " << name << ", "
+                       << string_human_readable_number(mem.memory_size()) << " bytes. ("
+                       << string_human_readable_size(mem.memory_size()) << ")";
 
                thread_scoped_lock lock(rpc_lock);
 
index 1b4e5421b5ae7d0f9fc808c9628a2ff8f4fec5d8..afe21c497309641bcb14261ff926c38d763508c3 100644 (file)
@@ -1187,7 +1187,9 @@ public:
                       InterpolationType /*interpolation*/,
                       ExtensionType /*extension*/)
        {
-               VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
+               VLOG(1) << "Texture allocate: " << name << ", "
+                       << string_human_readable_number(mem.memory_size()) << " bytes. ("
+                       << string_human_readable_size(mem.memory_size()) << ")";
                mem_alloc(mem, MEM_READ_ONLY);
                mem_copy_to(mem);
                assert(mem_map.find(name) == mem_map.end());
@@ -1222,18 +1224,28 @@ public:
                        CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &workgroup_size, NULL);
                clGetDeviceInfo(cdDevice,
                        CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(size_t)*3, max_work_items, NULL);
-       
-               /* try to divide evenly over 2 dimensions */
+
+               /* Try to divide evenly over 2 dimensions. */
                size_t sqrt_workgroup_size = max((size_t)sqrt((double)workgroup_size), 1);
                size_t local_size[2] = {sqrt_workgroup_size, sqrt_workgroup_size};
 
-               /* some implementations have max size 1 on 2nd dimension */
+               /* Some implementations have max size 1 on 2nd dimension. */
                if(local_size[1] > max_work_items[1]) {
                        local_size[0] = workgroup_size/max_work_items[1];
                        local_size[1] = max_work_items[1];
                }
 
-               size_t global_size[2] = {global_size_round_up(local_size[0], w), global_size_round_up(local_size[1], h)};
+               size_t global_size[2] = {global_size_round_up(local_size[0], w),
+                                        global_size_round_up(local_size[1], h)};
+
+               /* Vertical size of 1 is coming from bake/shade kernels where we should
+                * not round anything up because otherwise we'll either be doing too
+                * much work per pixel (if we don't check global ID on Y axis) or will
+                * be checking for global ID to always have Y of 0.
+                */
+               if (h == 1) {
+                       global_size[h] = 1;
+               }
 
                /* run kernel */
                opencl_assert(clEnqueueNDRangeKernel(cqCommandQueue, kernel, 2, NULL, global_size, NULL, 0, NULL, NULL));
@@ -1318,48 +1330,49 @@ public:
                else
                        kernel = ckShaderKernel;
 
-               for(int sample = 0; sample < task.num_samples; sample++) {
-
-                       if(task.get_cancel())
-                               break;
-
-                       cl_int d_sample = sample;
-
-                       cl_uint start_arg_index =
-                               kernel_set_args(kernel,
-                                               0,
-                                               d_data,
-                                               d_input,
-                                               d_output);
+               cl_uint start_arg_index =
+                       kernel_set_args(kernel,
+                                       0,
+                                       d_data,
+                                       d_input,
+                                       d_output);
 
-                       if(task.shader_eval_type < SHADER_EVAL_BAKE) {
-                               start_arg_index += kernel_set_args(kernel,
-                                                                  start_arg_index,
-                                                                  d_output_luma);
-                       }
+               if(task.shader_eval_type < SHADER_EVAL_BAKE) {
+                       start_arg_index += kernel_set_args(kernel,
+                                                          start_arg_index,
+                                                          d_output_luma);
+               }
 
 #define KERNEL_TEX(type, ttype, name) \
-                       set_kernel_arg_mem(kernel, &start_arg_index, #name);
+               set_kernel_arg_mem(kernel, &start_arg_index, #name);
 #include "kernel_textures.h"
 #undef KERNEL_TEX
 
+               start_arg_index += kernel_set_args(kernel,
+                                                  start_arg_index,
+                                                  d_shader_eval_type);
+               if(task.shader_eval_type >= SHADER_EVAL_BAKE) {
                        start_arg_index += kernel_set_args(kernel,
                                                           start_arg_index,
-                                                          d_shader_eval_type);
-                       if(task.shader_eval_type >= SHADER_EVAL_BAKE) {
-                               start_arg_index += kernel_set_args(kernel,
-                                                                  start_arg_index,
-                                                                  d_shader_filter);
-                       }
-                       start_arg_index += kernel_set_args(kernel,
-                                                          start_arg_index,
-                                                          d_shader_x,
-                                                          d_shader_w,
-                                                          d_offset,
-                                                          d_sample);
+                                                          d_shader_filter);
+               }
+               start_arg_index += kernel_set_args(kernel,
+                                                  start_arg_index,
+                                                  d_shader_x,
+                                                  d_shader_w,
+                                                  d_offset);
+
+               for(int sample = 0; sample < task.num_samples; sample++) {
+
+                       if(task.get_cancel())
+                               break;
+
+                       kernel_set_args(kernel, start_arg_index, sample);
 
                        enqueue_kernel(kernel, task.shader_w, 1);
 
+                       clFinish(cqCommandQueue);
+
                        task.update_progress(NULL);
                }
        }
index d482577b73b44c3b13d573c62e6379386edbb97d..941a66741c590197398b94df0b7d00197cc15655 100644 (file)
@@ -36,12 +36,8 @@ Node::Node(const NodeType *type_, ustring name_)
        }
 
        /* initialize default values */
-       typedef unordered_map<ustring, SocketType, ustringHash> map_type;
-       foreach(const map_type::value_type& it, type->inputs) {
-               const SocketType& socket = it.second;
-               const void *src = socket.default_value;
-               void *dst = ((char*)this) + socket.struct_offset;
-               memcpy(dst, src, socket.size());
+       foreach(const SocketType& socket, type->inputs) {
+               set_default_value(socket);
        }
 }
 
@@ -104,6 +100,11 @@ void Node::set(const SocketType& input, float3 value)
        get_socket_value<float3>(this, input) = value;
 }
 
+void Node::set(const SocketType& input, const char *value)
+{
+       set(input, ustring(value));
+}
+
 void Node::set(const SocketType& input, ustring value)
 {
        if(input.type == SocketType::STRING) {
@@ -292,7 +293,8 @@ const array<Node*>& Node::get_node_array(const SocketType& input) const
        return get_socket_value<array<Node*> >(this, input);
 }
 
-/* default values */
+/* generic value operations */
+
 bool Node::has_default_value(const SocketType& input) const
 {
        const void *src = input.default_value;
@@ -300,6 +302,48 @@ bool Node::has_default_value(const SocketType& input) const
        return memcmp(dst, src, input.size()) == 0;
 }
 
+void Node::set_default_value(const SocketType& socket)
+{
+       const void *src = socket.default_value;
+       void *dst = ((char*)this) + socket.struct_offset;
+       memcpy(dst, src, socket.size());
+}
+
+template<typename T>
+static void copy_array(const Node *node, const SocketType& socket, const Node *other, const SocketType& other_socket)
+{
+       const array<T>* src = (const array<T>*)(((char*)other) + other_socket.struct_offset);
+       array<T>* dst = (array<T>*)(((char*)node) + socket.struct_offset);
+       *dst = *src;
+}
+
+void Node::copy_value(const SocketType& socket, const Node& other, const SocketType& other_socket)
+{
+       assert(socket.type == other_socket.type);
+
+       if(socket.is_array()) {
+               switch(socket.type) {
+                       case SocketType::BOOLEAN_ARRAY: copy_array<bool>(this, socket, &other, other_socket); break;
+                       case SocketType::FLOAT_ARRAY: copy_array<float>(this, socket, &other, other_socket); break;
+                       case SocketType::INT_ARRAY: copy_array<int>(this, socket, &other, other_socket); break;
+                       case SocketType::COLOR_ARRAY: copy_array<float3>(this, socket, &other, other_socket); break;
+                       case SocketType::VECTOR_ARRAY: copy_array<float3>(this, socket, &other, other_socket); break;
+                       case SocketType::POINT_ARRAY: copy_array<float3>(this, socket, &other, other_socket); break;
+                       case SocketType::NORMAL_ARRAY: copy_array<float3>(this, socket, &other, other_socket); break;
+                       case SocketType::POINT2_ARRAY: copy_array<float2>(this, socket, &other, other_socket); break;
+                       case SocketType::STRING_ARRAY: copy_array<ustring>(this, socket, &other, other_socket); break;
+                       case SocketType::TRANSFORM_ARRAY: copy_array<Transform>(this, socket, &other, other_socket); break;
+                       case SocketType::NODE_ARRAY: copy_array<void*>(this, socket, &other, other_socket); break;
+                       default: assert(0); break;
+               }
+       }
+       else {
+               const void *src = ((char*)&other) + other_socket.struct_offset;
+               void *dst = ((char*)this) + socket.struct_offset;
+               memcpy(dst, src, socket.size());
+       }
+}
+
 template<typename T>
 static bool is_array_equal(const Node *node, const Node *other, const SocketType& socket)
 {
@@ -308,48 +352,43 @@ static bool is_array_equal(const Node *node, const Node *other, const SocketType
        return *a == *b;
 }
 
-/* modified */
-bool Node::modified(const Node& other)
+bool Node::equals_value(const Node& other, const SocketType& socket) const
+{
+       if(socket.is_array()) {
+               switch(socket.type) {
+                       case SocketType::BOOLEAN_ARRAY: return is_array_equal<bool>(this, &other, socket);
+                       case SocketType::FLOAT_ARRAY: return is_array_equal<float>(this, &other, socket);
+                       case SocketType::INT_ARRAY: return is_array_equal<int>(this, &other, socket);
+                       case SocketType::COLOR_ARRAY: return is_array_equal<float3>(this, &other, socket);
+                       case SocketType::VECTOR_ARRAY: return is_array_equal<float3>(this, &other, socket);
+                       case SocketType::POINT_ARRAY: return is_array_equal<float3>(this, &other, socket);
+                       case SocketType::NORMAL_ARRAY: return is_array_equal<float3>(this, &other, socket);
+                       case SocketType::POINT2_ARRAY: return is_array_equal<float2>(this, &other, socket);
+                       case SocketType::STRING_ARRAY: return is_array_equal<ustring>(this, &other, socket);
+                       case SocketType::TRANSFORM_ARRAY: return is_array_equal<Transform>(this, &other, socket);
+                       case SocketType::NODE_ARRAY: return is_array_equal<void*>(this, &other, socket);
+                       default: assert(0); return true;
+               }
+       }
+       else {
+               const void *a = ((char*)this) + socket.struct_offset;
+               const void *b = ((char*)&other) + socket.struct_offset;
+               return (memcmp(a, b, socket.size()) == 0);
+       }
+}
+
+/* equals */
+
+bool Node::equals(const Node& other) const
 {
        assert(type == other.type);
 
-       typedef unordered_map<ustring, SocketType, ustringHash> map_type;
-       foreach(const map_type::value_type& it, type->inputs) {
-               const SocketType& socket = it.second;
-
-               if(socket.is_array()) {
-                       bool equal = true;
-
-                       switch(socket.type)
-                       {
-                               case SocketType::BOOLEAN_ARRAY: equal = is_array_equal<bool>(this, &other, socket); break;
-                               case SocketType::FLOAT_ARRAY: equal = is_array_equal<float>(this, &other, socket); break;
-                               case SocketType::INT_ARRAY: equal = is_array_equal<int>(this, &other, socket); break;
-                               case SocketType::COLOR_ARRAY: equal = is_array_equal<float3>(this, &other, socket); break;
-                               case SocketType::VECTOR_ARRAY: equal = is_array_equal<float3>(this, &other, socket); break;
-                               case SocketType::POINT_ARRAY: equal = is_array_equal<float3>(this, &other, socket); break;
-                               case SocketType::NORMAL_ARRAY: equal = is_array_equal<float3>(this, &other, socket); break;
-                               case SocketType::POINT2_ARRAY: equal = is_array_equal<float2>(this, &other, socket); break;
-                               case SocketType::STRING_ARRAY: equal = is_array_equal<ustring>(this, &other, socket); break;
-                               case SocketType::TRANSFORM_ARRAY: equal = is_array_equal<Transform>(this, &other, socket); break;
-                               case SocketType::NODE_ARRAY: equal = is_array_equal<void*>(this, &other, socket); break;
-                               default: assert(0); break;
-                       }
-
-                       if(!equal) {
-                               return true;
-                       }
-               }
-               else {
-                       const void *a = ((char*)this) + socket.struct_offset;
-                       const void *b = ((char*)&other) + socket.struct_offset;
-                       if(memcmp(a, b, socket.size()) != 0) {
-                               return true;
-                       }
-               }
+       foreach(const SocketType& socket, type->inputs) {
+               if(!equals_value(other, socket))
+                       return false;
        }
 
-       return false;
+       return true;
 }
 
 CCL_NAMESPACE_END
index 33971fa714a38113c6564f072c7aae145220599a..bb84f982fb36523f92c9f379fff2ce592a8dbf05 100644 (file)
@@ -41,6 +41,7 @@ struct Node
        void set(const SocketType& input, float value);
        void set(const SocketType& input, float2 value);
        void set(const SocketType& input, float3 value);
+       void set(const SocketType& input, const char *value);
        void set(const SocketType& input, ustring value);
        void set(const SocketType& input, const Transform& value);
        void set(const SocketType& input, Node *value);
@@ -76,11 +77,14 @@ struct Node
        const array<Transform>& get_transform_array(const SocketType& input) const;
        const array<Node*>& get_node_array(const SocketType& input) const;
 
-       /* default values */
+       /* generic values operations */
        bool has_default_value(const SocketType& input) const;
+       void set_default_value(const SocketType& input);
+       bool equals_value(const Node& other, const SocketType& input) const;
+       void copy_value(const SocketType& input, const Node& other, const SocketType& other_input);
 
-       /* modified */
-       bool modified(const Node& other);
+       /* equals */
+       bool equals(const Node& other) const;
 
        ustring name;
        const NodeType *type;
index dc879655d7f8692e62a3672d952e1ab0644d7c40..7f68ae9c7c72a56e5e533af37f7d8ab0162aff64 100644 (file)
@@ -114,9 +114,15 @@ ustring SocketType::type_name(Type type)
        return names[(int)type];
 }
 
+bool SocketType::is_float3(Type type)
+{
+       return (type == COLOR || type == VECTOR || type == POINT || type == NORMAL);
+}
+
 /* Node Type */
 
-NodeType::NodeType()
+NodeType::NodeType(Type type_)
+: type(type_)
 {
 }
 
@@ -137,7 +143,7 @@ void NodeType::register_input(ustring name, ustring ui_name, SocketType::Type ty
        socket.enum_values = enum_values;
        socket.node_type = node_type;
        socket.flags = flags | extra_flags;
-       inputs[name] = socket;
+       inputs.push_back(socket);
 }
 
 void NodeType::register_output(ustring name, ustring ui_name, SocketType::Type type)
@@ -151,7 +157,29 @@ void NodeType::register_output(ustring name, ustring ui_name, SocketType::Type t
        socket.enum_values = NULL;
        socket.node_type = NULL;
        socket.flags = SocketType::LINKABLE;
-       outputs[name] = socket;
+       outputs.push_back(socket);
+}
+
+const SocketType *NodeType::find_input(ustring name) const
+{
+       foreach(const SocketType& socket, inputs) {
+               if(socket.name == name) {
+                       return &socket;
+               }
+       }
+
+       return NULL;
+}
+
+const SocketType *NodeType::find_output(ustring name) const
+{
+       foreach(const SocketType& socket, outputs) {
+               if(socket.name == name) {
+                       return &socket;
+               }
+       }
+
+       return NULL;
 }
 
 /* Node Type Registry */
@@ -162,7 +190,7 @@ unordered_map<ustring, NodeType, ustringHash>& NodeType::types()
        return _types;
 }
 
-NodeType *NodeType::add(const char *name_, CreateFunc create_)
+NodeType *NodeType::add(const char *name_, CreateFunc create_, Type type_)
 {
        ustring name(name_);
 
@@ -172,7 +200,7 @@ NodeType *NodeType::add(const char *name_, CreateFunc create_)
                return NULL;
        }
 
-       types()[name] = NodeType();
+       types()[name] = NodeType(type_);
 
        NodeType *type = &types()[name];
        type->name = name;
index 82ddd29da333ac5a6b2a4b1aabc86e29abd8c49e..20816f634cd18725d8952d9ac4cc49203c00c370 100644 (file)
@@ -21,6 +21,7 @@
 #include "util_map.h"
 #include "util_param.h"
 #include "util_string.h"
+#include "util_vector.h"
 
 CCL_NAMESPACE_BEGIN
 
@@ -94,13 +95,19 @@ struct SocketType
        static size_t max_size();
        static ustring type_name(Type type);
        static void *zero_default_value();
+       static bool is_float3(Type type);
 };
 
 /* Node Type */
 
 struct NodeType
 {
-       explicit NodeType();
+       enum Type {
+               NONE,
+               SHADER
+       };
+
+       explicit NodeType(Type type = NONE);
        ~NodeType();
 
        void register_input(ustring name, ustring ui_name, SocketType::Type type,
@@ -110,15 +117,18 @@ struct NodeType
                                                int flags = 0, int extra_flags = 0);
        void register_output(ustring name, ustring ui_name, SocketType::Type type);
 
+       const SocketType *find_input(ustring name) const;
+       const SocketType *find_output(ustring name) const;
+
        typedef Node *(*CreateFunc)(const NodeType *type);
-       typedef unordered_map<ustring, SocketType, ustringHash> SocketMap;
 
        ustring name;
-       SocketMap inputs;
-       SocketMap outputs;
+       Type type;
+       std::vector<SocketType> inputs;
+       std::vector<SocketType> outputs;
        CreateFunc create;
 
-       static NodeType *add(const char *name, CreateFunc create);
+       static NodeType *add(const char *name, CreateFunc create, Type type = NONE);
        static const NodeType *find(ustring name);
        static unordered_map<ustring, NodeType, ustringHash>& types();
 };
index fe06a243998797dbf367ea47e35963d4252395b2..022de7cf32a36f6d7ada615234d671d6055b9498 100644 (file)
@@ -58,9 +58,7 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
                node->name = ustring(name_attr.value());
        }
 
-       foreach(const NodeType::SocketMap::value_type& it, node->type->inputs) {
-               const SocketType& socket = it.second;
-
+       foreach(const SocketType& socket, node->type->inputs) {
                if(socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
                        continue;
                }
@@ -117,8 +115,9 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
 
                                array<int> value;
                                value.resize(tokens.size());
-                               for(size_t i = 0; i < value.size(); i++)
+                               for(size_t i = 0; i < value.size(); i++) {
                                        value[i] = (int)atoi(attr.value());
+                               }
                                node->set(socket, value);
                                break;
                        }
@@ -127,7 +126,7 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
                        case SocketType::POINT:
                        case SocketType::NORMAL:
                        {
-                               array<float> value;
+                               array<float3> value;
                                xml_read_float_array<3>(value, attr);
                                if(value.size() == 1) {
                                        node->set(socket, value[0]);
@@ -161,11 +160,21 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
                                break;
                        }
                        case SocketType::STRING:
-                       case SocketType::ENUM:
                        {
                                node->set(socket, attr.value());
                                break;
                        }
+                       case SocketType::ENUM:
+                       {
+                               ustring value(attr.value());
+                               if(socket.enum_values->exists(value)) {
+                                       node->set(socket, value);
+                               }
+                               else {
+                                       fprintf(stderr, "Unknown value \"%s\" for attribute \"%s\".\n", value.c_str(), socket.name.c_str());
+                               }
+                               break;
+                       }
                        case SocketType::STRING_ARRAY:
                        {
                                vector<string> tokens;
@@ -173,8 +182,9 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
 
                                array<ustring> value;
                                value.resize(tokens.size());
-                               for(size_t i = 0; i < value.size(); i++)
+                               for(size_t i = 0; i < value.size(); i++) {
                                        value[i] = ustring(tokens[i]);
+                               }
                                node->set(socket, value);
                                break;
                        }
@@ -245,9 +255,7 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
 
        xml_node.append_attribute("name") = node->name.c_str();
 
-       foreach(const NodeType::SocketMap::value_type& it, node->type->inputs) {
-               const SocketType& socket = it.second;
-
+       foreach(const SocketType& socket, node->type->inputs) {
                if(socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
                        continue;
                }
index 9eadc97386c7e80b798daad18230fb50e7fa6082..d0eedd3396afdc2bf29889ab08634e5f2df3081d 100644 (file)
@@ -48,6 +48,28 @@ CCL_NAMESPACE_BEGIN
 
 #define BVH_FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0)
 
+/* Debugging heleprs */
+#ifdef __KERNEL_DEBUG__
+#  define BVH_DEBUG_INIT() \
+       do { \
+               isect->num_traversal_steps = 0; \
+               isect->num_traversed_instances = 0; \
+       } while(0)
+#  define BVH_DEBUG_NEXT_STEP() \
+       do { \
+               ++isect->num_traversal_steps; \
+       } while(0)
+#  define BVH_DEBUG_NEXT_INSTANCE() \
+       do { \
+               ++isect->num_traversed_instances; \
+       } while(0)
+#else  /* __KERNEL_DEBUG__ */
+#  define BVH_DEBUG_INIT()
+#  define BVH_DEBUG_NEXT_STEP()
+#  define BVH_DEBUG_NEXT_INSTANCE()
+#endif  /* __KERNEL_DEBUG__ */
+
+
 /* Common QBVH functions. */
 #ifdef __QBVH__
 #  include "geom_qbvh.h"
index 8560612addcc4137cbb150e153a5182275ae281b..ae919ef3f869b08914d9372d9def78de032510a4 100644 (file)
@@ -74,10 +74,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        isect->prim = PRIM_NONE;
        isect->object = OBJECT_NONE;
 
-#if defined(__KERNEL_DEBUG__)
-       isect->num_traversal_steps = 0;
-       isect->num_traversed_instances = 0;
-#endif
+       BVH_DEBUG_INIT();
 
 #if defined(__KERNEL_SSE2__)
        const shuffle_swap_t shuf_identity = shuffle_swap_identity();
@@ -241,10 +238,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                --stackPtr;
                                        }
                                }
-
-#if defined(__KERNEL_DEBUG__)
-                               isect->num_traversal_steps++;
-#endif
+                               BVH_DEBUG_NEXT_STEP();
                        }
 
                        /* if node is leaf, fetch triangle list */
@@ -266,9 +260,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                        switch(type & PRIMITIVE_ALL) {
                                                case PRIMITIVE_TRIANGLE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                if(triangle_intersect(kg, &isect_precalc, isect, P, visibility, object, primAddr)) {
                                                                        /* shadow ray early termination */
@@ -287,9 +279,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 #if BVH_FEATURE(BVH_MOTION)
                                                case PRIMITIVE_MOTION_TRIANGLE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#  if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#  endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                if(motion_triangle_intersect(kg, isect, P, dir, ray->time, visibility, object, primAddr)) {
                                                                        /* shadow ray early termination */
@@ -310,9 +300,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                case PRIMITIVE_CURVE:
                                                case PRIMITIVE_MOTION_CURVE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#  if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#  endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                bool hit;
                                                                if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
@@ -364,9 +352,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 
                                        nodeAddr = kernel_tex_fetch(__object_node, object);
 
-#  if defined(__KERNEL_DEBUG__)
-                                       isect->num_traversed_instances++;
-#  endif
+                                       BVH_DEBUG_NEXT_INSTANCE();
                                }
                        }
 #endif  /* FEATURE(BVH_INSTANCING) */
index ce3bbbdf957168c735eb16f18f0212a304708494..738d08ac6fc9a17bc8795ca84aa1ebb036f09de7 100644 (file)
@@ -78,10 +78,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
        isect->prim = PRIM_NONE;
        isect->object = OBJECT_NONE;
 
-#if defined(__KERNEL_DEBUG__)
-       isect->num_traversal_steps = 0;
-       isect->num_traversed_instances = 0;
-#endif
+       BVH_DEBUG_INIT();
 
        ssef tnear(0.0f), tfar(ray->t);
        sse3f idir4(ssef(idir.x), ssef(idir.y), ssef(idir.z));
@@ -120,9 +117,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                int traverseChild;
                                ssef dist;
 
-#if defined(__KERNEL_DEBUG__)
-                               isect->num_traversal_steps++;
-#endif
+                               BVH_DEBUG_NEXT_STEP();
 
 #if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
                                if(difl != 0.0f) {
@@ -295,9 +290,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                        switch(type & PRIMITIVE_ALL) {
                                                case PRIMITIVE_TRIANGLE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                if(triangle_intersect(kg, &isect_precalc, isect, P, visibility, object, primAddr)) {
                                                                        tfar = ssef(isect->t);
@@ -311,9 +304,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
 #if BVH_FEATURE(BVH_MOTION)
                                                case PRIMITIVE_MOTION_TRIANGLE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#  if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#  endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                if(motion_triangle_intersect(kg, isect, P, dir, ray->time, visibility, object, primAddr)) {
                                                                        tfar = ssef(isect->t);
@@ -329,9 +320,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                                case PRIMITIVE_CURVE:
                                                case PRIMITIVE_MOTION_CURVE: {
                                                        for(; primAddr < primAddr2; primAddr++) {
-#  if defined(__KERNEL_DEBUG__)
-                                                               isect->num_traversal_steps++;
-#  endif
+                                                               BVH_DEBUG_NEXT_STEP();
                                                                kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
                                                                bool hit;
                                                                if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
@@ -381,9 +370,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
 
                                        nodeAddr = kernel_tex_fetch(__object_node, object);
 
-#  if defined(__KERNEL_DEBUG__)
-                                       isect->num_traversed_instances++;
-#  endif
+                                       BVH_DEBUG_NEXT_INSTANCE();
                                }
                        }
 #endif  /* FEATURE(BVH_INSTANCING) */
index 77982ee548a0d208afd6447bd5e8dd1b099b3f01..8d05befe1d432b06b1e70555f6a834362124e0ca 100644 (file)
@@ -30,8 +30,8 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
        Ray ray;
        float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
 
-       /* emission shader data memory used by various functions */
-       ShaderData emission_sd;
+       /* emission and indirect shader data memory used by various functions */
+       ShaderData emission_sd, indirect_sd;
 
        ray.P = sd->P + sd->Ng;
        ray.D = -sd->Ng;
@@ -94,6 +94,7 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
                                                                              &L_sample,
                                                                              &throughput);
                                        kernel_path_indirect(kg,
+                                                            &indirect_sd,
                                                             &emission_sd,
                                                             &rng,
                                                             &ray,
@@ -117,7 +118,7 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
                                state.ray_t = 0.0f;
 #endif
                                /* compute indirect light */
-                               kernel_path_indirect(kg, &emission_sd, &rng, &ray, throughput, 1, &state, &L_sample);
+                               kernel_path_indirect(kg, &indirect_sd, &emission_sd, &rng, &ray, throughput, 1, &state, &L_sample);
 
                                /* sum and reset indirect light pass variables for the next samples */
                                path_radiance_sum_indirect(&L_sample);
@@ -144,7 +145,8 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
                /* sample subsurface scattering */
                if((pass_filter & BAKE_FILTER_SUBSURFACE) && (sd->flag & SD_BSSRDF)) {
                        /* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
-                       kernel_branched_path_subsurface_scatter(kg, sd, &emission_sd, &L_sample, &state, &rng, &ray, throughput);
+                       kernel_branched_path_subsurface_scatter(kg, sd, &indirect_sd,
+                               &emission_sd, &L_sample, &state, &rng, &ray, throughput);
                }
 #endif
 
@@ -161,7 +163,7 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
 
                        /* indirect light */
                        kernel_branched_path_surface_indirect_light(kg, &rng,
-                               sd, &emission_sd, throughput, 1.0f, &state, &L_sample);
+                               sd, &indirect_sd, &emission_sd, throughput, 1.0f, &state, &L_sample);
                }
        }
 #endif
@@ -480,12 +482,10 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
        }
 
        /* write output */
-       float output_fac = is_aa_pass(type)? 1.0f/num_samples: 1.0f;
+       const float output_fac = is_aa_pass(type)? 1.0f/num_samples: 1.0f;
+       const float4 scaled_result = make_float4(out.x, out.y, out.z, 1.0f) * output_fac;
 
-       if(sample == 0)
-               output[i] = make_float4(out.x, out.y, out.z, 1.0f) * output_fac;
-       else
-               output[i] += make_float4(out.x, out.y, out.z, 1.0f) * output_fac;
+       output[i] = (sample == 0)?  scaled_result: output[i] + scaled_result;
 }
 
 #endif  /* __BAKING__ */
index 7e6cdf93fb93ad9e20fb5bdb777346efbcfebf72..e06c68f2fc96f17b3c762570b779d02cb288aa05 100644 (file)
@@ -35,10 +35,10 @@ struct Intersection;
 struct VolumeStep;
 
 typedef struct KernelGlobals {
-       texture_image_uchar4 texture_byte4_images[TEX_NUM_BYTE4_IMAGES_CPU];
-       texture_image_float4 texture_float4_images[TEX_NUM_FLOAT4_IMAGES_CPU];
-       texture_image_float texture_float_images[TEX_NUM_FLOAT_IMAGES_CPU];
-       texture_image_uchar texture_byte_images[TEX_NUM_BYTE_IMAGES_CPU];
+       texture_image_uchar4 texture_byte4_images[TEX_NUM_BYTE4_CPU];
+       texture_image_float4 texture_float4_images[TEX_NUM_FLOAT4_CPU];
+       texture_image_float texture_float_images[TEX_NUM_FLOAT_CPU];
+       texture_image_uchar texture_byte_images[TEX_NUM_BYTE_CPU];
 
 #  define KERNEL_TEX(type, ttype, name) ttype name;
 #  define KERNEL_IMAGE_TEX(type, ttype, name)
index 5527d8aa86141e129fdf5418f57e268d8bcac8e3..0dded397ffa40ed586710b2197c16c93c544288d 100644 (file)
@@ -53,6 +53,7 @@
 CCL_NAMESPACE_BEGIN
 
 ccl_device void kernel_path_indirect(KernelGlobals *kg,
+                                     ShaderData *sd,
                                      ShaderData *emission_sd,
                                      RNG *rng,
                                      Ray *ray,
@@ -61,9 +62,6 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                                      PathState *state,
                                      PathRadiance *L)
 {
-       /* shader data memory used for both volumes and surfaces, saves stack space */
-       ShaderData sd;
-
        /* path iteration */
        for(;;) {
                /* intersect scene */
@@ -121,12 +119,12 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                                VolumeSegment volume_segment;
 
                                shader_setup_from_volume(kg,
-                                                        &sd,
+                                                        sd,
                                                         &volume_ray);
                                kernel_volume_decoupled_record(kg,
                                                               state,
                                                               &volume_ray,
-                                                              &sd,
+                                                              sd,
                                                               &volume_segment,
                                                               heterogeneous);
 
@@ -149,7 +147,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                                        /* direct light sampling */
                                        kernel_branched_path_volume_connect_light(kg,
                                                                                  rng,
-                                                                                 &sd,
+                                                                                 sd,
                                                                                  emission_sd,
                                                                                  throughput,
                                                                                  state,
@@ -167,7 +165,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                                        result = kernel_volume_decoupled_scatter(kg,
                                                                                 state,
                                                                                 &volume_ray,
-                                                                                &sd,
+                                                                                sd,
                                                                                 &throughput,
                                                                                 rphase,
                                                                                 rscatter,
@@ -182,7 +180,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                                if(result == VOLUME_PATH_SCATTERED) {
                                        if(kernel_path_volume_bounce(kg,
                                                                     rng,
-                                                                    &sd,
+                                                                    sd,
                                                                     &throughput,
                                                                     state,
                                                                     L,
@@ -203,14 +201,14 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                        {
                                /* integrate along volume segment with distance sampling */
                                VolumeIntegrateResult result = kernel_volume_integrate(
-                                       kg, state, &sd, &volume_ray, L, &throughput, rng, heterogeneous);
+                                       kg, state, sd, &volume_ray, L, &throughput, rng, heterogeneous);
 
 #  ifdef __VOLUME_SCATTER__
                                if(result == VOLUME_PATH_SCATTERED) {
                                        /* direct lighting */
                                        kernel_path_volume_connect_light(kg,
                                                                         rng,
-                                                                        &sd,
+                                                                        sd,
                                                                         emission_sd,
                                                                         throughput,
                                                                         state,
@@ -219,7 +217,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                                        /* indirect light bounce */
                                        if(kernel_path_volume_bounce(kg,
                                                                     rng,
-                                                                    &sd,
+                                                                    sd,
                                                                     &throughput,
                                                                     state,
                                                                     L,
@@ -251,13 +249,13 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
 
                /* setup shading */
                shader_setup_from_ray(kg,
-                                     &sd,
+                                     sd,
                                      &isect,
                                      ray);
                float rbsdf = path_state_rng_1D_for_decision(kg, rng, state, PRNG_BSDF);
-               shader_eval_surface(kg, &sd, state, rbsdf, state->flag, SHADER_CONTEXT_INDIRECT);
+               shader_eval_surface(kg, sd, state, rbsdf, state->flag, SHADER_CONTEXT_INDIRECT);
 #ifdef __BRANCHED_PATH__
-               shader_merge_closures(&sd);
+               shader_merge_closures(sd);
 #endif
 
                /* blurring of bsdf after bounces, for rays that have a small likelihood
@@ -267,15 +265,15 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
 
                        if(blur_pdf < 1.0f) {
                                float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
-                               shader_bsdf_blur(kg, &sd, blur_roughness);
+                               shader_bsdf_blur(kg, sd, blur_roughness);
                        }
                }
 
 #ifdef __EMISSION__
                /* emission */
-               if(sd.flag & SD_EMISSION) {
+               if(sd->flag & SD_EMISSION) {
                        float3 emission = indirect_primitive_emission(kg,
-                                                                     &sd,
+                                                                     sd,
                                                                      isect.t,
                                                                      state->flag,
                                                                      state->ray_pdf);
@@ -305,30 +303,30 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
 
 #ifdef __AO__
                /* ambient occlusion */
-               if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
+               if(kernel_data.integrator.use_ambient_occlusion || (sd->flag & SD_AO)) {
                        float bsdf_u, bsdf_v;
                        path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
 
                        float ao_factor = kernel_data.background.ao_factor;
                        float3 ao_N;
-                       float3 ao_bsdf = shader_bsdf_ao(kg, &sd, ao_factor, &ao_N);
+                       float3 ao_bsdf = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
                        float3 ao_D;
                        float ao_pdf;
                        float3 ao_alpha = make_float3(0.0f, 0.0f, 0.0f);
 
                        sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
 
-                       if(dot(sd.Ng, ao_D) > 0.0f && ao_pdf != 0.0f) {
+                       if(dot(sd->Ng, ao_D) > 0.0f && ao_pdf != 0.0f) {
                                Ray light_ray;
                                float3 ao_shadow;
 
-                               light_ray.P = ray_offset(sd.P, sd.Ng);
+                               light_ray.P = ray_offset(sd->P, sd->Ng);
                                light_ray.D = ao_D;
                                light_ray.t = kernel_data.background.ao_distance;
 #  ifdef __OBJECT_MOTION__
-                               light_ray.time = sd.time;
+                               light_ray.time = sd->time;
 #  endif
-                               light_ray.dP = sd.dP;
+                               light_ray.dP = sd->dP;
                                light_ray.dD = differential3_zero();
 
                                if(!shadow_blocked(kg, emission_sd, state, &light_ray, &ao_shadow)) {
@@ -346,9 +344,9 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
 #ifdef __SUBSURFACE__
                /* bssrdf scatter to a different location on the same object, replacing
                 * the closures with a diffuse BSDF */
-               if(sd.flag & SD_BSSRDF) {
+               if(sd->flag & SD_BSSRDF) {
                        float bssrdf_probability;
-                       ShaderClosure *sc = subsurface_scatter_pick_closure(kg, &sd, &bssrdf_probability);
+                       ShaderClosure *sc = subsurface_scatter_pick_closure(kg, sd, &bssrdf_probability);
 
                        /* modify throughput for picking bssrdf or bsdf */
                        throughput *= bssrdf_probability;
@@ -364,7 +362,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                                                  PRNG_BSDF_U,
                                                  &bssrdf_u, &bssrdf_v);
                                subsurface_scatter_step(kg,
-                                                       &sd,
+                                                       sd,
                                                        state,
                                                        state->flag,
                                                        sc,
@@ -380,7 +378,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                        int all = kernel_data.integrator.sample_all_lights_indirect;
                        kernel_branched_path_surface_connect_light(kg,
                                                                   rng,
-                                                                  &sd,
+                                                                  sd,
                                                                   emission_sd,
                                                                   state,
                                                                   throughput,
@@ -390,7 +388,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
                }
 #endif
 
-               if(!kernel_path_surface_bounce(kg, rng, &sd, &throughput, state, L, ray))
+               if(!kernel_path_surface_bounce(kg, rng, sd, &throughput, state, L, ray))
                        break;
        }
 }
index b4dee220aa5a6b84a802999649adce52b8c4647d..fdba1a7b02518274ac65409d6accd99af103ab91 100644 (file)
@@ -64,8 +64,8 @@ ccl_device void kernel_branched_path_ao(KernelGlobals *kg,
 
 /* bounce off surface and integrate indirect light */
 ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGlobals *kg,
-       RNG *rng, ShaderData *sd, ShaderData *emission_sd, float3 throughput,
-       float num_samples_adjust, PathState *state, PathRadiance *L)
+       RNG *rng, ShaderData *sd, ShaderData *indirect_sd, ShaderData *emission_sd,
+       float3 throughput, float num_samples_adjust, PathState *state, PathRadiance *L)
 {
        for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
                const ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
@@ -112,6 +112,7 @@ ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGloba
                        }
 
                        kernel_path_indirect(kg,
+                                                        indirect_sd,
                                             emission_sd,
                                             rng,
                                             &bsdf_ray,
@@ -131,6 +132,7 @@ ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGloba
 #ifdef __SUBSURFACE__
 ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
                                                         ShaderData *sd,
+                                                        ShaderData *indirect_sd,
                                                         ShaderData *emission_sd,
                                                         PathRadiance *L,
                                                         PathState *state,
@@ -222,6 +224,7 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
                                        kg,
                                        rng,
                                        &bssrdf_sd,
+                                               indirect_sd,
                                        emission_sd,
                                        throughput,
                                        num_samples_inv,
@@ -244,8 +247,8 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
 
        /* shader data memory used for both volumes and surfaces, saves stack space */
        ShaderData sd;
-       /* shader data used by emission, shadows, volume stacks */
-       ShaderData emission_sd;
+       /* shader data used by emission, shadows, volume stacks, indirect path */
+       ShaderData emission_sd, indirect_sd;
 
        PathState state;
        path_state_init(kg, &emission_sd, &state, rng, sample, &ray);
@@ -356,6 +359,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
                                                                     &pray))
                                        {
                                                kernel_path_indirect(kg,
+                                                                    &indirect_sd,
                                                                     &emission_sd,
                                                                     rng,
                                                                     &pray,
@@ -413,6 +417,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
                                                                     &pray))
                                        {
                                                kernel_path_indirect(kg,
+                                                                    &indirect_sd,
                                                                     &emission_sd,
                                                                     rng,
                                                                     &pray,
@@ -522,8 +527,8 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
 #ifdef __SUBSURFACE__
                /* bssrdf scatter to a different location on the same object */
                if(sd.flag & SD_BSSRDF) {
-                       kernel_branched_path_subsurface_scatter(kg, &sd, &emission_sd, &L, &state,
-                                                               rng, &ray, throughput);
+                       kernel_branched_path_subsurface_scatter(kg, &sd, &indirect_sd, &emission_sd,
+                                                               &L, &state, rng, &ray, throughput);
                }
 #endif
 
@@ -541,7 +546,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
 
                        /* indirect light */
                        kernel_branched_path_surface_indirect_light(kg, rng,
-                               &sd, &emission_sd, throughput, 1.0f, &hit_state, &L);
+                               &sd, &indirect_sd, &emission_sd, throughput, 1.0f, &hit_state, &L);
 
                        /* continue in case of transparency */
                        throughput *= shader_bsdf_transparency(kg, &sd);
index c8f6503cf58bfb6ab38ba48af5e58a61f71c21b1..1abbbb2ddad61e512783b4f0b26a17b3f44f39bd 100644 (file)
@@ -126,8 +126,6 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ShaderData *shadow_sd,
                                /* stop if all light is blocked */
                                if(is_zero(throughput)) {
                                        /* free dynamic storage */
-                                       if(hits != hits_stack)
-                                               free(hits);
                                        return true;
                                }
 
index ba50d180acf7670f08cc523b0cf9d4a35d83d31f..1ffcfb94a15e93619b3f10ae5c7a1ef149fed967 100644 (file)
@@ -121,9 +121,7 @@ CCL_NAMESPACE_BEGIN
 #    define __OBJECT_MOTION__
 #    define __HAIR__
 #    define __BAKING__
-#    ifdef __KERNEL_EXPERIMENTAL__
-#      define __TRANSPARENT_SHADOWS__
-#    endif
+#    define __TRANSPARENT_SHADOWS__
 #  endif  /* __KERNEL_OPENCL_AMD__ */
 
 #  ifdef __KERNEL_OPENCL_INTEL_CPU__
index 365ce89135427c7880e88f0bae9d0b8c7fce8eb8..d8a83f69685488e0be77ec9693522cf8dc5aceb5 100644 (file)
@@ -95,7 +95,7 @@ void kernel_tex_copy(KernelGlobals *kg,
                int id = atoi(name + strlen("__tex_image_float4_"));
                int array_index = id;
 
-               if(array_index >= 0 && array_index < TEX_NUM_FLOAT4_IMAGES_CPU) {
+               if(array_index >= 0 && array_index < TEX_NUM_FLOAT4_CPU) {
                        tex = &kg->texture_float4_images[array_index];
                }
 
@@ -109,9 +109,9 @@ void kernel_tex_copy(KernelGlobals *kg,
        else if(strstr(name, "__tex_image_float")) {
                texture_image_float *tex = NULL;
                int id = atoi(name + strlen("__tex_image_float_"));
-               int array_index = id - TEX_IMAGE_FLOAT_START_CPU;
+               int array_index = id - TEX_START_FLOAT_CPU;
 
-               if(array_index >= 0 && array_index < TEX_NUM_FLOAT_IMAGES_CPU) {
+               if(array_index >= 0 && array_index < TEX_NUM_FLOAT_CPU) {
                        tex = &kg->texture_float_images[array_index];
                }
 
@@ -125,9 +125,9 @@ void kernel_tex_copy(KernelGlobals *kg,
        else if(strstr(name, "__tex_image_byte4")) {
                texture_image_uchar4 *tex = NULL;
                int id = atoi(name + strlen("__tex_image_byte4_"));
-               int array_index = id - TEX_IMAGE_BYTE4_START_CPU;
+               int array_index = id - TEX_START_BYTE4_CPU;
 
-               if(array_index >= 0 && array_index < TEX_NUM_BYTE4_IMAGES_CPU) {
+               if(array_index >= 0 && array_index < TEX_NUM_BYTE4_CPU) {
                        tex = &kg->texture_byte4_images[array_index];
                }
 
@@ -141,9 +141,9 @@ void kernel_tex_copy(KernelGlobals *kg,
        else if(strstr(name, "__tex_image_byte")) {
                texture_image_uchar *tex = NULL;
                int id = atoi(name + strlen("__tex_image_byte_"));
-               int array_index = id - TEX_IMAGE_BYTE_START_CPU;
+               int array_index = id - TEX_START_BYTE_CPU;
 
-               if(array_index >= 0 && array_index < TEX_NUM_BYTE_IMAGES_CPU) {
+               if(array_index >= 0 && array_index < TEX_NUM_BYTE_CPU) {
                        tex = &kg->texture_byte_images[array_index];
                }
 
index 4807f96a0df765f7147865d0a8143b1713063daa..b10861ab857ba495553e79cdd897e5260fccb524 100644 (file)
@@ -23,24 +23,24 @@ CCL_NAMESPACE_BEGIN
 
 ccl_device float4 kernel_tex_image_interp_impl(KernelGlobals *kg, int tex, float x, float y)
 {
-       if(tex >= TEX_IMAGE_BYTE_START_CPU)
-               return kg->texture_byte_images[tex - TEX_IMAGE_BYTE_START_CPU].interp(x, y);
-       else if(tex >= TEX_IMAGE_FLOAT_START_CPU)
-               return kg->texture_float_images[tex - TEX_IMAGE_FLOAT_START_CPU].interp(x, y);
-       else if(tex >= TEX_IMAGE_BYTE4_START_CPU)
-               return kg->texture_byte4_images[tex - TEX_IMAGE_BYTE4_START_CPU].interp(x, y);
+       if(tex >= TEX_START_BYTE_CPU)
+               return kg->texture_byte_images[tex - TEX_START_BYTE_CPU].interp(x, y);
+       else if(tex >= TEX_START_FLOAT_CPU)
+               return kg->texture_float_images[tex - TEX_START_FLOAT_CPU].interp(x, y);
+       else if(tex >= TEX_START_BYTE4_CPU)
+               return kg->texture_byte4_images[tex - TEX_START_BYTE4_CPU].interp(x, y);
        else
                return kg->texture_float4_images[tex].interp(x, y);
 }
 
 ccl_device float4 kernel_tex_image_interp_3d_impl(KernelGlobals *kg, int tex, float x, float y, float z)
 {
-       if(tex >= TEX_IMAGE_BYTE_START_CPU)
-               return kg->texture_byte_images[tex - TEX_IMAGE_BYTE_START_CPU].interp_3d(x, y, z);
-       else if(tex >= TEX_IMAGE_FLOAT_START_CPU)
-               return kg->texture_float_images[tex - TEX_IMAGE_FLOAT_START_CPU].interp_3d(x, y, z);
-       else if(tex >= TEX_IMAGE_BYTE4_START_CPU)
-               return kg->texture_byte4_images[tex - TEX_IMAGE_BYTE4_START_CPU].interp_3d(x, y, z);
+       if(tex >= TEX_START_BYTE_CPU)
+               return kg->texture_byte_images[tex - TEX_START_BYTE_CPU].interp_3d(x, y, z);
+       else if(tex >= TEX_START_FLOAT_CPU)
+               return kg->texture_float_images[tex - TEX_START_FLOAT_CPU].interp_3d(x, y, z);
+       else if(tex >= TEX_START_BYTE4_CPU)
+               return kg->texture_byte4_images[tex - TEX_START_BYTE4_CPU].interp_3d(x, y, z);
        else
                return kg->texture_float4_images[tex].interp_3d(x, y, z);
 
@@ -48,12 +48,12 @@ ccl_device float4 kernel_tex_image_interp_3d_impl(KernelGlobals *kg, int tex, fl
 
 ccl_device float4 kernel_tex_image_interp_3d_ex_impl(KernelGlobals *kg, int tex, float x, float y, float z, int interpolation)
 {
-       if(tex >= TEX_IMAGE_BYTE_START_CPU)
-               return kg->texture_byte_images[tex - TEX_IMAGE_BYTE_START_CPU].interp_3d_ex(x, y, z, interpolation);
-       else if(tex >= TEX_IMAGE_FLOAT_START_CPU)
-               return kg->texture_float_images[tex - TEX_IMAGE_FLOAT_START_CPU].interp_3d_ex(x, y, z, interpolation);
-       else if(tex >= TEX_IMAGE_BYTE4_START_CPU)
-               return kg->texture_byte4_images[tex - TEX_IMAGE_BYTE4_START_CPU].interp_3d_ex(x, y, z, interpolation);
+       if(tex >= TEX_START_BYTE_CPU)
+               return kg->texture_byte_images[tex - TEX_START_BYTE_CPU].interp_3d_ex(x, y, z, interpolation);
+       else if(tex >= TEX_START_FLOAT_CPU)
+               return kg->texture_float_images[tex - TEX_START_FLOAT_CPU].interp_3d_ex(x, y, z, interpolation);
+       else if(tex >= TEX_START_BYTE4_CPU)
+               return kg->texture_byte4_images[tex - TEX_START_BYTE4_CPU].interp_3d_ex(x, y, z, interpolation);
        else
                return kg->texture_float4_images[tex].interp_3d_ex(x, y, z, interpolation);
 }
index 35e01178ba8f72b61397f05c3fd883d92ae424f6..d5e0a7d4c8cc29d5eac3328bff2bd277ff7f779d 100644 (file)
@@ -59,10 +59,10 @@ float brick(point p, float mortar_size, float bias,
 shader node_brick_texture(
        int use_mapping = 0,
        matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
-       float Offset = 0.5,
-       int OffsetFrequency = 2,
-       float Squash = 1.0,
-       int SquashFrequency = 1,
+       float offset = 0.5,
+       int offset_frequency = 2,
+       float squash = 1.0,
+       int squash_frequency = 1,
        point Vector = P,
        color Color1 = 0.2,
        color Color2 = 0.8,
@@ -84,7 +84,7 @@ shader node_brick_texture(
        color Col = Color1;
        
        Fac = brick(p * Scale, MortarSize, Bias, BrickWidth, RowHeight,
-               Offset, OffsetFrequency, Squash, SquashFrequency, tint);
+               offset, offset_frequency, squash, squash_frequency, tint);
                
        if (Fac != 1.0) {
                float facm = 1.0 - tint;
index 44074317f4276b0cc320f71a3060ca86b2f8285b..e95a17f6fa14f53f97545613fa84b2adad47b5c6 100644 (file)
 #include "stdosl.h"
 
 shader node_convert_from_color(
-       color Color = 0.0,
-       output string String = "",
-       output float Val = 0.0,
-       output int ValInt = 0,
-       output vector Vector = vector(0.0, 0.0, 0.0),
-       output point Point = point(0.0, 0.0, 0.0),
-       output normal Normal = normal(0.0, 0.0, 0.0))
+       color value_color = 0.0,
+       output string value_string = "",
+       output float value_float = 0.0,
+       output int value_int = 0,
+       output vector value_vector = vector(0.0, 0.0, 0.0),
+       output point value_point = point(0.0, 0.0, 0.0),
+       output normal value_normal = normal(0.0, 0.0, 0.0))
 {
-       Val = Color[0] * 0.2126 + Color[1] * 0.7152 + Color[2] * 0.0722;
-       ValInt = (int)(Color[0] * 0.2126 + Color[1] * 0.7152 + Color[2] * 0.0722);
-       Vector = vector(Color[0], Color[1], Color[2]);
-       Point = point(Color[0], Color[1], Color[2]);
-       Normal = normal(Color[0], Color[1], Color[2]);
+       value_float = value_color[0] * 0.2126 + value_color[1] * 0.7152 + value_color[2] * 0.0722;
+       value_int = (int)(value_color[0] * 0.2126 + value_color[1] * 0.7152 + value_color[2] * 0.0722);
+       value_vector = vector(value_color[0], value_color[1], value_color[2]);
+       value_point = point(value_color[0], value_color[1], value_color[2]);
+       value_normal = normal(value_color[0], value_color[1], value_color[2]);
 }
 
index fc5c79c4c64d1c7b43d268d77ee4ab89308d0e68..a5c2e3b26ad160c308259f0ff5e7c6725d347817 100644 (file)
 #include "stdosl.h"
 
 shader node_convert_from_float(
-       float Val = 0.0,
-       output string String = "",
-       output int ValInt = 0,
-       output color Color = 0.0,
-       output vector Vector = vector(0.0, 0.0, 0.0),
-       output point Point = point(0.0, 0.0, 0.0),
-       output normal Normal = normal(0.0, 0.0, 0.0))
+       float value_float = 0.0,
+       output string value_string = "",
+       output int value_int = 0,
+       output color value_color = 0.0,
+       output vector value_vector = vector(0.0, 0.0, 0.0),
+       output point value_point = point(0.0, 0.0, 0.0),
+       output normal value_normal = normal(0.0, 0.0, 0.0))
 {
-       ValInt = (int)Val;
-       Color = color(Val, Val, Val);
-       Vector = vector(Val, Val, Val);
-       Point = point(Val, Val, Val);
-       Normal = normal(Val, Val, Val);
+       value_int = (int)value_float;
+       value_color = color(value_float, value_float, value_float);
+       value_vector = vector(value_float, value_float, value_float);
+       value_point = point(value_float, value_float, value_float);
+       value_normal = normal(value_float, value_float, value_float);
 }
 
index 3c3785ebc0d02ad13e867bdf6228b6fa044ad8b5..0e6ae711210089ca85ba4361598c738196d4f894 100644 (file)
 #include "stdosl.h"
 
 shader node_convert_from_int(
-       int ValInt = 0,
-       output string String = "",
-       output float Val = 0.0,
-       output color Color = 0.0,
-       output vector Vector = vector(0.0, 0.0, 0.0),
-       output point Point = point(0.0, 0.0, 0.0),
-       output normal Normal = normal(0.0, 0.0, 0.0))
+       int value_int = 0,
+       output string value_string = "",
+       output float value_float = 0.0,
+       output color value_color = 0.0,
+       output vector value_vector = vector(0.0, 0.0, 0.0),
+       output point value_point = point(0.0, 0.0, 0.0),
+       output normal value_normal = normal(0.0, 0.0, 0.0))
 {
-       float f = (float)ValInt;
-       Val = f;
-       Color = color(f, f, f);
-       Vector = vector(f, f, f);
-       Point = point(f, f, f);
-       Normal = normal(f, f, f);
+       float f = (float)value_int;
+       value_float = f;
+       value_color = color(f, f, f);
+       value_vector = vector(f, f, f);
+       value_point = point(f, f, f);
+       value_normal = normal(f, f, f);
 }
 
index 8ecc56ac8ce8482290284478264445622658d012..7fffa7f61691611c7fdf1fc396e23f24c21fa642 100644 (file)
 #include "stdosl.h"
 
 shader node_convert_from_normal(
-       normal Normal = normal(0.0, 0.0, 0.0),
-       output string String = "",
-       output float Val = 0.0,
-       output int ValInt = 0,
-       output vector Vector = vector(0.0, 0.0, 0.0),
-       output color Color = 0.0,
-       output point Point = point(0.0, 0.0, 0.0))
+       normal value_normal = normal(0.0, 0.0, 0.0),
+       output string value_string = "",
+       output float value_float = 0.0,
+       output int value_int = 0,
+       output vector value_vector = vector(0.0, 0.0, 0.0),
+       output color value_color = 0.0,
+       output point value_point = point(0.0, 0.0, 0.0))
 {
-       Val = (Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0);
-       ValInt = (int)((Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0));
-       Vector = vector(Normal[0], Normal[1], Normal[2]);
-       Color = color(Normal[0], Normal[1], Normal[2]);
-       Point = point(Normal[0], Normal[1], Normal[2]);
+       value_float = (value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0);
+       value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
+       value_vector = vector(value_normal[0], value_normal[1], value_normal[2]);
+       value_color = color(value_normal[0], value_normal[1], value_normal[2]);
+       value_point = point(value_normal[0], value_normal[1], value_normal[2]);
 }
 
index e5913b7a1e4f3f616b3d9a06b946b9b7e6dcd5a5..9e4930296bbac1fa2efde8193db550687ae64ef7 100644 (file)
 #include "stdosl.h"
 
 shader node_convert_from_point(
-       point Point = point(0.0, 0.0, 0.0),
-       output string String = "",
-       output float Val = 0.0,
-       output int ValInt = 0,
-       output vector Vector = vector(0.0, 0.0, 0.0),
-       output color Color = 0.0,
-       output normal Normal = normal(0.0, 0.0, 0.0))
+       point value_point = point(0.0, 0.0, 0.0),
+       output string value_string = "",
+       output float value_float = 0.0,
+       output int value_int = 0,
+       output vector value_vector = vector(0.0, 0.0, 0.0),
+       output color value_color = 0.0,
+       output normal value_normal = normal(0.0, 0.0, 0.0))
 {
-       Val = (Point[0] + Point[1] + Point[2]) * (1.0 / 3.0);
-       ValInt = (int)((Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0));
-       Vector = vector(Point[0], Point[1], Point[2]);
-       Color = color(Point[0], Point[1], Point[2]);
-       Normal = normal(Point[0], Point[1], Point[2]);
+       value_float = (value_point[0] + value_point[1] + value_point[2]) * (1.0 / 3.0);
+       value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
+       value_vector = vector(value_point[0], value_point[1], value_point[2]);
+       value_color = color(value_point[0], value_point[1], value_point[2]);
+       value_normal = normal(value_point[0], value_point[1], value_point[2]);
 }
 
index 0466734277b8d963e507ec60f7debb260c3ba792..cbc6653eada2bc1a1d2443e72346e7860f260c8c 100644 (file)
 #include "stdosl.h"
 
 shader node_convert_from_string(
-       string String = "",
-       output color Color = color(0.0, 0.0, 0.0),
-       output float Val = 0.0,
-       output int ValInt = 0,
-       output vector Vector = vector(0.0, 0.0, 0.0),
-       output point Point = point(0.0, 0.0, 0.0),
-       output normal Normal = normal(0.0, 0.0, 0.0))
+       string value_string = "",
+       output color value_color = color(0.0, 0.0, 0.0),
+       output float value_float = 0.0,
+       output int value_int = 0,
+       output vector value_vector = vector(0.0, 0.0, 0.0),
+       output point value_point = point(0.0, 0.0, 0.0),
+       output normal value_normal = normal(0.0, 0.0, 0.0))
 {
 }
 
index 79c5cb04550ccae5255deede6f30010c64696114..8bdca469b90eece96d3fd8fe7931f394b58d4814 100644 (file)
 #include "stdosl.h"
 
 shader node_convert_from_vector(
-       vector Vector = vector(0.0, 0.0, 0.0),
-       output string String = "",
-       output float Val = 0.0,
-       output int ValInt = 0,
-       output color Color = color(0.0, 0.0, 0.0),
-       output point Point = point(0.0, 0.0, 0.0),
-       output normal Normal = normal(0.0, 0.0, 0.0))
+       vector value_vector = vector(0.0, 0.0, 0.0),
+       output string value_string = "",
+       output float value_float = 0.0,
+       output int value_int = 0,
+       output color value_color = color(0.0, 0.0, 0.0),
+       output point value_point = point(0.0, 0.0, 0.0),
+       output normal value_normal = normal(0.0, 0.0, 0.0))
 {
-       Val = (Vector[0] + Vector[1] + Vector[2]) * (1.0 / 3.0);
-       ValInt = (int)((Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0));
-       Color = color(Vector[0], Vector[1], Vector[2]);
-       Point = point(Vector[0], Vector[1], Vector[2]);
-       Normal = normal(Vector[0], Vector[1], Vector[2]);
+       value_float = (value_vector[0] + value_vector[1] + value_vector[2]) * (1.0 / 3.0);
+       value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
+       value_color = color(value_vector[0], value_vector[1], value_vector[2]);
+       value_point = point(value_vector[0], value_vector[1], value_vector[2]);
+       value_normal = normal(value_vector[0], value_vector[1], value_vector[2]);
 }
 
index 52b49688ab31579238b8282cde1a74516736509e..69e2ee54bdf3451f38dbdcb5ff970cf42222e846 100644 (file)
@@ -63,7 +63,7 @@ float gradient(point p, string type)
 shader node_gradient_texture(
        int use_mapping = 0,
        matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
-       string Type = "Linear",
+       string type = "Linear",
        point Vector = P,
        output float Fac = 0.0,
        output color Color = 0.0)
@@ -73,7 +73,7 @@ shader node_gradient_texture(
        if (use_mapping)
                p = transform(mapping, p);
 
-       Fac = gradient(p, Type);
+       Fac = gradient(p, type);
        Color = color(Fac, Fac, Fac);
 }
 
index d3a347b70dbb874cb1d1bb9fbdd4578d041d6696..d09174ff5d3ed5300e5f6b1a7548df6059d59f7b 100644 (file)
@@ -62,9 +62,9 @@ color image_texture_lookup(string filename,
                            int use_alpha,
                            int is_float,
                            string interpolation,
-                           string wrap)
+                           string extension)
 {
-       color rgb = (color)texture(filename, u, 1.0 - v, "wrap", wrap, "interp", interpolation, "alpha", Alpha);
+       color rgb = (color)texture(filename, u, 1.0 - v, "wrap", extension, "interp", interpolation, "alpha", Alpha);
 
        if (use_alpha) {
                rgb = color_unpremultiply(rgb, Alpha);
index 55992e3494c437d328533d55a18c77d47bc7dd31..8d6af391e0411afe802ddecc58555cb47e6b37e5 100644 (file)
@@ -93,7 +93,7 @@ color magic(point p, int n, float distortion)
 shader node_magic_texture(
        int use_mapping = 0,
        matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
-       int Depth = 2,
+       int depth = 2,
        float Distortion = 5.0,
        float Scale = 5.0,
        point Vector = P,
@@ -105,7 +105,7 @@ shader node_magic_texture(
        if (use_mapping)
                p = transform(mapping, p);
 
-       Color = magic(p * Scale, Depth, Distortion);
+       Color = magic(p * Scale, depth, Distortion);
        Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
 }
 
index 7eef97fd7e861f0b464c2697f9076699eccadc8b..85eac0b97a6db23a353da6ede5418152e16446d8 100644 (file)
@@ -50,7 +50,7 @@ float safe_log(float a, float b)
 
 shader node_math(
        string type = "Add",
-       int Clamp = 0,
+       int use_clamp = 0,
        float Value1 = 0.0,
        float Value2 = 0.0,
        output float Value = 0.0)
@@ -96,7 +96,7 @@ shader node_math(
        else if (type == "Absolute")
                Value = fabs(Value1);
 
-       if (Clamp)
+       if (use_clamp)
                Value = clamp(Value, 0.0, 1.0);
 }
 
index 9ef58e4cbba9073b942b0473e63ce2c419ec2f7e..4a66748ed6a372f6097d17f47afaaad6e9433353 100644 (file)
@@ -278,7 +278,7 @@ color node_mix_clamp(color col)
 
 shader node_mix(
        string type = "Mix",
-       int Clamp = 0,
+       int use_clamp = 0,
        float Fac = 0.5,
        color Color1 = 0.0,
        color Color2 = 0.0,
@@ -323,7 +323,7 @@ shader node_mix(
        if (type == "Linear Light")
                Color = node_mix_linear(t, Color1, Color2);
 
-       if (Clamp)
+       if (use_clamp)
                Color = node_mix_clamp(Color);
 }
 
index 4f95dec910a995a02fe19179c24cb21e5f8f80f1..2f9f62bcfe8dd863687211bca3a9cb38d1e40a91 100644 (file)
@@ -187,7 +187,7 @@ float noise_musgrave_ridged_multi_fractal(point p, float H, float lacunarity,
 shader node_musgrave_texture(
        int use_mapping = 0,
        matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
-       string Type = "fBM",
+       string type = "fBM",
        float Dimension = 2.0,
        float Lacunarity = 1.0,
        float Detail = 2.0,
@@ -210,15 +210,15 @@ shader node_musgrave_texture(
 
        p = p * Scale;
 
-       if (Type == "Multifractal")
+       if (type == "Multifractal")
                Fac = intensity * noise_musgrave_multi_fractal(p, dimension, lacunarity, octaves);
-       else if (Type == "fBM")
+       else if (type == "fBM")
                Fac = intensity * noise_musgrave_fBm(p, dimension, lacunarity, octaves);
-       else if (Type == "Hybrid Multifractal")
+       else if (type == "Hybrid Multifractal")
                Fac = intensity * noise_musgrave_hybrid_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain);
-       else if (Type == "Ridged Multifractal")
+       else if (type == "Ridged Multifractal")
                Fac = intensity * noise_musgrave_ridged_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain);
-       else if (Type == "Hetero Terrain")
+       else if (type == "Hetero Terrain")
                Fac = intensity * noise_musgrave_hetero_terrain(p, dimension, lacunarity, octaves, Offset);
        
        Color = color(Fac, Fac, Fac);
index 2d04978fc722ff298588e387451648554d21d6c3..7307971edddb5ed08f48a5646e311238390dd96e 100644 (file)
 #include "stdosl.h"
 
 shader node_normal(
-       normal Direction = normal(0.0, 0.0, 0.0),
+       normal direction = normal(0.0, 0.0, 0.0),
        normal NormalIn = normal(0.0, 0.0, 0.0),
        output normal NormalOut = normal(0.0, 0.0, 0.0),
        output float Dot = 1.0)
 {
-       NormalOut = normalize(Direction);
+       NormalOut = normalize(direction);
        Dot = dot(NormalOut, normalize(NormalIn));
 }
 
index 2ab6b6778b7244a55fefd40e1f25072aae6a616a..c0ae74d6b33925ef38ac50295aa623f8e0d8f3ba 100644 (file)
@@ -20,7 +20,7 @@
 shader node_rgb_ramp(
        color ramp_color[] = {0.0},
        float ramp_alpha[] = {0.0},
-       int ramp_interpolate = 1,
+       int interpolate = 1,
 
        float Fac = 0.0,
        output color Color = 0.0,
@@ -38,7 +38,7 @@ shader node_rgb_ramp(
        Color = ramp_color[i];
        Alpha = ramp_alpha[i];
 
-       if (ramp_interpolate && t > 0.0) {
+       if (interpolate && t > 0.0) {
                Color = (1.0 - t) * Color + t * ramp_color[i + 1];
                Alpha = (1.0 - t) * Alpha + t * ramp_alpha[i + 1];
        }
index a67333c5d4e6d1637432bb18edc2c3319938bdda..1877c7e595ff2bf90b5098b3df48df136113ae70 100644 (file)
@@ -22,13 +22,13 @@ shader node_subsurface_scattering(
        vector Radius = vector(0.1, 0.1, 0.1),
        float TextureBlur = 0.0,
        float Sharpness = 0.0,
-       string Falloff = "Cubic",
+       string falloff = "Cubic",
        normal Normal = N,
        output closure color BSSRDF = 0)
 {
-       if (Falloff == "Gaussian")
+       if (falloff == "Gaussian")
                BSSRDF = Color * bssrdf_gaussian(Normal, Scale * Radius, TextureBlur);
-       else if (Falloff == "Cubic")
+       else if (falloff == "Cubic")
                BSSRDF = Color * bssrdf_cubic(Normal, Scale * Radius, TextureBlur, Sharpness);
        else
                BSSRDF = Color * bssrdf_burley(Normal, Scale * Radius, TextureBlur, Color);
index 29e143ae207ce59599a887afd360345e27b03e11..bacdd593c7c0a7b2885e4b2ad0c9c52a0121ccd0 100644 (file)
@@ -22,7 +22,7 @@
 shader node_voronoi_texture(
        int use_mapping = 0,
        matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
-       string Coloring = "Intensity",
+       string coloring = "Intensity",
        float Scale = 5.0,
        point Vector = P,
        output float Fac = 0.0,
@@ -40,7 +40,7 @@ shader node_voronoi_texture(
        voronoi(p * Scale, 1.0, da, pa);
 
        /* Colored output */
-       if (Coloring == "Intensity") {
+       if (coloring == "Intensity") {
                Fac = fabs(da[0]);
                Color = color(Fac);
        }
index 59f61d3b46a9c968f3e365058143dd587f50c69c..a07742faefc0a449b9155f8b2739e024dc13bae6 100644 (file)
@@ -48,8 +48,8 @@ float wave(point p, string type, string profile, float detail, float distortion,
 shader node_wave_texture(
        int use_mapping = 0,
        matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
-       string Type = "Bands",
-       string Profile = "Sine",
+       string type = "Bands",
+       string profile = "Sine",
        float Scale = 5.0,
        float Distortion = 0.0,
        float Detail = 2.0,
@@ -63,7 +63,7 @@ shader node_wave_texture(
        if (use_mapping)
                p = transform(mapping, p);
 
-       Fac = wave(p * Scale, Type, Profile, Detail, Distortion, DetailScale);
+       Fac = wave(p * Scale, type, profile, Detail, Distortion, DetailScale);
        Color = Fac;
 }
 
index 88397005b49074d8fabd7b613561c170498c9a7f..65512a0105cbf3fc17c85919866d44dbc2fd7839 100644 (file)
@@ -365,8 +365,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                        }
                        break;
                }
-               case CLOSURE_BSDF_DIFFUSE_TOON_ID:
-               case CLOSURE_BSDF_GLOSSY_TOON_ID: {
+               case CLOSURE_BSDF_GLOSSY_TOON_ID:
+#ifdef __CAUSTICS_TRICKS__
+                       if(!kernel_data.integrator.caustics_reflective && (path_flag & PATH_RAY_DIFFUSE))
+                               break;
+#endif
+               case CLOSURE_BSDF_DIFFUSE_TOON_ID: {
                        ShaderClosure *sc = svm_node_closure_get_bsdf(sd, mix_weight);
 
                        if(sc) {
index 92d2b36bbb198687f1680aa71d72c4b7ba311484..3d9ab405849738bd0347274963d1fa2c484b4de5 100644 (file)
@@ -18,15 +18,15 @@ CCL_NAMESPACE_BEGIN
 
 /* Float4 textures on various devices. */
 #if defined(__KERNEL_CPU__)
-#  define TEX_NUM_FLOAT4_IMAGES        TEX_NUM_FLOAT4_IMAGES_CPU
+#  define TEX_NUM_FLOAT4_IMAGES        TEX_NUM_FLOAT4_CPU
 #elif defined(__KERNEL_CUDA__)
 #  if __CUDA_ARCH__ < 300
-#    define TEX_NUM_FLOAT4_IMAGES      TEX_NUM_FLOAT4_IMAGES_CUDA
+#    define TEX_NUM_FLOAT4_IMAGES      TEX_NUM_FLOAT4_CUDA
 #  else
-#    define TEX_NUM_FLOAT4_IMAGES      TEX_NUM_FLOAT4_IMAGES_CUDA_KEPLER
+#    define TEX_NUM_FLOAT4_IMAGES      TEX_NUM_FLOAT4_CUDA_KEPLER
 #  endif
 #else
-#  define TEX_NUM_FLOAT4_IMAGES        TEX_NUM_FLOAT4_IMAGES_OPENCL
+#  define TEX_NUM_FLOAT4_IMAGES        TEX_NUM_FLOAT4_OPENCL
 #endif
 
 #ifdef __KERNEL_OPENCL__
index be87e35326e2e76c7b03366b216d066a35606ab1..e57d22b1b132f6a5fc57f7e68c52a5ccf65c7365 100644 (file)
@@ -343,6 +343,11 @@ typedef enum NodeNormalMapSpace {
        NODE_NORMAL_MAP_BLENDER_WORLD,
 } NodeNormalMapSpace;
 
+typedef enum NodeImageColorSpace {
+       NODE_COLOR_SPACE_NONE  = 0,
+       NODE_COLOR_SPACE_COLOR = 1,
+} NodeImageColorSpace;
+
 typedef enum NodeImageProjection {
        NODE_IMAGE_PROJ_FLAT   = 0,
        NODE_IMAGE_PROJ_BOX    = 1,
@@ -350,6 +355,11 @@ typedef enum NodeImageProjection {
        NODE_IMAGE_PROJ_TUBE   = 3,
 } NodeImageProjection;
 
+typedef enum NodeEnvironmentProjection {
+       NODE_ENVIRONMENT_EQUIRECTANGULAR = 0,
+       NODE_ENVIRONMENT_MIRROR_BALL = 1,
+} NodeEnvironmentProjection;
+
 typedef enum NodeBumpOffset {
        NODE_BUMP_OFFSET_CENTER,
        NODE_BUMP_OFFSET_DX,
index b7de83d89c1d5628e01aeec94b604f2101665a32..71a3cba681150382d407fd3aec610172f8d80741 100644 (file)
@@ -51,13 +51,13 @@ void Attribute::set(ustring name_, TypeDesc type_, AttributeElement element_)
                type == TypeDesc::TypeNormal || type == TypeDesc::TypeMatrix);
 }
 
-void Attribute::reserve(int numverts, int numtris, int numsteps, int numcurves, int numkeys, bool resize)
+void Attribute::resize(int numverts, int numtris, int numsteps, int numcurves, int numkeys, bool reserve_only)
 {
-       if(resize) {
-               buffer.resize(buffer_size(numverts, numtris, numsteps, numcurves, numkeys), 0);
+       if(reserve_only) {
+               buffer.reserve(buffer_size(numverts, numtris, numsteps, numcurves, numkeys));
        }
        else {
-               buffer.reserve(buffer_size(numverts, numtris, numsteps, numcurves, numkeys));
+               buffer.resize(buffer_size(numverts, numtris, numsteps, numcurves, numkeys), 0);
        }
 }
 
@@ -263,7 +263,7 @@ AttributeSet::~AttributeSet()
 {
 }
 
-Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement element, bool resize)
+Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement element)
 {
        Attribute *attr = find(name);
 
@@ -291,9 +291,9 @@ Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement eleme
 
        /* this is weak .. */
        if(triangle_mesh)
-               attr->reserve(triangle_mesh->verts.size(), triangle_mesh->triangles.size(), triangle_mesh->motion_steps, 0, 0, resize);
+               attr->resize(triangle_mesh->verts.size(), triangle_mesh->num_triangles(), triangle_mesh->motion_steps, 0, 0, false);
        if(curve_mesh)
-               attr->reserve(0, 0, curve_mesh->motion_steps, curve_mesh->curves.size(), curve_mesh->curve_keys.size(), resize);
+               attr->resize(0, 0, curve_mesh->motion_steps, curve_mesh->num_curves(), curve_mesh->curve_keys.size(), false);
        
        return attr;
 }
@@ -448,13 +448,13 @@ Attribute *AttributeSet::find(AttributeRequest& req)
                return find(req.std);
 }
 
-void AttributeSet::reserve()
+void AttributeSet::resize(bool reserve_only)
 {
        foreach(Attribute& attr, attributes) {
                if(triangle_mesh)
-                       attr.reserve(triangle_mesh->verts.size(), triangle_mesh->triangles.size(), triangle_mesh->motion_steps, 0, 0, true);
+                       attr.resize(triangle_mesh->verts.size(), triangle_mesh->num_triangles(), triangle_mesh->motion_steps, 0, 0, reserve_only);
                if(curve_mesh)
-                       attr.reserve(0, 0, 0, curve_mesh->curves.size(), curve_mesh->curve_keys.size(), true);
+                       attr.resize(0, 0, 0, curve_mesh->num_curves(), curve_mesh->curve_keys.size(), reserve_only);
        }
 }
 
index 01102d22aaa2d9fb78fd07108fe61e3ef671b902..41b3626afd3a9ea70aaad4bcd6f3379268f52b92 100644 (file)
@@ -58,7 +58,7 @@ public:
        Attribute() {}
        ~Attribute();
        void set(ustring name, TypeDesc type, AttributeElement element);
-       void reserve(int numverts, int numfaces, int numsteps, int numcurves, int numkeys, bool resize);
+       void resize(int numverts, int numfaces, int numsteps, int numcurves, int numkeys, bool reserve_only);
 
        size_t data_sizeof() const;
        size_t element_size(int numverts, int numfaces, int numsteps, int numcurves, int numkeys) const;
@@ -104,7 +104,7 @@ public:
        AttributeSet();
        ~AttributeSet();
 
-       Attribute *add(ustring name, TypeDesc type, AttributeElement element, bool resize = true);
+       Attribute *add(ustring name, TypeDesc type, AttributeElement element);
        Attribute *find(ustring name) const;
        void remove(ustring name);
 
@@ -114,7 +114,7 @@ public:
 
        Attribute *find(AttributeRequest& req);
 
-       void reserve();
+       void resize(bool reserve_only = false);
        void clear();
 };
 
index 6f8d1d1d461ad79d7751a065e5132544f19315e3..20536b74e87d8f8a45f37d3559c3d7d75cb13291 100644 (file)
@@ -116,6 +116,11 @@ void Background::device_free(Device * /*device*/, DeviceScene * /*dscene*/)
 {
 }
 
+bool Background::modified(const Background& background)
+{
+       return !Node::equals(background);
+}
+
 void Background::tag_update(Scene *scene)
 {
        scene->integrator->tag_update(scene);
index 843655b00a14b2b281b19cf561d3241e89a828dc..8029c6a9e80a3f4a92745849e9755b8639fff980 100644 (file)
@@ -50,6 +50,7 @@ public:
        void device_update(Device *device, DeviceScene *dscene, Scene *scene);
        void device_free(Device *device, DeviceScene *dscene);
 
+       bool modified(const Background& background);
        void tag_update(Scene *scene);
 };
 
index 5bf5e5113ef8798c8e2f2dc13890f5409a6f4e08..13310a61761b4d645a3e3bba813b5e792a67b8bc 100644 (file)
@@ -177,7 +177,7 @@ bool BakeManager::bake(Device *device, DeviceScene *dscene, Scene *scene, Progre
 
                device->mem_alloc(d_input, MEM_READ_ONLY);
                device->mem_copy_to(d_input);
-               device->mem_alloc(d_output, MEM_WRITE_ONLY);
+               device->mem_alloc(d_output, MEM_READ_WRITE);
 
                DeviceTask task(DeviceTask::SHADER);
                task.shader_input = d_input.device_pointer;
index d992cac531273c3861d47c64a616b2c3ab329d11..2310798be2ec292527fbf160eb52ccdd69039f4a 100644 (file)
 CCL_NAMESPACE_BEGIN
 
 static float shutter_curve_eval(float x,
-                                float shutter_curve[RAMP_TABLE_SIZE])
+                                array<float>& shutter_curve)
 {
-       x *= RAMP_TABLE_SIZE;
+       if (shutter_curve.size() == 0)
+               return 1.0f;
+
+       x *= shutter_curve.size();
        int index = (int)x;
        float frac = x - index;
-       if(index < RAMP_TABLE_SIZE - 1) {
+       if(index < shutter_curve.size() - 1) {
                return lerp(shutter_curve[index], shutter_curve[index + 1], frac);
        }
        else {
-               return shutter_curve[RAMP_TABLE_SIZE - 1];
+               return shutter_curve[shutter_curve.size() - 1];
        }
 }
 
+NODE_DEFINE(Camera)
+{
+       NodeType* type = NodeType::add("camera", create);
+
+       SOCKET_FLOAT(shuttertime, "Shutter Time", 1.0f);
+
+       static NodeEnum motion_position_enum;
+       motion_position_enum.insert("start", MOTION_POSITION_START);
+       motion_position_enum.insert("center", MOTION_POSITION_CENTER);
+       motion_position_enum.insert("end", MOTION_POSITION_END);
+       SOCKET_ENUM(motion_position, "Motion Position", motion_position_enum, MOTION_POSITION_CENTER);
+
+       static NodeEnum rolling_shutter_type_enum;
+       rolling_shutter_type_enum.insert("none", ROLLING_SHUTTER_NONE);
+       rolling_shutter_type_enum.insert("top", ROLLING_SHUTTER_TOP);
+       SOCKET_ENUM(rolling_shutter_type, "Rolling Shutter Type", rolling_shutter_type_enum,  ROLLING_SHUTTER_NONE);
+       SOCKET_FLOAT(rolling_shutter_duration, "Rolling Shutter Duration", 0.1f);
+
+       SOCKET_FLOAT_ARRAY(shutter_curve, "Shutter Curve", array<float>());
+
+       SOCKET_FLOAT(aperturesize, "Aperture Size", 0.0f);
+       SOCKET_FLOAT(focaldistance, "Focal Distance", 10.0f);
+       SOCKET_INT(blades, "Blades", 0);
+       SOCKET_FLOAT(bladesrotation, "Blades Rotation", 0.0f);
+
+       SOCKET_TRANSFORM(matrix, "Matrix", transform_identity());
+
+       SOCKET_FLOAT(aperture_ratio, "Aperture Ratio", 1.0f);
+
+       static NodeEnum type_enum;
+       type_enum.insert("perspective", CAMERA_PERSPECTIVE);
+       type_enum.insert("orthograph", CAMERA_ORTHOGRAPHIC);
+       type_enum.insert("panorama", CAMERA_PANORAMA);
+       SOCKET_ENUM(type, "Type", type_enum, CAMERA_PERSPECTIVE);
+
+       static NodeEnum panorama_type_enum;
+       panorama_type_enum.insert("equirectangular", PANORAMA_EQUIRECTANGULAR);
+       panorama_type_enum.insert("mirrorball", PANORAMA_MIRRORBALL);
+       panorama_type_enum.insert("fisheye_equidistant", PANORAMA_FISHEYE_EQUIDISTANT);
+       panorama_type_enum.insert("fisheye_equisolid", PANORAMA_FISHEYE_EQUISOLID);
+       SOCKET_ENUM(panorama_type, "Panorama Type", panorama_type_enum, PANORAMA_EQUIRECTANGULAR);
+
+       SOCKET_FLOAT(fisheye_fov, "Fisheye FOV", M_PI_F);
+       SOCKET_FLOAT(fisheye_lens, "Fisheye Lens", 10.5f);
+       SOCKET_FLOAT(latitude_min, "Latitude Min", -M_PI_2_F);
+       SOCKET_FLOAT(latitude_max, "Latitude Max", M_PI_2_F);
+       SOCKET_FLOAT(longitude_min, "Longitude Min", -M_PI_F);
+       SOCKET_FLOAT(longitude_max, "Longitude Max", M_PI_F);
+       SOCKET_FLOAT(fov, "FOV", M_PI_4_F);
+       SOCKET_FLOAT(fov_pre, "FOV Pre", M_PI_4_F);
+       SOCKET_FLOAT(fov_post, "FOV Post", M_PI_4_F);
+
+       static NodeEnum stereo_eye_enum;
+       stereo_eye_enum.insert("none", STEREO_NONE);
+       stereo_eye_enum.insert("left", STEREO_LEFT);
+       stereo_eye_enum.insert("right", STEREO_RIGHT);
+       SOCKET_ENUM(stereo_eye, "Stereo Eye", stereo_eye_enum, STEREO_NONE);
+
+       SOCKET_FLOAT(interocular_distance, "Interocular Distance", 0.065f);
+       SOCKET_FLOAT(convergence_distance, "Convergence Distance", 30.0f * 0.065f);
+
+       SOCKET_BOOLEAN(use_pole_merge, "Use Pole Merge", false);
+       SOCKET_FLOAT(pole_merge_angle_from, "Pole Merge Angle From",  60.0f * M_PI_F / 180.0f);
+       SOCKET_FLOAT(pole_merge_angle_to, "Pole Merge Angle To", 75.0f * M_PI_F / 180.0f);
+
+       SOCKET_FLOAT(sensorwidth, "Sensor Width", 0.036f);
+       SOCKET_FLOAT(sensorheight, "Sensor Height", 0.024f);
+
+       SOCKET_FLOAT(nearclip, "Near Clip", 1e-5f);
+       SOCKET_FLOAT(farclip, "Far Clip", 1e5f);
+
+       SOCKET_FLOAT(viewplane.left, "Viewplane Left", 0);
+       SOCKET_FLOAT(viewplane.right, "Viewplane Right", 0);
+       SOCKET_FLOAT(viewplane.bottom, "Viewplane Bottom", 0);
+       SOCKET_FLOAT(viewplane.top, "Viewplane Top", 0);
+
+       SOCKET_FLOAT(border.left, "Border Left", 0);
+       SOCKET_FLOAT(border.right, "Border Right", 0);
+       SOCKET_FLOAT(border.bottom, "Border Bottom", 0);
+       SOCKET_FLOAT(border.top, "Border Top", 0);
+
+       return type;
+}
+
 Camera::Camera()
+: Node(node_type)
 {
-       shuttertime = 1.0f;
-       motion_position = MOTION_POSITION_CENTER;
        shutter_table_offset = TABLE_OFFSET_INVALID;
 
-       aperturesize = 0.0f;
-       focaldistance = 10.0f;
-       blades = 0;
-       bladesrotation = 0.0f;
-
-       matrix = transform_identity();
+       width = 1024;
+       height = 512;
+       resolution = 1;
 
        motion.pre = transform_identity();
        motion.post = transform_identity();
        use_motion = false;
        use_perspective_motion = false;
 
-       aperture_ratio = 1.0f;
-
-       type = CAMERA_PERSPECTIVE;
-       panorama_type = PANORAMA_EQUIRECTANGULAR;
-       fisheye_fov = M_PI_F;
-       fisheye_lens = 10.5f;
-       latitude_min = -M_PI_2_F;
-       latitude_max = M_PI_2_F;
-       longitude_min = -M_PI_F;
-       longitude_max = M_PI_F;
-       fov = M_PI_4_F;
-       fov_pre = fov_post = fov;
-       stereo_eye = STEREO_NONE;
-       interocular_distance = 0.065f;
-       convergence_distance = 30.0f * 0.065f;
-       use_pole_merge = false;
-       pole_merge_angle_from = 60.0f * M_PI_F / 180.0f;
-       pole_merge_angle_to = 75.0f * M_PI_F / 180.0f;
-
-       sensorwidth = 0.036f;
-       sensorheight = 0.024f;
-
-       nearclip = 1e-5f;
-       farclip = 1e5f;
-
-       width = 1024;
-       height = 512;
-       resolution = 1;
+       shutter_curve.resize(RAMP_TABLE_SIZE);
+       for(int i = 0; i < shutter_curve.size(); ++i) {
+               shutter_curve[i] = 1.0f;
+       }
 
-       viewplane.left = -((float)width/(float)height);
-       viewplane.right = (float)width/(float)height;
-       viewplane.bottom = -1.0f;
-       viewplane.top = 1.0f;
+       compute_auto_viewplane();
 
        screentoworld = transform_identity();
        rastertoworld = transform_identity();
@@ -109,16 +165,6 @@ Camera::Camera()
        need_device_update = true;
        need_flags_update = true;
        previous_need_motion = -1;
-
-       /* Initialize shutter curve. */
-       const int num_shutter_points = sizeof(shutter_curve) / sizeof(*shutter_curve);
-       for(int i = 0; i < num_shutter_points; ++i) {
-               shutter_curve[i] = 1.0f;
-       }
-
-       /* Initialize rolling shutter effect. */
-       rolling_shutter_type = ROLLING_SHUTTER_NONE;
-       rolling_shutter_duration = 0.1f;
 }
 
 Camera::~Camera()
@@ -438,38 +484,14 @@ void Camera::device_free(Device * /*device*/,
 
 bool Camera::modified(const Camera& cam)
 {
-       return !((shuttertime == cam.shuttertime) &&
-               (aperturesize == cam.aperturesize) &&
-               (blades == cam.blades) &&
-               (bladesrotation == cam.bladesrotation) &&
-               (focaldistance == cam.focaldistance) &&
-               (type == cam.type) &&
-               (fov == cam.fov) &&
-               (nearclip == cam.nearclip) &&
-               (farclip == cam.farclip) &&
-               (sensorwidth == cam.sensorwidth) &&
-               (sensorheight == cam.sensorheight) &&
-               // modified for progressive render
-               // (width == cam.width) &&
-               // (height == cam.height) &&
-               (viewplane == cam.viewplane) &&
-               (border == cam.border) &&
-               (matrix == cam.matrix) &&
-               (aperture_ratio == cam.aperture_ratio) &&
-               (panorama_type == cam.panorama_type) &&
-               (fisheye_fov == cam.fisheye_fov) &&
-               (fisheye_lens == cam.fisheye_lens) &&
-               (latitude_min == cam.latitude_min) &&
-               (latitude_max == cam.latitude_max) &&
-               (longitude_min == cam.longitude_min) &&
-               (longitude_max == cam.longitude_max) &&
-               (stereo_eye == cam.stereo_eye));
+       return !Node::equals(cam);
 }
 
 bool Camera::motion_modified(const Camera& cam)
 {
        return !((motion == cam.motion) &&
-               (use_motion == cam.use_motion));
+                (use_motion == cam.use_motion) &&
+                (use_perspective_motion == cam.use_perspective_motion));
 }
 
 void Camera::tag_update()
index 57b9960e70b10af5ea48c56be68c95d406b070d6..141ef9cccef078d03c1448e4006c3298c0b215a1 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "kernel_types.h"
 
+#include "node.h"
+
 #include "util_boundbox.h"
 #include "util_transform.h"
 #include "util_types.h"
@@ -35,8 +37,10 @@ class Scene;
  * Renderman, and Blender after remapping.
  */
 
-class Camera {
+class Camera : public Node {
 public:
+       NODE_DECLARE;
+
        /* Specifies an offset for the shutter's time interval. */
        enum MotionPosition {
                /* Shutter opens at the current frame. */
@@ -69,7 +73,7 @@ public:
        /* motion blur */
        float shuttertime;
        MotionPosition motion_position;
-       float shutter_curve[RAMP_TABLE_SIZE];
+       array<float> shutter_curve;
        size_t shutter_table_offset;
 
        /* ** Rolling shutter effect. ** */
index 3d9b4e1f347d8360d5d04c57f79b2305df4d00cd..e41967eebf5d9e88866a6402c4f4753112f90fd1 100644 (file)
@@ -63,23 +63,23 @@ public:
        ParticleCurveData();
        ~ParticleCurveData();
 
-       vector<int> psys_firstcurve;
-       vector<int> psys_curvenum;
-       vector<int> psys_shader;
-
-       vector<float> psys_rootradius;
-       vector<float> psys_tipradius;
-       vector<float> psys_shape;
-       vector<bool> psys_closetip;
-
-       vector<int> curve_firstkey;
-       vector<int> curve_keynum;
-       vector<float> curve_length;
-       vector<float3> curve_uv;
-       vector<float3> curve_vcol;
-
-       vector<float3> curvekey_co;
-       vector<float> curvekey_time;
+       array<int> psys_firstcurve;
+       array<int> psys_curvenum;
+       array<int> psys_shader;
+
+       array<float> psys_rootradius;
+       array<float> psys_tipradius;
+       array<float> psys_shape;
+       array<bool> psys_closetip;
+
+       array<int> curve_firstkey;
+       array<int> curve_keynum;
+       array<float> curve_length;
+       array<float3> curve_uv;
+       array<float3> curve_vcol;
+
+       array<float3> curvekey_co;
+       array<float> curvekey_time;
 };
 
 /* HairSystem Manager */
index 12dce6ad999dbc3cba973c4b655d70b8c6fdf99a..e10a938e1eb2ed085ed7d1f60039444ef1f903ef 100644 (file)
@@ -465,7 +465,7 @@ void Film::device_free(Device * /*device*/,
 
 bool Film::modified(const Film& film)
 {
-       return Node::modified(film) || !Pass::equals(passes, film.passes);
+       return !Node::equals(film) || !Pass::equals(passes, film.passes);
 }
 
 void Film::tag_passes_update(Scene *scene, const array<Pass>& passes_)
index 24e4c9f33d58fc41a393d350edfd61d91457eed5..29c0eec9b977658b70c9fd95590406873448a831 100644 (file)
@@ -66,7 +66,7 @@ bool check_node_inputs_equals(const ShaderNode *node_a,
                            *input_b = node_b->inputs[i];
                if(input_a->link == NULL && input_b->link == NULL) {
                        /* Unconnected inputs are expected to have the same value. */
-                       if(input_a->value != input_b->value) {
+                       if(input_a->value() != input_b->value()) {
                                return false;
                        }
                }
@@ -90,23 +90,22 @@ bool check_node_inputs_equals(const ShaderNode *node_a,
 
 /* Input and Output */
 
-ShaderInput::ShaderInput(ShaderNode *parent_, const char *name_, ShaderSocketType type_)
+ShaderInput::ShaderInput(ShaderNode *parent_, const char *name, SocketType::Type type)
 {
        parent = parent_;
-       name = name_;
-       type = type_;
+       name_ = name;
+       type_ = type;
        link = NULL;
-       value = make_float3(0.0f, 0.0f, 0.0f);
+       value_ = make_float3(0.0f, 0.0f, 0.0f);
        stack_offset = SVM_STACK_INVALID;
-       default_value = NONE;
-       usage = USE_ALL;
+       flags_ = 0;
 }
 
-ShaderOutput::ShaderOutput(ShaderNode *parent_, const char *name_, ShaderSocketType type_)
+ShaderOutput::ShaderOutput(ShaderNode *parent_, const char *name, SocketType::Type type)
 {
        parent = parent_;
-       name = name_;
-       type = type_;
+       name_ = name;
+       type_ = type;
        stack_offset = SVM_STACK_INVALID;
 }
 
@@ -132,7 +131,7 @@ ShaderNode::~ShaderNode()
 ShaderInput *ShaderNode::input(const char *name)
 {
        foreach(ShaderInput *socket, inputs) {
-               if(strcmp(socket->name, name) == 0)
+               if(socket->name() == name)
                        return socket;
        }
 
@@ -142,39 +141,50 @@ ShaderInput *ShaderNode::input(const char *name)
 ShaderOutput *ShaderNode::output(const char *name)
 {
        foreach(ShaderOutput *socket, outputs)
-               if(strcmp(socket->name, name) == 0)
+               if(socket->name() == name)
                        return socket;
 
        return NULL;
 }
 
-ShaderInput *ShaderNode::add_input(const char *name, ShaderSocketType type, float value, int usage)
+ShaderInput *ShaderNode::input(ustring name)
 {
-       ShaderInput *input = new ShaderInput(this, name, type);
-       input->value.x = value;
-       input->usage = usage;
-       inputs.push_back(input);
-       return input;
+       foreach(ShaderInput *socket, inputs) {
+               if(socket->name() == name)
+                       return socket;
+       }
+
+       return NULL;
 }
 
-ShaderInput *ShaderNode::add_input(const char *name, ShaderSocketType type, float3 value, int usage)
+ShaderOutput *ShaderNode::output(ustring name)
+{
+       foreach(ShaderOutput *socket, outputs)
+               if(socket->name() == name)
+                       return socket;
+
+       return NULL;
+}
+
+ShaderInput *ShaderNode::add_input(const char *name, SocketType::Type type, float value, int flags)
 {
        ShaderInput *input = new ShaderInput(this, name, type);
-       input->value = value;
-       input->usage = usage;
+       input->value_.x = value;
+       input->flags_ = flags;
        inputs.push_back(input);
        return input;
 }
 
-ShaderInput *ShaderNode::add_input(const char *name, ShaderSocketType type, ShaderInput::DefaultValue value, int usage)
+ShaderInput *ShaderNode::add_input(const char *name, SocketType::Type type, float3 value, int flags)
 {
-       ShaderInput *input = add_input(name, type);
-       input->default_value = value;
-       input->usage = usage;
+       ShaderInput *input = new ShaderInput(this, name, type);
+       input->value_ = value;
+       input->flags_ = flags;
+       inputs.push_back(input);
        return input;
 }
 
-ShaderOutput *ShaderNode::add_output(const char *name, ShaderSocketType type)
+ShaderOutput *ShaderNode::add_output(const char *name, SocketType::Type type)
 {
        ShaderOutput *output = new ShaderOutput(this, name, type);
        outputs.push_back(output);
@@ -185,13 +195,13 @@ void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
 {
        foreach(ShaderInput *input, inputs) {
                if(!input->link) {
-                       if(input->default_value == ShaderInput::TEXTURE_GENERATED) {
+                       if(input->flags() & SocketType::LINK_TEXTURE_GENERATED) {
                                if(shader->has_surface)
                                        attributes->add(ATTR_STD_GENERATED);
                                if(shader->has_volume)
                                        attributes->add(ATTR_STD_GENERATED_TRANSFORM);
                        }
-                       else if(input->default_value == ShaderInput::TEXTURE_UV) {
+                       else if(input->flags() & SocketType::LINK_TEXTURE_UV) {
                                if(shader->has_surface)
                                        attributes->add(ATTR_STD_UV);
                        }
@@ -256,18 +266,18 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
                return;
        }
 
-       if(from->type != to->type) {
+       if(from->type() != to->type()) {
                /* for closures we can't do automatic conversion */
-               if(from->type == SHADER_SOCKET_CLOSURE || to->type == SHADER_SOCKET_CLOSURE) {
+               if(from->type() == SocketType::CLOSURE || to->type() == SocketType::CLOSURE) {
                        fprintf(stderr, "Cycles shader graph connect: can only connect closure to closure "
                                "(%s.%s to %s.%s).\n",
-                               from->parent->name.c_str(), from->name,
-                               to->parent->name.c_str(), to->name);
+                               from->parent->name.c_str(), from->name().c_str(),
+                               to->parent->name.c_str(), to->name().c_str());
                        return;
                }
 
                /* add automatic conversion node in case of type mismatch */
-               ShaderNode *convert = add(new ConvertNode(from->type, to->type, true));
+               ShaderNode *convert = add(new ConvertNode(from->type(), to->type(), true));
 
                connect(from, convert->inputs[0]);
                connect(convert->outputs[0], to);
@@ -401,8 +411,8 @@ void ShaderGraph::copy_nodes(ShaderNodeSet& nodes, ShaderNodeMap& nnodemap)
                                /* find new input and output */
                                ShaderNode *nfrom = nnodemap[input->link->parent];
                                ShaderNode *nto = nnodemap[input->parent];
-                               ShaderOutput *noutput = nfrom->output(input->link->name);
-                               ShaderInput *ninput = nto->input(input->name);
+                               ShaderOutput *noutput = nfrom->output(input->link->name());
+                               ShaderInput *ninput = nto->input(input->name());
 
                                /* connect */
                                connect(noutput, ninput);
@@ -447,10 +457,10 @@ void ShaderGraph::remove_proxy_nodes()
                                                vector<ShaderInput*> links = tonode->outputs[0]->links;
 
                                                foreach(ShaderInput *autoin, links) {
-                                                       if(autoin->default_value == ShaderInput::NONE)
-                                                               all_links_removed = false;
-                                                       else
+                                                       if(autoin->flags() & SocketType::DEFAULT_LINK_MASK)
                                                                disconnect(autoin);
+                                                       else
+                                                               all_links_removed = false;
                                                }
 
                                                if(all_links_removed)
@@ -460,8 +470,8 @@ void ShaderGraph::remove_proxy_nodes()
                                        disconnect(to);
 
                                        /* transfer the default input value to the target socket */
-                                       to->set(input->value);
-                                       to->set(input->value_string);
+                                       to->set(input->value());
+                                       to->set(input->value_string());
                                }
                        }
 
@@ -527,14 +537,13 @@ void ShaderGraph::constant_fold()
                                }
                        }
                        /* Optimize current node. */
-                       float3 optimized_value = make_float3(0.0f, 0.0f, 0.0f);
-                       if(node->constant_fold(this, output, &optimized_value)) {
-                               /* Apply optimized value to connected sockets. */
+                       if(node->constant_fold(this, output, output->links[0])) {
+                               /* Apply optimized value to other connected sockets and disconnect. */
                                vector<ShaderInput*> links(output->links);
-                               foreach(ShaderInput *input, links) {
-                                       /* Assign value and disconnect the optimizedinput. */
-                                       input->value = optimized_value;
-                                       disconnect(input);
+                               for(size_t i = 0; i < links.size(); i++) {
+                                       if(i > 0)
+                                               links[i]->set(links[0]->value());
+                                       disconnect(links[i]);
                                }
                        }
                }
@@ -706,38 +715,38 @@ void ShaderGraph::default_inputs(bool do_osl)
 
        foreach(ShaderNode *node, nodes) {
                foreach(ShaderInput *input, node->inputs) {
-                       if(!input->link && ((input->usage & ShaderInput::USE_SVM) || do_osl)) {
-                               if(input->default_value == ShaderInput::TEXTURE_GENERATED) {
+                       if(!input->link && (!(input->flags() & SocketType::OSL_INTERNAL) || do_os