Merging r46111 through r46136 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 1 May 2012 09:17:22 +0000 (09:17 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 1 May 2012 09:17:22 +0000 (09:17 +0000)
267 files changed:
CMakeLists.txt
intern/cycles/app/cycles_xml.cpp
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_camera.cpp
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/blender/blender_util.h
intern/cycles/kernel/kernel_bvh.h
intern/cycles/kernel/kernel_camera.h
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_light.h
intern/cycles/kernel/kernel_object.h
intern/cycles/kernel/kernel_passes.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/kernel_triangle.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/svm/svm_tex_coord.h
intern/cycles/render/CMakeLists.txt
intern/cycles/render/attribute.cpp
intern/cycles/render/attribute.h
intern/cycles/render/buffers.cpp
intern/cycles/render/camera.cpp
intern/cycles/render/camera.h
intern/cycles/render/film.cpp
intern/cycles/render/film.h
intern/cycles/render/graph.cpp
intern/cycles/render/integrator.cpp
intern/cycles/render/integrator.h
intern/cycles/render/mesh.cpp
intern/cycles/render/mesh.h
intern/cycles/render/mesh_displace.cpp
intern/cycles/render/nodes.cpp
intern/cycles/render/object.cpp
intern/cycles/render/object.h
intern/cycles/render/scene.cpp
intern/cycles/render/scene.h
intern/cycles/render/shader.cpp
intern/cycles/render/shader.h
intern/cycles/render/svm.cpp
intern/cycles/render/svm.h
intern/cycles/subd/subd_dice.cpp
intern/cycles/util/util_math.h
intern/cycles/util/util_transform.cpp
intern/cycles/util/util_transform.h
release/scripts/startup/bl_ui/properties_data_lamp.py
release/scripts/startup/bl_ui/space_info.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/avi/intern/avi.c
source/blender/avi/intern/avirgb.c
source/blender/avi/intern/codecs.c
source/blender/avi/intern/endian.c
source/blender/avi/intern/endian.h
source/blender/avi/intern/mjpeg.c
source/blender/avi/intern/options.c
source/blender/avi/intern/rgb32.c
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_customdata.h
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/BKE_dynamicpaint.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_utildefines.h
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/booleanops_mesh.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/screen.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenkernel/intern/writeframeserver.c
source/blender/blenlib/BLI_memarena.h
source/blender/blenlib/BLI_threads.h
source/blender/blenlib/PIL_time.h
source/blender/blenlib/intern/BLI_args.c
source/blender/blenlib/intern/bpath.c
source/blender/blenlib/intern/cpu.c
source/blender/blenlib/intern/jitter.c
source/blender/blenlib/intern/noise.c
source/blender/blenlib/intern/string_cursor_utf8.c
source/blender/blenlib/intern/threads.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/blenpluginapi/documentation.h
source/blender/blenpluginapi/externdef.h
source/blender/blenpluginapi/floatpatch.h
source/blender/blenpluginapi/iff.h
source/blender/blenpluginapi/plugin.h
source/blender/blenpluginapi/util.h
source/blender/bmesh/intern/bmesh_interp.c
source/blender/bmesh/intern/bmesh_interp.h
source/blender/collada/AnimationImporter.cpp
source/blender/collada/AnimationImporter.h
source/blender/collada/DocumentImporter.cpp
source/blender/collada/DocumentImporter.h
source/blender/collada/MeshImporter.cpp
source/blender/editors/animation/keyframing.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/editarmature_retarget.c
source/blender/editors/armature/poseUtils.c
source/blender/editors/armature/poseobject.c
source/blender/editors/curve/editcurve.c
source/blender/editors/datafiles/Bfont.c
source/blender/editors/datafiles/startup.blend.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/include/ED_fluidsim.h
source/blender/editors/include/ED_particle.h
source/blender/editors/include/ED_physics.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_utils.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/mesh/mesh_navmesh.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_bake.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_group.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_select.c
source/blender/editors/object/object_transform.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/render/render_preview.c
source/blender/editors/render/render_shading.c
source/blender/editors/sculpt_paint/paint_hide.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_undo.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_clip/clip_editor.c
source/blender/editors/space_clip/clip_graph_ops.c
source/blender/editors/space_clip/clip_intern.h
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_info/info_stats.c
source/blender/editors/space_logic/logic_buttons.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_select.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/editors/uvedit/uvedit_parametrizer.c
source/blender/editors/uvedit/uvedit_parametrizer.h
source/blender/editors/uvedit/uvedit_smart_stitch.c
source/blender/gpu/CMakeLists.txt
source/blender/gpu/GPU_extensions.h
source/blender/gpu/GPU_material.h
source/blender/gpu/SConscript
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/gpu/intern/gpu_material.c
source/blender/gpu/intern/gpu_shader_material.glsl.c [deleted file]
source/blender/gpu/intern/gpu_shader_vertex.glsl.c [deleted file]
source/blender/gpu/shaders/gpu_shader_material.glsl [moved from source/blender/gpu/intern/gpu_shader_material.glsl with 97% similarity]
source/blender/gpu/shaders/gpu_shader_material.glsl.c [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl.c [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl.c [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_vertex.glsl [moved from source/blender/gpu/intern/gpu_shader_vertex.glsl with 100% similarity]
source/blender/gpu/shaders/gpu_shader_vertex.glsl.c [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl.c [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl [new file with mode: 0644]
source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl.c [new file with mode: 0644]
source/blender/imbuf/IMB_imbuf_types.h
source/blender/imbuf/intern/IMB_allocimbuf.h
source/blender/imbuf/intern/IMB_anim.h
source/blender/imbuf/intern/IMB_filter.h
source/blender/imbuf/intern/cineon/cineonfile.h
source/blender/imbuf/intern/cineon/cineonlib.c
source/blender/imbuf/intern/cineon/cineonlib.h
source/blender/imbuf/intern/cineon/dpxfile.h
source/blender/imbuf/intern/cineon/dpxlib.c
source/blender/imbuf/intern/cineon/dpxlib.h
source/blender/imbuf/intern/cineon/logImageCore.c
source/blender/imbuf/intern/cineon/logImageCore.h
source/blender/imbuf/intern/cineon/logImageLib.c
source/blender/imbuf/intern/cineon/logImageLib.h
source/blender/imbuf/intern/cineon/logmemfile.c
source/blender/imbuf/intern/cineon/logmemfile.h
source/blender/imbuf/intern/filter.c
source/blender/imbuf/intern/imageprocess.c
source/blender/imbuf/intern/imbuf.h
source/blender/imbuf/intern/imbuf_cocoa.m
source/blender/imbuf/intern/tiff.c
source/blender/makesdna/DNA_boid_types.h
source/blender/makesdna/DNA_group_types.h
source/blender/makesdna/DNA_lamp_types.h
source/blender/makesdna/DNA_object_fluidsim.h
source/blender/makesdna/DNA_object_force.h
source/blender/makesdna/DNA_property_types.h
source/blender/makesdna/intern/dna_genfile.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_image_api.c
source/blender/makesrna/intern/rna_lamp.c
source/blender/makesrna/intern/rna_material_api.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_pose_api.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/nodes/composite/nodes/node_composite_chromaMatte.c
source/blender/nodes/composite/nodes/node_composite_diffMatte.c
source/blender/nodes/composite/nodes/node_composite_distanceMatte.c
source/blender/python/bmesh/bmesh_py_types_customdata.c
source/blender/python/bmesh/bmesh_py_types_meshdata.c
source/blender/python/bmesh/bmesh_py_types_meshdata.h
source/blender/python/intern/bpy_rna.c
source/blender/python/mathutils/mathutils.h
source/blender/python/mathutils/mathutils_Color.c
source/blender/python/mathutils/mathutils_Color.h
source/blender/python/mathutils/mathutils_Euler.c
source/blender/python/mathutils/mathutils_Euler.h
source/blender/python/mathutils/mathutils_Matrix.c
source/blender/python/mathutils/mathutils_Quaternion.h
source/blender/python/mathutils/mathutils_Vector.h
source/blender/python/mathutils/mathutils_geometry.c
source/blender/python/mathutils/mathutils_geometry.h
source/blender/quicktime/apple/quicktime_export.c
source/blender/quicktime/apple/quicktime_import.c
source/blender/render/intern/include/gammaCorrectionTables.h
source/blender/render/intern/include/initrender.h
source/blender/render/intern/include/occlusion.h
source/blender/render/intern/include/rendercore.h
source/blender/render/intern/include/shadbuf.h
source/blender/render/intern/include/texture.h
source/blender/render/intern/raytrace/rayobject_internal.h
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/external_engine.c
source/blender/render/intern/source/gammaCorrectionTables.c
source/blender/render/intern/source/imagetexture.c
source/blender/render/intern/source/occlusion.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pixelblending.c
source/blender/render/intern/source/render_result.c
source/blender/render/intern/source/sss.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c
source/gameengine/GameLogic/SCA_ActuatorSensor.h
source/gameengine/Ketsji/KX_Light.cpp
source/gameengine/Ketsji/KX_Light.h
source/gameengine/VideoTexture/Texture.cpp

index e8bdc5375fca46f344a59723082136ea8f0fb021..d91212fa47d14531ddb1974f91cab66fab324eb7 100644 (file)
@@ -304,7 +304,7 @@ endif()
 #-----------------------------------------------------------------------------
 # Check for conflicting/unsupported configurations
 
-if(NOT WITH_BLENDER AND NOT WITH_PLAYER)
+if(NOT WITH_BLENDER AND NOT WITH_PLAYER AND NOT WITH_CYCLES_TEST)
        message(FATAL_ERROR "At least one of WITH_BLENDER or WITH_PLAYER must be enabled, nothing to do!")
 endif()
 
@@ -1618,6 +1618,7 @@ if(WITH_PYTHON)
                if(NOT EXISTS "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy")
                        message(WARNING "Numpy path '${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy' is missing, "
                                                        "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
+                       set(WITH_PYTHON_INSTALL_NUMPY OFF)
                endif()
        endif()
 endif()
index b954ff45e2781db68001b58b351df06567e81adc..82f1338d86bd9a05213fda7198a417affebe26e5 100644 (file)
@@ -284,8 +284,7 @@ static void xml_read_camera(const XMLReadState& state, pugi::xml_node node)
        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->shutteropen, node, "shutteropen");
-       xml_read_float(&cam->shutterclose, node, "shutterclose");
+       xml_read_float(&cam->shuttertime, node, "shuttertime");
 
        if(xml_equal_string(node, "type", "orthographic"))
                cam->type = CAMERA_ORTHOGRAPHIC;
@@ -705,7 +704,7 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
        }
 
        /* temporary for test compatibility */
-       mesh->attributes.remove(Attribute::STD_VERTEX_NORMAL);
+       mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
 }
 
 /* Patch */
@@ -766,7 +765,7 @@ static void xml_read_patch(const XMLReadState& state, pugi::xml_node node)
                delete patch;
 
                /* temporary for test compatibility */
-               mesh->attributes.remove(Attribute::STD_VERTEX_NORMAL);
+               mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
        }
 }
 
index 41591085d0aeb2ff9dd1f08d11c204555f24b853..4a60a329e2b26f05a1fdc022ec66ebd6baa93b4e 100644 (file)
 bl_info = {
     "name": "Cycles Render Engine",
     "author": "",
-    "version": (0, 0),
-    "blender": (2, 6, 2),
+    "blender": (2, 6, 3),
     "location": "Info header, render engine menu",
-    "description": "Cycles Render Engine integration.",
+    "description": "Cycles Render Engine integration",
     "warning": "",
     "wiki_url": "http://wiki.blender.org/index.php/Dev:2.6/Source/Render/Cycles",
     "tracker_url": "",
index 0ed08589327a77a90a25ff6385887704fb95a474..8480b0a525611fd684b0531a2c1fc52ec90c3cea 100644 (file)
@@ -94,6 +94,29 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
         col.prop(cscene, "blur_glossy")
 
 
+class CyclesRender_PT_motion_blur(CyclesButtonsPanel, Panel):
+    bl_label = "Motion Blur"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        return False
+
+    def draw_header(self, context):
+        rd = context.scene.render
+
+        self.layout.prop(rd, "use_motion_blur", text="")
+
+    def draw(self, context):
+        layout = self.layout
+
+        rd = context.scene.render
+        layout.active = rd.use_motion_blur
+
+        row = layout.row()
+        row.prop(rd, "motion_blur_shutter")
+
+
 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
     bl_label = "Film"
 
@@ -202,10 +225,10 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
         col.prop(rl, "use_pass_combined")
         col.prop(rl, "use_pass_z")
         col.prop(rl, "use_pass_normal")
+        col.prop(rl, "use_pass_vector")
+        col.prop(rl, "use_pass_uv")
         col.prop(rl, "use_pass_object_index")
         col.prop(rl, "use_pass_material_index")
-        col.prop(rl, "use_pass_emit")
-        col.prop(rl, "use_pass_environment")
         col.prop(rl, "use_pass_ambient_occlusion")
         col.prop(rl, "use_pass_shadow")
 
@@ -227,6 +250,9 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
         row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True)
         row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True)
 
+        col.prop(rl, "use_pass_emit", text="Emission")
+        col.prop(rl, "use_pass_environment")
+
 
 class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
     bl_label = "Post Processing"
index a21b22bc35a62a6e08754ae7b3c605d24efef1a4..55a32d8fc1064e11f7b3f70e729b5321abc5eddb 100644 (file)
@@ -35,6 +35,7 @@ struct BlenderCamera {
        float ortho_scale;
 
        float lens;
+       float shuttertime;
 
        float aperturesize;
        uint apertureblades;
@@ -64,6 +65,7 @@ static void blender_camera_init(BlenderCamera *bcam)
        bcam->sensor_width = 32.0f;
        bcam->sensor_height = 18.0f;
        bcam->sensor_fit = BlenderCamera::AUTO;
+       bcam->shuttertime = 1.0f;
 }
 
 static float blender_camera_focal_distance(BL::Object b_ob, BL::Camera b_camera)
@@ -132,6 +134,28 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::Object b_ob)
        }
 }
 
+static Transform blender_camera_matrix(const Transform& tfm, CameraType type)
+{
+       Transform result;
+
+       if(type == CAMERA_ENVIRONMENT) {
+               /* make it so environment camera needs to be pointed in the direction
+                  of the positive x-axis to match an environment texture, this way
+                  it is looking at the center of the texture */
+               result = tfm *
+                       make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
+                                       0.0f,  0.0f, 1.0f, 0.0f,
+                                      -1.0f,  0.0f, 0.0f, 0.0f,
+                                       0.0f,  0.0f, 0.0f, 1.0f);
+       }
+       else {
+               /* note the blender camera points along the negative z-axis */
+               result = tfm * transform_scale(1.0f, 1.0f, -1.0f);
+       }
+
+       return transform_clear_scale(result);
+}
+
 static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int height)
 {
        /* copy camera to compare later */
@@ -224,24 +248,11 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
        cam->bladesrotation = bcam->aperturerotation;
 
        /* transform */
-       cam->matrix = bcam->matrix;
-
-       if(bcam->type == CAMERA_ENVIRONMENT) {
-               /* make it so environment camera needs to be pointed in the direction
-                  of the positive x-axis to match an environment texture, this way
-                  it is looking at the center of the texture */
-               cam->matrix = cam->matrix *
-                       make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
-                                       0.0f,  0.0f, 1.0f, 0.0f,
-                                      -1.0f,  0.0f, 0.0f, 0.0f,
-                                       0.0f,  0.0f, 0.0f, 1.0f);
-       }
-       else {
-               /* note the blender camera points along the negative z-axis */
-               cam->matrix = cam->matrix * transform_scale(1.0f, 1.0f, -1.0f);
-       }
-
-       cam->matrix = transform_clear_scale(cam->matrix);
+       cam->matrix = blender_camera_matrix(bcam->matrix, bcam->type);
+       cam->motion.pre = cam->matrix;
+       cam->motion.post = cam->matrix;
+       cam->use_motion = false;
+       cam->shuttertime = bcam->shuttertime;
 
        /* set update flag */
        if(cam->modified(prevcam))
@@ -260,6 +271,7 @@ void BlenderSync::sync_camera(BL::Object b_override, int width, int height)
 
        bcam.pixelaspect.x = r.pixel_aspect_x();
        bcam.pixelaspect.y = r.pixel_aspect_y();
+       bcam.shuttertime = r.motion_blur_shutter();
 
        /* camera object */
        BL::Object b_ob = b_scene.camera();
@@ -277,6 +289,23 @@ void BlenderSync::sync_camera(BL::Object b_override, int width, int height)
        blender_camera_sync(cam, &bcam, width, height);
 }
 
+void BlenderSync::sync_camera_motion(BL::Object b_ob, int motion)
+{
+       Camera *cam = scene->camera;
+
+       Transform tfm = get_transform(b_ob.matrix_world());
+       tfm = blender_camera_matrix(tfm, cam->type);
+
+       if(tfm != cam->matrix) {
+               if(motion == -1)
+                       cam->motion.pre = tfm;
+               else
+                       cam->motion.post = tfm;
+
+               cam->use_motion = true;
+       }
+}
+
 /* Sync 3D View Camera */
 
 void BlenderSync::sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height)
@@ -288,6 +317,7 @@ void BlenderSync::sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int
        bcam.nearclip = b_v3d.clip_start();
        bcam.farclip = b_v3d.clip_end();
        bcam.lens = b_v3d.lens();
+       bcam.shuttertime = b_scene.render().motion_blur_shutter();
 
        if(b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA) {
                /* camera view */
index 7caa6b3d511c2e47dbfbeb7c27f160aa27b16818..f77e6551de011badebd8fc542b1597b6052cd535 100644 (file)
@@ -33,30 +33,6 @@ CCL_NAMESPACE_BEGIN
 
 /* Find/Add */
 
-static bool mesh_need_attribute(Scene *scene, Mesh *mesh, Attribute::Standard std)
-{
-       if(std == Attribute::STD_NONE)
-               return false;
-
-       foreach(uint shader, mesh->used_shaders)
-               if(scene->shaders[shader]->attributes.find(std))
-                       return true;
-       
-       return false;
-}
-
-static bool mesh_need_attribute(Scene *scene, Mesh *mesh, ustring name)
-{
-       if(name == ustring())
-               return false;
-
-       foreach(uint shader, mesh->used_shaders)
-               if(scene->shaders[shader]->attributes.find(name))
-                       return true;
-       
-       return false;
-}
-
 static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<uint>& used_shaders)
 {
        /* create vertices */
@@ -66,7 +42,7 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
                mesh->verts.push_back(get_float3(v->co()));
 
        /* create vertex normals */
-       Attribute *attr_N = mesh->attributes.add(Attribute::STD_VERTEX_NORMAL);
+       Attribute *attr_N = mesh->attributes.add(ATTR_STD_VERTEX_NORMAL);
        float3 *N = attr_N->data_float3();
 
        for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++N)
@@ -94,8 +70,8 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
        /* create generated coordinates. todo: we should actually get the orco
           coordinates from modifiers, for now we use texspace loc/size which
           is available in the api. */
-       if(mesh_need_attribute(scene, mesh, Attribute::STD_GENERATED)) {
-               Attribute *attr = mesh->attributes.add(Attribute::STD_GENERATED);
+       if(mesh->need_attribute(scene, ATTR_STD_GENERATED)) {
+               Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED);
                float3 loc = get_float3(b_mesh.texspace_location());
                float3 size = get_float3(b_mesh.texspace_size());
 
@@ -118,7 +94,7 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
                BL::Mesh::tessface_vertex_colors_iterator l;
 
                for(b_mesh.tessface_vertex_colors.begin(l); l != b_mesh.tessface_vertex_colors.end(); ++l) {
-                       if(!mesh_need_attribute(scene, mesh, ustring(l->name().c_str())))
+                       if(!mesh->need_attribute(scene, ustring(l->name().c_str())))
                                continue;
 
                        Attribute *attr = mesh->attributes.add(
@@ -150,10 +126,10 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
                BL::Mesh::tessface_uv_textures_iterator l;
 
                for(b_mesh.tessface_uv_textures.begin(l); l != b_mesh.tessface_uv_textures.end(); ++l) {
-                       Attribute::Standard std = (l->active_render())? Attribute::STD_UV: Attribute::STD_NONE;
+                       AttributeStandard std = (l->active_render())? ATTR_STD_UV: ATTR_STD_NONE;
                        ustring name = ustring(l->name().c_str());
 
-                       if(!(mesh_need_attribute(scene, mesh, name) || mesh_need_attribute(scene, mesh, std)))
+                       if(!(mesh->need_attribute(scene, name) || mesh->need_attribute(scene, std)))
                                continue;
 
                        Attribute *attr;
@@ -329,5 +305,38 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool holdout, bool object_updated)
        return mesh;
 }
 
+void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion)
+{
+       /* todo: displacement, subdivision */
+       BL::ID b_ob_data = b_ob.data();
+       size_t size = mesh->verts.size();
+
+       /* skip objects without deforming modifiers. this is not a totally reliable,
+        * would need a more extensive check to see which objects are animated */
+       if(!size || !ccl::object_is_deform_modified(b_ob, b_scene, preview))
+               return;
+
+       /* get derived mesh */
+       BL::Mesh b_mesh = object_to_mesh(b_ob, b_scene, true, !preview);
+
+       if(b_mesh) {
+               BL::Mesh::vertices_iterator v;
+               AttributeStandard std = (motion == -1)? ATTR_STD_MOTION_PRE: ATTR_STD_MOTION_POST;
+               Attribute *attr_M = mesh->attributes.add(std);
+               float3 *M = attr_M->data_float3();
+               size_t i = 0, size = mesh->verts.size();
+
+               for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end() && i < size; ++v, M++, i++)
+                       *M = get_float3(v->co());
+
+               /* if number of vertices changed, or if coordinates stayed the same, drop it */
+               if(i != size || memcmp(M, &mesh->verts[0], sizeof(float3)*size) == 0)
+                       mesh->attributes.remove(std);
+
+               /* free derived mesh */
+               object_remove_mesh(b_data, b_mesh);
+       }
+}
+
 CCL_NAMESPACE_END
 
index 96faee19af4b27897e5a66fed28362386d678d44..b1cd778c6d3cd9564d779db8b0045bfeaee4fe67 100644 (file)
@@ -16,6 +16,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include "camera.h"
 #include "graph.h"
 #include "light.h"
 #include "mesh.h"
@@ -188,11 +189,12 @@ void BlenderSync::sync_background_light()
 
 /* Object */
 
-void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag)
+void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag, int motion)
 {
        /* light is handled separately */
        if(object_is_light(b_ob)) {
-               sync_light(b_parent, b_index, b_ob, tfm);
+               if(!motion)
+                       sync_light(b_parent, b_index, b_ob, tfm);
                return;
        }
 
@@ -200,9 +202,31 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
        if(!object_is_mesh(b_ob))
                return;
 
-       /* test if we need to sync */
+       /* key to lookup object */
        ObjectKey key(b_parent, b_index, b_ob);
        Object *object;
+
+       /* motion vector case */
+       if(motion) {
+               object = object_map.find(key);
+
+               if(object) {
+                       if(tfm != object->tfm) {
+                               if(motion == -1)
+                                       object->motion.pre = tfm;
+                               else
+                                       object->motion.post = tfm;
+
+                               object->use_motion = true;
+                       }
+
+                       sync_mesh_motion(b_ob, object->mesh, motion);
+               }
+
+               return;
+       }
+
+       /* test if we need to sync */
        bool object_updated = false;
 
        if(object_map.sync(&object, b_ob, b_parent, key))
@@ -219,6 +243,9 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
                object->name = b_ob.name().c_str();
                object->pass_id = b_ob.pass_index();
                object->tfm = tfm;
+               object->motion.pre = tfm;
+               object->motion.post = tfm;
+               object->use_motion = false;
 
                /* visibility flags for both parent */
                object->visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL;
@@ -238,16 +265,18 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
 
 /* Object Loop */
 
-void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
+void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
 {
        /* layer data */
        uint scene_layer = render_layer.scene_layer;
        
-       /* prepare for sync */
-       light_map.pre_sync();
-       mesh_map.pre_sync();
-       object_map.pre_sync();
-       mesh_synced.clear();
+       if(!motion) {
+               /* prepare for sync */
+               light_map.pre_sync();
+               mesh_map.pre_sync();
+               object_map.pre_sync();
+               mesh_synced.clear();
+       }
 
        /* object loop */
        BL::Scene::objects_iterator b_ob;
@@ -270,7 +299,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
                                        bool dup_hide = (b_v3d)? b_dup_ob.hide(): b_dup_ob.hide_render();
 
                                        if(!(b_dup->hide() || dup_hide))
-                                               sync_object(*b_ob, b_index, b_dup_ob, tfm, ob_layer);
+                                               sync_object(*b_ob, b_index, b_dup_ob, tfm, ob_layer, motion);
 
                                        b_index++;
                                }
@@ -296,21 +325,50 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
                        if(!hide) {
                                /* object itself */
                                Transform tfm = get_transform(b_ob->matrix_world());
-                               sync_object(*b_ob, 0, *b_ob, tfm, ob_layer);
+                               sync_object(*b_ob, 0, *b_ob, tfm, ob_layer, motion);
                        }
                }
        }
 
-       sync_background_light();
+       if(!motion) {
+               sync_background_light();
+
+               /* handle removed data and modified pointers */
+               if(light_map.post_sync())
+                       scene->light_manager->tag_update(scene);
+               if(mesh_map.post_sync())
+                       scene->mesh_manager->tag_update(scene);
+               if(object_map.post_sync())
+                       scene->object_manager->tag_update(scene);
+               mesh_synced.clear();
+       }
+}
+
+void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override)
+{
+       if(scene->need_motion() == Scene::MOTION_NONE)
+               return;
+
+       /* get camera object here to deal with camera switch */
+       BL::Object b_cam = b_scene.camera();
+       if(b_override)
+               b_cam = b_override;
+
+       /* go back and forth one frame */
+       int frame = b_scene.frame_current();
+
+       for(int motion = -1; motion <= 1; motion += 2) {
+               scene_frame_set(b_scene, frame + motion);
+
+               /* camera object */
+               if(b_cam)
+                       sync_camera_motion(b_cam, motion);
+
+               /* mesh objects */
+               sync_objects(b_v3d, motion);
+       }
 
-       /* handle removed data and modified pointers */
-       if(light_map.post_sync())
-               scene->light_manager->tag_update(scene);
-       if(mesh_map.post_sync())
-               scene->mesh_manager->tag_update(scene);
-       if(object_map.post_sync())
-               scene->object_manager->tag_update(scene);
-       mesh_synced.clear();
+       scene_frame_set(b_scene, frame);
 }
 
 CCL_NAMESPACE_END
index 5ece7aa26e205d8953028a2add9eb067a78be781..f79b99951651d5effcd8979632c9fb1aa97c1028 100644 (file)
@@ -91,7 +91,7 @@ void BlenderSession::create_session()
 
        /* create sync */
        sync = new BlenderSync(b_data, b_scene, scene, !background);
-       sync->sync_data(b_v3d);
+       sync->sync_data(b_v3d, b_engine.camera_override());
 
        if(b_rv3d)
                sync->sync_view(b_v3d, b_rv3d, width, height);
@@ -130,6 +130,8 @@ static PassType get_pass_type(BL::RenderPass b_pass)
                        return PASS_OBJECT_ID;
                case BL::RenderPass::type_UV:
                        return PASS_UV;
+               case BL::RenderPass::type_VECTOR:
+                       return PASS_MOTION;
                case BL::RenderPass::type_MATERIAL_INDEX:
                        return PASS_MATERIAL_ID;
 
@@ -168,7 +170,6 @@ static PassType get_pass_type(BL::RenderPass b_pass)
                case BL::RenderPass::type_REFRACTION:
                case BL::RenderPass::type_SPECULAR:
                case BL::RenderPass::type_REFLECTION:
-               case BL::RenderPass::type_VECTOR:
                case BL::RenderPass::type_MIST:
                        return PASS_NONE;
        }
@@ -209,6 +210,8 @@ void BlenderSession::render()
                                BL::RenderPass b_pass(*b_pass_iter);
                                PassType pass_type = get_pass_type(b_pass);
 
+                               if(pass_type == PASS_MOTION && scene->integrator->motion_blur)
+                                       continue;
                                if(pass_type != PASS_NONE)
                                        Pass::add(pass_type, passes);
                        }
@@ -219,7 +222,7 @@ void BlenderSession::render()
                scene->film->tag_update(scene);
 
                /* update scene */
-               sync->sync_data(b_v3d, b_iter->name().c_str());
+               sync->sync_data(b_v3d, b_engine.camera_override(), b_iter->name().c_str());
 
                /* update session */
                int samples = sync->get_layer_samples();
@@ -310,7 +313,7 @@ void BlenderSession::synchronize()
        }
 
        /* data and camera synchronize */
-       sync->sync_data(b_v3d);
+       sync->sync_data(b_v3d, b_engine.camera_override());
 
        if(b_rv3d)
                sync->sync_view(b_v3d, b_rv3d, width, height);
index 41cd200d0031ea234a1cfb04c0409a53f836cdb0..24cf10bc02879f4d855c110c3bf8c09bbc689f61 100644 (file)
@@ -121,19 +121,21 @@ bool BlenderSync::sync_recalc()
        return recalc;
 }
 
-void BlenderSync::sync_data(BL::SpaceView3D b_v3d, const char *layer)
+void BlenderSync::sync_data(BL::SpaceView3D b_v3d, BL::Object b_override, const char *layer)
 {
        sync_render_layers(b_v3d, layer);
        sync_integrator();
        sync_film();
        sync_shaders();
        sync_objects(b_v3d);
+       sync_motion(b_v3d, b_override);
 }
 
 /* Integrator */
 
 void BlenderSync::sync_integrator()
 {
+       BL::RenderSettings r = b_scene.render();
        PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
 
        experimental = (RNA_enum_get(&cscene, "feature_set") != 0);
@@ -160,6 +162,9 @@ void BlenderSync::sync_integrator()
        integrator->layer_flag = render_layer.layer;
 
        integrator->sample_clamp = get_float(cscene, "sample_clamp");
+#ifdef __MOTION__
+       integrator->motion_blur = (!preview && r.use_motion_blur());
+#endif
 
        if(integrator->modified(previntegrator))
                integrator->tag_update(scene);
index ab8e4bd8d00afa7486a515d37c69c5b9c3bfa4b8..acdcea1ef9bca4f6cd2dab6f6909afbf6c7c9b1d 100644 (file)
@@ -54,7 +54,7 @@ public:
 
        /* sync */
        bool sync_recalc();
-       void sync_data(BL::SpaceView3D b_v3d, const char *layer = 0);
+       void sync_data(BL::SpaceView3D b_v3d, BL::Object b_override, const char *layer = 0);
        void sync_camera(BL::Object b_override, int width, int height);
        void sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height);
        int get_layer_samples() { return render_layer.samples; }
@@ -69,7 +69,8 @@ private:
        /* sync */
        void sync_lamps();
        void sync_materials();
-       void sync_objects(BL::SpaceView3D b_v3d);
+       void sync_objects(BL::SpaceView3D b_v3d, int motion = 0);
+       void sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override);
        void sync_film();
        void sync_integrator();
        void sync_view();
@@ -79,9 +80,11 @@ private:
 
        void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree);
        Mesh *sync_mesh(BL::Object b_ob, bool holdout, bool object_updated);
-       void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag);
+       void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag, int motion);
        void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm);
        void sync_background_light();
+       void sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion);
+       void sync_camera_motion(BL::Object b_ob, int motion);
 
        /* util */
        void find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader);
index 67f3a3ab7d90672c2ec89eb96edc981e90610124..9184e14bc7608ece419cbe47a5714d95b7b70884 100644 (file)
@@ -49,8 +49,10 @@ void RE_engine_update_progress(struct RenderEngine *engine, float progress);
 void engine_tag_redraw(void *engine);
 void engine_tag_update(void *engine);
 int rna_Object_is_modified(void *ob, void *scene, int settings);
+int rna_Object_is_deform_modified(void *ob, void *scene, int settings);
 void BLI_timestr(double _time, char *str);
 void rna_ColorRamp_eval(void *coba, float position, float color[4]);
+void rna_Scene_frame_set(void *scene, int frame, float subframe);
 
 }
 
@@ -94,6 +96,16 @@ static inline bool object_is_modified(BL::Object self, BL::Scene scene, bool pre
        return rna_Object_is_modified(self.ptr.data, scene.ptr.data, (preview)? (1<<0): (1<<1))? true: false;
 }
 
+static inline bool object_is_deform_modified(BL::Object self, BL::Scene scene, bool preview)
+{
+       return rna_Object_is_deform_modified(self.ptr.data, scene.ptr.data, (preview)? (1<<0): (1<<1))? true: false;
+}
+
+static inline void scene_frame_set(BL::Scene scene, int frame)
+{
+       rna_Scene_frame_set(scene.ptr.data, frame, 0.0f);
+}
+
 /* Utilities */
 
 static inline Transform get_transform(BL::Array<float, 16> array)
index 523ae8ae92621fb92d7167ee24418c7889e12904..5da4253bd86b8b7e7f973f78244c55a85e5de999 100644 (file)
@@ -57,7 +57,7 @@ __device_inline float3 bvh_inverse_direction(float3 dir)
 
 __device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
 {
-       Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
+       Transform tfm = object_fetch_transform(kg, object, ray->time, OBJECT_INVERSE_TRANSFORM);
 
        *P = transform_point(&tfm, ray->P);
 
@@ -74,7 +74,7 @@ __device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray
 
 __device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
 {
-       Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
+       Transform tfm = object_fetch_transform(kg, object, ray->time, OBJECT_TRANSFORM);
 
        if(*t != FLT_MAX)
                *t *= len(transform_direction(&tfm, 1.0f/(*idir)));
@@ -341,7 +341,7 @@ __device_inline float3 ray_offset(float3 P, float3 Ng)
 #endif
 }
 
-__device_inline float3 bvh_triangle_refine(KernelGlobals *kg, const Intersection *isect, const Ray *ray)
+__device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
 {
        float3 P = ray->P;
        float3 D = ray->D;
@@ -349,7 +349,11 @@ __device_inline float3 bvh_triangle_refine(KernelGlobals *kg, const Intersection
 
 #ifdef __INTERSECTION_REFINE__
        if(isect->object != ~0) {
-               Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
+#ifdef __MOTION__
+               Transform tfm = sd->ob_itfm;
+#else
+               Transform tfm = object_fetch_transform(kg, isect->object, ray->time, OBJECT_INVERSE_TRANSFORM);
+#endif
 
                P = transform_point(&tfm, P);
                D = transform_direction(&tfm, D*t);
@@ -366,7 +370,12 @@ __device_inline float3 bvh_triangle_refine(KernelGlobals *kg, const Intersection
        P = P + D*rt;
 
        if(isect->object != ~0) {
-               Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
+#ifdef __MOTION__
+               Transform tfm = sd->ob_tfm;
+#else
+               Transform tfm = object_fetch_transform(kg, isect->object, ray->time, OBJECT_TRANSFORM);
+#endif
+
                P = transform_point(&tfm, P);
        }
 
index 99dac18d54527a1e993879ed7db80f8123cee775..7b93ed7c0e6ef8d65e0dd8b827dd71461890e3cd 100644 (file)
@@ -63,6 +63,11 @@ __device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float
        /* transform ray from camera to world */
        Transform cameratoworld = kernel_data.cam.cameratoworld;
 
+#ifdef __MOTION__
+       if(ray->time != TIME_INVALID)
+               transform_motion_interpolate(&cameratoworld, &kernel_data.cam.motion, ray->time);
+#endif
+
        ray->P = transform_point(&cameratoworld, ray->P);
        ray->D = transform_direction(&cameratoworld, ray->D);
        ray->D = normalize(ray->D);
@@ -101,6 +106,11 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa
        /* transform ray from camera to world */
        Transform cameratoworld = kernel_data.cam.cameratoworld;
 
+#ifdef __MOTION__
+       if(ray->time != TIME_INVALID)
+               transform_motion_interpolate(&cameratoworld, &kernel_data.cam.motion, ray->time);
+#endif
+
        ray->P = transform_point(&cameratoworld, ray->P);
        ray->D = transform_direction(&cameratoworld, ray->D);
        ray->D = normalize(ray->D);
@@ -136,6 +146,11 @@ __device void camera_sample_environment(KernelGlobals *kg, float raster_x, float
        /* transform ray from camera to world */
        Transform cameratoworld = kernel_data.cam.cameratoworld;
 
+#ifdef __MOTION__
+       if(ray->time != TIME_INVALID)
+               transform_motion_interpolate(&cameratoworld, &kernel_data.cam.motion, ray->time);
+#endif
+
        ray->P = transform_point(&cameratoworld, ray->P);
        ray->D = transform_direction(&cameratoworld, ray->D);
        ray->D = normalize(ray->D);
@@ -162,14 +177,20 @@ __device void camera_sample_environment(KernelGlobals *kg, float raster_x, float
 
 /* Common */
 
-__device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v, float lens_u, float lens_v, Ray *ray)
+__device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v,
+       float lens_u, float lens_v, float time, Ray *ray)
 {
        /* pixel filter */
        float raster_x = x + kernel_tex_interp(__filter_table, filter_u, FILTER_TABLE_SIZE);
        float raster_y = y + kernel_tex_interp(__filter_table, filter_v, FILTER_TABLE_SIZE);
 
+#ifdef __MOTION__
        /* motion blur */
-       //ray->time = lerp(time_t, kernel_data.cam.shutter_open, kernel_data.cam.shutter_close);
+       if(kernel_data.cam.shuttertime == 0.0f)
+               ray->time = TIME_INVALID;
+       else
+               ray->time = 0.5f + (time - 0.5f)*kernel_data.cam.shuttertime;
+#endif
 
        /* sample */
        if(kernel_data.cam.type == CAMERA_PERSPECTIVE)
index 764ac599991b5053f7cfbb8bc25f41fe3f6e2392..cd7701a0c75e3a93315832b02580d5228de25ede 100644 (file)
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
 /* Direction Emission */
 
 __device float3 direct_emissive_eval(KernelGlobals *kg, float rando,
-       LightSample *ls, float u, float v, float3 I)
+       LightSample *ls, float u, float v, float3 I, float time)
 {
        /* setup shading at emitter */
        ShaderData sd;
@@ -40,7 +40,7 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando,
        else
 #endif
        {
-               shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v);
+               shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v, time);
                ls->Ng = sd.Ng;
 
                /* no path flag, we're evaluating this for all closures. that's weak but
@@ -76,7 +76,7 @@ __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
 #endif
        {
                /* sample a light and position on int */
-               light_sample(kg, randt, randu, randv, sd->P, &ls, &pdf);
+               light_sample(kg, randt, randu, randv, sd->time, sd->P, &ls, &pdf);
        }
 
        /* compute pdf */
@@ -87,7 +87,7 @@ __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
                return false;
 
        /* evaluate closure */
-       float3 light_eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D);
+       float3 light_eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D, sd->time);
 
        if(is_zero(light_eval))
                return false;
index 42260577069324d4672dee9230c9d54b08f9c86e..c2cf293cab32d4dad92b7362772fe591533e173b 100644 (file)
@@ -251,7 +251,7 @@ __device float regular_light_pdf(KernelGlobals *kg,
 /* Triangle Light */
 
 __device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
-       float randu, float randv, LightSample *ls)
+       float randu, float randv, float time, LightSample *ls)
 {
        /* triangle, so get position, normal, shader */
        ls->P = triangle_sample_MT(kg, prim, randu, randv);
@@ -264,8 +264,11 @@ __device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
 #ifdef __INSTANCING__
        /* instance transform */
        if(ls->object >= 0) {
-               object_position_transform(kg, ls->object, &ls->P);
-               object_normal_transform(kg, ls->object, &ls->Ng);
+               Transform tfm = object_fetch_transform(kg, ls->object, time, OBJECT_TRANSFORM);
+               Transform itfm = object_fetch_transform(kg, ls->object, time, OBJECT_INVERSE_TRANSFORM);
+
+               ls->P = transform_point(&tfm, ls->P);
+               ls->Ng = transform_direction_transposed(&itfm, ls->Ng);
        }
 #endif
 }
@@ -313,7 +316,7 @@ __device int light_distribution_sample(KernelGlobals *kg, float randt)
 
 /* Generic Light */
 
-__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float3 P, LightSample *ls, float *pdf)
+__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls, float *pdf)
 {
        /* sample index */
        int index = light_distribution_sample(kg, randt);
@@ -324,7 +327,7 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra
 
        if(prim >= 0) {
                int object = __float_as_int(l.w);
-               triangle_light_sample(kg, prim, object, randu, randv, ls);
+               triangle_light_sample(kg, prim, object, randu, randv, time, ls);
        }
        else {
                int point = -prim-1;
index b676f58e5d4fd74251ee4c83dc6a8818c9f70feb..262ca848f2834ee724bf2002fe80f7e24165f40a 100644 (file)
@@ -20,41 +20,87 @@ CCL_NAMESPACE_BEGIN
 
 enum ObjectTransform {
        OBJECT_TRANSFORM = 0,
-       OBJECT_INVERSE_TRANSFORM = 4,
-       OBJECT_NORMAL_TRANSFORM = 8,
-       OBJECT_PROPERTIES = 12
+       OBJECT_INVERSE_TRANSFORM = 3,
+       OBJECT_PROPERTIES = 6,
+       OBJECT_TRANSFORM_MOTION_PRE = 8,
+       OBJECT_TRANSFORM_MOTION_POST = 12
 };
 
-__device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, enum ObjectTransform type)
+__device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, float time, enum ObjectTransform type)
 {
        Transform tfm;
 
+#ifdef __MOTION__
+       /* if we do motion blur */
+       if(time != TIME_INVALID) {
+               int offset = object*OBJECT_SIZE + (int)OBJECT_TRANSFORM_MOTION_PRE;
+               float4 have_motion = kernel_tex_fetch(__objects, offset + 0);
+
+               /* if this object have motion */
+               if(have_motion.x != FLT_MAX) {
+                       /* fetch motion transforms */
+                       MotionTransform motion;
+
+                       motion.pre.x = have_motion;
+                       motion.pre.y = kernel_tex_fetch(__objects, offset + 1);
+                       motion.pre.z = kernel_tex_fetch(__objects, offset + 2);
+                       motion.pre.w = kernel_tex_fetch(__objects, offset + 3);
+
+                       motion.post.x = kernel_tex_fetch(__objects, offset + 4);
+                       motion.post.y = kernel_tex_fetch(__objects, offset + 5);
+                       motion.post.z = kernel_tex_fetch(__objects, offset + 6);
+                       motion.post.w = kernel_tex_fetch(__objects, offset + 7);
+
+                       /* interpolate (todo: do only once per object) */
+                       transform_motion_interpolate(&tfm, &motion, time);
+
+                       /* invert */
+                       if(type == OBJECT_INVERSE_TRANSFORM)
+                               tfm = transform_quick_inverse(tfm);
+
+                       return tfm;
+               }
+       }
+#endif
+
        int offset = object*OBJECT_SIZE + (int)type;
 
        tfm.x = kernel_tex_fetch(__objects, offset + 0);
        tfm.y = kernel_tex_fetch(__objects, offset + 1);
        tfm.z = kernel_tex_fetch(__objects, offset + 2);
-       tfm.w = kernel_tex_fetch(__objects, offset + 3);
+       tfm.w = make_float4(0.0f, 0.0f, 0.0f, 1.0f);
 
        return tfm;
 }
 
-__device_inline void object_position_transform(KernelGlobals *kg, int object, float3 *P)
+__device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
 {
-       Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
+#ifdef __MOTION__
+       *P = transform_point(&sd->ob_tfm, *P);
+#else
+       Transform tfm = object_fetch_transform(kg, sd->object, TIME_INVALID, OBJECT_TRANSFORM);
        *P = transform_point(&tfm, *P);
+#endif
 }
 
-__device_inline void object_normal_transform(KernelGlobals *kg, int object, float3 *N)
+__device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
 {
-       Transform tfm = object_fetch_transform(kg, object, OBJECT_NORMAL_TRANSFORM);
-       *N = normalize(transform_direction(&tfm, *N));
+#ifdef __MOTION__
+       *N = normalize(transform_direction_transposed(&sd->ob_itfm, *N));
+#else
+       Transform tfm = object_fetch_transform(kg, sd->object, TIME_INVALID, OBJECT_INVERSE_TRANSFORM);
+       *N = normalize(transform_direction_transposed(&tfm, *N));
+#endif
 }
 
-__device_inline void object_dir_transform(KernelGlobals *kg, int object, float3 *D)
+__device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
 {
-       Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
+#ifdef __MOTION__
+       *D = transform_direction(&sd->ob_tfm, *D);
+#else
+       Transform tfm = object_fetch_transform(kg, sd->object, 0.0f, OBJECT_TRANSFORM);
        *D = transform_direction(&tfm, *D);
+#endif
 }
 
 __device_inline float object_surface_area(KernelGlobals *kg, int object)
index fd4ee17cdc1120e5e69aa012c43a2057c8766726..f3ddda4a392b46b955c9fe50ccc43144e3cbe1b2 100644 (file)
@@ -72,9 +72,14 @@ __device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float
                        kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal);
                }
                if(flag & PASS_UV) {
-                       float3 uv = make_float3(0.0f, 0.0f, 0.0f); /* todo: request and lookup */
+                       float3 uv = triangle_uv(kg, sd);
                        kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, sample, uv);
                }
+               if(flag & PASS_MOTION) {
+                       float4 speed = triangle_motion_vector(kg, sd);
+                       kernel_write_pass_float4(buffer + kernel_data.film.pass_motion, sample, speed);
+                       kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, sample, 1.0f);
+               }
        }
 
        if(flag & (PASS_DIFFUSE_INDIRECT|PASS_DIFFUSE_COLOR|PASS_DIFFUSE_DIRECT))
index 8ebac1772770b0e46521534d241f3ec9d558e873..b7c22087e1f3c7b739c68ad01121245e84ba9375 100644 (file)
@@ -18,8 +18,8 @@
 
 #include "kernel_differential.h"
 #include "kernel_montecarlo.h"
-#include "kernel_triangle.h"
 #include "kernel_object.h"
+#include "kernel_triangle.h"
 #ifdef __QBVH__
 #include "kernel_qbvh.h"
 #else
@@ -324,6 +324,9 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
                                light_ray.P = ray_offset(sd.P, sd.Ng);
                                light_ray.D = ao_D;
                                light_ray.t = kernel_data.background.ao_distance;
+#ifdef __MOTION__
+                               light_ray.time = sd.time;
+#endif
 
                                if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) {
                                        float3 ao_bsdf = shader_bsdf_diffuse(kg, &sd)*kernel_data.background.ao_factor;
@@ -346,6 +349,10 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
                                BsdfEval L_light;
                                bool is_lamp;
 
+#ifdef __MOTION__
+                               light_ray.time = sd.time;
+#endif
+
 #ifdef __MULTI_LIGHT__
                                /* index -1 means randomly sample from distribution */
                                int i = (kernel_data.integrator.num_distribution)? -1: 0;
@@ -449,7 +456,13 @@ __device void kernel_path_trace(KernelGlobals *kg,
        float lens_u = path_rng(kg, &rng, sample, PRNG_LENS_U);
        float lens_v = path_rng(kg, &rng, sample, PRNG_LENS_V);
 
-       camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, &ray);
+#ifdef __MOTION__
+       float time = path_rng(kg, &rng, sample, PRNG_TIME);
+#else
+       float time = 0.0f;
+#endif
+
+       camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, &ray);
 
        /* integrate */
        float4 L = kernel_path_integrate(kg, &rng, sample, ray, buffer);
index 46ef5d2022ae967ee67030c30c907daa9df0a6db..b2f2a7577be697ae02139e1d54c87f03d5a49be5 100644 (file)
@@ -53,16 +53,9 @@ __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
        float3 Ng = make_float3(Ns.x, Ns.y, Ns.z);
        int shader = __float_as_int(Ns.w);
 
-       /* vectors */
-       sd->P = bvh_triangle_refine(kg, isect, ray);
-       sd->Ng = Ng;
-       sd->N = Ng;
-       sd->I = -ray->D;
-       sd->shader = shader;
-
        /* triangle */
 #ifdef __INSTANCING__
-       sd->object = isect->object;
+       sd->object = (isect->object == ~0)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
 #endif
        sd->prim = prim;
 #ifdef __UV__
@@ -70,6 +63,21 @@ __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
        sd->v = isect->v;
 #endif
 
+       /* matrices and time */
+#ifdef __MOTION__
+       sd->ob_tfm = object_fetch_transform(kg, sd->object, ray->time, OBJECT_TRANSFORM);
+       sd->ob_itfm = object_fetch_transform(kg, sd->object, ray->time, OBJECT_INVERSE_TRANSFORM);
+
+       sd->time = ray->time;
+#endif
+
+       /* vectors */
+       sd->P = bvh_triangle_refine(kg, sd, isect, ray);
+       sd->Ng = Ng;
+       sd->N = Ng;
+       sd->I = -ray->D;
+       sd->shader = shader;
+
        /* smooth normal */
        if(sd->shader & SHADER_SMOOTH_NORMAL)
                sd->N = triangle_smooth_normal(kg, sd->prim, sd->u, sd->v);
@@ -82,19 +90,15 @@ __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
 #endif
 
 #ifdef __INSTANCING__
-       if(sd->object != ~0) {
+       if(isect->object != ~0) {
                /* instance transform */
-               object_normal_transform(kg, sd->object, &sd->N);
-               object_normal_transform(kg, sd->object, &sd->Ng);
+               object_normal_transform(kg, sd, &sd->N);
+               object_normal_transform(kg, sd, &sd->Ng);
 #ifdef __DPDU__
-               object_dir_transform(kg, sd->object, &sd->dPdu);
-               object_dir_transform(kg, sd->object, &sd->dPdv);
+               object_dir_transform(kg, sd, &sd->dPdu);
+               object_dir_transform(kg, sd, &sd->dPdv);
 #endif
        }
-       else {
-               /* non-instanced object index */
-               sd->object = kernel_tex_fetch(__prim_object, isect->prim);
-       }
 #endif
 
        /* backfacing test */
@@ -122,7 +126,7 @@ __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
 
 __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
        const float3 P, const float3 Ng, const float3 I,
-       int shader, int object, int prim,  float u, float v)
+       int shader, int object, int prim, float u, float v, float time)
 {
        /* vectors */
        sd->P = P;
@@ -155,13 +159,20 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
        }
 #endif
 
+#ifdef __MOTION__
+       sd->time = time;
+
+       sd->ob_tfm = object_fetch_transform(kg, sd->object, time, OBJECT_TRANSFORM);
+       sd->ob_itfm = object_fetch_transform(kg, sd->object, time, OBJECT_INVERSE_TRANSFORM);
+#endif
+
        /* smooth normal */
        if(sd->shader & SHADER_SMOOTH_NORMAL) {
                sd->N = triangle_smooth_normal(kg, sd->prim, sd->u, sd->v);
 
 #ifdef __INSTANCING__
                if(instanced)
-                       object_normal_transform(kg, sd->object, &sd->N);
+                       object_normal_transform(kg, sd, &sd->N);
 #endif
        }
 
@@ -178,8 +189,8 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
 
 #ifdef __INSTANCING__
                if(instanced) {
-                       object_dir_transform(kg, sd->object, &sd->dPdu);
-                       object_dir_transform(kg, sd->object, &sd->dPdv);
+                       object_dir_transform(kg, sd, &sd->dPdu);
+                       object_dir_transform(kg, sd, &sd->dPdv);
                }
 #endif
        }
@@ -229,7 +240,7 @@ __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
 
        /* watch out: no instance transform currently */
 
-       shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v);
+       shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v, TIME_INVALID);
 }
 
 /* ShaderData setup from ray into background */
@@ -243,6 +254,9 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData
        sd->I = -sd->P;
        sd->shader = kernel_data.background.shader;
        sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2);
+#ifdef __MOTION__
+       sd->time = ray->time;
+#endif
 
 #ifdef __INSTANCING__
        sd->object = ~0;
index 7eaf54d14bffc3e37a8f8678abdd3acc83be1b09..1b3956c1dd4e0e4421aca54ebf5c37eb97dd51aa 100644 (file)
@@ -179,5 +179,68 @@ __device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData *s
        }
 }
 
+/* motion */
+
+__device int triangle_find_attribute(KernelGlobals *kg, ShaderData *sd, uint id)
+{
+       /* find attribute by unique id */
+       uint attr_offset = sd->object*kernel_data.bvh.attributes_map_stride;
+       uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
+
+       while(attr_map.x != id)
+               attr_map = kernel_tex_fetch(__attributes_map, ++attr_offset);
+
+       /* return result */
+       return (attr_map.y == ATTR_ELEMENT_NONE)? ATTR_STD_NOT_FOUND: attr_map.z;
+}
+
+__device float4 triangle_motion_vector(KernelGlobals *kg, ShaderData *sd)
+{
+       float3 motion_pre = sd->P, motion_post = sd->P;
+
+       /* deformation motion */
+       int offset_pre = triangle_find_attribute(kg, sd, ATTR_STD_MOTION_PRE);
+       int offset_post = triangle_find_attribute(kg, sd, ATTR_STD_MOTION_POST);
+
+       if(offset_pre != ATTR_STD_NOT_FOUND)
+               motion_pre = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_VERTEX, offset_pre, NULL, NULL);
+       if(offset_post != ATTR_STD_NOT_FOUND)
+               motion_post = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_VERTEX, offset_post, NULL, NULL);
+
+       /* object motion. note that depending on the mesh having motion vectors, this
+          transformation was set match the world/object space of motion_pre/post */
+       Transform tfm;
+       
+       tfm = object_fetch_transform(kg, sd->object, TIME_INVALID, OBJECT_TRANSFORM_MOTION_PRE);
+       motion_pre = transform_point(&tfm, motion_pre);
+
+       tfm = object_fetch_transform(kg, sd->object, TIME_INVALID, OBJECT_TRANSFORM_MOTION_POST);
+       motion_post = transform_point(&tfm, motion_post);
+
+       /* camera motion */
+       tfm = kernel_data.cam.worldtoraster;
+       float3 P = transform_perspective(&tfm, sd->P);
+
+       tfm = kernel_data.cam.motion.pre;
+       motion_pre = transform_perspective(&tfm, motion_pre) - P;
+
+       tfm = kernel_data.cam.motion.post;
+       motion_post = P - transform_perspective(&tfm, motion_post);
+
+       return make_float4(motion_pre.x, motion_pre.y, motion_post.x, motion_post.y);
+}
+
+__device float3 triangle_uv(KernelGlobals *kg, ShaderData *sd)
+{
+       int offset_uv = triangle_find_attribute(kg, sd, ATTR_STD_UV);
+
+       if(offset_uv == ATTR_STD_NOT_FOUND)
+               return make_float3(0.0f, 0.0f, 0.0f);
+
+       float3 uv = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_CORNER, offset_uv, NULL, NULL);
+       uv.z = 1.0f;
+       return uv;
+}
+
 CCL_NAMESPACE_END
 
index 102a2bb036dc27405cbf206889a4c59953aa8d5d..e91030870257f9f43c95c62c1dc3f29d65e4291e 100644 (file)
 #define __KERNEL_TYPES_H__
 
 #include "kernel_math.h"
-
 #include "svm/svm_types.h"
 
+#ifndef __KERNEL_GPU__
+#define __KERNEL_CPU__
+#endif
+
 CCL_NAMESPACE_BEGIN
 
 /* constants */
@@ -30,6 +33,7 @@ CCL_NAMESPACE_BEGIN
 #define LIGHT_SIZE                     4
 #define FILTER_TABLE_SIZE      256
 #define RAMP_TABLE_SIZE                256
+#define TIME_INVALID           FLT_MAX
 
 /* device capabilities */
 #ifdef __KERNEL_CPU__
@@ -75,6 +79,7 @@ CCL_NAMESPACE_BEGIN
 #define __PASSES__
 #define __BACKGROUND_MIS__
 #define __AO__
+//#define __MOTION__
 #endif
 
 //#define __MULTI_LIGHT__
@@ -90,14 +95,21 @@ enum ShaderEvalType {
        SHADER_EVAL_BACKGROUND
 };
 
-/* Path Tracing */
+/* Path Tracing
+ * note we need to keep the u/v pairs at even values */
 
 enum PathTraceDimension {
        PRNG_FILTER_U = 0,
        PRNG_FILTER_V = 1,
        PRNG_LENS_U = 2,
        PRNG_LENS_V = 3,
+#ifdef __MOTION__
+       PRNG_TIME = 4,
+       PRNG_UNUSED = 5,
+       PRNG_BASE_NUM = 6,
+#else
        PRNG_BASE_NUM = 4,
+#endif
 
        PRNG_BSDF_U = 0,
        PRNG_BSDF_V = 1,
@@ -177,7 +189,9 @@ typedef enum PassType {
        PASS_EMISSION = 65536,
        PASS_BACKGROUND = 131072,
        PASS_AO = 262144,
-       PASS_SHADOW = 524288
+       PASS_SHADOW = 524288,
+       PASS_MOTION = 1048576,
+       PASS_MOTION_WEIGHT = 2097152
 } PassType;
 
 #define PASS_ALL (~0)
@@ -275,6 +289,7 @@ typedef struct Ray {
        float3 P;
        float3 D;
        float t;
+       float time;
 
 #ifdef __RAY_DIFFERENTIALS__
        differential3 dP;
@@ -300,6 +315,21 @@ typedef enum AttributeElement {
        ATTR_ELEMENT_NONE
 } AttributeElement;
 
+typedef enum AttributeStandard {
+       ATTR_STD_NONE = 0,
+       ATTR_STD_VERTEX_NORMAL,
+       ATTR_STD_FACE_NORMAL,
+       ATTR_STD_UV,
+       ATTR_STD_GENERATED,
+       ATTR_STD_POSITION_UNDEFORMED,
+       ATTR_STD_POSITION_UNDISPLACED,
+       ATTR_STD_MOTION_PRE,
+       ATTR_STD_MOTION_POST,
+       ATTR_STD_NUM,
+
+       ATTR_STD_NOT_FOUND = ~0
+} AttributeStandard;
+
 /* Closure data */
 
 #define MAX_CLOSURE 8
@@ -365,6 +395,16 @@ typedef struct ShaderData {
        /* object id if there is one, ~0 otherwise */
        int object;
 
+       /* motion blur sample time */
+       float time;
+
+#ifdef __MOTION__
+       /* object <-> world space transformations, cached to avoid
+        * re-interpolating them constantly for shading */
+       Transform ob_tfm;
+       Transform ob_itfm;
+#endif
+
 #ifdef __RAY_DIFFERENTIALS__
        /* differential of P. these are orthogonal to Ng, not N */
        differential3 dP;
@@ -422,8 +462,8 @@ typedef struct KernelCamera {
        float focaldistance;
 
        /* motion blur */
-       float shutteropen;
-       float shutterclose;
+       float shuttertime;
+       float pad;
 
        /* clipping */
        float nearclip;
@@ -437,6 +477,8 @@ typedef struct KernelCamera {
        Transform worldtoraster;
        Transform worldtondc;
        Transform worldtocamera;
+
+       MotionTransform motion;
 } KernelCamera;
 
 typedef struct KernelFilm {
@@ -448,27 +490,32 @@ typedef struct KernelFilm {
        int pass_combined;
        int pass_depth;
        int pass_normal;
-       int pass_pad;
+       int pass_motion;
 
+       int pass_motion_weight;
        int pass_uv;
        int pass_object_id;
        int pass_material_id;
-       int pass_diffuse_color;
 
+       int pass_diffuse_color;
        int pass_glossy_color;
        int pass_transmission_color;
        int pass_diffuse_indirect;
-       int pass_glossy_indirect;
 
+       int pass_glossy_indirect;
        int pass_transmission_indirect;
        int pass_diffuse_direct;
        int pass_glossy_direct;
-       int pass_transmission_direct;
 
+       int pass_transmission_direct;
        int pass_emission;
        int pass_background;
        int pass_ao;
+
        int pass_shadow;
+       int pass_pad1;
+       int pass_pad2;
+       int pass_pad3;
 } KernelFilm;
 
 typedef struct KernelBackground {
index 98f8734aed29437dc05f49e990daa0f97f032407..5ecda7952519a220558f28840a18dfcf12c2775a 100644 (file)
@@ -33,8 +33,8 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, float *stack
        switch(type) {
                case NODE_TEXCO_OBJECT: {
                        if(sd->object != ~0) {
-                               Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
-                               data = transform_point(&tfm, sd->P);
+                               data = sd->P;
+                               object_position_transform(kg, sd, &data);
                        }
                        else
                                data = sd->P;
@@ -42,8 +42,8 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, float *stack
                }
                case NODE_TEXCO_NORMAL: {
                        if(sd->object != ~0) {
-                               Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
-                               data = transform_direction(&tfm, sd->N);
+                               data = sd->N;
+                               object_normal_transform(kg, sd, &data);
                        }
                        else
                                data = sd->N;
@@ -87,8 +87,8 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, floa
        switch(type) {
                case NODE_TEXCO_OBJECT: {
                        if(sd->object != ~0) {
-                               Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
-                               data = transform_point(&tfm, sd->P + sd->dP.dx);
+                               data = sd->P + sd->dP.dx;
+                               object_position_transform(kg, sd, &data);
                        }
                        else
                                data = sd->P + sd->dP.dx;
@@ -96,8 +96,8 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, floa
                }
                case NODE_TEXCO_NORMAL: {
                        if(sd->object != ~0) {
-                               Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
-                               data = transform_direction(&tfm, sd->N);
+                               data = sd->N;
+                               object_normal_transform(kg, sd, &data);
                        }
                        else
                                data = sd->N;
@@ -144,8 +144,8 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, floa
        switch(type) {
                case NODE_TEXCO_OBJECT: {
                        if(sd->object != ~0) {
-                               Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
-                               data = transform_point(&tfm, sd->P + sd->dP.dy);
+                               data = sd->P + sd->dP.dy;
+                               object_position_transform(kg, sd, &data);
                        }
                        else
                                data = sd->P + sd->dP.dy;
@@ -153,8 +153,8 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, floa
                }
                case NODE_TEXCO_NORMAL: {
                        if(sd->object != ~0) {
-                               Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
-                               data = normalize(transform_direction(&tfm, sd->N));
+                               data = sd->N;
+                               object_normal_transform(kg, sd, &data);
                        }
                        else
                                data = sd->N;
index db92cf4ef5430a0618a29a2e481f93afed253f58..4d4fbfe681460a3ea19bd59de51c3fff42e8ae9b 100644 (file)
@@ -16,7 +16,7 @@ set(SRC
        buffers.cpp
        camera.cpp
        film.cpp
-       # film_response.cpp  # XXX, why isn't this in?
+       # film_response.cpp (code unused)
        filter.cpp
        graph.cpp
        image.cpp
@@ -41,7 +41,7 @@ set(SRC_HEADERS
        buffers.h
        camera.h
        film.h
-       # film_response.h  # XXX, why isn't this in?
+       # film_response.h (code unused)
        filter.h
        graph.h
        image.h
index 9e90bf1b6253a3ec31992d9e181264b6f2382299..c1a089cc8721abd2cec61977212b5a876617d505 100644 (file)
@@ -31,7 +31,7 @@ void Attribute::set(ustring name_, TypeDesc type_, Element element_)
        name = name_;
        type = type_;
        element = element_;
-       std = STD_NONE;
+       std = ATTR_STD_NONE;
 
        /* string and matrix not supported! */
        assert(type == TypeDesc::TypeFloat || type == TypeDesc::TypeColor ||
@@ -81,20 +81,24 @@ bool Attribute::same_storage(TypeDesc a, TypeDesc b)
        return false;
 }
 
-ustring Attribute::standard_name(Attribute::Standard std)
+ustring Attribute::standard_name(AttributeStandard std)
 {
-       if(std == Attribute::STD_VERTEX_NORMAL)
+       if(std == ATTR_STD_VERTEX_NORMAL)
                return ustring("N");
-       else if(std == Attribute::STD_FACE_NORMAL)
+       else if(std == ATTR_STD_FACE_NORMAL)
                return ustring("Ng");
-       else if(std == Attribute::STD_UV)
+       else if(std == ATTR_STD_UV)
                return ustring("uv");
-       else if(std == Attribute::STD_GENERATED)
+       else if(std == ATTR_STD_GENERATED)
                return ustring("generated");
-       else if(std == Attribute::STD_POSITION_UNDEFORMED)
+       else if(std == ATTR_STD_POSITION_UNDEFORMED)
                return ustring("undeformed");
-       else if(std == Attribute::STD_POSITION_UNDISPLACED)
+       else if(std == ATTR_STD_POSITION_UNDISPLACED)
                return ustring("undisplaced");
+       else if(std == ATTR_STD_MOTION_PRE)
+               return ustring("motion_pre");
+       else if(std == ATTR_STD_MOTION_POST)
+               return ustring("motion_post");
 
        return ustring();
 }
@@ -164,24 +168,28 @@ void AttributeSet::remove(ustring name)
        }
 }
 
-Attribute *AttributeSet::add(Attribute::Standard std, ustring name)
+Attribute *AttributeSet::add(AttributeStandard std, ustring name)
 {
        Attribute *attr = NULL;
 
        if(name == ustring())
                name = Attribute::standard_name(std);
 
-       if(std == Attribute::STD_VERTEX_NORMAL)
+       if(std == ATTR_STD_VERTEX_NORMAL)
                attr = add(name, TypeDesc::TypeNormal, Attribute::VERTEX);
-       else if(std == Attribute::STD_FACE_NORMAL)
+       else if(std == ATTR_STD_FACE_NORMAL)
                attr = add(name, TypeDesc::TypeNormal, Attribute::FACE);
-       else if(std == Attribute::STD_UV)
+       else if(std == ATTR_STD_UV)
                attr = add(name, TypeDesc::TypePoint, Attribute::CORNER);
-       else if(std == Attribute::STD_GENERATED)
+       else if(std == ATTR_STD_GENERATED)
                attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
-       else if(std == Attribute::STD_POSITION_UNDEFORMED)
+       else if(std == ATTR_STD_POSITION_UNDEFORMED)
                attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
-       else if(std == Attribute::STD_POSITION_UNDISPLACED)
+       else if(std == ATTR_STD_POSITION_UNDISPLACED)
+               attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
+       else if(std == ATTR_STD_MOTION_PRE)
+               attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
+       else if(std == ATTR_STD_MOTION_POST)
                attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
        else
                assert(0);
@@ -191,7 +199,7 @@ Attribute *AttributeSet::add(Attribute::Standard std, ustring name)
        return attr;
 }
 
-Attribute *AttributeSet::find(Attribute::Standard std)
+Attribute *AttributeSet::find(AttributeStandard std)
 {
        foreach(Attribute& attr, attributes)
                if(attr.std == std)
@@ -200,7 +208,7 @@ Attribute *AttributeSet::find(Attribute::Standard std)
        return NULL;
 }
 
-void AttributeSet::remove(Attribute::Standard std)
+void AttributeSet::remove(AttributeStandard std)
 {
        Attribute *attr = find(std);
 
@@ -218,7 +226,7 @@ void AttributeSet::remove(Attribute::Standard std)
 
 Attribute *AttributeSet::find(AttributeRequest& req)
 {
-       if(req.std == Attribute::STD_NONE)
+       if(req.std == ATTR_STD_NONE)
                return find(req.name);
        else
                return find(req.std);
@@ -240,14 +248,14 @@ void AttributeSet::clear()
 AttributeRequest::AttributeRequest(ustring name_)
 {
        name = name_;
-       std = Attribute::STD_NONE;
+       std = ATTR_STD_NONE;
 
        type = TypeDesc::TypeFloat;
        element = ATTR_ELEMENT_NONE;
        offset = 0;
 }
 
-AttributeRequest::AttributeRequest(Attribute::Standard std_)
+AttributeRequest::AttributeRequest(AttributeStandard std_)
 {
        name = ustring();
        std = std_;
@@ -296,7 +304,7 @@ void AttributeRequestSet::add(ustring name)
        requests.push_back(AttributeRequest(name));
 }
 
-void AttributeRequestSet::add(Attribute::Standard std)
+void AttributeRequestSet::add(AttributeStandard std)
 {
        foreach(AttributeRequest& req, requests)
                if(req.std == std)
@@ -308,7 +316,7 @@ void AttributeRequestSet::add(Attribute::Standard std)
 void AttributeRequestSet::add(AttributeRequestSet& reqs)
 {
        foreach(AttributeRequest& req, reqs.requests) {
-               if(req.std == Attribute::STD_NONE)
+               if(req.std == ATTR_STD_NONE)
                        add(req.name);
                else
                        add(req.std);
@@ -324,7 +332,7 @@ bool AttributeRequestSet::find(ustring name)
        return false;
 }
 
-bool AttributeRequestSet::find(Attribute::Standard std)
+bool AttributeRequestSet::find(AttributeStandard std)
 {
        foreach(AttributeRequest& req, requests)
                if(req.std == std)
index 7af4657daa3efb114d0497c8d33f55fcb8376919..707d558fc794465c937ac0acc3613a1d9de34ceb 100644 (file)
@@ -47,19 +47,8 @@ public:
                CORNER
        };
 
-       enum Standard {
-               STD_NONE = 0,
-               STD_VERTEX_NORMAL,
-               STD_FACE_NORMAL,
-               STD_UV,
-               STD_GENERATED,
-               STD_POSITION_UNDEFORMED,
-               STD_POSITION_UNDISPLACED,
-               STD_NUM
-       };
-
        ustring name;
-       Standard std;
+       AttributeStandard std;
 
        TypeDesc type;
        vector<char> buffer;
@@ -82,7 +71,7 @@ public:
        const float *data_float() const { return (float*)data(); }
 
        static bool same_storage(TypeDesc a, TypeDesc b);
-       static ustring standard_name(Attribute::Standard std);
+       static ustring standard_name(AttributeStandard std);
 };
 
 /* Attribute Set
@@ -101,9 +90,9 @@ public:
        Attribute *find(ustring name);
        void remove(ustring name);
 
-       Attribute *add(Attribute::Standard std, ustring name = ustring());
-       Attribute *find(Attribute::Standard std);
-       void remove(Attribute::Standard std);
+       Attribute *add(AttributeStandard std, ustring name = ustring());
+       Attribute *find(AttributeStandard std);
+       void remove(AttributeStandard std);
 
        Attribute *find(AttributeRequest& req);
 
@@ -120,7 +109,7 @@ public:
 class AttributeRequest {
 public:
        ustring name;
-       Attribute::Standard std;
+       AttributeStandard std;
 
        /* temporary variables used by MeshManager */
        TypeDesc type;
@@ -128,7 +117,7 @@ public:
        int offset;
 
        AttributeRequest(ustring name_);
-       AttributeRequest(Attribute::Standard std);
+       AttributeRequest(AttributeStandard std);
 };
 
 /* AttributeRequestSet
@@ -143,11 +132,11 @@ public:
        ~AttributeRequestSet();
 
        void add(ustring name);
-       void add(Attribute::Standard std);
+       void add(AttributeStandard std);
        void add(AttributeRequestSet& reqs);
 
        bool find(ustring name);
-       bool find(Attribute::Standard std);
+       bool find(AttributeStandard std);
 
        size_t size();
        void clear();
index bda20a8ab9d6ab3cd084c07b56ceec8794566574..a80851b945a14746414609cdf4d2b553058332b7 100644 (file)
@@ -221,6 +221,28 @@ bool RenderBuffers::get_pass(PassType type, float exposure, int sample, int comp
                                        pixels[3] = 1.0f;
                                }
                        }
+                       else if(type == PASS_MOTION) {
+                               /* need to normalize by number of samples accumulated for motion */
+                               pass_offset = 0;
+                               foreach(Pass& color_pass, params.passes) {
+                                       if(color_pass.type == PASS_MOTION_WEIGHT)
+                                               break;
+                                       pass_offset += color_pass.components;
+                               }
+
+                               float *in_weight = (float*)buffer.data_pointer + pass_offset;
+
+                               for(int i = 0; i < size; i++, in += pass_stride, in_weight += pass_stride, pixels += 4) {
+                                       float4 f = make_float4(in[0], in[1], in[2], in[3]);
+                                       float w = in_weight[0];
+                                       float invw = (w > 0.0f)? 1.0f/w: 0.0f;
+
+                                       pixels[0] = f.x*invw;
+                                       pixels[1] = f.y*invw;
+                                       pixels[2] = f.z*invw;
+                                       pixels[3] = f.w*invw;
+                               }
+                       }
                        else {
                                for(int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
                                        float4 f = make_float4(in[0], in[1], in[2], in[3]);
index f9290dfc83544d59da2b6a451c65cd20b69b448c..e9ca7c3a366939e55d05588d70db4f3e78e41f60 100644 (file)
@@ -25,8 +25,7 @@ CCL_NAMESPACE_BEGIN
 
 Camera::Camera()
 {
-       shutteropen = 0.0f;
-       shutterclose = 1.0f;
+       shuttertime = 1.0f;
 
        aperturesize = 0.0f;
        focaldistance = 10.0f;
@@ -35,6 +34,10 @@ Camera::Camera()
 
        matrix = transform_identity();
 
+       motion.pre = transform_identity();
+       motion.post = transform_identity();
+       use_motion = false;
+
        type = CAMERA_PERSPECTIVE;
        fov = M_PI_F/4.0f;
 
@@ -124,7 +127,7 @@ void Camera::update()
        need_device_update = true;
 }
 
-void Camera::device_update(Device *device, DeviceScene *dscene)
+void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene)
 {
        update();
 
@@ -140,10 +143,28 @@ void Camera::device_update(Device *device, DeviceScene *dscene)
        kcam->rastertocamera = rastertocamera;
        kcam->cameratoworld = cameratoworld;
        kcam->worldtoscreen = transform_inverse(screentoworld);
-       kcam->worldtoraster = transform_inverse(rastertoworld);
+       kcam->worldtoraster = worldtoraster;
        kcam->worldtondc = transform_inverse(ndctoworld);
        kcam->worldtocamera = transform_inverse(cameratoworld);
 
+       /* camera motion */
+       Scene::MotionType need_motion = scene->need_motion();
+
+       if(need_motion == Scene::MOTION_PASS) {
+               if(use_motion) {
+                       kcam->motion.pre = transform_inverse(motion.pre * rastertocamera);
+                       kcam->motion.post = transform_inverse(motion.post * rastertocamera);
+               }
+               else {
+                       kcam->motion.pre = worldtoraster;
+                       kcam->motion.post = worldtoraster;
+               }
+       }
+       else if(need_motion == Scene::MOTION_BLUR) {
+               /* todo: exact camera position will not be hit this way */
+               transform_motion_decompose(&kcam->motion, &motion);
+       }
+
        /* depth of field */
        kcam->aperturesize = aperturesize;
        kcam->focaldistance = focaldistance;
@@ -151,8 +172,7 @@ void Camera::device_update(Device *device, DeviceScene *dscene)
        kcam->bladesrotation = bladesrotation;
 
        /* motion blur */
-       kcam->shutteropen = shutteropen;
-       kcam->shutterclose = shutterclose;
+       kcam->shuttertime= (need_motion == Scene::MOTION_BLUR)? shuttertime: 0.0f;
 
        /* type */
        kcam->type = type;
@@ -175,8 +195,7 @@ void Camera::device_free(Device *device, DeviceScene *dscene)
 
 bool Camera::modified(const Camera& cam)
 {
-       return !((shutteropen == cam.shutteropen) &&
-               (shutterclose == cam.shutterclose) &&
+       return !((shuttertime== cam.shuttertime) &&
                (aperturesize == cam.aperturesize) &&
                (blades == cam.blades) &&
                (bladesrotation == cam.bladesrotation) &&
@@ -192,7 +211,9 @@ bool Camera::modified(const Camera& cam)
                (right == cam.right) &&
                (bottom == cam.bottom) &&
                (top == cam.top) &&
-               (matrix == cam.matrix));
+               (matrix == cam.matrix) &&
+               (motion == cam.motion) &&
+               (use_motion == cam.use_motion));
 }
 
 void Camera::tag_update()
index cfcc5406ee35c16fbe3cc6251a0c006604e22df3..935489711c84f9dc39863eadefaec223f01d71ce 100644 (file)
@@ -28,6 +28,7 @@ CCL_NAMESPACE_BEGIN
 
 class Device;
 class DeviceScene;
+class Scene;
 
 /* Camera
  *
@@ -37,8 +38,7 @@ class DeviceScene;
 class Camera {
 public:
        /* motion blur */
-       float shutteropen;
-       float shutterclose;
+       float shuttertime;
 
        /* depth of field */
        float focaldistance;
@@ -61,6 +61,10 @@ public:
        /* transformation */
        Transform matrix;
 
+       /* motion */
+       MotionTransform motion;
+       bool use_motion;
+
        /* computed camera parameters */
     Transform screentoworld;
        Transform rastertoworld;
@@ -82,7 +86,7 @@ public:
 
        void update();
 
-       void device_update(Device *device, DeviceScene *dscene);
+       void device_update(Device *device, DeviceScene *dscene, Scene *scene);
        void device_free(Device *device, DeviceScene *dscene);
 
        bool modified(const Camera& cam);
index cc17f86fcb67860479cae6a55ddc498828cf88d4..55c89b7b1b2641ed3cc7835e06079900c8fc2c19 100644 (file)
@@ -67,6 +67,13 @@ void Pass::add(PassType type, vector<Pass>& passes)
                case PASS_UV:
                        pass.components = 4;
                        break;
+               case PASS_MOTION:
+                       pass.components = 4;
+                       pass.divide_type = PASS_MOTION_WEIGHT;
+                       break;
+               case PASS_MOTION_WEIGHT:
+                       pass.components = 1;
+                       break;
                case PASS_OBJECT_ID:
                        pass.components = 1;
                        pass.filter = false;
@@ -154,6 +161,15 @@ bool Pass::equals(const vector<Pass>& A, const vector<Pass>& B)
        return true;
 }
 
+bool Pass::contains(const vector<Pass>& passes, PassType type)
+{
+       foreach(const Pass& pass, passes)
+               if(pass.type == type)
+                       return true;
+       
+       return false;
+}
+
 /* Film */
 
 Film::Film()
@@ -196,6 +212,12 @@ void Film::device_update(Device *device, DeviceScene *dscene)
                        case PASS_UV:
                                kfilm->pass_uv = kfilm->pass_stride;
                                break;
+                       case PASS_MOTION:
+                               kfilm->pass_motion = kfilm->pass_stride;
+                               break;
+                       case PASS_MOTION_WEIGHT:
+                               kfilm->pass_motion_weight = kfilm->pass_stride;
+                               break;
                        case PASS_OBJECT_ID:
                                kfilm->pass_object_id = kfilm->pass_stride;
                                break;
index 8a3dbbf1b0872f0e10604ec573183f3560c5f951..c7d2ee243881545e654ba50535d12bb9087fe041 100644 (file)
@@ -40,6 +40,7 @@ public:
 
        static void add(PassType type, vector<Pass>& passes);
        static bool equals(const vector<Pass>& A, const vector<Pass>& B);
+       static bool contains(const vector<Pass>& passes, PassType);
 };
 
 class Film {
index cc29047f0487cad59dd33afe311e0cea216383bb..d9486de47c9975d916b5181c8f9c9df24eb4e504 100644 (file)
@@ -120,9 +120,9 @@ void ShaderNode::attributes(AttributeRequestSet *attributes)
        foreach(ShaderInput *input, inputs) {
                if(!input->link) {
                        if(input->default_value == ShaderInput::TEXTURE_GENERATED)
-                               attributes->add(Attribute::STD_GENERATED);
+                               attributes->add(ATTR_STD_GENERATED);
                        else if(input->default_value == ShaderInput::TEXTURE_UV)
-                               attributes->add(Attribute::STD_UV);
+                               attributes->add(ATTR_STD_UV);
                }
        }
 }
index c1f066df10cea011e25c082381a55219ba940b91..b26ebfd91e178733c82773d724a1f4b8f152bded 100644 (file)
@@ -45,6 +45,7 @@ Integrator::Integrator()
        seed = 0;
        layer_flag = ~0;
        sample_clamp = 0.0f;
+       motion_blur = false;
 
        need_update = true;
 }
@@ -125,7 +126,8 @@ bool Integrator::modified(const Integrator& integrator)
                filter_glossy == integrator.filter_glossy &&
                layer_flag == integrator.layer_flag &&
                seed == integrator.seed &&
-               sample_clamp == integrator.sample_clamp);
+               sample_clamp == integrator.sample_clamp &&
+               motion_blur == integrator.motion_blur);
 }
 
 void Integrator::tag_update(Scene *scene)
index 0817fcaa457ec807481761e15a7cab291fcddf41..afda41a857ddc022412ed8fcad9e6ad851e93b8c 100644 (file)
@@ -47,6 +47,7 @@ public:
        int layer_flag;
 
        float sample_clamp;
+       bool motion_blur;
 
        bool need_update;
 
index 0ce16e65621e82aef13f21264f3535d52555977f..5d96611ff26a3c7e9918c43468dec49f171dcb2e 100644 (file)
@@ -113,11 +113,11 @@ void Mesh::compute_bounds()
 void Mesh::add_face_normals()
 {
        /* don't compute if already there */
-       if(attributes.find(Attribute::STD_FACE_NORMAL))
+       if(attributes.find(ATTR_STD_FACE_NORMAL))
                return;
 
        /* get attributes */
-       Attribute *attr_fN = attributes.add(Attribute::STD_FACE_NORMAL);
+       Attribute *attr_fN = attributes.add(ATTR_STD_FACE_NORMAL);
        float3 *fN = attr_fN->data_float3();
 
        /* compute face normals */
@@ -145,12 +145,12 @@ void Mesh::add_face_normals()
 void Mesh::add_vertex_normals()
 {
        /* don't compute if already there */
-       if(attributes.find(Attribute::STD_VERTEX_NORMAL))
+       if(attributes.find(ATTR_STD_VERTEX_NORMAL))
                return;
 
        /* get attributes */
-       Attribute *attr_fN = attributes.find(Attribute::STD_FACE_NORMAL);
-       Attribute *attr_vN = attributes.add(Attribute::STD_VERTEX_NORMAL);
+       Attribute *attr_fN = attributes.find(ATTR_STD_FACE_NORMAL);
+       Attribute *attr_vN = attributes.add(ATTR_STD_VERTEX_NORMAL);
 
        float3 *fN = attr_fN->data_float3();
        float3 *vN = attr_vN->data_float3();
@@ -179,8 +179,8 @@ void Mesh::add_vertex_normals()
 
 void Mesh::pack_normals(Scene *scene, float4 *normal, float4 *vnormal)
 {
-       Attribute *attr_fN = attributes.find(Attribute::STD_FACE_NORMAL);
-       Attribute *attr_vN = attributes.find(Attribute::STD_VERTEX_NORMAL);
+       Attribute *attr_fN = attributes.find(ATTR_STD_FACE_NORMAL);
+       Attribute *attr_vN = attributes.find(ATTR_STD_VERTEX_NORMAL);
 
        float3 *fN = attr_fN->data_float3();
        float3 *vN = attr_vN->data_float3();
@@ -348,7 +348,7 @@ void MeshManager::update_osl_attributes(Device *device, Scene *scene, vector<Att
                        else
                                osl_attr.type = TypeDesc::TypeColor;
 
-                       if(req.std != Attribute::STD_NONE) {
+                       if(req.std != ATTR_STD_NONE) {
                                /* if standard attribute, add lookup by std:: name convention */
                                ustring stdname = ustring(string("std::") + Attribute::standard_name(req.std).c_str());
                                og->attribute_map[i][stdname] = osl_attr;
@@ -371,7 +371,7 @@ void MeshManager::update_svm_attributes(Device *device, DeviceScene *dscene, Sce
        int attr_map_stride = 0;
 
        for(size_t i = 0; i < scene->meshes.size(); i++)
-               attr_map_stride = max(attr_map_stride, mesh_attributes[i].size());
+               attr_map_stride = max(attr_map_stride, mesh_attributes[i].size()+1);
 
        if(attr_map_stride == 0)
                return;
@@ -393,13 +393,12 @@ void MeshManager::update_svm_attributes(Device *device, DeviceScene *dscene, Sce
                AttributeRequestSet& attributes = mesh_attributes[j];
 
                /* set object attributes */
-               j = 0;
+               int index = i*attr_map_stride;
 
                foreach(AttributeRequest& req, attributes.requests) {
-                       int index = i*attr_map_stride + j;
                        uint id;
 
-                       if(req.std == Attribute::STD_NONE)
+                       if(req.std == ATTR_STD_NONE)
                                id = scene->shader_manager->get_attribute_id(req.name);
                        else
                                id = scene->shader_manager->get_attribute_id(req.std);
@@ -413,8 +412,14 @@ void MeshManager::update_svm_attributes(Device *device, DeviceScene *dscene, Sce
                        else
                                attr_map[index].w = NODE_ATTR_FLOAT3;
 
-                       j++;
+                       index++;
                }
+
+               /* terminator */
+               attr_map[index].x = ATTR_STD_NONE;
+               attr_map[index].y = 0;
+               attr_map[index].z = 0;
+               attr_map[index].w = 0;
        }
 
        /* copy to device */
@@ -434,6 +439,8 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene,
        for(size_t i = 0; i < scene->meshes.size(); i++) {
                Mesh *mesh = scene->meshes[i];
 
+               scene->need_global_attributes(mesh_attributes[i]);
+
                foreach(uint sindex, mesh->used_shaders) {
                        Shader *shader = scene->shaders[sindex];
                        mesh_attributes[i].add(shader->attributes);
@@ -456,8 +463,8 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene,
                        Attribute *mattr = mesh->attributes.find(req);
 
                        /* todo: get rid of this exception */
-                       if(!mattr && req.std == Attribute::STD_GENERATED) {
-                               mattr = mesh->attributes.add(Attribute::STD_GENERATED);
+                       if(!mattr && req.std == ATTR_STD_GENERATED) {
+                               mattr = mesh->attributes.add(ATTR_STD_GENERATED);
                                if(mesh->verts.size())
                                        memcpy(mattr->data_float3(), &mesh->verts[0], sizeof(float3)*mesh->verts.size());
                        }
@@ -489,19 +496,19 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene,
                                float *data = mattr->data_float();
                                req.offset = attr_float.size();
 
+                               attr_float.resize(attr_float.size() + size);
+
                                for(size_t k = 0; k < size; k++)
-                                       attr_float.push_back(data[k]);
+                                       attr_float[req.offset+k] = data[k];
                        }
                        else {
                                float3 *data = mattr->data_float3();
                                req.offset = attr_float3.size();
 
-                               for(size_t k = 0; k < size; k++) {
-                                       float3 f3 = data[k];
-                                       float4 f4 = make_float4(f3.x, f3.y, f3.z, 0.0f);
+                               attr_float3.resize(attr_float3.size() + size);
 
-                                       attr_float3.push_back(f4);
-                               }
+                               for(size_t k = 0; k < size; k++)
+                                       attr_float3[req.offset+k] = float3_to_float4(data[k]);
                        }
 
                        /* mesh vertex/triangle index is global, not per object, so we sneak
@@ -712,8 +719,10 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
        foreach(Shader *shader, scene->shaders)
                shader->need_update_attributes = false;
 
+       bool motion_blur = scene->need_motion() == Scene::MOTION_BLUR;
+
        foreach(Object *object, scene->objects)
-               object->compute_bounds();
+               object->compute_bounds(motion_blur);
 
        if(progress.get_cancel()) return;
 
@@ -759,5 +768,32 @@ void MeshManager::tag_update(Scene *scene)
        scene->object_manager->need_update = true;
 }
 
+bool Mesh::need_attribute(Scene *scene, AttributeStandard std)
+{
+       if(std == ATTR_STD_NONE)
+               return false;
+       
+       if(scene->need_global_attribute(std))
+               return true;
+
+       foreach(uint shader, used_shaders)
+               if(scene->shaders[shader]->attributes.find(std))
+                       return true;
+       
+       return false;
+}
+
+bool Mesh::need_attribute(Scene *scene, ustring name)
+{
+       if(name == ustring())
+               return false;
+
+       foreach(uint shader, used_shaders)
+               if(scene->shaders[shader]->attributes.find(name))
+                       return true;
+       
+       return false;
+}
+
 CCL_NAMESPACE_END
 
index 585203484c79342cbfc72f756188bd2cffa283a2..047a2d2624d420a22f9bc3b1696b98dc785230e4 100644 (file)
@@ -98,6 +98,9 @@ public:
        void pack_verts(float4 *tri_verts, float4 *tri_vindex, size_t vert_offset);
        void compute_bvh(SceneParams *params, Progress& progress);
 
+       bool need_attribute(Scene *scene, AttributeStandard std);
+       bool need_attribute(Scene *scene, ustring name);
+
        void tag_update(Scene *scene, bool rebuild);
 };
 
index a6f8e3f6be88b3ff309c64028d68b0e2ab9fadc6..dea694a811e9e82f8264e029515f1251a830c37c 100644 (file)
@@ -140,11 +140,11 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p
         * normals, as bump mapping in the shader will already alter the
         * vertex normal, so we start from the non-displaced vertex normals
         * to avoid applying the perturbation twice. */
-       mesh->attributes.remove(Attribute::STD_FACE_NORMAL);
+       mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
        mesh->add_face_normals();
 
        if(mesh->displacement_method == Mesh::DISPLACE_TRUE) {
-               mesh->attributes.remove(Attribute::STD_VERTEX_NORMAL);
+               mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
                mesh->add_vertex_normals();
        }
 
index d71438ebae1bd8053878b64d113598437ae43200..7039f5b64122e57e95fd1a34827778b38b5c016a 100644 (file)
@@ -1514,9 +1514,9 @@ TextureCoordinateNode::TextureCoordinateNode()
 void TextureCoordinateNode::attributes(AttributeRequestSet *attributes)
 {
        if(!output("Generated")->links.empty())
-               attributes->add(Attribute::STD_GENERATED);
+               attributes->add(ATTR_STD_GENERATED);
        if(!output("UV")->links.empty())
-               attributes->add(Attribute::STD_UV);
+               attributes->add(ATTR_STD_UV);
 
        ShaderNode::attributes(attributes);
 }
@@ -1546,7 +1546,7 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler)
                        compiler.add_node(geom_node, NODE_GEOM_P, out->stack_offset);
                }
                else {
-                       int attr = compiler.attribute(Attribute::STD_GENERATED);
+                       int attr = compiler.attribute(ATTR_STD_GENERATED);
                        compiler.stack_assign(out);
                        compiler.add_node(attr_node, attr, out->stack_offset, NODE_ATTR_FLOAT3);
                }
@@ -1560,7 +1560,7 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler)
 
        out = output("UV");
        if(!out->links.empty()) {
-               int attr = compiler.attribute(Attribute::STD_UV);
+               int attr = compiler.attribute(ATTR_STD_UV);
                compiler.stack_assign(out);
                compiler.add_node(attr_node, attr, out->stack_offset, NODE_ATTR_FLOAT3);
        }
index 28645d856a83a0eeaaa079950fae2334d8fd140a..ccc654965f1e040ec85eb35888c69f9f4d804286 100644 (file)
@@ -38,15 +38,37 @@ Object::Object()
        visibility = ~0;
        pass_id = 0;
        bounds = BoundBox::empty;
+       motion.pre = transform_identity();
+       motion.post = transform_identity();
+       use_motion = false;
 }
 
 Object::~Object()
 {
 }
 
-void Object::compute_bounds()
+void Object::compute_bounds(bool motion_blur)
 {
-       bounds = mesh->bounds.transformed(&tfm);
+       BoundBox mbounds = mesh->bounds;
+
+       if(motion_blur && use_motion) {
+               MotionTransform decomp;
+               transform_motion_decompose(&decomp, &motion);
+
+               bounds = BoundBox::empty;
+
+               /* todo: this is really terrible. according to pbrt there is a better
+                * way to find this iteratively, but did not find implementation yet
+                * or try to implement myself */
+               for(float t = 0.0f; t < 1.0f; t += 1.0f/128.0f) {
+                       Transform ttfm;
+
+                       transform_motion_interpolate(&ttfm, &decomp, t);
+                       bounds.grow(mbounds.transformed(&ttfm));
+               }
+       }
+       else
+               bounds = mbounds.transformed(&tfm);
 }
 
 void Object::apply_transform()
@@ -57,8 +79,8 @@ void Object::apply_transform()
        for(size_t i = 0; i < mesh->verts.size(); i++)
                mesh->verts[i] = transform_point(&tfm, mesh->verts[i]);
 
-       Attribute *attr_fN = mesh->attributes.find(Attribute::STD_FACE_NORMAL);
-       Attribute *attr_vN = mesh->attributes.find(Attribute::STD_VERTEX_NORMAL);
+       Attribute *attr_fN = mesh->attributes.find(ATTR_STD_FACE_NORMAL);
+       Attribute *attr_vN = mesh->attributes.find(ATTR_STD_VERTEX_NORMAL);
 
        Transform ntfm = transform_transpose(transform_inverse(tfm));
 
@@ -83,7 +105,7 @@ void Object::apply_transform()
 
        if(bounds.valid()) {
                mesh->compute_bounds();
-               compute_bounds();
+               compute_bounds(false);
        }
        
        tfm = transform_identity();
@@ -123,6 +145,7 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
        float4 *objects = dscene->objects.resize(OBJECT_SIZE*scene->objects.size());
        int i = 0;
        map<Mesh*, float> surface_area_map;
+       Scene::MotionType need_motion = scene->need_motion();
 
        foreach(Object *ob, scene->objects) {
                Mesh *mesh = ob->mesh;
@@ -130,7 +153,6 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
                /* compute transformations */
                Transform tfm = ob->tfm;
                Transform itfm = transform_inverse(tfm);
-               Transform ntfm = transform_transpose(itfm);
 
                /* compute surface area. for uniform scale we can do avoid the many
                   transform calls and share computation for instances */
@@ -171,10 +193,38 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
                /* pack in texture */
                int offset = i*OBJECT_SIZE;
 
-               memcpy(&objects[offset], &tfm, sizeof(float4)*4);
-               memcpy(&objects[offset+4], &itfm, sizeof(float4)*4);
-               memcpy(&objects[offset+8], &ntfm, sizeof(float4)*4);
-               objects[offset+12] = make_float4(surface_area, pass_id, 0.0f, 0.0f);
+               memcpy(&objects[offset], &tfm, sizeof(float4)*3);
+               memcpy(&objects[offset+3], &itfm, sizeof(float4)*3);
+               objects[offset+6] = make_float4(surface_area, pass_id, 0.0f, 0.0f);
+
+               if(need_motion == Scene::MOTION_PASS) {
+                       /* motion transformations, is world/object space depending if mesh
+                          comes with deformed position in object space, or if we transform
+                          the shading point in world space */
+                       Transform mtfm_pre = ob->motion.pre;
+                       Transform mtfm_post = ob->motion.post;
+
+                       if(!mesh->attributes.find(ATTR_STD_MOTION_PRE))
+                               mtfm_pre = mtfm_pre * itfm;
+                       if(!mesh->attributes.find(ATTR_STD_MOTION_POST))
+                               mtfm_post = mtfm_post * itfm;
+
+                       memcpy(&objects[offset+8], &mtfm_pre, sizeof(float4)*4);
+                       memcpy(&objects[offset+12], &mtfm_post, sizeof(float4)*4);
+               }
+               else if(need_motion == Scene::MOTION_BLUR) {
+                       if(ob->use_motion) {
+                               /* decompose transformations for interpolation */
+                               MotionTransform decomp;
+
+                               transform_motion_decompose(&decomp, &ob->motion);
+                               memcpy(&objects[offset+8], &decomp, sizeof(float4)*8);
+                       }
+                       else {
+                               float4 no_motion = make_float4(FLT_MAX);
+                               memcpy(&objects[offset+8], &no_motion, sizeof(float4));
+                       }
+               }
 
                i++;
 
@@ -225,6 +275,7 @@ void ObjectManager::apply_static_transforms(Scene *scene, Progress& progress)
 
        /* counter mesh users */
        map<Mesh*, int> mesh_users;
+       bool motion_blur = scene->need_motion() == Scene::MOTION_BLUR;
 
        foreach(Object *object, scene->objects) {
                map<Mesh*, int>::iterator it = mesh_users.find(object->mesh);
@@ -240,12 +291,14 @@ void ObjectManager::apply_static_transforms(Scene *scene, Progress& progress)
        /* apply transforms for objects with single user meshes */
        foreach(Object *object, scene->objects) {
                if(mesh_users[object->mesh] == 1) {
-                       if(!object->mesh->transform_applied) {
-                               object->apply_transform();
-                               object->mesh->transform_applied = true;
-                       }
+                       if(!(motion_blur && object->use_motion)) {
+                               if(!object->mesh->transform_applied) {
+                                       object->apply_transform();
+                                       object->mesh->transform_applied = true;
 
-                       if(progress.get_cancel()) return;
+                                       if(progress.get_cancel()) return;
+                               }
+                       }
                }
        }
 }
index 14da2cfb35d4f4fa420be4cd0e3114f72a75acd3..e84c4b267672d2d564d07c70a1f9f4e766728f29 100644 (file)
@@ -44,13 +44,15 @@ public:
        int pass_id;
        vector<ParamValue> attributes;
        uint visibility;
+       MotionTransform motion;
+       bool use_motion;
 
        Object();
        ~Object();
 
        void tag_update(Scene *scene);
 
-       void compute_bounds();
+       void compute_bounds(bool motion_blur);
        void apply_transform();
 };
 
index 079f2744e730d621218e6acba0eefb08c2ac9e5f..b6453339d41f1287a700144653b27faf8be465da 100644 (file)
@@ -128,7 +128,7 @@ void Scene::device_update(Device *device_, Progress& progress)
        if(progress.get_cancel()) return;
 
        progress.set_status("Updating Camera");
-       camera->device_update(device, &dscene);
+       camera->device_update(device, &dscene, this);
 
        if(progress.get_cancel()) return;
 
@@ -166,6 +166,33 @@ void Scene::device_update(Device *device_, Progress& progress)
        device->const_copy_to("__data", &dscene.data, sizeof(dscene.data));
 }
 
+Scene::MotionType Scene::need_motion()
+{
+       if(integrator->motion_blur)
+               return MOTION_BLUR;
+       else if(Pass::contains(film->passes, PASS_MOTION))
+               return MOTION_PASS;
+       else
+               return MOTION_NONE;
+}
+
+bool Scene::need_global_attribute(AttributeStandard std)
+{
+       if(std == ATTR_STD_UV)
+               return Pass::contains(film->passes, PASS_UV);
+       if(std == ATTR_STD_MOTION_PRE || ATTR_STD_MOTION_POST)
+               return need_motion() == MOTION_PASS;
+       
+       return false;
+}
+
+void Scene::need_global_attributes(AttributeRequestSet& attributes)
+{
+       for(int std = ATTR_STD_NONE; std < ATTR_STD_NUM; std++)
+               if(need_global_attribute((AttributeStandard)std))
+                       attributes.add((AttributeStandard)std);
+}
+
 bool Scene::need_update()
 {
        return (need_reset() || film->need_update);
index af4301b1cd95d1fe7e9d2838373bcd4beea877f3..7d4acf369fdc5441ef2976835b228c4a40977951 100644 (file)
@@ -33,6 +33,7 @@
 
 CCL_NAMESPACE_BEGIN
 
+class AttributeRequestSet;
 class Background;
 class Camera;
 class Device;
@@ -175,6 +176,12 @@ public:
 
        void device_update(Device *device, Progress& progress);
 
+       bool need_global_attribute(AttributeStandard std);
+       void need_global_attributes(AttributeRequestSet& attributes);
+
+       enum MotionType { MOTION_NONE = 0, MOTION_PASS, MOTION_BLUR };
+       MotionType need_motion();
+
        bool need_update();
        bool need_reset();
 };
index c1f7b3518d21225129f118bfbde4945c2ed54799..f50709146efd68d36cde87970106c1a630d13a2e 100644 (file)
@@ -133,12 +133,12 @@ uint ShaderManager::get_attribute_id(ustring name)
        if(it != unique_attribute_id.end())
                return it->second;
        
-       uint id = (uint)Attribute::STD_NUM + unique_attribute_id.size();
+       uint id = (uint)ATTR_STD_NUM + unique_attribute_id.size();
        unique_attribute_id[name] = id;
        return id;
 }
 
-uint ShaderManager::get_attribute_id(Attribute::Standard std)
+uint ShaderManager::get_attribute_id(AttributeStandard std)
 {
        return (uint)std;
 }
index 35f3cfe27f5e0d973ef0e965ea67d20060d97ded..48d517ce21aa9b8d46734f2b2efc2e5d4051bee1 100644 (file)
@@ -103,7 +103,7 @@ public:
 
        /* get globally unique id for a type of attribute */
        uint get_attribute_id(ustring name);
-       uint get_attribute_id(Attribute::Standard std);
+       uint get_attribute_id(AttributeStandard std);
 
        /* get shader id for mesh faces */
        int get_shader_id(uint shader, Mesh *mesh = NULL, bool smooth = false);
index a52e30c6030f364536197b01cc72ae469fa99a06..1ff3ac20d5051a55d6b3bfbf31504f6353ee5333 100644 (file)
@@ -337,7 +337,7 @@ uint SVMCompiler::attribute(ustring name)
        return shader_manager->get_attribute_id(name);
 }
 
-uint SVMCompiler::attribute(Attribute::Standard std)
+uint SVMCompiler::attribute(AttributeStandard std)
 {
        return shader_manager->get_attribute_id(std);
 }
index 56c930f6217a111446d57c46837be38097cbab82..0db68f400fc62ceb87a3ec4cc34f5851b69bd6c2 100644 (file)
@@ -69,7 +69,7 @@ public:
        void add_node(const float4& f);
        void add_array(float4 *f, int num);
        uint attribute(ustring name);
-       uint attribute(Attribute::Standard std);
+       uint attribute(AttributeStandard std);
        uint encode_uchar4(uint x, uint y = 0, uint z = 0, uint w = 0);
        uint closure_mix_weight_offset() { return mix_weight_offset; }
 
index 6b29d1ca51a21481ed111bbba93883ecac72287a..6e24bb410b578f1913c1635022ce8f665e0f8ac9 100644 (file)
@@ -39,7 +39,7 @@ EdgeDice::EdgeDice(Mesh *mesh_, int shader_, bool smooth_, float dicing_rate_)
        smooth = smooth_;
        camera = NULL;
 
-       mesh->attributes.add(Attribute::STD_VERTEX_NORMAL);
+       mesh->attributes.add(ATTR_STD_VERTEX_NORMAL);
 }
 
 void EdgeDice::reserve(int num_verts, int num_tris)
@@ -49,7 +49,7 @@ void EdgeDice::reserve(int num_verts, int num_tris)
 
        mesh->reserve(vert_offset + num_verts, tri_offset + num_tris);
 
-       Attribute *attr_vN = mesh->attributes.add(Attribute::STD_VERTEX_NORMAL);
+       Attribute *attr_vN = mesh->attributes.add(ATTR_STD_VERTEX_NORMAL);
 
        mesh_P = &mesh->verts[0];
        mesh_N = attr_vN->data_float3();
index 53c1302b4a1168df554279c9f23eb64f41b81349..f09803d8b0908058dd78660099bee32b0d4464a7 100644 (file)
@@ -55,6 +55,10 @@ CCL_NAMESPACE_BEGIN
 #ifndef M_2_PI_F
 #define M_2_PI_F       ((float)0.636619772367581343075535053490057448)
 #endif
+#ifndef M_SQRT2_F
+#define M_SQRT2_F      ((float)1.41421356237309504880)
+#endif
+
 
 /* Scalar */
 
@@ -719,6 +723,45 @@ __device_inline float4 cross(const float4& a, const float4& b)
 #endif
 }
 
+__device_inline bool is_zero(const float4& a)
+{
+#ifdef __KERNEL_SSE__
+       return a == make_float4(0.0f);
+#else
+       return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f && a.w == 0.0f);
+#endif
+}
+
+__device_inline float reduce_add(const float4& a)
+{
+#ifdef __KERNEL_SSE__
+       float4 h = shuffle<1,0,3,2>(a) + a;
+       return _mm_cvtss_f32(shuffle<2,3,0,1>(h) + h); /* todo: efficiency? */
+#else
+       return ((a.x + a.y) + (a.z + a.w));
+#endif
+}
+
+__device_inline float average(const float4& a)
+{
+       return reduce_add(a) * 0.25f;
+}
+
+__device_inline float dot(const float4& a, const float4& b)
+{
+       return reduce_add(a * b);
+}
+
+__device_inline float len(const float4 a)
+{
+       return sqrtf(dot(a, a));
+}
+
+__device_inline float4 normalize(const float4 a)
+{
+       return a/len(a);
+}
+
 __device_inline float4 min(float4 a, float4 b)
 {
 #ifdef __KERNEL_SSE__
@@ -790,39 +833,6 @@ __device_inline void print_float4(const char *label, const float4& a)
 
 #endif
 
-#ifndef __KERNEL_OPENCL__
-
-__device_inline bool is_zero(const float4& a)
-{
-#ifdef __KERNEL_SSE__
-       return a == make_float4(0.0f);
-#else
-       return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f && a.w == 0.0f);
-#endif
-}
-
-__device_inline float reduce_add(const float4& a)
-{
-#ifdef __KERNEL_SSE__
-       float4 h = shuffle<1,0,3,2>(a) + a;
-       return _mm_cvtss_f32(shuffle<2,3,0,1>(h) + h); /* todo: efficiency? */
-#else
-       return ((a.x + a.y) + (a.z + a.w));
-#endif
-}
-
-__device_inline float average(const float4& a)
-{
-       return reduce_add(a) * 0.25f;
-}
-
-__device_inline float dot(const float4& a, const float4& b)
-{
-       return reduce_add(a * b);
-}
-
-#endif
-
 /* Int3 */
 
 #ifndef __KERNEL_OPENCL__
index 0fd26825911873b7380be0623c3fa1057a4bd777..1780994da27f48e679b8de7a6a18dd8ce47c5757 100644 (file)
@@ -53,6 +53,8 @@
 
 CCL_NAMESPACE_BEGIN
 
+/* Transform Inverse */
+
 static bool transform_matrix4_gj_inverse(float R[][4], float M[][4])
 {
        /* forward elimination */
@@ -151,5 +153,104 @@ Transform transform_inverse(const Transform& tfm)
        return tfmR;
 }
 
+/* Motion Transform */
+
+static float4 transform_to_quat(const Transform& tfm)
+{
+       double trace = tfm[0][0] + tfm[1][1] + tfm[2][2];
+       float4 qt;
+
+       if(trace > 0.0f) {
+               double s = sqrt(trace + 1.0);
+
+               qt.w = (float)(s/2.0);
+               s = 0.5/s;
+
+               qt.x = (float)((tfm[2][1] - tfm[1][2]) * s);
+               qt.y = (float)((tfm[0][2] - tfm[2][0]) * s);
+               qt.z = (float)((tfm[1][0] - tfm[0][1]) * s);
+       }
+       else {
+               int i = 0;
+
+               if(tfm[1][1] > tfm[i][i])
+                       i = 1;
+               if(tfm[2][2] > tfm[i][i])
+                       i = 2;
+
+               int j = (i + 1)%3;
+               int k = (j + 1)%3;
+
+               double s = sqrt((tfm[i][i] - (tfm[j][j] + tfm[k][k])) + 1.0);
+
+               double q[3];
+               q[i] = s * 0.5;
+               if(s != 0.0)
+                       s = 0.5/s;
+
+               double w = (tfm[k][j] - tfm[j][k]) * s;
+               q[j] = (tfm[j][i] + tfm[i][j]) * s;
+               q[k] = (tfm[k][i] + tfm[i][k]) * s;
+
+               qt.x = (float)q[0];
+               qt.y = (float)q[1];
+               qt.z = (float)q[2];
+               qt.w = (float)w;
+       }
+
+       return qt;
+}
+
+static void transform_decompose(Transform *decomp, const Transform *tfm)
+{
+       /* extract translation */
+       decomp->y = make_float4(tfm->x.w, tfm->y.w, tfm->z.w, 0.0f);
+
+       /* extract rotation */
+       Transform M = *tfm;
+       M.x.w = 0.0f; M.y.w = 0.0f; M.z.w = 0.0f; M.w.w = 1.0f;
+
+       Transform R = M;
+       float norm;
+       int iteration = 0;
+
+       do {
+               Transform Rnext;
+               Transform Rit = transform_inverse(transform_transpose(R));
+
+               for(int i = 0; i < 4; i++)
+                       for(int j = 0; j < 4; j++)
+                               Rnext[i][j] = 0.5f * (R[i][j] + Rit[i][j]);
+               
+               norm = 0.0f;
+               for(int i = 0; i < 3; i++) {
+                       norm = max(norm,
+                               fabsf(R[i][0] - Rnext[i][0]) +
+                               fabsf(R[i][1] - Rnext[i][1]) +
+                               fabsf(R[i][2] - Rnext[i][2]));
+               }
+
+               R = Rnext;
+               iteration++;
+       } while(iteration < 100 && norm > 1e-4f);
+
+       if(transform_negative_scale(R))
+               R = R * transform_scale(-1.0f, -1.0f, -1.0f); /* todo: test scale */
+
+       decomp->x = transform_to_quat(R);
+
+       /* extract scale and pack it */
+       Transform scale = transform_inverse(R) * M;
+       decomp->y.w = scale.x.x;
+       decomp->z = make_float4(scale.x.y, scale.x.z, scale.y.x, scale.y.y);
+       decomp->w = make_float4(scale.y.z, scale.z.x, scale.z.y, scale.z.z);
+}
+
+void transform_motion_decompose(MotionTransform *decomp, const MotionTransform *motion)
+{
+       transform_decompose(&decomp->pre, &motion->pre);
+       transform_decompose(&decomp->post, &motion->post);
+}
+
 CCL_NAMESPACE_END
 
index aeaef7b0e216c72e8356b202423a2fc804a3ce70..03dfbaa441d20be31ee92819862d850869acd460 100644 (file)
@@ -28,6 +28,8 @@
 
 CCL_NAMESPACE_BEGIN
 
+/* Data Types */
+
 typedef struct Transform {
        float4 x, y, z, w; /* rows */
 
@@ -37,6 +39,17 @@ typedef struct Transform {
 #endif
 } Transform;
 
+typedef struct MotionTransform {
+       Transform pre;
+       Transform post;
+} MotionTransform;
+
+/* transform decomposed in rotation/translation/scale. we use the same data
+ * structure as Transform, and tightly pack decomposition into it. first the
+ * rotation (4), then translation (3), then 3x3 scale matrix (9) */
+
+/* Functions */
+
 __device_inline float3 transform_perspective(const Transform *t, const float3 a)
 {
        float4 b = make_float4(a.x, a.y, a.z, 1.0f);
@@ -62,6 +75,15 @@ __device_inline float3 transform_direction(const Transform *t, const float3 a)
        return c;
 }
 
+__device_inline float3 transform_direction_transposed(const Transform *t, const float3 a)
+{
+       float3 x = make_float3(t->x.x, t->y.x, t->z.x);
+       float3 y = make_float3(t->x.y, t->y.y, t->z.y);
+       float3 z = make_float3(t->x.z, t->y.z, t->z.z);
+
+       return make_float3(dot(x, a), dot(y, a), dot(z, a));
+}
+
 #ifndef __KERNEL_GPU__
 
 __device_inline void print_transform(const char *label, const Transform& t)
@@ -272,6 +294,102 @@ __device_inline Transform transform_clear_scale(const Transform& tfm)
 
 #endif
 
+/* Motion Transform */
+
+__device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
+{
+       float costheta = dot(q1, q2);
+
+       if(costheta > 0.9995f) {
+               return normalize((1.0f - t)*q1 + t*q2);
+       }
+       else  {
+               float theta = acosf(clamp(costheta, -1.0f, 1.0f));
+               float thetap = theta * t;
+               float4 qperp = normalize(q2 - q1 * costheta);
+               return q1 * cosf(thetap) + qperp * sinf(thetap);
+       }
+}
+
+__device_inline Transform transform_quick_inverse(Transform M)
+{
+       Transform R;
+       float det = M.x.x*(M.z.z*M.y.y - M.z.y*M.y.z) - M.y.x*(M.z.z*M.x.y - M.z.y*M.x.z) + M.z.x*(M.y.z*M.x.y - M.y.y*M.x.z);
+
+       det = (det != 0.0f)? 1.0f/det: 0.0f;
+
+       float3 Rx = det*make_float3(M.z.z*M.y.y - M.z.y*M.y.z, M.z.y*M.x.z - M.z.z*M.x.y, M.y.z*M.x.y - M.y.y*M.x.z);
+       float3 Ry = det*make_float3(M.z.x*M.y.z - M.z.z*M.y.x, M.z.z*M.x.x - M.z.x*M.x.z, M.y.x*M.x.z - M.y.z*M.x.x);
+       float3 Rz = det*make_float3(M.z.y*M.y.x - M.z.x*M.y.y, M.z.x*M.x.y - M.z.y*M.x.x, M.y.y*M.x.x - M.y.x*M.x.y);
+       float3 T = -make_float3(M.x.w, M.y.w, M.z.w);
+
+       R.x = make_float4(Rx.x, Rx.y, Rx.z, dot(Rx, T));
+       R.y = make_float4(Ry.x, Ry.y, Ry.z, dot(Ry, T));
+       R.z = make_float4(Rz.x, Rz.y, Rz.z, dot(Rz, T));
+       R.w = make_float4(0.0f, 0.0f, 0.0f, 1.0f);
+
+       return R;
+}
+
+__device_inline void transform_compose(Transform *tfm, const Transform *decomp)
+{
+       /* rotation */
+       float q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc;
+
+       q0 = M_SQRT2_F * decomp->x.w;
+       q1 = M_SQRT2_F * decomp->x.x;
+       q2 = M_SQRT2_F * decomp->x.y;
+       q3 = M_SQRT2_F * decomp->x.z;
+
+       qda = q0*q1;
+       qdb = q0*q2;
+       qdc = q0*q3;
+       qaa = q1*q1;
+       qab = q1*q2;
+       qac = q1*q3;
+       qbb = q2*q2;
+       qbc = q2*q3;
+       qcc = q3*q3;
+
+       float3 rotation_x = make_float3(1.0f-qbb-qcc, -qdc+qab, qdb+qac);
+       float3 rotation_y = make_float3(qdc+qab, 1.0f-qaa-qcc, -qda+qbc);
+       float3 rotation_z = make_float3(-qdb+qac, qda+qbc, 1.0f-qaa-qbb);
+
+       /* scale */
+       float3 scale_x = make_float3(decomp->y.w, decomp->z.z, decomp->w.y);
+       float3 scale_y = make_float3(decomp->z.x, decomp->z.w, decomp->w.z);
+       float3 scale_z = make_float3(decomp->z.y, decomp->w.x, decomp->w.w);
+
+       /* compose with translation */
+       tfm->x = make_float4(dot(rotation_x, scale_x), dot(rotation_x, scale_y), dot(rotation_x, scale_z), decomp->y.x);
+       tfm->y = make_float4(dot(rotation_y, scale_x), dot(rotation_y, scale_y), dot(rotation_y, scale_z), decomp->y.y);
+       tfm->z = make_float4(dot(rotation_z, scale_x), dot(rotation_z, scale_y), dot(rotation_z, scale_z), decomp->y.z);
+       tfm->w = make_float4(0.0f, 0.0f, 0.0f, 1.0f);
+}
+
+__device void transform_motion_interpolate(Transform *tfm, const MotionTransform *motion, float t)
+{
+       Transform decomp;
+
+       decomp.x = quat_interpolate(motion->pre.x, motion->post.x, t);
+       decomp.y = (1.0f - t)*motion->pre.y + t*motion->post.y;
+       decomp.z = (1.0f - t)*motion->pre.z + t*motion->post.z;
+       decomp.w = (1.0f - t)*motion->pre.w + t*motion->post.w;
+
+       transform_compose(tfm, &decomp);
+}
+
+#ifndef __KERNEL_GPU__
+
+__device_inline bool operator==(const MotionTransform& A, const MotionTransform& B)
+{
+       return (A.pre == B.pre && A.post == B.post);
+}
+
+void transform_motion_decompose(MotionTransform *decomp, const MotionTransform *motion);
+
+#endif
+
 CCL_NAMESPACE_END
 
 #endif /* __UTIL_TRANSFORM_H__ */
index 974924be46cbac8a12a7b49f8cfe565d18642ab0..567833c4988f7b05b12f3636849aa8513bea027a 100644 (file)
@@ -186,11 +186,62 @@ class DATA_PT_sunsky(DataButtonsPanel, Panel):
         sub = col.column(align=True)
         sub.prop(lamp, "atmosphere_inscattering", slider=True, text="Inscattering")
         sub.prop(lamp, "atmosphere_extinction", slider=True, text="Extinction")
+        
+class DATA_PT_shadow_game(DataButtonsPanel, bpy.types.Panel):
+    bl_label = "Shadow"
+    COMPAT_ENGINES = {'BLENDER_GAME'}
 
+    @classmethod
+    def poll(cls, context):
+        COMPAT_LIGHTS = {'SPOT', 'SUN'}
+        lamp = context.lamp
+        engine = context.scene.render.engine
+        return (lamp and lamp.type in COMPAT_LIGHTS) and (engine in cls.COMPAT_ENGINES)
+        
+    def draw_header(self, context):
+        lamp = context.lamp
+        
+        self.layout.prop(lamp, "use_shadow", text="")
+
+    def draw(self, context):
+        layout = self.layout
+
+        lamp = context.lamp
+        
+        split = layout.split()
+
+        col = split.column()
+        col.prop(lamp, "shadow_color", text="")
+
+        col = split.column()
+        col.prop(lamp, "use_shadow_layer", text="This Layer Only")
+        col.prop(lamp, "use_only_shadow")
+    
+        col = layout.column()
+        col.label("Buffer Type:")
+        col.prop(lamp, "ge_shadow_buffer_type", text="", toggle=True)
+        col.label("Quality:")
+        col = layout.column(align=True)
+        col.prop(lamp, "shadow_buffer_size", text="Size")
+        col.prop(lamp, "shadow_buffer_bias", text="Bias")
+        col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias")
+               
+        
+        row = layout.row()
+        row.label("Clipping:")
+        row = layout.row(align=True)
+        row.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
+        row.prop(lamp, "shadow_buffer_clip_end", text="Clip End")
+
+        if lamp.type == 'SUN':
+            row = layout.row()
+            row.prop(lamp, "shadow_frustum_size", text="Frustum Size")
+        
+        layout.active = lamp.use_shadow
 
 class DATA_PT_shadow(DataButtonsPanel, Panel):
     bl_label = "Shadow"
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     @classmethod
     def poll(cls, context):
index 66d18fc6f191c808e8038972bef261500e4fd5aa..778e66bffcc1924e1f77e42cb02fac646c709d8a 100644 (file)
@@ -42,6 +42,7 @@ class INFO_HT_header(Header):
                 sub.menu("INFO_MT_game")
             else:
                 sub.menu("INFO_MT_render")
+            sub.menu("INFO_MT_window")
             sub.menu("INFO_MT_help")
 
         if window.screen.show_fullscreen:
@@ -66,9 +67,6 @@ class INFO_HT_header(Header):
         row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
         row.label(text=scene.statistics())
 
-        # XXX: this should be right-aligned to the RHS of the region
-        layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="")
-
         # XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!!
         """
         sinfo = context.space_data
@@ -350,19 +348,30 @@ class INFO_MT_render(Menu):
 
         layout.operator("render.view_show")
         layout.operator("render.play_rendered_anim")
-
+        
+class INFO_MT_window(bpy.types.Menu):
+    bl_label = "Window"
+    
+    def draw(self, context):
+        import sys
+        
+        layout = self.layout
+        
+        layout.operator("wm.window_duplicate")
+        layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
+        if sys.platform[:3] == "win":
+            layout.separator()
+            layout.operator("wm.console_toggle", icon='CONSOLE')
+        
 
 class INFO_MT_help(Menu):
     bl_label = "Help"
 
     def draw(self, context):
-        import sys
-
         layout = self.layout
 
         layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:2.6/Manual'
         layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-263/'
-
         layout.separator()
 
         layout.operator("wm.url_open", text="Blender Website", icon='URL').url = 'http://www.blender.org/'
@@ -377,12 +386,10 @@ class INFO_MT_help(Menu):
         layout.operator("wm.operator_cheat_sheet", icon='TEXT')
         layout.operator("wm.sysinfo", icon='TEXT')
         layout.separator()
-        if sys.platform[:3] == "win":
-            layout.operator("wm.console_toggle", icon='CONSOLE')
-            layout.separator()
         layout.operator("anim.update_data_paths", text="FCurve/Driver Version fix", icon='HELP')
         layout.operator("logic.texface_convert", text="TexFace to Material Convert", icon='GAME')
         layout.separator()
+        
         layout.operator("wm.splash", icon='BLENDER')
 
 if __name__ == "__main__":  # only for live edit.
index ff9484e6baf599ef801557643e1d2ef1bb8d25ac..b1b9742e16a446e37cf8e92fb8d4a87c6d609ed5 100644 (file)
@@ -69,7 +69,7 @@ class VIEW3D_HT_header(Header):
                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
 
             # Occlude geometry
-            if view.viewport_shade in {'SOLID', 'SHADED', 'TEXTURED'} and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
+            if view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
                 row.prop(view, "use_occlude_geometry", text="")
 
             # Proportional editing
index 3a64a8aa8ac039aa0367540641407f2489dfaec6..17c29e2a834852f14edbf64ebded8a3bacfa7fd9 100644 (file)
@@ -1,7 +1,4 @@
 /*
- *
- * This is external code.
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -31,6 +28,8 @@
 
 /** \file blender/avi/intern/avi.c
  *  \ingroup avi
+ *
+ * This is external code.
  */
 
 
index e06d0bbfa1126d1b3d2d30b535e9c30cb930b2e5..36e862708f4db2eff5d161e17b14bf5be8f0749d 100644 (file)
@@ -1,7 +1,4 @@
 /*
- *
- * This is external code. Converts rgb-type avi-s.
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -31,6 +28,8 @@
 
 /** \file blender/avi/intern/avirgb.c
  *  \ingroup avi
+ *
+ * This is external code. Converts rgb-type avi-s.
  */
 
 
index 87db5915dc8fab4666cb2e9c359a5634aa945ea6..c99938e7b9eb927c114b74b8288c09c2c7da649f 100644 (file)
@@ -1,7 +1,4 @@
 /*
- *
- * This is external code. Identify and convert different avi-files.
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -30,6 +27,8 @@
 
 /** \file blender/avi/intern/codecs.c
  *  \ingroup avi
+ *
+ * This is external code. Identify and convert different avi-files.
  */
 
 
index 41b8202af036ad82b632b3a5f63d4fa797715884..fd8cc56f5515fa9debc4236d93e2479283bd852e 100644 (file)
@@ -1,8 +1,4 @@
 /*
- *
- * This is external code. Streams bytes to output depending on the
- * endianness of the system.
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -32,6 +28,9 @@
 
 /** \file blender/avi/intern/endian.c
  *  \ingroup avi
+ *
+ * This is external code. Streams bytes to output depending on the
+ * endianness of the system.
  */
 
 
index 3229f32cbbd4b04040da1bf47c86eae819ec73d1..7ef49cb1699573d023bd2b1c68dc970aae3413fb 100644 (file)
@@ -1,7 +1,4 @@
 /*
- *
- * This is external code.
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * Contributor(s): none yet.
  *
  * ***** END GPL LICENSE BLOCK *****
- *
  */
 
 /** \file blender/avi/intern/endian.h
  *  \ingroup avi
+ *
+ * This is external code.
  */
 
-
 #ifndef __ENDIAN_H__
 #define __ENDIAN_H__
 
@@ -49,7 +46,7 @@
 #define AVI_INDEXE   6
 #define AVI_MJPEGU   7
 
-void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int type);
+void awrite(AviMovie *movie, void *datain, int block, int size, FILE *fp, int type);
 
 #endif
 
index f6ebcab2aebfa0c648a693ccb6c0e5a9d9f67e25..29356f8ef289bfd984989c0a63500e894fa47fc0 100644 (file)
@@ -1,7 +1,4 @@
 /*
- *
- * This is external code. Converts between avi and mpeg/jpeg.
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -31,6 +28,8 @@
 
 /** \file blender/avi/intern/mjpeg.c
  *  \ingroup avi
+ *
+ * This is external code. Converts between avi and mpeg/jpeg.
  */
 
 
index fb1ed24926eae03f463238b990fc0139567c3c5e..db9719c171ddbb09216cd30fc10be664e66356dd 100644 (file)
@@ -1,8 +1,4 @@
 /*
- *
- * This is external code. Sets some compression related options
- * (width, height quality, framerate).
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -32,6 +28,9 @@
 
 /** \file blender/avi/intern/options.c
  *  \ingroup avi
+ *
+ * This is external code. Sets some compression related options
+ * (width, height quality, framerate).
  */
 
 #include "AVI_avi.h"
index c6830d9666a34c09b9480c7ee0f6b966a5b41750..7b4958ca02641b2e035872b1b9256d65240fb6db 100644 (file)
@@ -1,7 +1,4 @@
 /*
- *
- * This is external code. Converts between rgb32 and avi.
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -31,6 +28,8 @@
 
 /** \file blender/avi/intern/rgb32.c
  *  \ingroup avi
+ *
+ * This is external code. Converts between rgb32 and avi.
  */
 
 
index 51daac871383ff6a28b4b90d50b5c5f586015f13..19ca0f8cc61e78c0f4a332d7bbe26a457c7b14d4 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION                        263
-#define BLENDER_SUBVERSION             1
+#define BLENDER_SUBVERSION             2
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
index 6a3625e213397aa4bacf315ce836c56c10960ea1..4b52189d8b77503cd35d7fc7359be4d0ad8250e0 100644 (file)
@@ -305,6 +305,7 @@ int CustomData_sizeof(int type);
 
 /* get the name of a layer type */
 const char *CustomData_layertype_name(int type);
+int         CustomData_layertype_is_singleton(int type);
 
 /* make sure the name of layer at index is unique */
 void CustomData_set_layer_unique_name(struct CustomData *data, int index);
index b59fc9af37cf3bd7c80d4884c17b91965757815b..559dd4571f5ec5676f7393a9594257c39080cfdc 100644 (file)
@@ -69,13 +69,13 @@ void defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, const i
 void defvert_normalize(struct MDeformVert *dvert);
 void defvert_normalize_lock(struct MDeformVert *dvert, const int def_nr_lock);
 
-/* utility function, note that 32 chars is the maximum string length since its only
+/* utility function, note that MAX_VGROUP_NAME chars is the maximum string length since its only
  * used with defgroups currently */
 
 void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]);
 void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]);
 
-void flip_side_name(char name[64], const char from_name[64], int strip_number);
+void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number);
 
 #endif
 
index 5a36add2834a2db69eb9e2104615e77090a7f146..c5684e839039fb930214ca842c802be35e4f47b4 100644 (file)
@@ -1,5 +1,4 @@
 /* 
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -24,8 +23,7 @@
  * Contributor(s): none yet.
  *
  * ***** END GPL LICENSE BLOCK *****
-
-*/
+ */
 
 #ifndef __BKE_DISPLIST_H__
 #define __BKE_DISPLIST_H__
index a71522773fe9471c1096166bf3e549a42d43fa1c..59f8864bb2100e1a219a2e0c2d42a7d2e6b874a1 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -6,6 +6,15 @@
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
  *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
  * Contributor(s): Miika Hämäläinen
  *
  * ***** END GPL LICENSE BLOCK *****
 #ifndef __BKE_DYNAMICPAINT_H__
 #define __BKE_DYNAMICPAINT_H__
 
+/** \file BKE_dynamicpaint.h
+ *  \ingroup bke
+ */
+
 struct bContext;
 struct wmOperator;
 
index 971320765e9162c42ea83fd549f3b61b644771f6..4fced71d7f2bf0c5d3019a679ab7ea103f4a0673 100644 (file)
@@ -152,6 +152,7 @@ int object_insert_ptcache(struct Object *ob);
 struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, const char *name, int from_mix);
 
 int object_is_modified(struct Scene *scene, struct Object *ob);
+int object_is_deform_modified(struct Scene *scene, struct Object *ob);
 
 void object_relink(struct Object *ob);
 
index 39458cb3a137cfdfc7c6530a0a3deb78f373d28b..591be9e81c4d52e78debd53918f816df1c44c717 100644 (file)
@@ -1,5 +1,4 @@
-/* 
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 198d644b21163e6629a3665126b1d1591a35bec4..2b741d6d8eb25e361d15dfe9e11c8ba616e721f0 100644 (file)
@@ -129,9 +129,9 @@ void initglobals(void)
        strcpy(G.ima, "//");
 
        if (BLENDER_SUBVERSION)
-               BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
+               BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
        else
-               BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d", BLENDER_VERSION);
+               BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100);
 
 #ifdef _WIN32  // FULLSCREEN
        G.windowstate = G_WINDOWSTATE_USERDEF;
index 31c90d54d141d52300ef5cef1141532e027eeb9d..7c225eb0fad1f11a8a0c036b3137c2b222b7fd20 100644 (file)
@@ -1,7 +1,5 @@
 #if 0
-
 /*
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 4666aa6a4561468e350b5a85d54337efe56931b6..4cf48ff6005b25489349ea0dbbbc2d98a8e62a7d 100644 (file)
@@ -71,7 +71,11 @@ typedef struct LayerTypeInfo {
        int size;          /* the memory size of one element of this layer's data */
        const char *structname;  /* name of the struct used, for file writing */
        int structnum;     /* number of structs per element, for file writing */
-       const char *defaultname; /* default layer name */
+
+       /* default layer name.
+        * note! when NULL this is a way to ensure there is only ever one item
+        * see: CustomData_layertype_is_singleton() */
+       const char *defaultname;
 
        /* a function to copy count elements of this layer's data
         * (deep copy if appropriate)
@@ -2601,6 +2605,16 @@ const char *CustomData_layertype_name(int type)
        return layerType_getName(type);
 }
 
+
+/**
+ * Can only ever be one of these.
+ */
+int CustomData_layertype_is_singleton(int type)
+{
+       const LayerTypeInfo *typeInfo = layerType_getInfo(type);
+       return typeInfo->defaultname != NULL;
+}
+
 static int  CustomData_is_property_layer(int type)
 {
        if ((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR))
index 3e8727897f31e9bb56df1bcc80575de84eb8ae17..1411c910894eceac9fdebc2c4c3c7e9464935d27 100644 (file)
@@ -1,5 +1,4 @@
 /*
-
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index c334a6f42a475c598ef6dfa2b8afa95e81f1ebe1..6c5826c5babc77f45b2c556c77993e38b13cbce6 100644 (file)
@@ -1,11 +1,20 @@
-/**
-***** BEGIN GPL LICENSE BLOCK *****
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
  *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
  * Contributor(s): Miika Hämäläinen
  *
  * ***** END GPL LICENSE BLOCK *****
index 079d157e41d35319120392644c39a50b16594ffb..d46ceebdfeee98821b97e6b38316037ca3b7f9fc 100644 (file)
@@ -1,5 +1,4 @@
-/* 
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index c2d101f9d3b60dd14c03491fb0ad37893c971259..48763382f2a174f9e09df6313d0f4136b4f94200 100644 (file)
@@ -1906,7 +1906,8 @@ void do_versions_ipos_to_animato(Main *main)
                        
                        AnimData *adt= BKE_id_add_animdata(id);
                        
-                       SEQ_BEGIN (ed, seq) {
+                       SEQ_BEGIN (ed, seq)
+                       {
                                IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL;
                                short adrcode = SEQ_FAC1;
                                
index e981d772df65a0f14d3f8350a2e5db6b55c7d496..11c3269ad37e87d4fd2d024f3071a009128b6d1c 100644 (file)
@@ -96,6 +96,7 @@ void *add_lamp(const char *name)
        la->skyblendfac= 1.0f;
        la->sky_colorspace= BLI_XYZ_CIE;
        la->sky_exposure= 1.0f;
+       la->shadow_frustum_size= 10.0f;
        
        curvemapping_initialize(la->curfalloff);
        return la;
index 9959edaac16b690a59d6ffa682b157620e552179..2cfacbcf03493428155ebe639cda26128e1c08d7 100644 (file)
@@ -626,7 +626,8 @@ void unlink_object(Object *ob)
 #endif
                        if (sce->ed) {
                                Sequence *seq;
-                               SEQ_BEGIN (sce->ed, seq) {
+                               SEQ_BEGIN (sce->ed, seq)
+                               {
                                        if (seq->scene_camera == ob) {
                                                seq->scene_camera = NULL;
                                        }
@@ -2982,8 +2983,7 @@ KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, in
 }
 
 /* most important if this is modified it should _always_ return True, in certain
- * cases false positives are hard to avoid (shape keys for eg)
- */
+ * cases false positives are hard to avoid (shape keys for example) */
 int object_is_modified(Scene *scene, Object *ob)
 {
        int flag= 0;
@@ -2998,13 +2998,38 @@ int object_is_modified(Scene *scene, Object *ob)
                     md && (flag != (eModifierMode_Render | eModifierMode_Realtime));
                     md=md->next)
                {
-                       if ((flag & eModifierMode_Render) == 0  && modifier_isEnabled(scene, md, eModifierMode_Render)) {
+                       if ((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render))
                                flag |= eModifierMode_Render;
-                       }
 
-                       if ((flag & eModifierMode_Realtime) == 0        && modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
+                       if ((flag & eModifierMode_Realtime) == 0 && modifier_isEnabled(scene, md, eModifierMode_Realtime))
+                               flag |= eModifierMode_Realtime;
+               }
+       }
+
+       return flag;
+}
+
+/* test if object is affected by deforming modifiers (for motion blur). again
+ * most important is to avoid false positives, this is to skip computations
+ * and we can still if there was actual deformation afterwards */
+int object_is_deform_modified(Scene *scene, Object *ob)
+{
+       ModifierData *md;
+       int flag= 0;
+
+       /* cloth */
+       for (md=modifiers_getVirtualModifierList(ob);
+                md && (flag != (eModifierMode_Render | eModifierMode_Realtime));
+                md=md->next)
+       {
+               ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+
+               if (mti->type == eModifierTypeType_OnlyDeform) {
+                       if (!(flag & eModifierMode_Render) && modifier_isEnabled(scene, md, eModifierMode_Render))
+                               flag |= eModifierMode_Render;
+
+                       if (!(flag & eModifierMode_Realtime) && modifier_isEnabled(scene, md, eModifierMode_Realtime))
                                flag |= eModifierMode_Realtime;
-                       }
                }
        }
 
index af0c5eae9a8c03f75ca46042c7db02742a57172a..f69495483ea552af7ffffc7b1d87eef00aa54bff 100644 (file)
@@ -1,5 +1,4 @@
-/* 
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 9291cb90dffdb0e16fde1dd492c88817ecf86731..395214b1609e1340c9461dd4bf983c5a553dcdb2 100644 (file)
@@ -259,7 +259,8 @@ void seq_free_editing(Scene *scene)
        if (ed == NULL)
                return;
 
-       SEQ_BEGIN (ed, seq) {
+       SEQ_BEGIN (ed, seq)
+       {
                seq_free_sequence(scene, seq);
        }
        SEQ_END
index 129d3a3f698f6c2cceb1cca0eeedaa4af1a51c08..c3f864a8b2aa56112a0bdfbd90c9e271966581d5 100644 (file)
@@ -3134,8 +3134,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
                float *w2;
                int s, x, y;
                
-               origIndex = base_polyOrigIndex ? base_polyOrigIndex[origIndex] : origIndex;
-               
                w = get_ss_weights(&wtable, gridCuts, numVerts);
 
                ccgdm->faceMap[index].startVert = vertNum;
@@ -3146,6 +3144,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
                faceFlags->mat_nr = mpoly ? mpoly[origIndex].mat_nr : 0;
                faceFlags++;
 
+               origIndex = base_polyOrigIndex ? base_polyOrigIndex[origIndex] : origIndex;
+
                /* set the face base vert */
                *((int *)ccgSubSurf_getFaceUserData(ss, f)) = vertNum;
 
index 31278ab53aab9048ecb7449b976ae60afc59b4cc..85ecc7c204d4014f4c9b6132ae02b1639a078a18 100644 (file)
@@ -957,9 +957,8 @@ void txt_move_right(Text *text, short sel)
 void txt_jump_left(Text *text, short sel)
 {
        TextLine **linep, *oldl;
-       int *charp, oldc, oldflags, i;
+       int *charp, oldc, oldflags;
        unsigned char oldu;
-       int pos;
 
        if (!text) return;
        if (sel) txt_curs_sel(text, &linep, &charp);
@@ -974,13 +973,9 @@ void txt_jump_left(Text *text, short sel)
        oldu= undoing;
        undoing= 1; /* Don't push individual moves to undo stack */
 
-       pos = *charp;
        BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len,
-                                &pos, STRCUR_DIR_PREV,
+                             charp, STRCUR_DIR_PREV,
                                 STRCUR_JUMP_DELIM);
-       for (i = *charp; i > pos; i--) {
-               txt_move_left(text, sel);
-       }
 
        text->flags = oldflags;
 
@@ -991,9 +986,8 @@ void txt_jump_left(Text *text, short sel)
 void txt_jump_right(Text *text, short sel)
 {
        TextLine **linep, *oldl;
-       int *charp, oldc, oldflags, i;
+       int *charp, oldc, oldflags;
        unsigned char oldu;
-       int pos;
 
        if (!text) return;
        if (sel) txt_curs_sel(text, &linep, &charp);
@@ -1008,13 +1002,9 @@ void txt_jump_right(Text *text, short sel)
        oldu= undoing;
        undoing= 1; /* Don't push individual moves to undo stack */
 
-       pos = *charp;
        BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len,
-                                &pos, STRCUR_DIR_NEXT,
+                             charp, STRCUR_DIR_NEXT,
                                 STRCUR_JUMP_DELIM);
-       for (i = *charp; i < pos; i++) {
-               txt_move_right(text, sel);
-       }
 
        text->flags = oldflags;
 
index 079bde0afec2db8caba31a34ca3a59416d839f17..7330269c1f4df84443b9018123d04dae353801b1 100644 (file)
@@ -1,19 +1,25 @@
 /*
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
- * ffmpeg-write support
- *
- * Partial Copyright (c) 2006 Peter Schlaile
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s):
+ *
+ * Partial Copyright (c) 2006 Peter Schlaile
+ *
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 /** \file blender/blenkernel/intern/writeffmpeg.c
index 6c818965e9a88dcd266ebc9af6e4b51c1588ff4d..0ff095607e3b5760bf7ddfa782bbaf811fdb2890 100644 (file)
@@ -1,25 +1,33 @@
 /*
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
- * Frameserver
- * Makes Blender accessible from TMPGenc directly using VFAPI (you can
- * use firefox too ;-)
- *
- * Copyright (c) 2006 Peter Schlaile
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright (c) 2006 Peter Schlaile
+ *
+ * Contributor(s):
+ *
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 /** \file blender/blenkernel/intern/writeframeserver.c
  *  \ingroup bke
+ *
+ * Frameserver
+ * Makes Blender accessible from TMPGenc directly using VFAPI (you can
+ * use firefox too ;-)
  */
 
 #ifdef WITH_FRAMESERVER
index 8306a69e567b3cebda312aab0ce34fdb0e37244e..508cc03d848d815539e8538f94f841d731de529c 100644 (file)
@@ -1,5 +1,4 @@
-/* 
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 8e75a2db6290f02c6f366d1d0497e12339ecbc37..a4698ab4dd009b8c1de038492dbc4e4b64d45cf4 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 7d34d33d68619bcc6106e89900d6c13f5a8f4ff9..c3c10239a8e5a7f10602e2801715437722521d4c 100644 (file)
@@ -1,6 +1,4 @@
-/* 
- * Platform independent time functions.
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -29,6 +27,7 @@
 
 /** \file blender/blenlib/PIL_time.h
  *  \ingroup bli
+ *  \brief Platform independent time functions.
  */
 
  
index cd904030bb9c32be2f1970f5c2825b6ec89d2aaa..ed3c6fad1a0d3fec38a762fe3b566a531426d257 100644 (file)
@@ -1,7 +1,4 @@
 /*
- * A general argument parsing module
- *
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -30,9 +27,9 @@
 
 /** \file blender/blenlib/intern/BLI_args.c
  *  \ingroup bli
+ *  \brief A general argument parsing module
  */
 
-
 #include <ctype.h> /* for tolower */
 #include <string.h>
 
index 8534621ccf1bf02a8b6d53c06233b384c83a320a..739c4e00cc7d7e5fbfe71a3c76922e803b7c62f4 100644 (file)
@@ -510,7 +510,8 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla
                        if (scene->ed) {
                                Sequence *seq;
 
-                               SEQ_BEGIN (scene->ed, seq) {
+                               SEQ_BEGIN (scene->ed, seq)
+                               {
                                        if (SEQ_HAS_PATH(seq)) {
                                                if (ELEM(seq->type, SEQ_MOVIE, SEQ_SOUND)) {
                                                        rewrite_path_fixed_dirfile(seq->strip->dir, seq->strip->stripdata->name,
index 0a805293a05905321b67e2f9d51f61ec8140f5ed..4e2003dcbf72f5083754dc89d84e48d878bc86b9 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 35651323ac4a663253d7a76d1ce458257a5c5cb9..c7977378f6a3f499f43c9d00858c4a8028fe6b63 100644 (file)
@@ -1,7 +1,4 @@
 /*
- * Jitter offset table
- *
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -30,9 +27,9 @@
 
 /** \file blender/blenlib/intern/jitter.c
  *  \ingroup bli
+ *  \brief Jitter offset table
  */
 
-
 #include <math.h>
 #include <string.h>
 #include "MEM_guardedalloc.h"
index 5b669c4ff1c6ab941c597bd23040de05282cc5a6..dde7efcb4a7347afcd3d9b55ce81e9c997322e65 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 97559d6ba1073042dfff34c0c74283d4745c7344..422a600e51ca3f83671e27bad294fc26c3ce7bc7 100644 (file)
@@ -93,6 +93,7 @@ static strCursorDelimType test_special_char(const char *ch_utf8)
                        return STRCUR_DELIM_QUOTE;
 
                case ' ':
+               case '\t':
                        return STRCUR_DELIM_WHITESPACE;
 
                case '\\':
index 2d82c0989b1c17890b4cd8abbd01e2db8f7553d9..448f1c1b408519fd4af531ec0f65a26fdb46fad2 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 2426aadcda84ad26941483318181794609366678..84bc089e3916352683770ae665724913fc902dd1 100644 (file)
@@ -4843,7 +4843,8 @@ static void lib_link_scene(FileData *fd, Main *main)
                                }
                        }
 
-                       SEQ_BEGIN (sce->ed, seq) {
+                       SEQ_BEGIN (sce->ed, seq)
+                       {
                                if (seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo);
                                seq->scene_sound = NULL;
                                if (seq->scene) {
@@ -4974,7 +4975,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
                /* recursive link sequences, lb will be correctly initialized */
                link_recurs_seq(fd, &ed->seqbase);
 
-               SEQ_BEGIN (ed, seq) {
+               SEQ_BEGIN (ed, seq)
+               {
                        seq->seq1= newdataadr(fd, seq->seq1);
                        seq->seq2= newdataadr(fd, seq->seq2);
                        seq->seq3= newdataadr(fd, seq->seq3);
@@ -9102,7 +9104,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                while (sce) {
                        ed= sce->ed;
                        if (ed) {
-                               SEQ_BEGIN (sce->ed, seq) {
+                               SEQ_BEGIN (sce->ed, seq)
+                               {
                                        if (seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE)
                                                seq->flag |= SEQ_MAKE_PREMUL;
                                }
@@ -10517,7 +10520,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                Sequence *seq;
                
                for (sce=main->scene.first; sce; sce=sce->id.next) {
-                       SEQ_BEGIN (sce->ed, seq) {
+                       SEQ_BEGIN (sce->ed, seq)
+                       {
                                if (seq->blend_mode == 0)
                                        seq->blend_opacity = 100.0f;
                        }
@@ -10870,7 +10874,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                while (sce) {
                        ed= sce->ed;
                        if (ed) {
-                               SEQP_BEGIN (ed, seq) {
+                               SEQP_BEGIN (ed, seq)
+                               {
                                        if (seq->strip && seq->strip->proxy) {
                                                seq->strip->proxy->quality =90;
                                        }
@@ -10939,7 +10944,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
 
                for (scene = main->scene.first; scene; scene = scene->id.next) {
                        if (scene->ed && scene->ed->seqbasep) {
-                               SEQ_BEGIN (scene->ed, seq) {
+                               SEQ_BEGIN (scene->ed, seq)
+                               {
                                        if (seq->type == SEQ_HD_SOUND) {
                                                char str[FILE_MAX];
                                                BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
@@ -11909,7 +11915,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0)
                                sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
 
-                       SEQ_BEGIN (sce->ed, seq) {
+                       SEQ_BEGIN (sce->ed, seq)
+                       {
                                seq->volume = 1.0f;
                        }
                        SEQ_END
@@ -12178,7 +12185,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                for (scene= main->scene.first; scene; scene=scene->id.next) {
                        if (scene) {
                                Sequence *seq;
-                               SEQ_BEGIN (scene->ed, seq) {
+                               SEQ_BEGIN (scene->ed, seq)
+                               {
                                        if (seq->sat==0.0f) {
                                                seq->sat= 1.0f;
                                        }
@@ -12653,7 +12661,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        for (scene=main->scene.first; scene; scene=scene->id.next) {
                                scene->r.ffcodecdata.audio_channels = 2;
                                scene->audio.volume = 1.0f;
-                               SEQ_BEGIN (scene->ed, seq) {
+                               SEQ_BEGIN (scene->ed, seq)
+                               {
                                        seq->pitch = 1.0f;
                                }
                                SEQ_END
@@ -12956,15 +12965,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                                v3d->bundle_size= 0.2f;
                                                                v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
                                                        }
-                                                       else if (sl->spacetype==SPACE_CLIP) {
-                                                               SpaceClip *sc= (SpaceClip *)sl;
-                                                               if (sc->scopes.track_preview_height==0)
-                                                                       sc->scopes.track_preview_height= 120;
-                                                       }
 
                                                        if (v3d->bundle_drawtype==0)
                                                                v3d->bundle_drawtype= OB_PLAINAXES;
                                                }
+                                               else if (sl->spacetype==SPACE_CLIP) {
+                                                       SpaceClip *sc= (SpaceClip *)sl;
+                                                       if (sc->scopes.track_preview_height==0)
+                                                               sc->scopes.track_preview_height= 120;
+                                               }
                                        }
                                }
                        }
@@ -13390,7 +13399,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
-       {
+       if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 2)) {
                bScreen *sc;
 
                for (sc = main->screen.first; sc; sc = sc->id.next) {
@@ -13424,6 +13433,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        }
                }
        }
+       
+       {
+               Lamp *la;
+               for (la= main->lamp.first; la; la= la->id.next) {
+                       if (la->shadow_frustum_size == 0.0)
+                               la->shadow_frustum_size= 10.0f;
+               }
+       }
+       
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
 
@@ -14384,7 +14402,8 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
        if (sce->ed) {
                Sequence *seq;
 
-               SEQ_BEGIN (sce->ed, seq) {
+               SEQ_BEGIN (sce->ed, seq)
+               {
                        if (seq->scene) expand_doit(fd, mainvar, seq->scene);
                        if (seq->scene_camera) expand_doit(fd, mainvar, seq->scene_camera);
                        if (seq->sound) expand_doit(fd, mainvar, seq->sound);
index e11e0274b28d1883b1c46d9fa026f37836e91837..0cd57ee545d1f83d80ad1cc35e49dfb05941cb9d 100644 (file)
@@ -2109,13 +2109,15 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
                        
                        /* reset write flags too */
                        
-                       SEQ_BEGIN (ed, seq) {
+                       SEQ_BEGIN (ed, seq)
+                       {
                                if (seq->strip) seq->strip->done= 0;
                                writestruct(wd, DATA, "Sequence", 1, seq);
                        }
                        SEQ_END
                        
-                       SEQ_BEGIN (ed, seq) {
+                       SEQ_BEGIN (ed, seq)
+                       {
                                if (seq->strip && seq->strip->done==0) {
                                        /* write strip with 'done' at 0 because readfile */
                                        
index 3e4aa3cd2ed22b3f258efcac8306aa819e0d9268..8a15109428f4e5fc18c474477711d12a89e9c62b 100644 (file)
  * Contributor(s): none yet.
  *
  * ***** END GPL LICENSE BLOCK *****
+ */
+
+/**
+ * \file blender/blenpluginapi/documentation.h
+ * \ingroup blpluginapi
  *
- * @mainpage plugin API - the access point for texture and sequence
+ * \mainpage plugin API - the access point for texture and sequence
  * plugins
  *
  * \section about About the plugin API
  *
  * The plugins wraps functions from IMB and BLI. In addition, they
  * define some useful variables.
- * */
-
-/** \file blender/blenpluginapi/documentation.h
- *  \ingroup blpluginapi
  */
-
-
index fbd81a832725ba32124f96e2461f4171041328c8..154b276c851f5f82776242527ca05bdc475cd475 100644 (file)
@@ -1,6 +1,3 @@
-/** \file blender/blenpluginapi/externdef.h
- *  \ingroup blpluginapi
- */
 /* Copyright (c) 1999, Not a Number / NeoGeo b.v. 
  * 
  * All rights reserved.
 #ifndef __EXTERNDEF_H__
 #define __EXTERNDEF_H__
 
+/** \file blender/blenpluginapi/externdef.h
+ *  \ingroup blpluginapi
+ */
+
 #ifdef WIN32
  #ifdef PLUGIN_INTERN
   #define LIBEXPORT    __declspec(dllexport)
index 4c9b98d073d992a5e44052ab84e16b7c18f14828..d1c7edcc307fd2a86ce85f644de9b5a0cb143d21 100644 (file)
@@ -1,8 +1,5 @@
-/** \file blender/blenpluginapi/floatpatch.h
- *  \ingroup blpluginapi
- */
 /* Copyright (c) 1999, Not a Number / NeoGeo b.v. 
- * 
+ *
  * All rights reserved.
  * 
  * Contact:      info@blender.org   
 #ifndef __FLOATPATCH_H__
 #define __FLOATPATCH_H__
 
+/** \file blender/blenpluginapi/floatpatch.h
+ *  \ingroup blpluginapi
+ */
+
 /* floating point libs differ at systems... with these defines it comilies at all! */
 
 #ifdef MIPS1
index 6a6764cd961755ed5d1e11d5119395f3dd6b2811..98382aca889b594d6da805deb9fc145033155fc3 100644 (file)
@@ -1,6 +1,3 @@
-/** \file blender/blenpluginapi/iff.h
- *  \ingroup blpluginapi
- */
 /* Copyright (c) 1999, Not a Number / NeoGeo b.v. 
  * 
  * All rights reserved.
 #ifndef __IFF_H__
 #define __IFF_H__
 
+/** \file blender/blenpluginapi/iff.h
+ *  \ingroup blpluginapi
+ */
+
 #include <sys/types.h>
 #include "util.h"
 #include "externdef.h"
index eb32fe80fa3cd4fb97d5919c46b8c9e1834ca678..d7acb988ccd085c89ea8dcf1bdc9d8df711d8547 100644 (file)
@@ -1,6 +1,3 @@
-/** \file blender/blenpluginapi/plugin.h
- *  \ingroup blpluginapi
- */
 /* Copyright (c) 1999, Not a Number / NeoGeo b.v. 
  * 
  * All rights reserved.
 #ifndef __PLUGIN_H__
 #define __PLUGIN_H__
 
+/** \file blender/blenpluginapi/plugin.h
+ *  \ingroup blpluginapi
+ */
+
 #include "externdef.h"
 #include "iff.h"
 #include "util.h"
index 340201924d70f8d1fca4eb2afce81a752ddb7bfa..8a049350bc67867909c961c46bd988bd0a91d92a 100644 (file)
@@ -1,6 +1,3 @@
-/** \file blender/blenpluginapi/util.h
- *  \ingroup blpluginapi
- */
 /* Copyright (c) 1999, Not a Number / NeoGeo b.v. 
  * 
  * All rights reserved.
  * SUCH DAMAGE.
  */
 
+/** \file blender/blenpluginapi/util.h
+ *  \ingroup blpluginapi
+ */
+
 #ifndef __UTIL_H__
 #define __UTIL_H__
 
index 5149a5436a2ae3d835535848c3462d7fb748c04e..c774880332bf549ccb340939b621bf84145faf90 100644 (file)
@@ -853,6 +853,52 @@ void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n)
        if (olddata.layers) MEM_freeN(olddata.layers);
 }
 
+void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n)
+{
+       BMIter iter;
+
+       if (&bm->vdata == data) {
+               BMVert *eve;
+
+               BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+                       void *ptr = CustomData_bmesh_get_n(data, eve->head.data, type, dst_n);
+                       CustomData_bmesh_set_n(data, eve->head.data, type, src_n, ptr);
+               }
+       }
+       else if (&bm->edata == data) {
+               BMEdge *eed;
+
+               BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
+                       void *ptr = CustomData_bmesh_get_n(data, eed->head.data, type, dst_n);
+                       CustomData_bmesh_set_n(data, eed->head.data, type, src_n, ptr);
+               }
+       }
+       else if (&bm->pdata == data) {
+               BMFace *efa;
+
+               BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+                       void *ptr = CustomData_bmesh_get_n(data, efa->head.data, type, dst_n);
+                       CustomData_bmesh_set_n(data, efa->head.data, type, src_n, ptr);
+               }
+       }
+       else if (&bm->ldata == data) {
+               BMIter liter;
+               BMFace *efa;
+               BMLoop *l;
+
+               BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+                       BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+                               void *ptr = CustomData_bmesh_get_n(data, l->head.data, type, dst_n);
+                               CustomData_bmesh_set_n(data, l->head.data, type, src_n, ptr);
+                       }
+               }
+       }
+       else {
+               /* should never reach this! */
+               BLI_assert(0);
+       }
+}
+
 float BM_elem_float_data_get(CustomData *cd, void *element, int type)
 {
        float *f = CustomData_bmesh_get(cd, ((BMHeader *)element)->data, type);
index 0d97fbcc0ec4f48a7aa4791cd790cdf0d4746d94..3380a3e6b1b7fe0f60aa19dc2e2573539082268c 100644 (file)
@@ -36,6 +36,8 @@ void  BM_data_layer_add(BMesh *em, CustomData *data, int type);
 void  BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name);
 void  BM_data_layer_free(BMesh *em, CustomData *data, int type);
 void  BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n);
+void  BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n);
+
 float BM_elem_float_data_get(CustomData *cd, void *element, int type);
 void  BM_elem_float_data_set(CustomData *cd, void *element, int type, const float val);
 
index 6ba0aeb28506bb53246bb93317aec5d2121a8212..6a66f1fb8172e8fdc7c40b0e58bd0ca8a56c819c 100644 (file)
@@ -779,15 +779,15 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
 }
 
 void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
-                                                                                                  std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
-                                                                                                  std::map<COLLADAFW::UniqueId, Object*>& object_map,
-                                                                                                  std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
+                                                                                               std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
+                                                                                               std::multimap<COLLADAFW::UniqueId, Object*>& object_map,
+                                                                                               std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
 {
        AnimationImporter::AnimMix* animType = get_animation_type(node, FW_object_map );
 
        bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
        COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()];
-       Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map[node->getUniqueId()];
+    Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map.find(node->getUniqueId())->second;
        if (!ob) {
                fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str());
                return;
index 953c454c73c72219e4eec9c2986393a1450bdbe5..492d63dbe8e47da15c4b2777b07ec17688bc278c 100644 (file)
@@ -143,10 +143,10 @@ public:
        virtual void change_eul_to_quat(Object *ob, bAction *act);
 #endif
 
-       void translate_Animations(COLLADAFW::Node * Node,
-                                 std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
-                                 std::map<COLLADAFW::UniqueId, Object*>& object_map,
-                                 std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map);
+       void translate_Animations(COLLADAFW::Node * Node , 
+                                                         std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
+                                                         std::multimap<COLLADAFW::UniqueId, Object*>& object_map ,
+                                                         std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map);
 
        AnimMix* get_animation_type( const COLLADAFW::Node * node, std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map );
 
index 352f477c9d8b6142f38157e952bcb7b654216e8f..a3c9ff38e871973c9543e044f05ced5581d8687d 100644 (file)
@@ -371,10 +371,11 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
                        Object *new_child = NULL;
                        if (inodes.getCount()) { // \todo loop through instance nodes
                                const COLLADAFW::UniqueId& id = inodes[0]->getInstanciatedObjectId();
-                               new_child = create_instance_node(object_map[id], node_map[id], child_node, sce, is_library_node);
+                               fprintf(stderr,"Doing %d child nodes\n" ,node_map.count(id));
+                               new_child = create_instance_node(object_map.find(id)->second, node_map[id], child_node, sce, is_library_node);
                        }
                        else {
-                               new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, is_library_node);
+                               new_child = create_instance_node(object_map.find(child_id)->second, child_node, NULL, sce, is_library_node);
                        }
                        bc_set_parent(new_child, obn, mContext, true);
 
@@ -392,13 +393,15 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
        bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
        bool read_transform = true;
 
+       std::vector<Object*> * objects_done = new std::vector<Object *>();
+
        if (is_joint) {
                if ( par ) {
                Object * empty = par;
                par = add_object(sce, OB_ARMATURE);
                bc_set_parent(par, empty->parent, mContext);
                //remove empty : todo
-               object_map[parent_node->getUniqueId()] = par;
+               object_map.insert( std::make_pair<COLLADAFW::UniqueId, Object *>(parent_node->getUniqueId(),par) );
                }
                armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par, sce);
        }
@@ -420,19 +423,23 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
                while (geom_done < geom.getCount()) {
                        ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map,
                                                                                                  material_texture_mapping_map);
+                       objects_done->push_back(ob);
                        ++geom_done;
                }
                while (camera_done < camera.getCount()) {
                        ob = create_camera_object(camera[camera_done], sce);
+                       objects_done->push_back(ob);
                        ++camera_done;
                }
                while (lamp_done < lamp.getCount()) {
                        ob = create_lamp_object(lamp[lamp_done], sce);
+                       objects_done->push_back(ob);
                        ++lamp_done;
                }
                while (controller_done < controller.getCount()) {
                        COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry*)controller[controller_done];
                        ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map);
+                       objects_done->push_back(ob);
                        ++controller_done;
                }
                // XXX instance_node is not supported yet
@@ -443,11 +450,14 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
                                ob = NULL;
                        }
                        else {
-                               Object *source_ob = object_map[node_id];
-                               COLLADAFW::Node *source_node = node_map[node_id];
-
-                               ob = create_instance_node(source_ob, source_node, node, sce, is_library_node);
+                               std::pair<std::multimap<COLLADAFW::UniqueId,Object *>::iterator, std::multimap<COLLADAFW::UniqueId,Object *>::iterator> pair_iter = object_map.equal_range(node_id);
+                               for(std::multimap<COLLADAFW::UniqueId,Object *>::iterator it2 = pair_iter.first; it2 != pair_iter.second; it2++){
+                                       Object *source_ob = (Object *)it2->second;
+                                       COLLADAFW::Node *source_node = node_map[node_id];
+                                       ob = create_instance_node(source_ob, source_node, node, sce, is_library_node);
+                               }
                        }
+                       if(ob != NULL) objects_done->push_back(ob);
                        ++inst_done;
 
                        read_transform = false;
@@ -456,31 +466,37 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
                // XXX empty node may not mean it is empty object, not sure about this
                if ( (geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) {
                        ob = add_object(sce, OB_EMPTY);
+                       objects_done->push_back(ob);
                }
                
                // XXX: if there're multiple instances, only one is stored
 
                if (!ob) return;
-               
-               std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
-               rename_id(&ob->id, (char*)nodename.c_str());
+               for(std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
+                       ob = *it;
+                       std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
+                       rename_id(&ob->id, (char*)nodename.c_str());
+                       object_map.insert( std::make_pair<COLLADAFW::UniqueId,Object *>(node->getUniqueId(),ob) );
+                       node_map[node->getUniqueId()] = node;
 
-               object_map[node->getUniqueId()] = ob;
-               node_map[node->getUniqueId()] = node;
+                       if (is_library_node)
+                               libnode_ob.push_back(ob);
+               }
 
-               if (is_library_node)
-                       libnode_ob.push_back(ob);
        }
 
-       if (read_transform)
-               anim_importer.read_node_transform(node, ob); // overwrites location set earlier
+       for(std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
+               ob =*it;
 
-       if (!is_joint) {
-               // if par was given make this object child of the previous 
-               if (par && ob)
-                       bc_set_parent(ob, par, mContext);
-       }
+               if (read_transform)
+                       anim_importer.read_node_transform(node, ob); // overwrites location set earlier
 
+               if (!is_joint) {
+                       // if par was given make this object child of the previous
+                       if (par && ob)
+                               bc_set_parent(ob, par, mContext);
+               }
+       }
        // if node has child nodes write them
        COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
        for (unsigned int i = 0; i < child_nodes.getCount(); i++) {     
index 606218b644d8d6d7debca8c095fe421639587e6d..13f23b2338819db3b642068b05d30a3b077f6f70 100644 (file)
@@ -151,7 +151,7 @@ private:
        std::map<COLLADAFW::UniqueId, Camera*> uid_camera_map;
        std::map<COLLADAFW::UniqueId, Lamp*> uid_lamp_map;
        std::map<Material*, TexIndexTextureArrayMap> material_texture_mapping_map;
-       std::map<COLLADAFW::UniqueId, Object*> object_map;
+       std::multimap<COLLADAFW::UniqueId, Object*> object_map;
        std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map;
        std::vector<const COLLADAFW::VisualScene*> vscenes;
        std::vector<Object*> libnode_ob;
index 0bf33206fa7eced98ff222b5629453d80cb27863..73b2a1c23ad80a37c47cfbeec5f1e6ad620ffd0e 100644 (file)
@@ -845,7 +845,6 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
                                prim.mface++;
                                // bind texture images to faces
                                if (texture_face && (*color_texture)) {
-                                       texture_face->mode = TF_TEX;
                                        texture_face->tpage = (Image*)(*color_texture)->tex->ima;
                                        texture_face++;
                                }
index 0df68c3775cf039be6c51b522ecdce74f2ebbf20..4dd3406dafc7605f11111f7f2e9306dc8a8a32a1 100644 (file)
@@ -1353,7 +1353,8 @@ static int delete_key_v3d_exec (bContext *C, wmOperator *op)
        float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
        
        // XXX more comprehensive tests will be needed
-       CTX_DATA_BEGIN (C, Object*, ob, selected_objects) {
+       CTX_DATA_BEGIN (C, Object*, ob, selected_objects)
+       {
                ID *id= (ID *)ob;
                FCurve *fcu, *fcn;
                short success= 0;
index e983b89e3d82d0b7f049dcd5d6fdf78bf7175da9..eb821ffc14740091401ec773106bd2dd574b51f3 100644 (file)
@@ -756,7 +756,8 @@ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op)
         *
         * TODO, loop over children before parents if multiple bones
         * at once are to be predictable*/
-       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
+       {
                float delta_mat[4][4];
                
                /* chan_mat already contains the delta transform from rest pose to pose-mode pose
@@ -922,7 +923,8 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
        pose= ob->pose;
        ob->mode &= ~OB_MODE_POSE;
 
-       CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) {
+       CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases)
+       {
                if ((base->object->type==OB_ARMATURE) && (base->object!=ob)) {
                        bArmature *curarm= base->object->data;
                        
@@ -1193,7 +1195,8 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
        
        /* 1) only edit-base selected */
        // TODO: use context iterators for this?
-       CTX_DATA_BEGIN (C, Base *, base, visible_bases) {
+       CTX_DATA_BEGIN (C, Base *, base, visible_bases)
+       {
                if (base->object==obedit) base->flag |= 1;
                else base->flag &= ~1;
        }
@@ -2816,7 +2819,8 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
 
        /* loop over all bones, and only consider if visible */
-       CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones) {
+       CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones)
+       {
                if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL))
                        fill_add_joint(ebone, 0, &points);
                if (ebone->flag & BONE_TIPSEL) 
@@ -3529,7 +3533,8 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
        
        /* loop over all editable bones */
        // XXX the old code did this in reverse order though!
-       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
+       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
+       {
                for (i=numcuts+1; i>1; i--) {
                        /* compute cut ratio first */
                        float cutratio= 1.0f / (float)i;
@@ -3817,7 +3822,8 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
                 */
                
                /* parent selected bones to the active one */
-               CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
+               CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
+               {
                        if (ELEM(ebone, actbone, actmirb) == 0) {
                                if (ebone->flag & BONE_SELECTED) 
                                        bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
@@ -3842,7 +3848,8 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEve
        uiLayout *layout= uiPupMenuLayout(pup);
        int allchildbones = 0;
        
-       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
+       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
+       {
                if (ebone != actbone) {
                        if (ebone->parent != actbone) allchildbones= 1; 
                }       
@@ -3901,7 +3908,8 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
        bArmature *arm= (bArmature *)ob->data;
        int val = RNA_enum_get(op->ptr, "type");
                
-       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
+       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
+       {
                editbone_clear_parent(ebone, val);
        }
        CTX_DATA_END;
@@ -3937,7 +3945,8 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
 static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
 {
        /*      Set the flags */
-       CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones) {
+       CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones)
+       {
                /* ignore bone if selection can't change */
                if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
                        /* select bone */
@@ -3979,7 +3988,8 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
        }
        
        /*      Set the flags */
-       CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones) {
+       CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones)
+       {
                /* ignore bone if selection can't change */
                if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
                        switch (action) {
@@ -4398,7 +4408,8 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
                 */
                
                /* align selected bones to the active one */
-               CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
+               CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
+               {
                        if (ELEM(ebone, actbone, actmirb) == 0) {
                                if (ebone->flag & BONE_SELECTED)
                                        bone_align_to_bone(arm->edbo, ebone, actbone);
@@ -5087,7 +5098,8 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
        }
        
        /* only clear relevant transforms for selected bones */
-       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
+       {
                /* run provided clearing function */
                clear_func(pchan);
                
@@ -5228,7 +5240,8 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
        }
        
        /*      Set the flags */
-       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+       {
                /* select pchan only if selectable, but deselect works always */
                switch (action) {
                case SEL_SELECT:
@@ -5617,7 +5630,8 @@ static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
        arm= ob->data;
        
        /* loop through selected bones, auto-naming them */
-       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
+       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
+       {
                flip_side_name(newname, ebone->name, TRUE); // 1 = do strip off number extensions
                ED_armature_bone_rename(arm, ebone->name, newname);
        }
@@ -5661,7 +5675,8 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op)
        arm= ob->data;
        
        /* loop through selected bones, auto-naming them */
-       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
+       CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
+       {
                BLI_strncpy(newname, ebone->name, sizeof(newname));
                if (bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis]))
                        ED_armature_bone_rename(arm, ebone->name, newname);
index 77b035024a999ddbc7567e3625931c158d123c8e..a97823ebcc8e22e6263b954d3658635403da616f 100644 (file)
@@ -2555,7 +2555,8 @@ void BIF_retargetArmature(bContext *C)
        
        printf("Reeb Graph created\n");
 
-       CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) {
+       CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases)
+       {
                Object *ob = base->object;
 
                if (ob->type==OB_ARMATURE) {
index c32655fb680477fa1446be129a2ed95357794f02..3c855ff96e664694d75e228e9dff38eff7aabffa 100644 (file)
@@ -131,7 +131,8 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
        /* for each Pose-Channel which gets affected, get the F-Curves for that channel 
         * and set the relevant transform flags...
         */
-       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
+       {
                fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
        }
        CTX_DATA_END;
@@ -140,7 +141,8 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
         * i.e. if nothing selected, do whole pose
         */
        if (pfLinks->first == NULL) {
-               CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones) {
+               CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones)
+               {
                        fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
                }
                CTX_DATA_END;
index 817a2da83259ea26e0dc774b9af67a9a8e33b480..1bc6bc0bf07b9ecae28775d024729dbbf5fc7164 100644 (file)
@@ -216,7 +216,8 @@ static int pose_calculate_paths_exec (bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
        
        /* set up path data for bones being calculated */
-       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
+       {
                /* verify makes sure that the selected bone has a bone with the appropriate settings */
                animviz_verify_motionpaths(op->reports, scene, ob, pchan);
        }
@@ -323,7 +324,8 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
        bConstraint *con;
        int found= 0;
        
-       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+       {
                if (pchan->bone->flag & BONE_SELECTED) {
                        for (con= pchan->constraints.first; con; con= con->next) {
                                bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
@@ -385,7 +387,8 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
        int add_to_sel = RNA_boolean_get(op->ptr, "extend");
        int found= 0;
        
-       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+       {
                curbone= pchan->bone;
                
                if ((curbone->flag & BONE_UNSELECTABLE)==0) {
@@ -502,7 +505,8 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend)
         */
        group_flags= MEM_callocN(numGroups+1, "pose_select_same_group");
        
-       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+       {
                /* keep track of group as group to use later? */
                if (pchan->bone->flag & BONE_SELECTED) {
                        group_flags[pchan->agrp_index] = 1;
@@ -518,7 +522,8 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend)
        /* small optimization: only loop through bones a second time if there are any groups tagged */
        if (tagged) {
                /* only if group matches (and is not selected or current bone) */
-               CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
+               CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+               {
                        if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
                                /* check if the group used by this bone is counted */
                                if (group_flags[pchan->agrp_index]) {
@@ -547,7 +552,8 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend)
                return 0;
        
        /* figure out what bones are selected */
-       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+       {
                /* keep track of layers to use later? */
                if (pchan->bone->flag & BONE_SELECTED)
                        layers |= pchan->bone->layer;
@@ -561,7 +567,8 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend)
                return 0;
                
        /* select bones that are on same layers as layers flag */
-       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+       {
                /* if bone is on a suitable layer, and the bone can have its selection changed, select it */
                if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
                        pchan->bone->flag |= BONE_SELECTED;
@@ -591,7 +598,8 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend)
                
        /* if not extending selection, deselect all selected first */
        if (extend == 0) {
-               CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
+               CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+               {
                        if ((pchan->bone->flag & BONE_UNSELECTABLE)==0)
                                pchan->bone->flag &= ~BONE_SELECTED;
                }
@@ -1395,7 +1403,8 @@ static int pose_group_assign_exec (bContext *C, wmOperator *op)
                pose_add_group(ob);
        
        /* add selected bones to group then */
-       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
+       {
                pchan->agrp_index= pose->active_group;
                done= 1;
        }
@@ -1448,7 +1457,8 @@ static int pose_group_unassign_exec (bContext *C, wmOperator *UNUSED(op))
                return OPERATOR_CANCELLED;
        
        /* find selected bones to remove from all bone groups */
-       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
+       {
                if (pchan->agrp_index) {
                        pchan->agrp_index= 0;
                        done= 1;
@@ -1650,7 +1660,8 @@ static void pose_group_select(bContext *C, Object *ob, int select)
 {
        bPose *pose= ob->pose;
        
-       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones)
+       {
                if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
                        if (select) {
                                if (pchan->agrp_index == pose->active_group) 
@@ -1754,7 +1765,8 @@ static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
        arm= ob->data;
        
        /* loop through selected bones, auto-naming them */
-       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
+       {
                char newname[MAXBONENAME];
                flip_side_name(newname, pchan->name, TRUE);
                ED_armature_bone_rename(arm, pchan->name, newname);
@@ -1800,7 +1812,8 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op)
        arm= ob->data;
        
        /* loop through selected bones, auto-naming them */
-       CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) {
+       CTX_DATA_BEGIN (C, bPoseChannel*, pchan,