Merging r42193 through r42349 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 2 Dec 2011 19:40:20 +0000 (19:40 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 2 Dec 2011 19:40:20 +0000 (19:40 +0000)
219 files changed:
SConstruct
build_files/scons/config/darwin-config.py
build_files/scons/config/linux-config.py
build_files/scons/tools/Blender.py
build_files/scons/tools/btools.py
doc/python_api/rst/info_best_practice.rst
extern/libmv/CMakeLists.txt
extern/libmv/bundle.sh
extern/libmv/libmv-capi.cpp
extern/libmv/libmv-capi.h
extern/libmv/libmv/tracking/esm_region_tracker.cc
extern/libmv/libmv/tracking/klt_region_tracker.cc
extern/libmv/libmv/tracking/lmicklt_region_tracker.cc
extern/libmv/libmv/tracking/sad.cc
extern/libmv/libmv/tracking/trklt_region_tracker.cc
intern/cycles/CMakeLists.txt
intern/cycles/SConscript
intern/cycles/app/cycles_xml.cpp
intern/cycles/blender/CMakeLists.txt
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/enums.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/addon/xml.py [deleted file]
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/device/device_cuda.cpp
intern/cycles/kernel/CMakeLists.txt
intern/cycles/kernel/SConscript [new file with mode: 0644]
intern/cycles/kernel/kernel_bvh.h
intern/cycles/kernel/osl/nodes/CMakeLists.txt
intern/cycles/kernel/osl/nodes/node_color.h
intern/cycles/kernel/osl/nodes/node_hsv.osl [new file with mode: 0644]
intern/cycles/kernel/osl/nodes/node_mix.osl
intern/cycles/kernel/osl/nodes/node_sepcomb_rgb.osl [new file with mode: 0644]
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_hsv.h [new file with mode: 0644]
intern/cycles/kernel/svm/svm_mix.h
intern/cycles/kernel/svm/svm_sepcomb_rgb.h [new file with mode: 0644]
intern/cycles/kernel/svm/svm_types.h
intern/cycles/render/mesh.cpp
intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h
intern/cycles/subd/subd_mesh.cpp
intern/cycles/util/util_cache.h
intern/cycles/util/util_system.cpp
intern/memutil/intern/MEM_CacheLimiterC-Api.cpp
release/scripts/startup/bl_operators/clip.py
release/scripts/startup/bl_ui/space_clip.py
release/scripts/startup/bl_ui/space_info.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/keyingsets_builtins.py
release/text/readme.html
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_bmesh.h
source/blender/blenkernel/BKE_bmeshCustomData.h
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/BKE_depsgraph.h
source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/BME_Customdata.c
source/blender/blenkernel/intern/BME_tools.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/bmesh_private.h
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/editderivedmesh.c [new file with mode: 0644]
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/mesh_validate.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/speaker.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenkernel/intern/world.c
source/blender/blenlib/BLI_mempool.h
source/blender/blenlib/intern/BLI_mempool.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/armature/reeb.c
source/blender/editors/gpencil/gpencil_buttons.c
source/blender/editors/include/ED_render.h
source/blender/editors/include/ED_screen.h
source/blender/editors/include/ED_view3d.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.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_transform.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/physics_intern.h
source/blender/editors/render/render_opengl.c
source/blender/editors/render/render_update.c
source/blender/editors/screen/area.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_file/filelist.h
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/util/undo.c
source/blender/gpu/GPU_buffers.h
source/blender/gpu/GPU_draw.h
source/blender/gpu/GPU_extensions.h
source/blender/gpu/GPU_material.h
source/blender/gpu/intern/gpu_buffers.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_codegen.h
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/gpu/intern/gpu_shader_material.glsl
source/blender/gpu/intern/gpu_shader_material.glsl.c
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesdna/DNA_texture_types.h
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesdna/intern/dna_genfile.c
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_define.c
source/blender/makesrna/intern/rna_internal_types.h
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_nodetree_types.h
source/blender/makesrna/intern/rna_rna.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_tracking.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/modifiers/MOD_modifiertypes.h
source/blender/modifiers/intern/MOD_fluidsim_util.c
source/blender/modifiers/intern/MOD_none.c
source/blender/modifiers/intern/MOD_util.c
source/blender/modifiers/intern/MOD_util.h
source/blender/modifiers/intern/MOD_weightvg_util.c
source/blender/nodes/NOD_composite.h
source/blender/nodes/NOD_shader.h
source/blender/nodes/NOD_texture.h
source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
source/blender/python/generic/CMakeLists.txt
source/blender/python/generic/noise_py_api.c [deleted file]
source/blender/python/intern/bpy_driver.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_library.c
source/blender/python/intern/bpy_props.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/gpu.h
source/blender/python/mathutils/CMakeLists.txt
source/blender/python/mathutils/mathutils.c
source/blender/python/mathutils/mathutils.h
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_Matrix.h
source/blender/python/mathutils/mathutils_Quaternion.c
source/blender/python/mathutils/mathutils_Quaternion.h
source/blender/python/mathutils/mathutils_Vector.c
source/blender/python/mathutils/mathutils_Vector.h
source/blender/python/mathutils/mathutils_noise.c [new file with mode: 0644]
source/blender/python/mathutils/mathutils_noise.h [moved from source/blender/python/generic/noise_py_api.h with 72% similarity]
source/blender/quicktime/apple/qtkit_export.m
source/blender/quicktime/apple/quicktime_export.c
source/blender/render/intern/include/render_types.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/rendercore.c
source/blender/windowmanager/CMakeLists.txt
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_jobs.c
source/blender/windowmanager/intern/wm_operators.c
source/blenderplayer/CMakeLists.txt
source/gameengine/Converter/KX_BlenderSceneConverter.cpp
source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
source/gameengine/Ketsji/KX_ObstacleSimulation.h
source/gameengine/Ketsji/KX_ParentActuator.cpp
source/gameengine/Ketsji/KX_ParentActuator.h
source/gameengine/Ketsji/KX_SteeringActuator.cpp
source/gameengine/Ketsji/KX_SteeringActuator.h
source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

index cd4e31efeff917e03ee5085a0a89ca87b26c6d59..fd99933e976b636305a46121bef6b3b61a47ae4e 100644 (file)
@@ -581,6 +581,14 @@ if env['OURPLATFORM']!='darwin':
             source.remove('CMakeLists.txt')
             source=['intern/cycles/doc/license/'+s for s in source]
             scriptinstall.append(env.Install(dir=dir,source=source))
+
+            # cuda binaries
+            if env['WITH_BF_CYCLES_CUDA_BINARIES']:
+                dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'lib')
+                for arch in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
+                    kernel_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel')
+                    cubin_file = os.path.join(kernel_build_dir, "kernel_%s.cubin" % arch)
+                    scriptinstall.append(env.Install(dir=dir,source=cubin_file))
     
     if env['WITH_BF_INTERNATIONAL']:
         internationalpaths=['release' + os.sep + 'datafiles']
index 028b1bd028900b1b72002bac3bed2c51e8c34c36..e0b8822ce367897d481bcabc9e2d2a61f6898b24 100644 (file)
@@ -283,7 +283,7 @@ BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
 #BF_EXPAT_LIB = 'expat'
 #BF_EXPAT_LIBPATH = '/usr/lib'
 
-#Cycles
+# Cycles
 WITH_BF_CYCLES = True
 
 WITH_BF_OIIO = True
@@ -298,6 +298,10 @@ BF_BOOST_INC = BF_BOOST + '/include'
 BF_BOOST_LIB = 'boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt'
 BF_BOOST_LIBPATH = BF_BOOST + '/lib'
 
+WITH_BF_CYCLES_CUDA_BINARIES = False
+BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21']
+
 #Ray trace optimization
 if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386':
     WITH_BF_RAYOPTIMIZATION = True
index b25bf98c9e62e98b9ae3ffe5572070f9bdca4f5c..6964ff993b6b2293d9ee1b676e012b8870cb9847 100644 (file)
@@ -219,6 +219,10 @@ BF_BOOST_LIBPATH = BF_BOOST + '/lib'
 
 WITH_BF_CYCLES = WITH_BF_OIIO and WITH_BF_BOOST
 
+WITH_BF_CYCLES_CUDA_BINARIES = False
+BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
+BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21']
+
 WITH_BF_OPENMP = True
 
 #Ray trace optimization
index 38cd960ebe15f4595b34987ca275037789c65ed1..8e431d8f43c8ef9329e513339fa8e15c39c286c8 100644 (file)
@@ -291,7 +291,7 @@ def setup_syslibs(lenv):
 
     syslibs += Split(lenv['BF_JPEG_LIB'])
     syslibs += Split(lenv['BF_PNG_LIB'])
-       
+
     syslibs += lenv['LLIBS']
 
     return syslibs
@@ -588,6 +588,8 @@ def AppIt(target=None, source=None, env=None):
             commands.getoutput(cmd)
             cmd = 'mkdir %s/kernel' % (cinstalldir)
             commands.getoutput(cmd)
+            cmd = 'mkdir %s/lib' % (cinstalldir)
+            commands.getoutput(cmd)
             cmd = 'cp -R %s/blender/addon/*.py %s/' % (croot, cinstalldir)
             commands.getoutput(cmd)
             cmd = 'cp -R %s/doc/license %s/license' % (croot, cinstalldir)
@@ -596,6 +598,8 @@ def AppIt(target=None, source=None, env=None):
             commands.getoutput(cmd)
             cmd = 'cp -R %s/kernel/svm %s/util/util_color.h %s/util/util_math.h %s/util/util_transform.h %s/util/util_types.h %s/kernel/' % (croot, croot, croot, croot, croot, cinstalldir)
             commands.getoutput(cmd)
+            cmd = 'cp -R %s/../intern/cycles/kernel/*.cubin %s/lib/' % (builddir, cinstalldir)
+            commands.getoutput(cmd)
 
     if env['WITH_OSX_STATICPYTHON']:
         cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/python/'%(installdir,binary, VERSION)
index 1ddbfcb96082332980b56f6195f3846e640e021d..98c1b74d5ccc0a344a10e153526ac833c2aa2e1e 100644 (file)
@@ -157,7 +157,7 @@ def validate_arguments(args, bc):
             'WITH_BF_JEMALLOC', 'WITH_BF_STATICJEMALLOC', 'BF_JEMALLOC', 'BF_JEMALLOC_INC', 'BF_JEMALLOC_LIBPATH', 'BF_JEMALLOC_LIB', 'BF_JEMALLOC_LIB_STATIC',
             'BUILDBOT_BRANCH',
             'WITH_BF_3DMOUSE', 'WITH_BF_STATIC3DMOUSE', 'BF_3DMOUSE', 'BF_3DMOUSE_INC', 'BF_3DMOUSE_LIB', 'BF_3DMOUSE_LIBPATH', 'BF_3DMOUSE_LIB_STATIC',
-            'WITH_BF_CYCLES', 'WITH_BF_CYCLES_BINARIES' 'BF_CYCLES_BINARIES_ARCH',
+            'WITH_BF_CYCLES', 'WITH_BF_CYCLES_CUDA_BINARIES' 'BF_CYCLES_CUDA_NVCC', 'BF_CYCLES_CUDA_NVCC',
             'WITH_BF_OIIO', 'WITH_BF_STATICOIIO', 'BF_OIIO', 'BF_OIIO_INC', 'BF_OIIO_LIB', 'BF_OIIO_LIB_STATIC', 'BF_OIIO_LIBPATH',
             'WITH_BF_BOOST', 'WITH_BF_STATICBOOST', 'BF_BOOST', 'BF_BOOST_INC', 'BF_BOOST_LIB', 'BF_BOOST_LIB_STATIC', 'BF_BOOST_LIBPATH'
             ]
@@ -544,7 +544,9 @@ def read_opts(env, cfg, args):
 
     localopts.AddVariables(
         (BoolVariable('WITH_BF_CYCLES', 'Build with the Cycles engine', True)),
-        (BoolVariable('WITH_BF_CYCLES_BINARIES', 'Build with precompiled CUDA binaries', False)),
+        (BoolVariable('WITH_BF_CYCLES_CUDA_BINARIES', 'Build with precompiled CUDA binaries', False)),
+        ('BF_CYCLES_CUDA_NVCC', 'CUDA nvcc compiler path', ''),
+        ('BF_CYCLES_CUDA_BINARIES_ARCH', 'CUDA architectures to compile binaries for', []),
 
         (BoolVariable('WITH_BF_OIIO', 'Build with OpenImageIO', False)),
         (BoolVariable('WITH_BF_STATICOIIO', 'Staticly link to OpenImageIO', False)),
index 180a9fd1aa3028e4b971ad3e5558a425938bd496..f4daed9ad9f0f54159a972240259d3091693368b 100644 (file)
@@ -39,7 +39,7 @@ As well as pep8 we have other conventions used for blender python scripts.
 
   .. code-block:: python
 
-     bpy.context.scene.render.file_format = 'PNG'
+     bpy.context.scene.render.image_settings.file_format = 'PNG'
      bpy.context.scene.render.filepath = "//render_out"
 
 * pep8 also defines that lines should not exceed 79 characters, we felt this is too restrictive so this is optional per script.
@@ -181,7 +181,7 @@ When removing many items in a large list this can provide a good speedup.
 Avoid Copying Lists
 ^^^^^^^^^^^^^^^^^^^
 
-When passing a list/dictionary to a function, it is faster to have the function modify the list rather then returning a new list so python dosn't have tp duplicate the list in memory.
+When passing a list/dictionary to a function, it is faster to have the function modify the list rather then returning a new list so python doesn't have to duplicate the list in memory.
 
 Functions that modify a list in-place are more efficient then functions that create new lists.
 
index 6f0d5f3d126cd67b02922cc3beb39fc02a571918..0349ad7200033b8f17047b74ebd6d090a25acf4f 100644 (file)
@@ -175,9 +175,9 @@ if(WIN32)
 
        if(MSVC)
                set(MSVC_OFLAGS O1 O2 Ox)
-               foreach(FLAG )
-                       string(REPLACE "" "Od" CMAKE_CXX_FLAGS_RELEASE "")
-                       string(REPLACE "" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "")
+               foreach(FLAG ${MSVC_OFLAGS})
+                       string(REPLACE "${FLAG}" "Od" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+                       string(REPLACE "${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
                endforeach()
        endif()
 else(WIN32)
index 690f78df387ac098e106d53f0784121d5a17546d..fb336c66d610b4db49e5711fb57ab6387564c2ed 100755 (executable)
@@ -183,9 +183,9 @@ IF(WIN32)
 
        IF(MSVC)
                set(MSVC_OFLAGS O1 O2 Ox)
-               foreach(FLAG ${MSVC_OFLAGS})
-                       string(REPLACE "${FLAG}" "Od" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
-                       string(REPLACE "${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+               foreach(FLAG \${MSVC_OFLAGS})
+                       string(REPLACE "\${FLAG}" "Od" CMAKE_CXX_FLAGS_RELEASE "\${CMAKE_CXX_FLAGS_RELEASE}")
+                       string(REPLACE "\${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "\${CMAKE_C_FLAGS_RELWITHDEBINFO}")
                endforeach()
        ENDIF(MSVC)
 ELSE(WIN32)
index f08aea9fbd1359c651359def49a920584e925963..aa05279d7312e344a1634b096c9b754d740a5a51 100644 (file)
@@ -297,16 +297,16 @@ void libmv_regionTrackerDestroy(libmv_RegionTracker *libmv_tracker)
 /* ************ Tracks ************ */
 
 void libmv_SADSamplePattern(unsigned char *image, int stride,
-                       float warp[3][2], unsigned char *pattern)
+                       float warp[3][2], unsigned char *pattern, int pattern_size)
 {
        libmv::mat32 mat32;
 
        memcpy(mat32.data, warp, sizeof(float)*3*2);
 
-       libmv::SamplePattern(image, stride, mat32, pattern, 16);
+       libmv::SamplePattern(image, stride, mat32, pattern, pattern_size);
 }
 
-float libmv_SADTrackerTrack(unsigned char *pattern, unsigned char *warped, unsigned char *image, int stride,
+float libmv_SADTrackerTrack(unsigned char *pattern, unsigned char *warped, int pattern_size, unsigned char *image, int stride,
                        int width, int height, float warp[3][2])
 {
        float result;
@@ -314,7 +314,7 @@ float libmv_SADTrackerTrack(unsigned char *pattern, unsigned char *warped, unsig
 
        memcpy(mat32.data, warp, sizeof(float)*3*2);
 
-       result = libmv::Track(pattern, warped, 16, image, stride, width, height, &mat32, 16, 16);
+       result = libmv::Track(pattern, warped, pattern_size, image, stride, width, height, &mat32, 16, 16);
 
        memcpy(warp, mat32.data, sizeof(float)*3*2);
 
index 536f8a5f14cf4edb5fa631cd965c14ef5733d6ed..321593520b53eeb0ada73b80f6ecc14d47480f26 100644 (file)
@@ -50,8 +50,8 @@ void libmv_regionTrackerDestroy(struct libmv_RegionTracker *libmv_tracker);
 
 /* SAD Tracker */
 void libmv_SADSamplePattern(unsigned char *image, int stride,
-                       float warp[3][2], unsigned char *pattern);
-float libmv_SADTrackerTrack(unsigned char *pattern, unsigned char *warped, unsigned char *image,
+                       float warp[3][2], unsigned char *pattern, int pattern_size);
+float libmv_SADTrackerTrack(unsigned char *pattern, unsigned char *warped, int pattern_size, unsigned char *image,
                        int stride, int width, int height, float warp[3][2]);
 
 /* Tracks */
index 01edee3bbb524e4f9acc155d9d540c750535e2ac..844b5ff3cb9853e52110f341db4eb3845551675e 100644 (file)
@@ -31,7 +31,7 @@
 namespace libmv {
 
 // TODO(keir): Reduce duplication between here and the other region trackers.
-bool RegionIsInBounds(const FloatImage &image1,
+static bool RegionIsInBounds(const FloatImage &image1,
                       double x, double y,
                       int half_window_size) {
   // Check the minimum coordinates.
@@ -56,7 +56,7 @@ bool RegionIsInBounds(const FloatImage &image1,
 
 // Sample a region centered at x,y in image with size extending by half_width
 // from x,y. Channels specifies the number of channels to sample from.
-void SamplePattern(const FloatImage &image,
+static void SamplePattern(const FloatImage &image,
                    double x, double y,
                    int half_width,
                    int channels,
@@ -74,7 +74,7 @@ void SamplePattern(const FloatImage &image,
 
 // Estimate "reasonable" error by computing autocorrelation for a small shift.
 // TODO(keir): Add a facility for 
-double EstimateReasonableError(const FloatImage &image,
+static double EstimateReasonableError(const FloatImage &image,
                                double x, double y,
                                int half_width) {
   double error = 0.0;
index 78ce0be603c3f84f705b180d568093ac86987d37..c8e605de572a54e2285e8b31fbd403ada769a345 100644 (file)
@@ -63,7 +63,7 @@ static void ComputeTrackingEquation(const Array3Df &image_and_gradient1,
   }
 }
 
-bool RegionIsInBounds(const FloatImage &image1,
+static bool RegionIsInBounds(const FloatImage &image1,
                       double x, double y,
                       int half_window_size) {
   // Check the minimum coordinates.
index 5ac96e661759d8ae31f34a7205b699aa6a6c35e0..c06a1d3302c528a62c5d4f785cb54c84e4aad68e 100644 (file)
@@ -29,7 +29,7 @@
 namespace libmv {
 
 // TODO(keir): Reduce duplication between here and the other region trackers.
-bool RegionIsInBounds(const FloatImage &image1,
+static bool RegionIsInBounds(const FloatImage &image1,
                       double x, double y,
                       int half_window_size) {
   // Check the minimum coordinates.
@@ -54,7 +54,7 @@ bool RegionIsInBounds(const FloatImage &image1,
 
 // Sample a region centered at x,y in image with size extending by half_width
 // from x,y. Channels specifies the number of channels to sample from.
-void SamplePattern(const FloatImage &image,
+static void SamplePattern(const FloatImage &image,
                    double x, double y,
                    int half_width,
                    int channels,
@@ -71,7 +71,7 @@ void SamplePattern(const FloatImage &image,
 }
 
 // Estimate "reasonable" error by computing autocorrelation for a small shift.
-double EstimateReasonableError(const FloatImage &image,
+static double EstimateReasonableError(const FloatImage &image,
                                double x, double y,
                                int half_width) {
   double error = 0.0;
index 9b446bb4c35c0a61f5aed40248e97c136717622a..0876ef2fe731d52772f53b320612bf53905af3a3 100644 (file)
@@ -25,6 +25,7 @@
 #include "libmv/tracking/sad.h"
 #include <stdlib.h>
 #include <math.h>
+#include <stdio.h>
 
 namespace libmv {
 
@@ -78,15 +79,31 @@ void SamplePattern(ubyte* image, int stride, mat32 warp, ubyte* pattern, int siz
 
 #ifdef __SSE2__
 #include <emmintrin.h>
-static uint SAD(const ubyte* pattern, const ubyte* image, int stride, int size) {
+  static uint SAD(/*const*/ ubyte* pattern, /*const*/ ubyte* image, int stride, int size) {
+  uint sad = 0;
   __m128i a = _mm_setzero_si128();
+
   for(int i = 0; i < size; i++) {
-    for(int j = 0; j < size/16; j++) {
+    int j = 0;
+
+    for(j = 0; j < size/16; j++) {
+      if((i*size/16+j) % 32 == 0) {
+        sad += _mm_extract_epi16(a,0) + _mm_extract_epi16(a,4);
+        a = _mm_setzero_si128();
+      }
+
       a = _mm_adds_epu16(a, _mm_sad_epu8( _mm_loadu_si128((__m128i*)(pattern+i*size+j*16)),
                                           _mm_loadu_si128((__m128i*)(image+i*stride+j*16))));
     }
+
+    for(j = j*16; j < size; j++) {
+      sad += abs((int)pattern[i*size+j] - image[i*stride+j]);
+    }
   }
-  return _mm_extract_epi16(a,0) + _mm_extract_epi16(a,4);
+
+  sad += _mm_extract_epi16(a,0) + _mm_extract_epi16(a,4);
+
+  return sad;
 }
 #else
 static uint SAD(const ubyte* pattern, const ubyte* image, int stride, int size) {
index 7e51787ebacca00d8c562737d6859661e5285686..f19315b6b11f157ec235cf77693ffef918dcac37 100644 (file)
@@ -81,7 +81,7 @@ static void ComputeTrackingEquation(const Array3Df &image_and_gradient1,
   *e = (A + lambda*Mat2f::Identity())*Di*(V - W) + 0.5*(S - R);
 }
 
-bool RegionIsInBounds(const FloatImage &image1,
+static bool RegionIsInBounds(const FloatImage &image1,
                       double x, double y,
                       int half_window_size) {
   // Check the minimum coordinates.
index c5c4f6b22a6a46639bf36618747fa920c18b89d3..3dc9ca5d284da360dc6ee4a4c45c8ed67b9d9292 100644 (file)
@@ -10,12 +10,14 @@ include(cmake/external_libs.cmake)
 
 if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
        set(WITH_CYCLES_OPTIMIZED_KERNEL ON)
+endif()
 
-       if(WIN32 AND MSVC)
-               set(CYCLES_OPTIMIZED_KERNEL_FLAGS "/arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast")
-       elseif(CMAKE_COMPILER_IS_GNUCC)
-               set(CYCLES_OPTIMIZED_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3")
-       endif()
+if(WIN32 AND MSVC)
+       set(CYCLES_OPTIMIZED_KERNEL_FLAGS "/arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /EHsc")
+       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /EHsc")
+elseif(CMAKE_COMPILER_IS_GNUCC)
+       set(CYCLES_OPTIMIZED_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mfpmath=sse")
+       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
 endif()
 
 # for OSL, not needed yet
index ecd22f654e8fc6030ebdac5bf9b9ac35c8d9fe22..bc9eb563e50f332738673ae6555554621bb7fdc4 100644 (file)
@@ -14,6 +14,7 @@ sources.remove(path.join('kernel', 'kernel_optimized.cpp'))
 
 incs = [] 
 defs = []
+cxxflags = []
 
 defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {')
 defs.append('CCL_NAMESPACE_END=}')
@@ -22,7 +23,7 @@ defs.append('WITH_OPENCL')
 defs.append('WITH_MULTI')
 defs.append('WITH_CUDA')
 
-if env['WITH_BF_CYCLES_BINARIES']:
+if env['WITH_BF_CYCLES_CUDA_BINARIES']:
     defs.append('WITH_CUDA_BINARIES')
 
 incs.extend('. bvh render device kernel kernel/osl kernel/svm util subd'.split())
@@ -33,20 +34,31 @@ incs.append(cycles['BF_OIIO_INC'])
 incs.append(cycles['BF_BOOST_INC'])
 incs.append(cycles['BF_PYTHON_INC'])
 
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
+    cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /EHsc'.split())
+else:
+    cxxflags.append('-ffast-math'.split())
+
 # optimized kernel
 if env['WITH_BF_RAYOPTIMIZATION']:
     optim_cxxflags = []
 
     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
-        optim_cxxflags.append('/Ox /Ot /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /EHsc /fp:fast'.split())
+        optim_cxxflags.append('/arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /EHsc'.split())
     else:
-        optim_cxxflags.append('-ffast-math -msse -msse2 -msse3'.split())
+        optim_cxxflags.append('-ffast-math -msse -msse2 -msse3 -mfpmath=sse'.split())
     
-    optim_defs = defs + ['WITH_OPTIMIZED_KERNEL']
+    defs.append('WITH_OPTIMIZED_KERNEL')
+    optim_defs = defs[:]
     optim_sources = [path.join('kernel', 'kernel_optimized.cpp')]
 
     cycles_optim = cycles.Clone()
-    cycles_optim.BlenderLib('bf_intern_cycles_optimized', optim_sources, incs, optim_defs, libtype=['intern'], priority=[0], compileflags=[None], cxx_compileflags=optim_cxxflags)
+    cycles_optim.BlenderLib('bf_intern_cycles_optimized', optim_sources, incs, optim_defs, libtype=['intern'], priority=[10], compileflags=[None], cxx_compileflags=optim_cxxflags)
+
+cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], compileflags=[None], cxx_compileflags=cxxflags)
 
-cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], compileflags=[None])
+# cuda kernel binaries
+if env['WITH_BF_CYCLES_CUDA_BINARIES']:
+    kernel_binaries = SConscript(['kernel/SConscript'])
+    cycles.Depends("device/device_cuda.o", kernel_binaries)
 
index 5f9e1d7a5ffbb87c6012cc5e500b640abdc0ef8c..00acae9295590565ebf972ebc33cc35986105df2 100644 (file)
@@ -339,64 +339,33 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
                else if(string_iequals(node.name(), "noise_texture")) {
                        snode = new NoiseTextureNode();
                }
-               else if(string_iequals(node.name(), "blend_texture")) {
-                       BlendTextureNode *blend = new BlendTextureNode();
-                       xml_read_enum(&blend->progression, BlendTextureNode::progression_enum, node, "progression");
-                       xml_read_enum(&blend->axis, BlendTextureNode::axis_enum, node, "axis");
+               else if(string_iequals(node.name(), "gradient_texture")) {
+                       GradientTextureNode *blend = new GradientTextureNode();
+                       xml_read_enum(&blend->type, GradientTextureNode::type_enum, node, "type");
                        snode = blend;
                }
-               else if(string_iequals(node.name(), "clouds_texture")) {
-                       CloudsTextureNode *clouds = new CloudsTextureNode();
-                       xml_read_bool(&clouds->hard, node, "hard");
-                       xml_read_int(&clouds->depth, node, "depth");
-                       xml_read_enum(&clouds->basis, CloudsTextureNode::basis_enum, node, "basis");
-                       snode = clouds;
-               }
                else if(string_iequals(node.name(), "voronoi_texture")) {
                        VoronoiTextureNode *voronoi = new VoronoiTextureNode();
-                       xml_read_enum(&voronoi->distance_metric, VoronoiTextureNode::distance_metric_enum, node, "distance_metric");
                        xml_read_enum(&voronoi->coloring, VoronoiTextureNode::coloring_enum, node, "coloring");
                        snode = voronoi;
                }
                else if(string_iequals(node.name(), "musgrave_texture")) {
                        MusgraveTextureNode *musgrave = new MusgraveTextureNode();
                        xml_read_enum(&musgrave->type, MusgraveTextureNode::type_enum, node, "type");
-                       xml_read_enum(&musgrave->basis, MusgraveTextureNode::basis_enum, node, "basis");
                        snode = musgrave;
                }
-               else if(string_iequals(node.name(), "marble_texture")) {
-                       MarbleTextureNode *marble = new MarbleTextureNode();
-                       xml_read_enum(&marble->type, MarbleTextureNode::type_enum, node, "type");
-                       xml_read_enum(&marble->wave, MarbleTextureNode::wave_enum, node, "wave");
-                       xml_read_enum(&marble->basis, MarbleTextureNode::basis_enum, node, "basis");
-                       xml_read_bool(&marble->hard, node, "hard");
-                       xml_read_int(&marble->depth, node, "depth");
-                       snode = marble;
-               }
                else if(string_iequals(node.name(), "magic_texture")) {
                        MagicTextureNode *magic = new MagicTextureNode();
                        xml_read_int(&magic->depth, node, "depth");
                        snode = magic;
                }
-               else if(string_iequals(node.name(), "stucci_texture")) {
-                       StucciTextureNode *stucci = new StucciTextureNode();
-                       xml_read_enum(&stucci->type, StucciTextureNode::type_enum, node, "type");
-                       xml_read_enum(&stucci->basis, StucciTextureNode::basis_enum, node, "basis");
-                       xml_read_bool(&stucci->hard, node, "hard");
-                       snode = stucci;
-               }
-               else if(string_iequals(node.name(), "distorted_noise_texture")) {
-                       DistortedNoiseTextureNode *dist = new DistortedNoiseTextureNode();
-                       xml_read_enum(&dist->basis, DistortedNoiseTextureNode::basis_enum, node, "basis");
-                       xml_read_enum(&dist->distortion_basis, DistortedNoiseTextureNode::basis_enum, node, "distortion_basis");
+               else if(string_iequals(node.name(), "noise_texture")) {
+                       NoiseTextureNode *dist = new NoiseTextureNode();
                        snode = dist;
                }
-               else if(string_iequals(node.name(), "wood_texture")) {
-                       WoodTextureNode *wood = new WoodTextureNode();
-                       xml_read_enum(&wood->type, WoodTextureNode::type_enum, node, "type");
-                       xml_read_enum(&wood->wave, WoodTextureNode::wave_enum, node, "wave");
-                       xml_read_enum(&wood->basis, WoodTextureNode::basis_enum, node, "basis");
-                       xml_read_bool(&wood->hard, node, "hard");
+               else if(string_iequals(node.name(), "wave_texture")) {
+                       WaveTextureNode *wood = new WaveTextureNode();
+                       xml_read_enum(&wood->type, WaveTextureNode::type_enum, node, "type");
                        snode = wood;
                }
                else if(string_iequals(node.name(), "mapping")) {
@@ -471,6 +440,15 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
                        xml_read_enum(&mix->type, MixNode::type_enum, node, "type");
                        snode = mix;
                }
+               else if(string_iequals(node.name(), "combine_rgb")) {
+                       snode = new CombineRGBNode();
+               }
+               else if(string_iequals(node.name(), "separate_rgb")) {
+                       snode = new SeparateRGBNode();
+               }
+               else if(string_iequals(node.name(), "hsv")) {
+                       snode = new HSVNode();
+               }
                else if(string_iequals(node.name(), "attribute")) {
                        AttributeNode *attr = new AttributeNode();
                        xml_read_ustring(&attr->attribute, node, "attribute");
index b96048acf054fb1db502b5e21465dc759cb0afbb..3b685346791c8b2ceb419925abd64c9b86c95361 100644 (file)
@@ -39,7 +39,6 @@ set(ADDON_FILES
        addon/presets.py
        addon/properties.py
        addon/ui.py
-       addon/xml.py
 )
 
 blender_add_lib(bf_intern_cycles "${SRC}" "${INC}" "${INC_SYS}")
index 34ed3dd8072d3087a2c9e20468c1a671ff13b667..a82d69903a8f5a0927678d1842a6fbc6536a1970 100644 (file)
@@ -33,7 +33,7 @@ bl_info = {
     "category": "Render"}
 
 import bpy
-from . import ui, properties, xml, engine, presets
+from . import ui, properties, engine, presets
 
 
 class CyclesRender(bpy.types.RenderEngine):
@@ -77,13 +77,11 @@ class CyclesRender(bpy.types.RenderEngine):
 def register():
     properties.register()
     ui.register()
-    xml.register()
     presets.register()
     bpy.utils.register_module(__name__)
 
 
 def unregister():
-    xml.unregister()
     ui.unregister()
     properties.unregister()
     presets.unregister()
index 581dc08436a925d670de865cc207fc41315b2fe3..a11f5ca0f87fadfd3be9517a0caed51ea895ff98 100644 (file)
@@ -41,7 +41,12 @@ devices = (
 
 gpu_type = (
     ("CUDA", "CUDA", "NVidia only"),
-    ("OPENCL", "OpenCL (incomplete)", ""),
+    ("OPENCL", "OpenCL", ""),
+    )
+
+feature_set = (
+    ("SUPPORTED", "Supported", "Only use finished and supported features"),
+    ("EXPERIMENTAL", "Experimental", "Use experimental and incomplete features that might be broken or change in the future"),
     )
 
 shading_systems = (
index 37de27dc6b4f7c9d1ff6d3182735bbb8e02b4cfc..0ea7396f9c2e3599587069a6070aea176e44f65a 100644 (file)
@@ -41,6 +41,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
         cls.gpu_type = EnumProperty(name="GPU Type", description="Processing system to use on the GPU",
             items=enums.gpu_type, default="CUDA")
 
+        cls.feature_set = EnumProperty(name="Feature Set", description="Feature set to use for rendering",
+            items=enums.feature_set, default="SUPPORTED")
+
         cls.shading_system = EnumProperty(name="Shading System", description="Shading system to use for rendering",
             items=enums.shading_systems, default="GPU_COMPATIBLE")
 
index ca733c6eeb080bd7d185a9d7208c21ea080a9f6c..d23347b937d2c234c0241db4c85ac43152eedd31 100644 (file)
@@ -294,7 +294,12 @@ class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        return CyclesButtonsPanel.poll(context) and (context.mesh or context.curve or context.meta_ball)
+        if CyclesButtonsPanel.poll(context):
+            if context.mesh or context.curve or context.meta_ball:
+                if context.scene.cycles.feature_set == 'EXPERIMENTAL':
+                    return True
+
+        return False
 
     def draw(self, context):
         layout = self.layout
@@ -706,18 +711,20 @@ def draw_device(self, context):
     if scene.render.engine == "CYCLES":
         cscene = scene.cycles
 
+        layout.prop(cscene, "feature_set")
+        experimental = cscene.feature_set == 'EXPERIMENTAL'
+
         available_devices = engine.available_devices()
         available_cuda = 'cuda' in available_devices
-        available_opencl = 'opencl' in available_devices
+        available_opencl = experimental and 'opencl' in available_devices
 
         if available_cuda or available_opencl:
             layout.prop(cscene, "device")
             if cscene.device == 'GPU' and available_cuda and available_opencl:
                 layout.prop(cscene, "gpu_type")
-        if cscene.device == 'CPU' and engine.with_osl():
+        if experimental and cscene.device == 'CPU' and engine.with_osl():
             layout.prop(cscene, "shading_system")
 
-
 def draw_pause(self, context):
     layout = self.layout
     scene = context.scene
diff --git a/intern/cycles/blender/addon/xml.py b/intern/cycles/blender/addon/xml.py
deleted file mode 100644 (file)
index f17051d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#
-# Copyright 2011, Blender Foundation.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-
-# <pep8 compliant>
-
-# XML exporter for generating test files, not intended for end users
-
-import os
-import bpy
-from bpy_extras.io_utils import ExportHelper
-import xml.etree.ElementTree as etree
-import xml.dom.minidom as dom
-
-
-def strip(root):
-    root.text = None
-    root.tail = None
-
-    for elem in root:
-        strip(elem)
-
-
-def write(node, fname):
-    strip(node)
-
-    s = etree.tostring(node)
-    s = dom.parseString(s).toprettyxml()
-
-    f = open(fname, "w")
-    f.write(s)
-
-
-class ExportCyclesXML(bpy.types.Operator, ExportHelper):
-    ''''''
-    bl_idname = "export_mesh.cycles_xml"
-    bl_label = "Export Cycles XML"
-
-    filename_ext = ".xml"
-
-    @classmethod
-    def poll(cls, context):
-        return context.active_object != None
-
-    def execute(self, context):
-        filepath = bpy.path.ensure_ext(self.filepath, ".xml")
-
-        # get mesh
-        scene = context.scene
-        obj = context.object
-
-        if not obj:
-            raise Exception("No active object")
-
-        mesh = obj.to_mesh(scene, True, 'PREVIEW')
-
-        if not mesh:
-            raise Exception("No mesh data in active object")
-
-        # generate mesh node
-        nverts = ""
-        verts = ""
-        P = ""
-
-        for v in mesh.vertices:
-            P += "%f %f %f  " % (v.co[0], v.co[1], v.co[2])
-
-        for i, f in enumerate(mesh.faces):
-            nverts += str(len(f.vertices)) + " "
-
-            for v in f.vertices:
-                verts += str(v) + " "
-            verts += " "
-
-        node = etree.Element('mesh', attrib={'nverts': nverts, 'verts': verts, 'P': P})
-
-        # write to file
-        write(node, filepath)
-
-        return {'FINISHED'}
-
-
-def register():
-    pass
-
-
-def unregister():
-    pass
-
-if __name__ == "__main__":
-    register()
index 2bc79224e087dbf9f7899f2d85bf989ca243172b..e247b3744fa4216d1d4daef9e96fe12d4e98e97c 100644 (file)
@@ -281,7 +281,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated)
        mesh->name = ustring(b_ob_data.name().c_str());
 
        if(b_mesh) {
-               if(cmesh.data && RNA_boolean_get(&cmesh, "use_subdivision"))
+               if(cmesh.data && experimental && RNA_boolean_get(&cmesh, "use_subdivision"))
                        create_subd_mesh(mesh, b_mesh, &cmesh, used_shaders);
                else
                        create_mesh(scene, mesh, b_mesh, used_shaders);
@@ -294,7 +294,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated)
        if(cmesh.data) {
                int method = RNA_enum_get(&cmesh, "displacement_method");
 
-               if(method == 0)
+               if(method == 0 || !experimental)
                        mesh->displacement_method = Mesh::DISPLACE_BUMP;
                else if(method == 1)
                        mesh->displacement_method = Mesh::DISPLACE_TRUE;
index cf8527b9760dc36a89cde5a65145dd03a1fb7172..e081ad8bdee5246c3205e400c6ca9c6494e6c7fe 100644 (file)
@@ -128,18 +128,15 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
        switch(b_node.type()) {
                /* not supported */
                case BL::ShaderNode::type_CAMERA: break;
-               case BL::ShaderNode::type_COMBRGB: break;
                case BL::ShaderNode::type_CURVE_RGB: break;
                case BL::ShaderNode::type_CURVE_VEC: break;
                case BL::ShaderNode::type_GEOMETRY: break;
-               case BL::ShaderNode::type_HUE_SAT: break;
                case BL::ShaderNode::type_INVERT: break;
                case BL::ShaderNode::type_MATERIAL: break;
                case BL::ShaderNode::type_MATERIAL_EXT: break;
                case BL::ShaderNode::type_NORMAL: break;
                case BL::ShaderNode::type_OUTPUT: break;
                case BL::ShaderNode::type_SCRIPT: break;
-               case BL::ShaderNode::type_SEPRGB: break;
                case BL::ShaderNode::type_SQUEEZE: break;
                case BL::ShaderNode::type_TEXTURE: break;
                case BL::ShaderNode::type_VALTORGB: break;
@@ -165,6 +162,18 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        node = mix;
                        break;
                }
+               case BL::ShaderNode::type_SEPRGB: {
+                       node = new SeparateRGBNode();
+                       break;
+               }
+               case BL::ShaderNode::type_COMBRGB: {
+                       node = new CombineRGBNode();
+                       break;
+               }
+               case BL::ShaderNode::type_HUE_SAT: {
+                       node = new HSVNode();
+                       break;
+               }
                case BL::ShaderNode::type_RGBTOBW: {
                        node = new ConvertNode(SHADER_SOCKET_COLOR, SHADER_SOCKET_FLOAT);
                        break;
index 36cf29de12885f31a3b845e45426c35c53f11828..f7b1ca53fd3bc302701101abbc30f96548541a09 100644 (file)
@@ -47,7 +47,8 @@ BlenderSync::BlenderSync(BL::BlendData b_data_, BL::Scene b_scene_, Scene *scene
   mesh_map(&scene_->meshes),
   light_map(&scene_->lights),
   world_map(NULL),
-  world_recalc(false)
+  world_recalc(false),
+  experimental(false)
 {
        scene = scene_;
        preview = preview_;
@@ -134,6 +135,8 @@ void BlenderSync::sync_integrator()
 {
        PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
 
+       experimental = (RNA_enum_get(&cscene, "feature_set") != 0);
+
        Integrator *integrator = scene->integrator;
        Integrator previntegrator = *integrator;
 
@@ -253,6 +256,9 @@ SessionParams BlenderSync::get_session_params(BL::Scene b_scene, bool background
        SessionParams params;
        PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
 
+       /* feature set */
+       bool experimental = (RNA_enum_get(&cscene, "feature_set") != 0);
+
        /* device type */
        params.device_type = DEVICE_CPU;
 
@@ -262,7 +268,7 @@ SessionParams BlenderSync::get_session_params(BL::Scene b_scene, bool background
 
                if(device_type_available(types, dtype))
                        params.device_type = dtype;
-               else if(device_type_available(types, DEVICE_OPENCL))
+               else if(experimental && device_type_available(types, DEVICE_OPENCL))
                        params.device_type = DEVICE_OPENCL;
                else if(device_type_available(types, DEVICE_CUDA))
                        params.device_type = DEVICE_CUDA;
index 2e7b8ed253d3d5bf1132886aeda49657da9f36f9..bde3207e1be4bccf558feffdb55144df115f43f3 100644 (file)
@@ -100,6 +100,7 @@ private:
 
        Scene *scene;
        bool preview;
+       bool experimental;
 
        struct RenderLayerInfo {
                RenderLayerInfo()
index e32cbfcc8a7b7272b5eb1107f84f3feb27624527..83d3f79d96fa58fea33e19a6eda4d8a99eab8ffc 100644 (file)
@@ -237,7 +237,10 @@ public:
                        return cubin;
 
 #ifdef WITH_CUDA_BINARIES
-               cuda_error("CUDA binary kernel for this graphics card not found.");
+               if(major <= 1 && minor <= 2)
+                       cuda_error(string_printf("CUDA device supported only with shader model 1.3 or up, found %d.%d.", major, minor));
+               else
+                       cuda_error("CUDA binary kernel for this graphics card not found.");
                return "";
 #else
                /* if not, find CUDA compiler */
index 73425486be1f90cc675a007bcc86a9c3641e44bc..a09fe1d726ee67b2eab6a0841f82f2268ac7a87c 100644 (file)
@@ -60,6 +60,7 @@ set(SRC_SVM_HEADERS
        svm/svm_fresnel.h
        svm/svm_geometry.h
        svm/svm_gradient.h
+       svm/svm_hsv.h
        svm/svm_image.h
        svm/svm_light_path.h
        svm/svm_magic.h
@@ -69,6 +70,7 @@ set(SRC_SVM_HEADERS
        svm/svm_musgrave.h
        svm/svm_noise.h
        svm/svm_noisetex.h
+       svm/svm_sepcomb_rgb.h
        svm/svm_sky.h
        svm/svm_tex_coord.h
        svm/svm_texture.h
diff --git a/intern/cycles/kernel/SConscript b/intern/cycles/kernel/SConscript
new file mode 100644 (file)
index 0000000..c9beb3a
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+import sys
+import os
+
+def normpath(path):
+    return os.path.abspath(os.path.normpath(path))
+
+Import ('env')
+
+kernel_binaries = []
+
+if env['WITH_BF_CYCLES_CUDA_BINARIES']:
+    kernel = env.Clone()
+
+    # cuda info
+    nvcc = env['BF_CYCLES_CUDA_NVCC']
+    cuda_archs = env['BF_CYCLES_CUDA_BINARIES_ARCH']
+
+    # build directory
+    root_build_dir = normpath(env['BF_BUILDDIR'])
+    build_dir = os.path.join(root_build_dir, 'intern/cycles/kernel')
+
+    # source directories and files
+    source_dir = Dir('.').srcnode().path
+    kernel_file = os.path.join(source_dir, "kernel.cu")
+    util_dir = os.path.join(source_dir, "../util")
+    svm_dir = os.path.join(source_dir, "../svm")
+
+    # nvcc flags
+    nvcc_flags = "--cubin -use_fast_math --ptxas-options=\"-v\" --maxrregcount=24"
+    nvcc_flags += " --opencc-options -OPT:Olimit=0"
+    nvcc_flags += " -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC"
+    nvcc_flags += " -I \"%s\" -I \"%s\"" % (util_dir, svm_dir)
+
+    # dependencies
+    dependencies = ['kernel.cu'] + kernel.Glob('*.h') + kernel.Glob('../util/*.h') + kernel.Glob('svm/*.h')
+
+    # add command for each cuda architecture
+    for arch in cuda_archs:
+        cubin_file = os.path.join(build_dir, "kernel_%s.cubin" % arch)
+
+        command = "\"%s\" -arch=%s %s \"%s\" -o \"%s\"" % (nvcc, arch, nvcc_flags, kernel_file, cubin_file)
+
+        kernel.Command(cubin_file, 'kernel.cu', command)
+        kernel.Depends(cubin_file, dependencies)
+
+        kernel_binaries.append(cubin_file)
+
+Return('kernel_binaries')
+
index e98bb158f6edbd60eca3375588d6f1a9cbafb3b6..35215fd0f9fd1de4b58cb491cd5209ddf42486bb 100644 (file)
@@ -33,6 +33,15 @@ CCL_NAMESPACE_BEGIN
 #define BVH_NODE_SIZE 4
 #define TRI_NODE_SIZE 3
 
+/* silly workaround for float extended precision that happens when compiling
+   without sse support on x86, it results in different results for float ops
+   that you would otherwise expect to compare correctly */
+#if !defined(__i386__) || defined(__SSE__)
+#define NO_EXTENDED_PRECISION
+#else
+#define NO_EXTENDED_PRECISION volatile
+#endif
+
 __device_inline float3 bvh_inverse_direction(float3 dir)
 {
        /* avoid divide by zero (ooeps = exp2f(-80.0f)) */
@@ -94,17 +103,17 @@ __device_inline void bvh_node_intersect(KernelGlobals *kg,
        float c0hiy = n0xy.w * idir.y - ood.y;
        float c0loz = nz.x * idir.z - ood.z;
        float c0hiz = nz.y * idir.z - ood.z;
+       NO_EXTENDED_PRECISION float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f);
+       NO_EXTENDED_PRECISION float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t);
+
        float c1loz = nz.z * idir.z - ood.z;
        float c1hiz = nz.w * idir.z - ood.z;
-
-       float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f);
-       float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t);
        float c1lox = n1xy.x * idir.x - ood.x;
        float c1hix = n1xy.y * idir.x - ood.x;
        float c1loy = n1xy.z * idir.y - ood.y;
        float c1hiy = n1xy.w * idir.y - ood.y;
-       float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f);
-       float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t);
+       NO_EXTENDED_PRECISION float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f);
+       NO_EXTENDED_PRECISION float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t);
 
        /* decide which nodes to traverse next */
 #ifdef __VISIBILITY_FLAG__
index 1b8b81eb6f6f948694d91be56b0107a7a1fd15ef..50e763a6b83f3fd9e1b6a75305357accb56478c7 100644 (file)
@@ -21,6 +21,7 @@ set(SRC_OSL
        node_geometry.osl
        node_glass_bsdf.osl
        node_glossy_bsdf.osl
+       node_hsv.osl
        node_image_texture.osl
        node_light_path.osl
        node_magic_texture.osl
@@ -35,6 +36,7 @@ set(SRC_OSL
        node_output_displacement.osl
        node_output_surface.osl
        node_output_volume.osl
+       node_sepcomb_rgb.osl
        node_sky_texture.osl
        node_stucci_texture.osl
        node_texture_coordinate.osl
index b92973d1dfe1b45d2ade66dbd76e594e1e44895f..37d092eae786a8b92aa4204478936a551d7225cf 100644 (file)
@@ -48,3 +48,78 @@ color color_scene_linear_to_srgb(color c)
                color_scene_linear_to_srgb(c[2]));
 }
 
+/* Color Operations */
+
+color rgb_to_hsv(color rgb)
+{
+       float cmax, cmin, h, s, v, cdelta;
+       color c;
+
+       cmax = max(rgb[0], max(rgb[1], rgb[2]));
+       cmin = min(rgb[0], min(rgb[1], rgb[2]));
+       cdelta = cmax - cmin;
+
+       v = cmax;
+
+       if(cmax != 0.0) {
+               s = cdelta/cmax;
+       }
+       else {
+               s = 0.0;
+               h = 0.0;
+       }
+
+       if(s == 0.0) {
+               h = 0.0;
+       }
+       else {
+               c = (color(cmax, cmax, cmax) - rgb)/cdelta;
+
+               if(rgb[0] == cmax) h = c[2] - c[1];
+               else if(rgb[1] == cmax) h = 2.0 + c[0] -  c[2];
+               else h = 4.0 + c[1] - c[0];
+
+               h /= 6.0;
+
+               if(h < 0.0)
+                       h += 1.0;
+       }
+
+       return color(h, s, v);
+}
+
+color hsv_to_rgb(color hsv)
+{
+       float i, f, p, q, t, h, s, v;
+       color rgb;
+
+       h = hsv[0];
+       s = hsv[1];
+       v = hsv[2];
+
+       if(s==0.0) {
+               rgb = color(v, v, v);
+       }
+       else {
+               if(h==1.0)
+                       h = 0.0;
+               
+               h *= 6.0;
+               i = floor(h);
+               f = h - i;
+               rgb = color(f, f, f);
+               p = v*(1.0-s);
+               q = v*(1.0-(s*f));
+               t = v*(1.0-(s*(1.0-f)));
+               
+               if(i == 0.0) rgb = color(v, t, p);
+               else if(i == 1.0) rgb = color(q, v, p);
+               else if(i == 2.0) rgb = color(p, v, t);
+               else if(i == 3.0) rgb = color(p, q, v);
+               else if(i == 4.0) rgb = color(t, p, v);
+               else rgb = color(v, p, q);
+       }
+
+       return rgb;
+}
+
diff --git a/intern/cycles/kernel/osl/nodes/node_hsv.osl b/intern/cycles/kernel/osl/nodes/node_hsv.osl
new file mode 100644 (file)
index 0000000..da776c8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+#include "node_color.h"
+
+shader node_hsv(
+       float Hue = 0.5,
+       float Saturation = 1.0,
+       float Value = 1.0,
+       float Fac = 0.5,
+       color ColorIn = color(0.0, 0.0, 0.0),
+       output color ColorOut = color(0.0, 0.0, 0.0))
+{
+       float t = clamp(Fac, 0.0, 1.0);
+       color Color = rgb_to_hsv(ColorIn);
+
+       Color[0] += Hue - 0.5;
+       Color[0] = fmod(Color[0], 1.0);
+       Color[1] *= Saturation;
+       Color[2] *= Value;
+
+       Color = hsv_to_rgb(Color);
+
+       ColorOut = mix(Color, ColorIn, t);
+}
+
index 582aa7b3c6032003320aeda0f2576ad73039cf87..8a462c995d369b15cd640630e7ad2029bcec66ef 100644 (file)
  */
 
 #include "stdosl.h"
-
-color rgb_to_hsv(color rgb)
-{
-       float cmax, cmin, h, s, v, cdelta;
-       color c;
-
-       cmax = max(rgb[0], max(rgb[1], rgb[2]));
-       cmin = min(rgb[0], min(rgb[1], rgb[2]));
-       cdelta = cmax - cmin;
-
-       v = cmax;
-
-       if(cmax != 0.0) {
-               s = cdelta/cmax;
-       }
-       else {
-               s = 0.0;
-               h = 0.0;
-       }
-
-       if(s == 0.0) {
-               h = 0.0;
-       }
-       else {
-               c = (color(cmax, cmax, cmax) - rgb)/cdelta;
-
-               if(rgb[0] == cmax) h = c[2] - c[1];
-               else if(rgb[1] == cmax) h = 2.0 + c[0] -  c[2];
-               else h = 4.0 + c[1] - c[0];
-
-               h /= 6.0;
-
-               if(h < 0.0)
-                       h += 1.0;
-       }
-
-       return color(h, s, v);
-}
-
-color hsv_to_rgb(color hsv)
-{
-       float i, f, p, q, t, h, s, v;
-       color rgb;
-
-       h = hsv[0];
-       s = hsv[1];
-       v = hsv[2];
-
-       if(s==0.0) {
-               rgb = color(v, v, v);
-       }
-       else {
-               if(h==1.0)
-                       h = 0.0;
-               
-               h *= 6.0;
-               i = floor(h);
-               f = h - i;
-               rgb = color(f, f, f);
-               p = v*(1.0-s);
-               q = v*(1.0-(s*f));
-               t = v*(1.0-(s*(1.0-f)));
-               
-               if(i == 0.0) rgb = color(v, t, p);
-               else if(i == 1.0) rgb = color(q, v, p);
-               else if(i == 2.0) rgb = color(p, v, t);
-               else if(i == 3.0) rgb = color(p, q, v);
-               else if(i == 4.0) rgb = color(t, p, v);
-               else rgb = color(v, p, q);
-       }
-
-       return rgb;
-}
+#include "node_color.h"
 
 color node_mix_blend(float t, color col1, color col2)
 {
diff --git a/intern/cycles/kernel/osl/nodes/node_sepcomb_rgb.osl b/intern/cycles/kernel/osl/nodes/node_sepcomb_rgb.osl
new file mode 100644 (file)
index 0000000..a02f31f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_separate_rgb(
+       color Image = color(0.8, 0.8, 0.8),
+       output float R = 0.0,
+       output float G = 0.0,
+       output float B = 0.0)
+{
+               R = Image[0];
+               G = Image[1];
+               B = Image[2];
+}
+
+shader node_combine_rgb(
+       float R = 0.0,
+       float G = 0.0,
+       float B = 0.0,
+       output color Image = color(0.8, 0.8, 0.8)
+{
+       Image = color(R, G, B)
+}
+
index 2615272691c66b56d2172b1ae9f14046741cd30a..004875b0de5a0c17a2dc81339804415964a11444 100644 (file)
@@ -127,6 +127,7 @@ CCL_NAMESPACE_END
 #include "svm_displace.h"
 #include "svm_fresnel.h"
 #include "svm_geometry.h"
+#include "svm_hsv.h"
 #include "svm_image.h"
 #include "svm_light_path.h"
 #include "svm_magic.h"
@@ -134,6 +135,7 @@ CCL_NAMESPACE_END
 #include "svm_wave.h"
 #include "svm_math.h"
 #include "svm_mix.h"
+#include "svm_sepcomb_rgb.h"
 #include "svm_musgrave.h"
 #include "svm_sky.h"
 #include "svm_tex_coord.h"
@@ -254,6 +256,15 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
                        case NODE_MIX:
                                svm_node_mix(kg, sd, stack, node.y, node.z, node.w, &offset);
                                break;
+                       case NODE_SEPARATE_RGB:
+                               svm_node_separate_rgb(sd, stack, node.y, node.z, node.w);
+                               break;
+                       case NODE_COMBINE_RGB:
+                               svm_node_combine_rgb(sd, stack, node.y, node.z, node.w);
+                               break;
+                       case NODE_HSV:
+                               svm_node_hsv(kg, sd, stack, node.y, node.z, node.w, &offset);
+                               break;
                        case NODE_ATTR:
                                svm_node_attr(kg, sd, stack, node);
                                break;
diff --git a/intern/cycles/kernel/svm/svm_hsv.h b/intern/cycles/kernel/svm/svm_hsv.h
new file mode 100644 (file)
index 0000000..fc927f2
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __SVM_HSV_H__
+#define __SVM_HSV_H__
+
+CCL_NAMESPACE_BEGIN
+
+__device float3 rgb_to_hsv(float3 rgb)
+{
+       float cmax, cmin, h, s, v, cdelta;
+       float3 c;
+
+       cmax = fmaxf(rgb.x, fmaxf(rgb.y, rgb.z));
+       cmin = min(rgb.x, min(rgb.y, rgb.z));
+       cdelta = cmax - cmin;
+
+       v = cmax;
+
+       if(cmax != 0.0f) {
+               s = cdelta/cmax;
+       }
+       else {
+               s = 0.0f;
+               h = 0.0f;
+       }
+
+       if(s == 0.0f) {
+               h = 0.0f;
+       }
+       else {
+               float3 cmax3 = make_float3(cmax, cmax, cmax);
+               c = (cmax3 - rgb)/cdelta;
+
+               if(rgb.x == cmax) h = c.z - c.y;
+               else if(rgb.y == cmax) h = 2.0f + c.x -  c.z;
+               else h = 4.0f + c.y - c.x;
+
+               h /= 6.0f;
+
+               if(h < 0.0f)
+                       h += 1.0f;
+       }
+
+       return make_float3(h, s, v);
+}
+
+__device float3 hsv_to_rgb(float3 hsv)
+{
+       float i, f, p, q, t, h, s, v;
+       float3 rgb;
+
+       h = hsv.x;
+       s = hsv.y;
+       v = hsv.z;
+
+       if(s==0.0f) {
+               rgb = make_float3(v, v, v);
+       }
+       else {
+               if(h==1.0f)
+                       h = 0.0f;
+               
+               h *= 6.0f;
+               i = floor(h);
+               f = h - i;
+               rgb = make_float3(f, f, f);
+               p = v*(1.0f-s);
+               q = v*(1.0f-(s*f));
+               t = v*(1.0f-(s*(1.0f-f)));
+               
+               if(i == 0.0f) rgb = make_float3(v, t, p);
+               else if(i == 1.0f) rgb = make_float3(q, v, p);
+               else if(i == 2.0f) rgb = make_float3(p, v, t);
+               else if(i == 3.0f) rgb = make_float3(p, q, v);
+               else if(i == 4.0f) rgb = make_float3(t, p, v);
+               else rgb = make_float3(v, p, q);
+       }
+
+       return rgb;
+}
+
+__device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_color_offset, uint fac_offset, uint out_color_offset, int *offset)
+{
+       /* read extra data */
+       uint4 node1 = read_node(kg, offset);
+
+       float fac = stack_load_float(stack, fac_offset);
+       float3 in_color = stack_load_float3(stack, in_color_offset);
+       float3 color = in_color;
+
+       float hue = stack_load_float(stack, node1.y);
+       float sat = stack_load_float(stack, node1.z);
+       float val = stack_load_float(stack, node1.w);
+
+       color = rgb_to_hsv(color);
+
+       color.x += hue - 0.5f;
+       color.x = fmod(color.x, 1.0f);
+       color.y *= sat;
+       color.z *= val;
+
+       color = hsv_to_rgb(color);
+
+       color.x = fac*color.x + (1.0f - fac)*in_color.x;
+       color.y = fac*color.y + (1.0f - fac)*in_color.y;
+       color.z = fac*color.z + (1.0f - fac)*in_color.z;
+
+       if (stack_valid(out_color_offset))
+               stack_store_float3(stack, out_color_offset, color);
+}
+
+CCL_NAMESPACE_END
+
+#endif /* __SVM_HSV_H__ */
+
index c9e6cdf43b954c3693d3b883cabdbc408bf0e80a..e2274a2e691be12e1945e95a675625b91e8cc152 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-CCL_NAMESPACE_BEGIN
-
-__device float3 rgb_to_hsv(float3 rgb)
-{
-       float cmax, cmin, h, s, v, cdelta;
-       float3 c;
-
-       cmax = fmaxf(rgb.x, fmaxf(rgb.y, rgb.z));
-       cmin = min(rgb.x, min(rgb.y, rgb.z));
-       cdelta = cmax - cmin;
-
-       v = cmax;
-
-       if(cmax != 0.0f) {
-               s = cdelta/cmax;
-       }
-       else {
-               s = 0.0f;
-               h = 0.0f;
-       }
-
-       if(s == 0.0f) {
-               h = 0.0f;
-       }
-       else {
-               float3 cmax3 = make_float3(cmax, cmax, cmax);
-               c = (cmax3 - rgb)/cdelta;
-
-               if(rgb.x == cmax) h = c.z - c.y;
-               else if(rgb.y == cmax) h = 2.0f + c.x -  c.z;
-               else h = 4.0f + c.y - c.x;
-
-               h /= 6.0f;
+#include "svm_hsv.h"
 
-               if(h < 0.0f)
-                       h += 1.0f;
-       }
-
-       return make_float3(h, s, v);
-}
-
-__device float3 hsv_to_rgb(float3 hsv)
-{
-       float i, f, p, q, t, h, s, v;
-       float3 rgb;
-
-       h = hsv.x;
-       s = hsv.y;
-       v = hsv.z;
-
-       if(s==0.0f) {
-               rgb = make_float3(v, v, v);
-       }
-       else {
-               if(h==1.0f)
-                       h = 0.0f;
-               
-               h *= 6.0f;
-               i = floor(h);
-               f = h - i;
-               rgb = make_float3(f, f, f);
-               p = v*(1.0f-s);
-               q = v*(1.0f-(s*f));
-               t = v*(1.0f-(s*(1.0f-f)));
-               
-               if(i == 0.0f) rgb = make_float3(v, t, p);
-               else if(i == 1.0f) rgb = make_float3(q, v, p);
-               else if(i == 2.0f) rgb = make_float3(p, v, t);
-               else if(i == 3.0f) rgb = make_float3(p, q, v);
-               else if(i == 4.0f) rgb = make_float3(t, p, v);
-               else rgb = make_float3(v, p, q);
-       }
-
-       return rgb;
-}
+CCL_NAMESPACE_BEGIN
 
 __device float3 svm_lerp(const float3 a, const float3 b, float t)
 {
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_rgb.h b/intern/cycles/kernel/svm/svm_sepcomb_rgb.h
new file mode 100644 (file)
index 0000000..4e23221
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+__device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset, uint color_index, uint out_offset)
+{
+       float color = stack_load_float(stack, in_offset);
+
+       if (stack_valid(out_offset))
+               stack_store_float(stack, out_offset+color_index, color);
+}
+
+__device void svm_node_separate_rgb(ShaderData *sd, float *stack, uint icolor_offset, uint color_index, uint out_offset)
+{
+       float3 color = stack_load_float3(stack, icolor_offset);
+
+       if (stack_valid(out_offset)) {
+               if (color_index == 0)
+                       stack_store_float(stack, out_offset, color.x);
+               else if (color_index == 1)
+                       stack_store_float(stack, out_offset, color.y);
+               else
+                       stack_store_float(stack, out_offset, color.z);
+       }
+}
+
+CCL_NAMESPACE_END
+
index 071477a83c70924bb6e7bfcfd463aa75d147c6d1..53bba644e41331cab519192ca2e52b7fd4e64277 100644 (file)
@@ -79,7 +79,10 @@ typedef enum NodeType {
        NODE_TEX_ENVIRONMENT = 4600,
        NODE_CLOSURE_HOLDOUT = 4700,
        NODE_LAYER_WEIGHT = 4800,
-       NODE_CLOSURE_VOLUME = 4900
+       NODE_CLOSURE_VOLUME = 4900,
+       NODE_SEPARATE_RGB = 5000,
+       NODE_COMBINE_RGB = 5100,
+       NODE_HSV = 5200
 } NodeType;
 
 typedef enum NodeAttributeType {
index 19992771c1d508b879314aeedee0a4e4d5771e6c..fc2dd49205a712e3c19f9440d3af479f8234ddc8 100644 (file)
@@ -685,9 +685,9 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
                        if(!mesh->transform_applied) {
                                string msg = "Updating Mesh BVH ";
                                if(mesh->name == "")
-                                       msg += string_printf("%ld/%ld", i+1, num_instance_bvh);
+                                       msg += string_printf("%lu/%lu", (unsigned long)(i+1), (unsigned long)num_instance_bvh);
                                else
-                                       msg += string_printf("%s %ld/%ld", mesh->name.c_str(), i+1, num_instance_bvh);
+                                       msg += string_printf("%s %lu/%lu", mesh->name.c_str(), (unsigned long)(i+1), (unsigned long)num_instance_bvh);
                                progress.set_status(msg, "Building BVH");
 
                                mesh->compute_bvh(&scene->params, progress);
index d7bd74c9ec7eb14d9be3b5301c6cbaa5f7009383..45bb1511785bb377e4101afaf60901866faa9907 100644 (file)
@@ -1629,6 +1629,111 @@ void MixNode::compile(OSLCompiler& compiler)
        compiler.add(this, "node_mix");
 }
 
+/* Combine RGB */
+CombineRGBNode::CombineRGBNode()
+: ShaderNode("combine_rgb")
+{
+       add_input("R", SHADER_SOCKET_FLOAT);
+       add_input("G", SHADER_SOCKET_FLOAT);
+       add_input("B", SHADER_SOCKET_FLOAT);
+       add_output("Image", SHADER_SOCKET_COLOR);
+}
+
+void CombineRGBNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *red_in = input("R");
+       ShaderInput *green_in = input("G");
+       ShaderInput *blue_in = input("B");
+       ShaderOutput *color_out = output("Image");
+
+       compiler.stack_assign(color_out);
+
+       compiler.stack_assign(red_in);
+       compiler.add_node(NODE_COMBINE_RGB, red_in->stack_offset, 0, color_out->stack_offset);
+
+       compiler.stack_assign(green_in);
+       compiler.add_node(NODE_COMBINE_RGB, green_in->stack_offset, 1, color_out->stack_offset);
+
+       compiler.stack_assign(blue_in);
+       compiler.add_node(NODE_COMBINE_RGB, blue_in->stack_offset, 2, color_out->stack_offset);
+}
+
+void CombineRGBNode::compile(OSLCompiler& compiler)
+{
+       compiler.add(this, "node_combine_rgb");
+}
+
+/* Separate RGB */
+SeparateRGBNode::SeparateRGBNode()
+: ShaderNode("separate_rgb")
+{
+       add_input("Image", SHADER_SOCKET_COLOR);
+       add_output("R", SHADER_SOCKET_FLOAT);
+       add_output("G", SHADER_SOCKET_FLOAT);
+       add_output("B", SHADER_SOCKET_FLOAT);
+}
+
+void SeparateRGBNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *color_in = input("Image");
+       ShaderOutput *red_out = output("R");
+       ShaderOutput *green_out = output("G");
+       ShaderOutput *blue_out = output("B");
+
+       compiler.stack_assign(color_in);
+
+       compiler.stack_assign(red_out);
+       compiler.add_node(NODE_SEPARATE_RGB, color_in->stack_offset, 0, red_out->stack_offset);
+
+       compiler.stack_assign(green_out);
+       compiler.add_node(NODE_SEPARATE_RGB, color_in->stack_offset, 1, green_out->stack_offset);
+
+       compiler.stack_assign(blue_out);
+       compiler.add_node(NODE_SEPARATE_RGB, color_in->stack_offset, 2, blue_out->stack_offset);
+}
+
+void SeparateRGBNode::compile(OSLCompiler& compiler)
+{
+       compiler.add(this, "node_separate_rgb");
+}
+
+/* Separate RGB */
+HSVNode::HSVNode()
+: ShaderNode("hsv")
+{
+       add_input("Hue", SHADER_SOCKET_FLOAT);
+       add_input("Saturation", SHADER_SOCKET_FLOAT);
+       add_input("Value", SHADER_SOCKET_FLOAT);
+       add_input("Fac", SHADER_SOCKET_FLOAT);
+       add_input("Color", SHADER_SOCKET_COLOR);
+       add_output("Color", SHADER_SOCKET_COLOR);
+}
+
+void HSVNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *hue_in = input("Hue");
+       ShaderInput *saturation_in = input("Saturation");
+       ShaderInput *value_in = input("Value");
+       ShaderInput *fac_in = input("Fac");
+       ShaderInput *color_in = input("Color");
+       ShaderOutput *color_out = output("Color");
+
+       compiler.stack_assign(hue_in);
+       compiler.stack_assign(saturation_in);
+       compiler.stack_assign(value_in);
+       compiler.stack_assign(fac_in);
+       compiler.stack_assign(color_in);
+       compiler.stack_assign(color_out);
+
+       compiler.add_node(NODE_HSV, color_in->stack_offset, fac_in->stack_offset, color_out->stack_offset);
+       compiler.add_node(NODE_HSV, hue_in->stack_offset, saturation_in->stack_offset, value_in->stack_offset);
+}
+
+void HSVNode::compile(OSLCompiler& compiler)
+{
+       compiler.add(this, "node_hsv");
+}
+
 /* Attribute */
 
 AttributeNode::AttributeNode()
index d9cbd7ff5897c791a8109a043c7eb77828ad16c9..dfff955c4fe52f0b2b6c9a09923c847c458527f2 100644 (file)
@@ -292,6 +292,21 @@ public:
        static ShaderEnum type_enum;
 };
 
+class CombineRGBNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(CombineRGBNode)
+};
+
+class SeparateRGBNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(SeparateRGBNode)
+};
+
+class HSVNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(HSVNode)
+};
+
 class AttributeNode : public ShaderNode {
 public:
        SHADER_NODE_CLASS(AttributeNode)
index 8ed4854b786829ae2b705ea1bcdf40ee4d629b0a..3e6e0de48eaa65c4fbf3c0b9c2c5746e0e97e8c2 100644 (file)
@@ -88,7 +88,7 @@ SubdFace *SubdMesh::add_face(int *index, int num)
        /* test non-manifold cases */
        if(!can_add_face(index, num)) {
                /* we could try to add face in opposite winding instead .. */
-               fprintf(stderr, "Warning: non manifold mesh, invalid face '%lu'.\n", faces.size());
+               fprintf(stderr, "Warning: non manifold mesh, invalid face '%lu'.\n", (unsigned long)faces.size());
                return NULL;
        }
        
index 91e8a94a58423ebd0fbc11a9be68dfbf2a42b8c9..6e3c7c47e39bba02c68024751f699ae36b633bf7 100644 (file)
@@ -106,7 +106,7 @@ public:
                data.resize(size/sizeof(T));
 
                if(!fread(&data[0], size, 1, f)) {
-                       fprintf(stderr, "Failed to read vector data from cache (%ld).\n", size);
+                       fprintf(stderr, "Failed to read vector data from cache (%lu).\n", (unsigned long)size);
                        return;
                }
        }
index abf5e08de9700e44ba12a95db6212441a44eed74..e8c81e576542cf7e73fcc2c466d20384fe4212f3 100644 (file)
@@ -142,15 +142,15 @@ bool system_cpu_support_optimized()
        static bool caps_init = false;
 
        if(!caps_init) {
-               int result[4], num, num_ex;
+               int result[4], num; //, num_ex;
 
                memset(&caps, 0, sizeof(caps));
 
                __cpuid(result, 0);
                num = result[0];
 
-               __cpuid(result, 0x80000000);
-               num_ex = result[0];
+               /*__cpuid(result, 0x80000000);
+               num_ex = result[0];*/
 
                if(num >= 1){
                        __cpuid(result, 0x00000001);
index cc8d2497f37747aa812365ddd3bcf6144664c118..4fdbbf8f9d4c899cb8468358597ed28e032e3d3c 100644 (file)
@@ -1,14 +1,10 @@
-/** \file memutil/intern/MEM_CacheLimiterC-Api.cpp
- *  \ingroup memutil
- */
-/**
+/*
+ * ***** 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * 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
  *
  * Contributor(s): Peter Schlaile <peter@schlaile.de> 2005
  *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ */
+
+/** \file memutil/intern/MEM_CacheLimiterC-Api.cpp
+ *  \ingroup memutil
  */
 
 #include <cstddef>
index 269871b72305b5e5afc12892c5b20bad2330e2d2..11d545849ef2855adbecf5daf3ea5ad33466f388 100644 (file)
@@ -40,14 +40,14 @@ def CLIP_set_viewport_background(context, all_screens, clip, clip_user):
         bgpic = None
 
         for x in space_v3d.background_images:
-            if x.source == 'MOVIE':
+            if x.source == 'MOVIE_CLIP':
                 bgpic = x
                 break
 
         if not bgpic:
             bgpic = space_v3d.background_images.new()
 
-        bgpic.source = 'MOVIE'
+        bgpic.source = 'MOVIE_CLIP'
         bgpic.clip = clip
         bgpic.clip_user.proxy_render_size = user.proxy_render_size
         bgpic.clip_user.use_render_undistorted = True
index 22d44ed47936344f3b6d61566b6154b059347213..cacf61249dc7b06a5be37224f5034bf690608b8d 100644 (file)
@@ -105,7 +105,7 @@ class CLIP_PT_tools_marker(Panel):
         box = layout.box()
         row = box.row(align=True)
         row.prop(settings, "show_default_expanded", text="", emboss=False)
-        row.label(text="Default Settings")
+        row.label(text="Tracking Settings")
 
         if settings.show_default_expanded:
             col = box.column()
@@ -120,9 +120,9 @@ class CLIP_PT_tools_marker(Panel):
 
             col.separator()
 
-            col2 = col.column(align=True)
-            col2.prop(settings, "default_pattern_size")
-            col2.prop(settings, "default_search_size")
+            sub = col.column(align=True)
+            sub.prop(settings, "default_pattern_size")
+            sub.prop(settings, "default_search_size")
 
             col.label(text="Tracker:")
             col.prop(settings, "default_tracker", text="")
@@ -134,9 +134,9 @@ class CLIP_PT_tools_marker(Panel):
 
             col.separator()
 
-            col2 = col.column(align=True)
-            col2.prop(settings, "default_frames_limit")
-            col2.prop(settings, "default_margin")
+            sub = col.column(align=True)
+            sub.prop(settings, "default_frames_limit")
+            sub.prop(settings, "default_margin")
 
             col.label(text="Match:")
             col.prop(settings, "default_pattern_match", text="")
@@ -814,7 +814,7 @@ class CLIP_MT_reconstruction(Menu):
         layout.separator()
 
         layout.operator("clip.track_to_empty")
-        layout.operator("clip.tracks_to_mesh")
+        layout.operator("clip.bundles_to_mesh")
 
 
 class CLIP_MT_track_visibility(Menu):
index 2d22a39862496fcae0c58bf5b7faf16bc9450232..56a48ad77b988d896f6da8f9a3f1fc8be975a78f 100644 (file)
@@ -359,8 +359,8 @@ class INFO_MT_help(Menu):
 
         layout = self.layout
 
-        layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:Manual'
-        layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-260/'
+        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-261/'
 
         layout.separator()
 
index 55437d63a5d3d4061966dce4833ddad80b549bd4..ce0d56b9fcacf39a59ee1b06a9fb692d73dce615 100644 (file)
@@ -2296,10 +2296,16 @@ class VIEW3D_PT_background_image(Panel):
             row.prop(bg, "show_expanded", text="", emboss=False)
             if bg.source == 'IMAGE' and bg.image:
                 row.prop(bg.image, "name", text="", emboss=False)
-            elif bg.source == 'MOVIE' and bg.clip:
+            elif bg.source == 'MOVIE_CLIP' and bg.clip:
                 row.prop(bg.clip, "name", text="", emboss=False)
             else:
                 row.label(text="Not Set")
+
+            if bg.show_background_image:
+                row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
+            else:
+                row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
+
             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
 
             box.prop(bg, "view_axis", text="Axis")
@@ -2316,7 +2322,7 @@ class VIEW3D_PT_background_image(Panel):
                         box.template_image(bg, "image", bg.image_user, compact=True)
                         has_bg = True
 
-                elif bg.source == 'MOVIE':
+                elif bg.source == 'MOVIE_CLIP':
                     box.prop(bg, 'use_camera_clip')
 
                     column = box.column()
index c7922a0dfa197ca8990b8d069607a1fe8d7cb748..bc0252aa61660fc92ae22182fd080d71bb757758 100644 (file)
@@ -354,7 +354,7 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
     # custom properties
     def doCustomProps(ksi, ks, bone):
 
-        prop_type_compat = {bpy.types.BooleanProperty,
+        prop_type_compat = {bpy.types.BoolProperty,
                             bpy.types.IntProperty,
                             bpy.types.FloatProperty}
 
index 8c5ead490360379146d0f7ea67c9648e38c5c403..0627624d2e70e01a2afd8cc04aea595fb0fe0629 100644 (file)
   </style>
 </head>
 <body>
-<p class="title"><b>Blender 2.60</b></p>
+<p class="title"><b>Blender 2.61</b></p>
 <p><br></p>
 <p class="header"><b>About</b></p>
 <p class="body">Welcome to Blender, the free, open source 3D application for modeling, animation, rendering, compositing, video editing and game creation. Blender is available for Linux, Mac OS X, Windows, Solaris and FreeBSD and has a large world-wide community.</p>
 <p class="body">Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.</p>
 <p class="body">For more information, visit <a href="http://www.blender.org">blender.org</a>.</p>
 <p><br></p>
-<p class="header"><b>2.60</b></p>
-<p class="body">The Blender Foundation and online developer community is proud to present Blender 2.60. This release is the first official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features again.<a href="http://www.blender.org/development/release-logs/blender-260/">More information about this release</a>.</p>
+<p class="header"><b>2.61</b></p>
+<p class="body">The Blender Foundation and online developer community is proud to present Blender 2.61. This release is the second official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features again.<a href="http://www.blender.org/development/release-logs/blender-261/">More information about this release</a>.</p>
 <p><br></p>
 <p class="header"><b>Bugs</b></p>
-<p class="body">Although Blender 2.60 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.</p>
+<p class="body">Although Blender 2.61 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.</p>
 <p><br></p>
 <p class="header"><b>Package Contents</b></p>
 <p class="body">The downloaded Blender package includes:</p>
@@ -47,7 +47,7 @@
 <p class="header"><b>Links</b></p>
 <p class="body">Users:</p>
 <p class="body">       General information             <a href="http://www.blender.org">www.blender.org</a> <br>
-       Full release log                        <a href="http://www.blender.org/development/release-logs/blender-260/">www.blender.org/development/release-logs/blender-260/</a><br>
+       Full release log                        <a href="http://www.blender.org/development/release-logs/blender-261/">www.blender.org/development/release-logs/blender-261/</a><br>
        Tutorials                       <a href="http://www.blender.org/education-help/">www.blender.org/education-help/</a>    <br>
        Manual                  <a href="http://wiki.blender.org/index.php/Doc:Manual">wiki.blender.org/index.php/Doc:Manual</a><br>
        User Forum                      <a href="http://www.blenderartists.org">www.blenderartists.org</a><br>
index 84f1bf75a3f2e64ed69b4cdbc9c323a822512e58..429d5e84785ec215c532126ed75427b4f4b8b0eb 100644 (file)
@@ -255,7 +255,11 @@ struct DerivedMesh {
         */
        void (*drawFacesTex)(DerivedMesh *dm,
                                                 int (*setDrawOptions)(struct MTFace *tface,
-                                                int has_mcol, int matnr));
+                                                        int has_mcol, int matnr),
+                                               int (*compareDrawOptions)(void *userData,
+                                                        int cur_index,
+                                                        int next_index),
+                                               void *userData);
 
        /* Draw all faces with GLSL materials
         *  o setMaterial is called for every different material nr
@@ -280,9 +284,11 @@ struct DerivedMesh {
        void (*drawMappedFaces)(DerivedMesh *dm,
                                                        int (*setDrawOptions)(void *userData, int index,
                                                                                                  int *drawSmooth_r),
-                                                       void *userData, int useColors,
                                                        int (*setMaterial)(int, void *attribs),
-                                                       int (*compareDrawOptions)(void *userData, int cur_index, int next_index));
+                                                       int (*compareDrawOptions)(void *userData,
+                                                                                 int cur_index,
+                                                                                 int next_index),
+                                                       void *userData, int useColors);
 
        /* Draw mapped faces using MTFace 
         *  o Drawing options too complicated to enumerate, look at code.
@@ -290,6 +296,9 @@ struct DerivedMesh {
        void (*drawMappedFacesTex)(DerivedMesh *dm,
                                                           int (*setDrawOptions)(void *userData,
                                                                                                         int index),
+                                                          int (*compareDrawOptions)(void *userData,
+                                                                                    int cur_index,
+                                                                                    int next_index),
                                                           void *userData);
 
        /* Draw mapped faces with GLSL materials
@@ -299,7 +308,8 @@ struct DerivedMesh {
         */
        void (*drawMappedFacesGLSL)(DerivedMesh *dm,
                int (*setMaterial)(int, void *attribs),
-               int (*setDrawOptions)(void *userData, int index), void *userData);
+               int (*setDrawOptions)(void *userData, int index),
+               void *userData);
 
        /* Draw mapped edges as lines
         *  o Only if !setDrawOptions or setDrawOptions(userData, mapped-edge)
@@ -554,6 +564,16 @@ typedef struct DMVertexAttribs {
        int tottface, totmcol, tottang, totorco;
 } DMVertexAttribs;
 
+/* should be local, bmesh replaces this */
+typedef struct {
+       DerivedMesh dm;
+
+       struct EditMesh *em;
+       float (*vertexCos)[3];
+       float (*vertexNos)[3];
+       float (*faceNos)[3];
+} EditMeshDerivedMesh;
+
 void DM_vertex_attributes_from_gpu(DerivedMesh *dm,
        struct GPUVertexAttribs *gattribs, DMVertexAttribs *attribs);
 
index fdd876ff29b570d26616591389f3e852654db586..8738dc0830a474169207a080d2c0241432d49ac2 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION                        260
-#define BLENDER_SUBVERSION             5
+#define BLENDER_SUBVERSION             6
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
index 9739a5eacf2bf2ae07dc250c2f607ed4b7accfdd..c8df6c4f455e6a939cb913379f8bd06c291eca46 100644 (file)
@@ -4,10 +4,7 @@
  * 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this. 
+ * 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
index 2c6449eb290155160c652b9ed0c46a7ed13a25c5..793410371df429d79bec8979e3bbc6199cf533fb 100644 (file)
@@ -4,10 +4,7 @@
  * 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this. 
+ * 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
index 3e643fe961cac5caa79858a778765b87491aeabd..ed8ea6911346a28ae0b3a98967ccbb7ab2829358 100644 (file)
@@ -52,13 +52,16 @@ void                                 defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob);
 
 struct MDeformWeight   *defvert_find_index(const struct MDeformVert *dv, const int defgroup);
 struct MDeformWeight   *defvert_verify_index(struct MDeformVert *dv, const int defgroup);
+void                     defvert_remove_index(struct MDeformVert *dvert, int defgroup, struct MDeformWeight *dw);
 
-float  defvert_find_weight(const struct MDeformVert *dvert, const int group_num);
-float  defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int group_num);
+float  defvert_find_weight(const struct MDeformVert *dvert, const int defgroup);
+float  defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup);
 
-void defvert_copy(struct MDeformVert *dvert_r, const struct MDeformVert *dvert);
-void defvert_sync(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int use_verify);
-void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, const int *flip_map, const int flip_map_len, const int use_verify);
+void defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src);
+void defvert_copy_index(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int defgroup);
+void defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, int use_verify);
+void defvert_sync_mapped(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src,
+                         const int *flip_map, const int flip_map_len, const int use_verify);
 void defvert_remap (struct MDeformVert *dvert, int *map);
 void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
 void defvert_normalize(struct MDeformVert *dvert);
index e0b8e40d73172c6b434038556c982c9aa6947085..5d475903febf5f1ed57dc77038b2ddefbce5457d 100644 (file)
@@ -121,7 +121,7 @@ void        DAG_id_tag_update(struct ID *id, short flag);
                /* flush all tagged updates */
 void   DAG_ids_flush_tagged(struct Main *bmain);
                /* check and clear ID recalc flags */
-void   DAG_ids_check_recalc(struct Main *bmain);
+void   DAG_ids_check_recalc(struct Main *bmain, struct Scene *scene, int time);
 void   DAG_ids_clear_recalc(struct Main *bmain);
                /* test if any of this id type is tagged for update */
 void   DAG_id_type_tag(struct Main *bmain, short idtype);
@@ -131,7 +131,8 @@ int         DAG_id_type_tagged(struct Main *bmain, short idtype);
 void   DAG_pose_sort(struct Object *ob);
 
                /* callback for editors module to do updates */
-void   DAG_editors_update_cb(void (*func)(struct Main *bmain, struct ID *id));
+void   DAG_editors_update_cb(void (*id_func)(struct Main *bmain, struct ID *id),
+                              void (*scene_func)(struct Main *bmain, struct Scene *scene, int updated));
 
                /* debugging */
 void   DAG_print_dependencies(struct Main *bmain, struct Scene *scene, struct Object *ob);
index ade055ac457b8e6ae2442e6bfd7d182aadd5c6be..e8d6c85664be1623697e173c5ed24f69594740f7 100644 (file)
@@ -49,7 +49,7 @@ void *alloc_libblock(struct ListBase *lb, short type, const char *name);
 void *copy_libblock(struct ID *id);
 void copy_libblock_data(struct ID *id, const struct ID *id_from, const short do_action);
 
-void BKE_id_lib_local_paths(struct Main *bmain, struct ID *id);
+void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
 void id_lib_extern(struct ID *id);
 void BKE_library_filepath_set(struct Library *lib, const char *filepath);
 void id_us_plus(struct ID *id);
index 82e42ae27e27c338771ff1c5ec8616d47b37b142..5dbf22b54bf8fe453d35a873a5573670e709a513 100644 (file)
@@ -4,10 +4,7 @@
  * 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * 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
index 7cb31505430214db27fab8013f105f81a0253934..2df5e7ac2c6f09b00f8368cb2974869e8ac24c23 100644 (file)
@@ -90,7 +90,6 @@ float BKE_curframe(struct Scene *scene);
 float BKE_frame_to_ctime(struct Scene *scene, const float frame);
 
 void scene_update_tagged(struct Main *bmain, struct Scene *sce);
-void scene_clear_tagged(struct Main *bmain, struct Scene *sce);
 
 void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay);
 
index 715febf2fd16088a4c0cbff81dc892dd1184c330..3a4ac2798528ae2744cada51c486a667290a88dd 100644 (file)
@@ -4,10 +4,7 @@
  * 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this. 
+ * 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
index b4745669ff03ef274d5379dbda6fdad8f01f7699..9135f3e39f0bf5749602ccac5ca076b36b6ff658 100644 (file)
@@ -91,6 +91,7 @@ set(SRC
        intern/displist.c
        intern/dynamicpaint.c
        intern/effect.c
+       intern/editderivedmesh.c
        intern/fcurve.c
        intern/fluidsim.c
        intern/fmodifier.c
index 67215b5e40f8ee6f96f6c29b9e6a0ee80b2edf82..bb909dcbbddd182f1462c4afb691095bd5816f23 100644 (file)
@@ -9,10 +9,7 @@
  * 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this. 
+ * 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
index d1c258cbc93a313913334ab2b1d14b89c396212e..44258f92024660932c489981ec478454f1956f66 100644 (file)
@@ -68,9 +68,11 @@ void BME_free_transdata(BME_TransData_Head *td) {
        MEM_freeN(td);
 }
 
-BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Vert *v,
-               float *co, float *org, float *vec, float *loc,
-               float factor, float weight, float maxfactor, float *max) {
+BME_TransData *BME_assign_transdata(
+        BME_TransData_Head *td, BME_Mesh *bm, BME_Vert *v,
+        float *co, float *org, float *vec, float *loc,
+        float factor, float weight, float maxfactor, float *max)
+{
        BME_TransData *vtd;
        int is_new = 0;
 
@@ -85,13 +87,23 @@ BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Ve
 
        vtd->bm = bm;
        vtd->v = v;
-       if (co != NULL) VECCOPY(vtd->co,co);
-       if (org == NULL && is_new) { VECCOPY(vtd->org,v->co); } /* default */
-       else if (org != NULL) VECCOPY(vtd->org,org);
+
+       if (co != NULL) {
+               copy_v3_v3(vtd->co, co);
+       }
+
+       if (org == NULL && is_new) {
+               copy_v3_v3(vtd->org, v->co); /* default */
+       }
+       else if (org != NULL) {
+               copy_v3_v3(vtd->org,org);
+       }
+
        if (vec != NULL) {
-               VECCOPY(vtd->vec,vec);
+               copy_v3_v3(vtd->vec,vec);
                normalize_v3(vtd->vec);
        }
+
        vtd->loc = loc;
 
        vtd->factor = factor;
@@ -324,7 +336,8 @@ static int BME_bevel_is_split_vert(BME_Loop *l) {
  * the bevel operation as a whole based on the relationship between v1 and v2
  * (won't necessarily be a vec from v1->co to v2->co, though it probably will be);
  * the return value is -1 for failure, 0 if we used vert co's, and 1 if we used transform origins */
-static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransData_Head *td) {
+static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransData_Head *td)
+{
        BME_TransData *vtd1, *vtd2;
 
        vtd1 = BME_get_transdata(td,v1);
@@ -338,16 +351,16 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa
         * if they belong to different origins, then we will use the origins to determine
         * the vector */
        if (compare_v3v3(vtd1->org,vtd2->org,0.000001f)) {
-               VECSUB(vec,v2->co,v1->co);
+               sub_v3_v3v3(vec, v2->co, v1->co);
                if (len_v3(vec) < 0.000001f) {
-                       mul_v3_fl(vec,0);
+                       zero_v3(vec);
                }
                return 0;
        }
        else {
-               VECSUB(vec,vtd2->org,vtd1->org);
+               sub_v3_v3v3(vec,vtd2->org,vtd1->org);
                if (len_v3(vec) < 0.000001f) {
-                       mul_v3_fl(vec,0);
+                       zero_v3(vec);
                }
                return 1;
        }
@@ -362,7 +375,8 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa
  * vec2 is the direction of projection (pointing away from vec1)
  * up_vec is used for orientation (expected to be normalized)
  * returns the length of the projected vector that lies along vec1 */
-static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *UNUSED(td)) {
+static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *UNUSED(td))
+{
        float factor, vec3[3], tmp[3],c1,c2;
 
        cross_v3_v3v3(tmp,vec1,vec2);
@@ -377,7 +391,7 @@ static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int
        normalize_v3(vec3);
        c1 = dot_v3v3(vec3,vec1);
        c2 = dot_v3v3(vec1,vec1);
-       if (fabs(c1) < 0.000001f || fabs(c2) < 0.000001f) {
+       if (fabsf(c1) < 0.000001f || fabsf(c2) < 0.000001f) {
                factor = 0.0f;
        }
        else {
@@ -525,8 +539,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
        if (is_edge || dis > maxfactor*value) {
                dis = maxfactor*value;
        }
-       VECADDFAC(sv->co,v->co,vec1,dis);
-       VECSUB(vec1,sv->co,vtd1->org);
+       madd_v3_v3v3fl(sv->co, v->co, vec1, dis);
+       sub_v3_v3v3(vec1, sv->co, vtd1->org);
        dis = len_v3(vec1);
        normalize_v3(vec1);
        BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, maxfactor, vtd->max);
@@ -546,11 +560,11 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
                fac1 = 0;
        }
        else {
-               VECCOPY(vec2,vtd1->vec);
-               mul_v3_fl(vec2,vtd1->factor);
+               copy_v3_v3(vec2, vtd1->vec);
+               mul_v3_fl(vec2, vtd1->factor);
                if (dot_v3v3(vec1, vec1)) {
-                       project_v3_v3v3(vec2,vec2,vec1);
-                       fac1 = len_v3(vec2)/value;
+                       project_v3_v3v3(vec2, vec2,vec1);
+                       fac1 = len_v3(vec2) / value;
                }
                else {
                        fac1 = 0;
@@ -561,11 +575,11 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
                fac2 = 0;
        }
        else {
-               VECCOPY(vec3,vtd2->vec);
-               mul_v3_fl(vec3,vtd2->factor);
+               copy_v3_v3(vec3, vtd2->vec);
+               mul_v3_fl(vec3, vtd2->factor);
                if (dot_v3v3(vec1, vec1)) {
-                       project_v3_v3v3(vec2,vec3,vec1);
-                       fac2 = len_v3(vec2)/value;
+                       project_v3_v3v3(vec2, vec3, vec1);
+                       fac2 = len_v3(vec2) / value;
                }
                else {
                        fac2 = 0;
@@ -573,7 +587,7 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
        }
 
        if (fac1 || fac2) {
-               max = len_v3(vec1)/(fac1 + fac2);
+               max = len_v3(vec1) / (fac1 + fac2);
                if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
                        *vtd1->max = max;
                }
@@ -762,8 +776,8 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
        for (i=0,ol=f->loopbase,l=ol->next; l->next!=ol; l=l->next) {
                BME_bevel_get_vec(vec1,l->next->v,ol->v,td);
                BME_bevel_get_vec(vec2,l->v,ol->v,td);
-               cross_v3_v3v3(vec3,vec2,vec1);
-               VECADD(up_vec,up_vec,vec3);
+               cross_v3_v3v3(vec3, vec2, vec1);
+               add_v3_v3(up_vec, vec3);
                i++;
        }
        mul_v3_fl(up_vec,1.0f/i);
@@ -792,7 +806,7 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
                                        fac1 = 0;
                                }
                                else {
-                                       VECCOPY(vec2,vtd1->vec);
+                                       copy_v3_v3(vec2,vtd1->vec);
                                        mul_v3_fl(vec2,vtd1->factor);
                                        if (dot_v3v3(vec1, vec1)) {
                                                project_v3_v3v3(vec2,vec2,vec1);
@@ -806,7 +820,7 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
                                        fac2 = 0;
                                }
                                else {
-                                       VECCOPY(vec3,vtd2->vec);
+                                       copy_v3_v3(vec3,vtd2->vec);
                                        mul_v3_fl(vec3,vtd2->factor);
                                        if (dot_v3v3(vec1, vec1)) {
                                                project_v3_v3v3(vec2,vec3,vec1);
@@ -832,7 +846,8 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
        return l->f;
 }
 
-static void BME_bevel_add_vweight(BME_TransData_Head *td, BME_Mesh *bm, BME_Vert *v, float weight, float factor, int options) {
+static void BME_bevel_add_vweight(BME_TransData_Head *td, BME_Mesh *bm, BME_Vert *v, float weight, float factor, int options)
+{
        BME_TransData *vtd;
 
        if (v->tflag1 & BME_BEVEL_NONMAN) return;
@@ -1104,6 +1119,7 @@ static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int UNUSED(defg
        }
 
        return bm;
+
 }
 
 /* tags all elements as originals */
@@ -1123,8 +1139,8 @@ static BME_Mesh *BME_bevel_reinitialize(BME_Mesh *bm) {
        for (f=bm->polys.first; f; f=f->next) {
                f->tflag1 |= BME_BEVEL_ORIG;
        }
-
        return bm;
+
 }
 
 /**
@@ -1317,7 +1333,7 @@ BME_Mesh *BME_bevel(BME_Mesh *bm, float value, int res, int options, int defgrp_
                        else {
                                d = value;
                        }
-                       VECADDFAC(v->co,vtd->org,vtd->vec,vtd->factor*d);
+                       madd_v3_v3v3fl(v->co,vtd->org,vtd->vec,vtd->factor*d);
                }
                v->tflag1 = 0;
        }
index 4e26078a2c55dd67a0b42f950250019bd605879a..795b36813e108dbd5ce42b4d1e8908b7999f7105 100644 (file)
@@ -456,1180 +456,6 @@ DerivedMesh *mesh_create_derived(Mesh *me, Object *ob, float (*vertCos)[3])
        return dm;
 }
 
-///
-
-typedef struct {
-       DerivedMesh dm;
-
-       EditMesh *em;
-       float (*vertexCos)[3];
-       float (*vertexNos)[3];
-       float (*faceNos)[3];
-} EditMeshDerivedMesh;
-
-static void emDM_foreachMappedVert(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no_f, short *no_s), void *userData)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditVert *eve;
-       int i;
-
-       for (i=0,eve= emdm->em->verts.first; eve; i++,eve=eve->next) {
-               if (emdm->vertexCos) {
-                       func(userData, i, emdm->vertexCos[i], emdm->vertexNos[i], NULL);
-               } else {
-                       func(userData, i, eve->co, eve->no, NULL);
-               }
-       }
-}
-static void emDM_foreachMappedEdge(DerivedMesh *dm, void (*func)(void *userData, int index, float *v0co, float *v1co), void *userData)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditEdge *eed;
-       int i;
-
-       if (emdm->vertexCos) {
-               EditVert *eve;
-
-               for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
-                       eve->tmp.l = (intptr_t) i++;
-               for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next)
-                       func(userData, i, emdm->vertexCos[(int) eed->v1->tmp.l], emdm->vertexCos[(int) eed->v2->tmp.l]);
-       } else {
-               for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next)
-                       func(userData, i, eed->v1->co, eed->v2->co);
-       }
-}
-static void emDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData) 
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditEdge *eed;
-       int i;
-
-       if (emdm->vertexCos) {
-               EditVert *eve;
-
-               for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
-                       eve->tmp.l = (intptr_t) i++;
-
-               glBegin(GL_LINES);
-               for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
-                       if(!setDrawOptions || setDrawOptions(userData, i)) {
-                               glVertex3fv(emdm->vertexCos[(int) eed->v1->tmp.l]);
-                               glVertex3fv(emdm->vertexCos[(int) eed->v2->tmp.l]);
-                       }
-               }
-               glEnd();
-       } else {
-               glBegin(GL_LINES);
-               for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
-                       if(!setDrawOptions || setDrawOptions(userData, i)) {
-                               glVertex3fv(eed->v1->co);
-                               glVertex3fv(eed->v2->co);
-                       }
-               }
-               glEnd();
-       }
-}
-static void emDM_drawEdges(DerivedMesh *dm, int UNUSED(drawLooseEdges), int UNUSED(drawAllEdges))
-{
-       emDM_drawMappedEdges(dm, NULL, NULL);
-}
-static void emDM_drawMappedEdgesInterp(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void (*setDrawInterpOptions)(void *userData, int index, float t), void *userData) 
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditEdge *eed;
-       int i;
-
-       if (emdm->vertexCos) {
-               EditVert *eve;
-
-               for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
-                       eve->tmp.l = (intptr_t) i++;
-
-               glBegin(GL_LINES);
-               for (i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
-                       if(!setDrawOptions || setDrawOptions(userData, i)) {
-                               setDrawInterpOptions(userData, i, 0.0);
-                               glVertex3fv(emdm->vertexCos[(int) eed->v1->tmp.l]);
-                               setDrawInterpOptions(userData, i, 1.0);
-                               glVertex3fv(emdm->vertexCos[(int) eed->v2->tmp.l]);
-                       }
-               }
-               glEnd();
-       } else {
-               glBegin(GL_LINES);
-               for (i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
-                       if(!setDrawOptions || setDrawOptions(userData, i)) {
-                               setDrawInterpOptions(userData, i, 0.0);
-                               glVertex3fv(eed->v1->co);
-                               setDrawInterpOptions(userData, i, 1.0);
-                               glVertex3fv(eed->v2->co);
-                       }
-               }
-               glEnd();
-       }
-}
-
-static void emDM_drawUVEdges(DerivedMesh *dm)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditFace *efa;
-       MTFace *tf;
-
-       glBegin(GL_LINES);
-       for(efa= emdm->em->faces.first; efa; efa= efa->next) {
-               tf = CustomData_em_get(&emdm->em->fdata, efa->data, CD_MTFACE);
-
-               if(tf && !(efa->h)) {
-                       glVertex2fv(tf->uv[0]);
-                       glVertex2fv(tf->uv[1]);
-
-                       glVertex2fv(tf->uv[1]);
-                       glVertex2fv(tf->uv[2]);
-
-                       if (!efa->v4) {
-                               glVertex2fv(tf->uv[2]);
-                               glVertex2fv(tf->uv[0]);
-                       } else {
-                               glVertex2fv(tf->uv[2]);
-                               glVertex2fv(tf->uv[3]);
-                               glVertex2fv(tf->uv[3]);
-                               glVertex2fv(tf->uv[0]);
-                       }
-               }
-       }
-       glEnd();
-}
-
-static void emDM__calcFaceCent(EditFace *efa, float cent[3], float (*vertexCos)[3])
-{
-       if (vertexCos) {
-               copy_v3_v3(cent, vertexCos[(int) efa->v1->tmp.l]);
-               add_v3_v3(cent, vertexCos[(int) efa->v2->tmp.l]);
-               add_v3_v3(cent, vertexCos[(int) efa->v3->tmp.l]);
-               if (efa->v4) add_v3_v3(cent, vertexCos[(int) efa->v4->tmp.l]);
-       } else {
-               copy_v3_v3(cent, efa->v1->co);
-               add_v3_v3(cent, efa->v2->co);
-               add_v3_v3(cent, efa->v3->co);
-               if (efa->v4) add_v3_v3(cent, efa->v4->co);
-       }
-
-       if (efa->v4) {
-               mul_v3_fl(cent, 0.25f);
-       } else {
-               mul_v3_fl(cent, 0.33333333333f);
-       }
-}
-static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no), void *userData)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditVert *eve;
-       EditFace *efa;
-       float cent[3];
-       int i;
-
-       if (emdm->vertexCos) {
-               for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
-                       eve->tmp.l = (intptr_t) i++;
-       }
-
-       for(i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
-               emDM__calcFaceCent(efa, cent, emdm->vertexCos);
-               func(userData, i, cent, emdm->vertexCos?emdm->faceNos[i]:efa->n);
-       }
-}
-
-/* note, material function is ignored for now. */
-static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int UNUSED(useColors), int (*setMaterial)(int, void *attribs),
-                       int (*compareDrawOptions)(void *userData, int cur_index, int next_index))
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditFace *efa;
-       int i, draw;
-       const int skip_normals= !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */
-
-       /* GL_ZERO is used to detect if drawing has started or not */
-       GLenum poly_prev= GL_ZERO;
-       GLenum shade_prev= GL_ZERO;
-
-       (void)setMaterial; /* unused */
-
-       /* currently unused -- each original face is handled separately */
-       (void)compareDrawOptions;
-
-       if (emdm->vertexCos) {
-               /* add direct access */
-               float (*vertexCos)[3]= emdm->vertexCos;
-               float (*vertexNos)[3]= emdm->vertexNos;
-               float (*faceNos)[3]=   emdm->faceNos;
-               EditVert *eve;
-
-               for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
-                       eve->tmp.l = (intptr_t) i++;
-
-               for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
-                       int drawSmooth = (efa->flag & ME_SMOOTH);
-                       draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
-                       if(draw) {
-                               const GLenum poly_type= efa->v4 ? GL_QUADS:GL_TRIANGLES;
-                               if (draw==2) { /* enabled with stipple */
-
-                                       if(poly_prev != GL_ZERO) glEnd();
-                                       poly_prev= GL_ZERO; /* force glBegin */
-
-                                       glEnable(GL_POLYGON_STIPPLE);
-                                       glPolygonStipple(stipple_quarttone);
-                               }
-                               
-                               if(skip_normals) {
-                                       if(poly_type != poly_prev) {
-                                               if(poly_prev != GL_ZERO) glEnd();
-                                               glBegin((poly_prev= poly_type));
-                                       }
-                                       glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-                                       if(poly_type == GL_QUADS) glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                               }
-                               else {
-                                       const GLenum shade_type= drawSmooth ? GL_SMOOTH : GL_FLAT;
-                                       if (shade_type != shade_prev) {
-                                               if(poly_prev != GL_ZERO) glEnd();
-                                               glShadeModel((shade_prev= shade_type)); /* same as below but switch shading */
-                                               glBegin((poly_prev= poly_type));
-                                       }
-                                       else if(poly_type != poly_prev) {
-                                               if(poly_prev != GL_ZERO) glEnd();
-                                               glBegin((poly_prev= poly_type));
-                                       }
-
-                                       if (!drawSmooth) {
-                                               glNormal3fv(faceNos[i]);
-                                               glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-                                               glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-                                               glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-                                               if(poly_type == GL_QUADS) glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                                       } else {
-                                               glNormal3fv(vertexNos[(int) efa->v1->tmp.l]);
-                                               glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-                                               glNormal3fv(vertexNos[(int) efa->v2->tmp.l]);
-                                               glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-                                               glNormal3fv(vertexNos[(int) efa->v3->tmp.l]);
-                                               glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-                                               if(poly_type == GL_QUADS) {
-                                                       glNormal3fv(vertexNos[(int) efa->v4->tmp.l]);
-                                                       glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                                               }
-                                       }
-                               }
-
-                               
-                               if (draw==2) {
-                                       glEnd();
-                                       poly_prev= GL_ZERO; /* force glBegin */
-
-                                       glDisable(GL_POLYGON_STIPPLE);
-                               }
-                       }
-               }
-       }
-       else {
-               for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
-                       int drawSmooth = (efa->flag & ME_SMOOTH);
-                       draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
-                       if(draw) {
-                               const GLenum poly_type= efa->v4 ? GL_QUADS:GL_TRIANGLES;
-                               if (draw==2) { /* enabled with stipple */
-
-                                       if(poly_prev != GL_ZERO) glEnd();
-                                       poly_prev= GL_ZERO; /* force glBegin */
-
-                                       glEnable(GL_POLYGON_STIPPLE);
-                                       glPolygonStipple(stipple_quarttone);
-                               }
-
-                               if(skip_normals) {
-                                       if(poly_type != poly_prev) {
-                                               if(poly_prev != GL_ZERO) glEnd();
-                                               glBegin((poly_prev= poly_type));
-                                       }
-                                       glVertex3fv(efa->v1->co);
-                                       glVertex3fv(efa->v2->co);
-                                       glVertex3fv(efa->v3->co);
-                                       if(poly_type == GL_QUADS) glVertex3fv(efa->v4->co);
-                               }
-                               else {
-                                       const GLenum shade_type= drawSmooth ? GL_SMOOTH : GL_FLAT;
-                                       if (shade_type != shade_prev) {
-                                               if(poly_prev != GL_ZERO) glEnd();
-                                               glShadeModel((shade_prev= shade_type)); /* same as below but switch shading */
-                                               glBegin((poly_prev= poly_type));
-                                       }
-                                       else if(poly_type != poly_prev) {
-                                               if(poly_prev != GL_ZERO) glEnd();
-                                               glBegin((poly_prev= poly_type));
-                                       }
-
-                                       if (!drawSmooth) {
-                                               glNormal3fv(efa->n);
-                                               glVertex3fv(efa->v1->co);
-                                               glVertex3fv(efa->v2->co);
-                                               glVertex3fv(efa->v3->co);
-                                               if(poly_type == GL_QUADS) glVertex3fv(efa->v4->co);
-                                       } else {
-                                               glNormal3fv(efa->v1->no);
-                                               glVertex3fv(efa->v1->co);
-                                               glNormal3fv(efa->v2->no);
-                                               glVertex3fv(efa->v2->co);
-                                               glNormal3fv(efa->v3->no);
-                                               glVertex3fv(efa->v3->co);
-                                               if(poly_type == GL_QUADS) {
-                                                       glNormal3fv(efa->v4->no);
-                                                       glVertex3fv(efa->v4->co);
-                                               }
-                                       }
-                               }
-
-                               
-                               if (draw==2) {
-                                       glEnd();
-                                       poly_prev= GL_ZERO;
-
-                                       glDisable(GL_POLYGON_STIPPLE);
-                               }
-                       }
-               }
-       }
-
-       /* if non zero we know a face was rendered */
-       if(poly_prev != GL_ZERO) glEnd();
-}
-
-static void emDM_drawFacesTex_common(DerivedMesh *dm,
-                          int (*drawParams)(MTFace *tface, int has_mcol, int matnr),
-                          int (*drawParamsMapped)(void *userData, int index),
-                          void *userData) 
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditMesh *em= emdm->em;
-       float (*vertexCos)[3]= emdm->vertexCos;
-       float (*vertexNos)[3]= emdm->vertexNos;
-       EditFace *efa;
-       int i;
-
-       /* always use smooth shading even for flat faces, else vertex colors wont interpolate */
-       glShadeModel(GL_SMOOTH);
-       
-       if (vertexCos) {
-               EditVert *eve;
-
-               for (i=0,eve=em->verts.first; eve; eve= eve->next)
-                       eve->tmp.l = (intptr_t) i++;
-
-               for (i=0,efa= em->faces.first; efa; i++,efa= efa->next) {
-                       MTFace *tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                       MCol *mcol= CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
-                       unsigned char *cp= NULL;
-                       int drawSmooth= (efa->flag & ME_SMOOTH);
-                       int flag;
-
-                       if(drawParams)
-                               flag= drawParams(tf, (mcol != NULL), efa->mat_nr);
-                       else if(drawParamsMapped)
-                               flag= drawParamsMapped(userData, i);
-                       else
-                               flag= 1;
-
-                       if(flag != 0) { /* flag 0 == the face is hidden or invisible */
-                               
-                               /* we always want smooth here since otherwise vertex colors dont interpolate */
-                               if (mcol) {
-                                       if (flag==1) {
-                                               cp= (unsigned char*)mcol;
-                                       }
-                               } else {
-                                       glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
-                               } 
-                               
-                               glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
-                               if (!drawSmooth) {
-                                       glNormal3fv(emdm->faceNos[i]);
-
-                                       if(tf) glTexCoord2fv(tf->uv[0]);
-                                       if(cp) glColor3ub(cp[3], cp[2], cp[1]);
-                                       glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-
-                                       if(tf) glTexCoord2fv(tf->uv[1]);
-                                       if(cp) glColor3ub(cp[7], cp[6], cp[5]);
-                                       glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-
-                                       if(tf) glTexCoord2fv(tf->uv[2]);
-                                       if(cp) glColor3ub(cp[11], cp[10], cp[9]);
-                                       glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-
-                                       if(efa->v4) {
-                                               if(tf) glTexCoord2fv(tf->uv[3]);
-                                               if(cp) glColor3ub(cp[15], cp[14], cp[13]);
-                                               glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                                       }
-                               } else {
-                                       if(tf) glTexCoord2fv(tf->uv[0]);
-                                       if(cp) glColor3ub(cp[3], cp[2], cp[1]);
-                                       glNormal3fv(vertexNos[(int) efa->v1->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-
-                                       if(tf) glTexCoord2fv(tf->uv[1]);
-                                       if(cp) glColor3ub(cp[7], cp[6], cp[5]);
-                                       glNormal3fv(vertexNos[(int) efa->v2->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-
-                                       if(tf) glTexCoord2fv(tf->uv[2]);
-                                       if(cp) glColor3ub(cp[11], cp[10], cp[9]);
-                                       glNormal3fv(vertexNos[(int) efa->v3->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-
-                                       if(efa->v4) {
-                                               if(tf) glTexCoord2fv(tf->uv[3]);
-                                               if(cp) glColor3ub(cp[15], cp[14], cp[13]);
-                                               glNormal3fv(vertexNos[(int) efa->v4->tmp.l]);
-                                               glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                                       }
-                               }
-                               glEnd();
-                       }
-               }
-       } else {
-               for (i=0,efa= em->faces.first; efa; i++,efa= efa->next) {
-                       MTFace *tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                       MCol *mcol= CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
-                       unsigned char *cp= NULL;
-                       int drawSmooth= (efa->flag & ME_SMOOTH);
-                       int flag;
-
-                       if(drawParams)
-                               flag= drawParams(tf, (mcol != NULL), efa->mat_nr);
-                       else if(drawParamsMapped)
-                               flag= drawParamsMapped(userData, i);
-                       else
-                               flag= 1;
-
-                       if(flag != 0) { /* flag 0 == the face is hidden or invisible */
-                               /* we always want smooth here since otherwise vertex colors dont interpolate */
-                               if (mcol) {
-                                       if (flag==1) {
-                                               cp= (unsigned char*)mcol;
-                                       }
-                               } else {
-                                       glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
-                               } 
-
-                               glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
-                               if (!drawSmooth) {
-                                       glNormal3fv(efa->n);
-
-                                       if(tf) glTexCoord2fv(tf->uv[0]);
-                                       if(cp) glColor3ub(cp[3], cp[2], cp[1]);
-                                       glVertex3fv(efa->v1->co);
-
-                                       if(tf) glTexCoord2fv(tf->uv[1]);
-                                       if(cp) glColor3ub(cp[7], cp[6], cp[5]);
-                                       glVertex3fv(efa->v2->co);
-
-                                       if(tf) glTexCoord2fv(tf->uv[2]);
-                                       if(cp) glColor3ub(cp[11], cp[10], cp[9]);
-                                       glVertex3fv(efa->v3->co);
-
-                                       if(efa->v4) {
-                                               if(tf) glTexCoord2fv(tf->uv[3]);
-                                               if(cp) glColor3ub(cp[15], cp[14], cp[13]);
-                                               glVertex3fv(efa->v4->co);
-                                       }
-                               } else {
-                                       if(tf) glTexCoord2fv(tf->uv[0]);
-                                       if(cp) glColor3ub(cp[3], cp[2], cp[1]);
-                                       glNormal3fv(efa->v1->no);
-                                       glVertex3fv(efa->v1->co);
-
-                                       if(tf) glTexCoord2fv(tf->uv[1]);
-                                       if(cp) glColor3ub(cp[7], cp[6], cp[5]);
-                                       glNormal3fv(efa->v2->no);
-                                       glVertex3fv(efa->v2->co);
-
-                                       if(tf) glTexCoord2fv(tf->uv[2]);
-                                       if(cp) glColor3ub(cp[11], cp[10], cp[9]);
-                                       glNormal3fv(efa->v3->no);
-                                       glVertex3fv(efa->v3->co);
-
-                                       if(efa->v4) {
-                                               if(tf) glTexCoord2fv(tf->uv[3]);
-                                               if(cp) glColor3ub(cp[15], cp[14], cp[13]);
-                                               glNormal3fv(efa->v4->no);
-                                               glVertex3fv(efa->v4->co);
-                                       }
-                               }
-                               glEnd();
-                       }
-               }
-       }
-}
-
-static void emDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr))
-{
-       emDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL);
-}
-
-static void emDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
-{
-       emDM_drawFacesTex_common(dm, NULL, setDrawOptions, userData);
-}
-
-static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
-                          int (*setMaterial)(int, void *attribs),
-                          int (*setDrawOptions)(void *userData, int index), void *userData) 
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditMesh *em= emdm->em;
-       float (*vertexCos)[3]= emdm->vertexCos;
-       float (*vertexNos)[3]= emdm->vertexNos;
-       EditVert *eve;
-       EditFace *efa;
-       DMVertexAttribs attribs= {{{0}}};
-       GPUVertexAttribs gattribs;
-       /* int tfoffset; */ /* UNUSED */
-       int i, b, matnr, new_matnr, dodraw /* , layer */ /* UNUSED */;
-
-       dodraw = 0;
-       matnr = -1;
-
-       /* layer = CustomData_get_layer_index(&em->fdata, CD_MTFACE); */ /* UNUSED */
-       /* tfoffset = (layer == -1)? -1: em->fdata.layers[layer].offset; */ /* UNUSED */
-
-       /* always use smooth shading even for flat faces, else vertex colors wont interpolate */
-       glShadeModel(GL_SMOOTH);
-
-       for (i=0,eve=em->verts.first; eve; eve= eve->next)
-               eve->tmp.l = (intptr_t) i++;
-
-#define PASSATTRIB(efa, eve, vert) {                                                                                   \
-       if(attribs.totorco) {                                                                                                           \
-               float *orco = attribs.orco.array[eve->tmp.l];                                                   \
-               glVertexAttrib3fvARB(attribs.orco.glIndex, orco);                                               \
-       }                                                                                                                                                       \
-       for(b = 0; b < attribs.tottface; b++) {                                                                         \
-               MTFace *_tf = (MTFace*)((char*)efa->data + attribs.tface[b].emOffset);  \
-               glVertexAttrib2fvARB(attribs.tface[b].glIndex, _tf->uv[vert]);                  \
-       }                                                                                                                                                       \
-       for(b = 0; b < attribs.totmcol; b++) {                                                                          \
-               MCol *cp = (MCol*)((char*)efa->data + attribs.mcol[b].emOffset);                \
-               GLubyte col[4];                                                                                                                 \
-               col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;                             \
-               glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col);                                    \
-       }                                                                                                                                                       \
-       if(attribs.tottang) {                                                                                                           \
-               float *tang = attribs.tang.array[i*4 + vert];                                                   \
-               glVertexAttrib4fvARB(attribs.tang.glIndex, tang);                                               \
-       }                                                                                                                                                       \
-}
-
-       for (i=0,efa= em->faces.first; efa; i++,efa= efa->next) {
-               int drawSmooth= (efa->flag & ME_SMOOTH);
-
-               if(setDrawOptions && !setDrawOptions(userData, i))
-                       continue;
-
-               new_matnr = efa->mat_nr + 1;
-               if(new_matnr != matnr) {
-                       dodraw = setMaterial(matnr = new_matnr, &gattribs);
-                       if(dodraw)
-                               DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
-               }
-
-               if(dodraw) {
-                       glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
-                       if (!drawSmooth) {
-                               if(vertexCos) glNormal3fv(emdm->faceNos[i]);
-                               else glNormal3fv(efa->n);
-
-                               PASSATTRIB(efa, efa->v1, 0);
-                               if(vertexCos) glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-                               else glVertex3fv(efa->v1->co);
-
-                               PASSATTRIB(efa, efa->v2, 1);
-                               if(vertexCos) glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-                               else glVertex3fv(efa->v2->co);
-
-                               PASSATTRIB(efa, efa->v3, 2);
-                               if(vertexCos) glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-                               else glVertex3fv(efa->v3->co);
-
-                               if(efa->v4) {
-                                       PASSATTRIB(efa, efa->v4, 3);
-                                       if(vertexCos) glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                                       else glVertex3fv(efa->v4->co);
-                               }
-                       } else {
-                               PASSATTRIB(efa, efa->v1, 0);
-                               if(vertexCos) {
-                                       glNormal3fv(vertexNos[(int) efa->v1->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-                               }
-                               else {
-                                       glNormal3fv(efa->v1->no);
-                                       glVertex3fv(efa->v1->co);
-                               }
-
-                               PASSATTRIB(efa, efa->v2, 1);
-                               if(vertexCos) {
-                                       glNormal3fv(vertexNos[(int) efa->v2->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-                               }
-                               else {
-                                       glNormal3fv(efa->v2->no);
-                                       glVertex3fv(efa->v2->co);
-                               }
-
-                               PASSATTRIB(efa, efa->v3, 2);
-                               if(vertexCos) {
-                                       glNormal3fv(vertexNos[(int) efa->v3->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-                               }
-                               else {
-                                       glNormal3fv(efa->v3->no);
-                                       glVertex3fv(efa->v3->co);
-                               }
-
-                               if(efa->v4) {
-                                       PASSATTRIB(efa, efa->v4, 3);
-                                       if(vertexCos) {
-                                               glNormal3fv(vertexNos[(int) efa->v4->tmp.l]);
-                                               glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                                       }
-                                       else {
-                                               glNormal3fv(efa->v4->no);
-                                               glVertex3fv(efa->v4->co);
-                                       }
-                               }
-                       }
-                       glEnd();
-               }
-       }
-#undef PASSATTRIB
-}
-
-static void emDM_drawFacesGLSL(DerivedMesh *dm,
-                          int (*setMaterial)(int, void *attribs))
-{
-       dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
-}
-
-static void emDM_drawMappedFacesMat(DerivedMesh *dm,
-                          void (*setMaterial)(void *userData, int, void *attribs),
-                          int (*setFace)(void *userData, int index), void *userData) 
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditMesh *em= emdm->em;
-       float (*vertexCos)[3]= emdm->vertexCos;
-       float (*vertexNos)[3]= emdm->vertexNos;
-       EditVert *eve;
-       EditFace *efa;
-       DMVertexAttribs attribs= {{{0}}};
-       GPUVertexAttribs gattribs;
-       int i, b, matnr, new_matnr;
-
-       matnr = -1;
-
-       /* always use smooth shading even for flat faces, else vertex colors wont interpolate */
-       glShadeModel(GL_SMOOTH);
-
-       for (i=0,eve=em->verts.first; eve; eve= eve->next)
-               eve->tmp.l = (intptr_t) i++;
-
-#define PASSATTRIB(efa, eve, vert) {                                                                                   \
-       if(attribs.totorco) {                                                                                                           \
-               float *orco = attribs.orco.array[eve->tmp.l];                                                   \
-               if(attribs.orco.glTexco)                                                                                                \
-                       glTexCoord3fv(orco);                                                                                            \
-               else                                                                                                                                    \
-                       glVertexAttrib3fvARB(attribs.orco.glIndex, orco);                                       \
-       }                                                                                                                                                       \
-       for(b = 0; b < attribs.tottface; b++) {                                                                         \
-               MTFace *_tf = (MTFace*)((char*)efa->data + attribs.tface[b].emOffset);  \
-               if(attribs.tface[b].glTexco)                                                                                    \
-                       glTexCoord2fv(_tf->uv[vert]);                                                                           \
-               else                                                                                                                                    \
-                       glVertexAttrib2fvARB(attribs.tface[b].glIndex, _tf->uv[vert]);          \
-       }                                                                                                                                                       \
-       for(b = 0; b < attribs.totmcol; b++) {                                                                          \
-               MCol *cp = (MCol*)((char*)efa->data + attribs.mcol[b].emOffset);                \
-               GLubyte col[4];                                                                                                                 \
-               col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;                             \
-               glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col);                                    \
-       }                                                                                                                                                       \
-       if(attribs.tottang) {                                                                                                           \
-               float *tang = attribs.tang.array[i*4 + vert];                                                   \
-               glVertexAttrib4fvARB(attribs.tang.glIndex, tang);                                               \
-       }                                                                                                                                                       \
-}
-
-       for (i=0,efa= em->faces.first; efa; i++,efa= efa->next) {
-               int drawSmooth= (efa->flag & ME_SMOOTH);
-
-               /* face hiding */
-               if(setFace && !setFace(userData, i))
-                       continue;
-
-               /* material */
-               new_matnr = efa->mat_nr + 1;
-               if(new_matnr != matnr) {
-                       setMaterial(userData, matnr = new_matnr, &gattribs);
-                       DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
-               }
-
-               /* face */
-               glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
-               if (!drawSmooth) {
-                       if(vertexCos) glNormal3fv(emdm->faceNos[i]);
-                       else glNormal3fv(efa->n);
-
-                       PASSATTRIB(efa, efa->v1, 0);
-                       if(vertexCos) glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-                       else glVertex3fv(efa->v1->co);
-
-                       PASSATTRIB(efa, efa->v2, 1);
-                       if(vertexCos) glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-                       else glVertex3fv(efa->v2->co);
-
-                       PASSATTRIB(efa, efa->v3, 2);
-                       if(vertexCos) glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-                       else glVertex3fv(efa->v3->co);
-
-                       if(efa->v4) {
-                               PASSATTRIB(efa, efa->v4, 3);
-                               if(vertexCos) glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                               else glVertex3fv(efa->v4->co);
-                       }
-               } else {
-                       PASSATTRIB(efa, efa->v1, 0);
-                       if(vertexCos) {
-                               glNormal3fv(vertexNos[(int) efa->v1->tmp.l]);
-                               glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
-                       }
-                       else {
-                               glNormal3fv(efa->v1->no);
-                               glVertex3fv(efa->v1->co);
-                       }
-
-                       PASSATTRIB(efa, efa->v2, 1);
-                       if(vertexCos) {
-                               glNormal3fv(vertexNos[(int) efa->v2->tmp.l]);
-                               glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
-                       }
-                       else {
-                               glNormal3fv(efa->v2->no);
-                               glVertex3fv(efa->v2->co);
-                       }
-
-                       PASSATTRIB(efa, efa->v3, 2);
-                       if(vertexCos) {
-                               glNormal3fv(vertexNos[(int) efa->v3->tmp.l]);
-                               glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
-                       }
-                       else {
-                               glNormal3fv(efa->v3->no);
-                               glVertex3fv(efa->v3->co);
-                       }
-
-                       if(efa->v4) {
-                               PASSATTRIB(efa, efa->v4, 3);
-                               if(vertexCos) {
-                                       glNormal3fv(vertexNos[(int) efa->v4->tmp.l]);
-                                       glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
-                               }
-                               else {
-                                       glNormal3fv(efa->v4->no);
-                                       glVertex3fv(efa->v4->co);
-                               }
-                       }
-               }
-               glEnd();
-       }
-#undef PASSATTRIB
-}
-
-static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditVert *eve;
-       int i;
-
-       if (emdm->em->verts.first) {
-               for (i=0,eve= emdm->em->verts.first; eve; i++,eve= eve->next) {
-                       if (emdm->vertexCos) {
-                               DO_MINMAX(emdm->vertexCos[i], min_r, max_r);
-                       } else {
-                               DO_MINMAX(eve->co, min_r, max_r);
-                       }
-               }
-       } else {
-               min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0;
-       }
-}
-static int emDM_getNumVerts(DerivedMesh *dm)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-
-       return BLI_countlist(&emdm->em->verts);
-}
-
-static int emDM_getNumEdges(DerivedMesh *dm)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-
-       return BLI_countlist(&emdm->em->edges);
-}
-
-static int emDM_getNumFaces(DerivedMesh *dm)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-
-       return BLI_countlist(&emdm->em->faces);
-}
-
-static void emDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditVert *eve;
-       int i;
-
-       for (i=0,eve= emdm->em->verts.first; eve; i++,eve=eve->next) {
-               if (emdm->vertexCos) {
-                       copy_v3_v3(cos_r[i], emdm->vertexCos[i]);
-               } else {
-                       copy_v3_v3(cos_r[i], eve->co);
-               }
-       }
-}
-
-static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
-{
-       EditVert *ev = ((EditMeshDerivedMesh *)dm)->em->verts.first;
-       int i;
-
-       for(i = 0; i < index; ++i) ev = ev->next;
-
-       copy_v3_v3(vert_r->co, ev->co);
-
-       normal_float_to_short_v3(vert_r->no, ev->no);
-
-       /* TODO what to do with vert_r->flag? */
-       vert_r->bweight = (unsigned char) (ev->bweight*255.0f);
-}
-
-static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
-{
-       EditMesh *em = ((EditMeshDerivedMesh *)dm)->em;
-       EditEdge *ee = em->edges.first;
-       EditVert *ev, *v1, *v2;
-       int i;
-
-       for(i = 0; i < index; ++i) ee = ee->next;
-
-       edge_r->crease = (unsigned char) (ee->crease*255.0f);
-       edge_r->bweight = (unsigned char) (ee->bweight*255.0f);
-       /* TODO what to do with edge_r->flag? */
-       edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER;
-       if (ee->seam) edge_r->flag |= ME_SEAM;
-       if (ee->sharp) edge_r->flag |= ME_SHARP;
-#if 0
-       /* this needs setup of f2 field */
-       if (!ee->f2) edge_r->flag |= ME_LOOSEEDGE;
-#endif
-
-       /* goddamn, we have to search all verts to find indices */
-       v1 = ee->v1;
-       v2 = ee->v2;
-       for(i = 0, ev = em->verts.first; v1 || v2; i++, ev = ev->next) {
-               if(ev == v1) {
-                       edge_r->v1 = i;
-                       v1 = NULL;
-               }
-               if(ev == v2) {
-                       edge_r->v2 = i;
-                       v2 = NULL;
-               }
-       }
-}
-
-static void emDM_getFace(DerivedMesh *dm, int index, MFace *face_r)
-{
-       EditMesh *em = ((EditMeshDerivedMesh *)dm)->em;
-       EditFace *ef = em->faces.first;
-       EditVert *ev, *v1, *v2, *v3, *v4;
-       int i;
-
-       for(i = 0; i < index; ++i) ef = ef->next;
-
-       face_r->mat_nr = ef->mat_nr;
-       face_r->flag = ef->flag;
-
-       /* goddamn, we have to search all verts to find indices */
-       v1 = ef->v1;
-       v2 = ef->v2;
-       v3 = ef->v3;
-       v4 = ef->v4;
-       if(!v4) face_r->v4 = 0;
-
-       for(i = 0, ev = em->verts.first; v1 || v2 || v3 || v4;
-               i++, ev = ev->next) {
-               if(ev == v1) {
-                       face_r->v1 = i;
-                       v1 = NULL;
-               }
-               if(ev == v2) {
-                       face_r->v2 = i;
-                       v2 = NULL;
-               }
-               if(ev == v3) {
-                       face_r->v3 = i;
-                       v3 = NULL;
-               }
-               if(ev == v4) {
-                       face_r->v4 = i;
-                       v4 = NULL;
-               }
-       }
-
-       test_index_face(face_r, NULL, 0, ef->v4?4:3);
-}
-
-static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditVert *ev = emdm->em->verts.first;
-       int i;
-
-       for(i=0; ev; ev = ev->next, ++vert_r, ++i) {
-               if(emdm->vertexCos)
-                       copy_v3_v3(vert_r->co, emdm->vertexCos[i]);
-               else
-                       copy_v3_v3(vert_r->co, ev->co);
-
-               normal_float_to_short_v3(vert_r->no, ev->no);
-
-               /* TODO what to do with vert_r->flag? */
-               vert_r->flag = 0;
-               vert_r->bweight = (unsigned char) (ev->bweight*255.0f);
-       }
-}
-
-static void emDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r)
-{
-       EditMesh *em = ((EditMeshDerivedMesh *)dm)->em;
-       EditEdge *ee = em->edges.first;
-       EditVert *ev;
-       int i;
-
-       /* store vertex indices in tmp union */
-       for(ev = em->verts.first, i = 0; ev; ev = ev->next, ++i)
-               ev->tmp.l = (intptr_t) i;
-
-       for( ; ee; ee = ee->next, ++edge_r) {
-               edge_r->crease = (unsigned char) (ee->crease*255.0f);
-               edge_r->bweight = (unsigned char) (ee->bweight*255.0f);
-               /* TODO what to do with edge_r->flag? */
-               edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER;
-               if (ee->seam) edge_r->flag |= ME_SEAM;
-               if (ee->sharp) edge_r->flag |= ME_SHARP;
-#if 0
-               /* this needs setup of f2 field */
-               if (!ee->f2) edge_r->flag |= ME_LOOSEEDGE;
-#endif
-
-               edge_r->v1 = (int)ee->v1->tmp.l;
-               edge_r->v2 = (int)ee->v2->tmp.l;
-       }
-}
-
-static void emDM_copyFaceArray(DerivedMesh *dm, MFace *face_r)
-{
-       EditMesh *em = ((EditMeshDerivedMesh *)dm)->em;
-       EditFace *ef = em->faces.first;
-       EditVert *ev;
-       int i;
-
-       /* store vertexes indices in tmp union */
-       for(ev = em->verts.first, i = 0; ev; ev = ev->next, ++i)
-               ev->tmp.l = (intptr_t) i;
-
-       for( ; ef; ef = ef->next, ++face_r) {
-               face_r->mat_nr = ef->mat_nr;
-               face_r->flag = ef->flag;
-
-               face_r->v1 = (int)ef->v1->tmp.l;
-               face_r->v2 = (int)ef->v2->tmp.l;
-               face_r->v3 = (int)ef->v3->tmp.l;
-               if(ef->v4) face_r->v4 = (int)ef->v4->tmp.l;
-               else face_r->v4 = 0;
-
-               test_index_face(face_r, NULL, 0, ef->v4?4:3);
-       }
-}
-
-static void *emDM_getFaceDataArray(DerivedMesh *dm, int type)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-       EditMesh *em= emdm->em;
-       EditFace *efa;
-       char *data, *emdata;
-       void *datalayer;
-       int index, size;
-
-       datalayer = DM_get_face_data_layer(dm, type);
-       if(datalayer)
-               return datalayer;
-
-       /* layers are store per face for editmesh, we convert to a temporary
-        * data layer array in the derivedmesh when these are requested */
-       if(type == CD_MTFACE || type == CD_MCOL) {
-               index = CustomData_get_layer_index(&em->fdata, type);
-
-               if(index != -1) {
-                       /* int offset = em->fdata.layers[index].offset; */ /* UNUSED */
-                       size = CustomData_sizeof(type);
-
-                       DM_add_face_layer(dm, type, CD_CALLOC, NULL);
-                       index = CustomData_get_layer_index(&dm->faceData, type);
-                       dm->faceData.layers[index].flag |= CD_FLAG_TEMPORARY;
-
-                       data = datalayer = DM_get_face_data_layer(dm, type);
-                       for(efa=em->faces.first; efa; efa=efa->next, data+=size) {
-                               emdata = CustomData_em_get(&em->fdata, efa->data, type);
-                               memcpy(data, emdata, size);
-                       }
-               }
-       }
-
-       return datalayer;
-}
-
-static void emDM_release(DerivedMesh *dm)
-{
-       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-
-       if (DM_release(dm)) {
-               if (emdm->vertexCos) {
-                       MEM_freeN(emdm->vertexCos);
-                       MEM_freeN(emdm->vertexNos);
-                       MEM_freeN(emdm->faceNos);
-               }
-
-               MEM_freeN(emdm);
-       }
-}
-
-DerivedMesh *editmesh_get_derived(EditMesh *em, float (*vertexCos)[3])
-{
-       EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "emdm");
-
-       DM_init(&emdm->dm, DM_TYPE_EDITMESH, BLI_countlist(&em->verts),
-                                        BLI_countlist(&em->edges), BLI_countlist(&em->faces));
-
-       emdm->dm.getMinMax = emDM_getMinMax;
-
-       emdm->dm.getNumVerts = emDM_getNumVerts;
-       emdm->dm.getNumEdges = emDM_getNumEdges;
-       emdm->dm.getNumFaces = emDM_getNumFaces;
-
-       emdm->dm.getVertCos = emDM_getVertCos;
-
-       emdm->dm.getVert = emDM_getVert;
-       emdm->dm.getEdge = emDM_getEdge;
-       emdm->dm.getFace = emDM_getFace;
-       emdm->dm.copyVertArray = emDM_copyVertArray;
-       emdm->dm.copyEdgeArray = emDM_copyEdgeArray;
-       emdm->dm.copyFaceArray = emDM_copyFaceArray;
-       emdm->dm.getFaceDataArray = emDM_getFaceDataArray;
-
-       emdm->dm.foreachMappedVert = emDM_foreachMappedVert;
-       emdm->dm.foreachMappedEdge = emDM_foreachMappedEdge;
-       emdm->dm.foreachMappedFaceCenter = emDM_foreachMappedFaceCenter;
-
-       emdm->dm.drawEdges = emDM_drawEdges;
-       emdm->dm.drawMappedEdges = emDM_drawMappedEdges;
-       emdm->dm.drawMappedEdgesInterp = emDM_drawMappedEdgesInterp;
-       emdm->dm.drawMappedFaces = emDM_drawMappedFaces;
-       emdm->dm.drawMappedFacesTex = emDM_drawMappedFacesTex;
-       emdm->dm.drawMappedFacesGLSL = emDM_drawMappedFacesGLSL;
-       emdm->dm.drawFacesTex = emDM_drawFacesTex;
-       emdm->dm.drawFacesGLSL = emDM_drawFacesGLSL;
-       emdm->dm.drawMappedFacesMat = emDM_drawMappedFacesMat;
-       emdm->dm.drawUVEdges = emDM_drawUVEdges;
-
-       emdm->dm.release = emDM_release;
-       
-       emdm->em = em;
-       emdm->vertexCos = vertexCos;
-
-       if(CustomData_has_layer(&em->vdata, CD_MDEFORMVERT)) {
-               EditVert *eve;
-               int i;
-
-               DM_add_vert_layer(&emdm->dm, CD_MDEFORMVERT, CD_CALLOC, NULL);
-
-               for(eve = em->verts.first, i = 0; eve; eve = eve->next, ++i)
-                       DM_set_vert_data(&emdm->dm, i, CD_MDEFORMVERT,
-                                                        CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT));
-       }
-
-       if(vertexCos) {
-               EditVert *eve;
-               EditFace *efa;
-               int totface = BLI_countlist(&em->faces);
-               int i;
-
-               for (i=0,eve=em->verts.first; eve; eve= eve->next)
-                       eve->tmp.l = (intptr_t) i++;
-
-               emdm->vertexNos = MEM_callocN(sizeof(*emdm->vertexNos)*i, "emdm_vno");
-               emdm->faceNos = MEM_mallocN(sizeof(*emdm->faceNos)*totface, "emdm_vno");
-
-               for(i=0, efa= em->faces.first; efa; i++, efa=efa->next) {
-                       float *v1 = vertexCos[(int) efa->v1->tmp.l];
-                       float *v2 = vertexCos[(int) efa->v2->tmp.l];
-                       float *v3 = vertexCos[(int) efa->v3->tmp.l];
-                       float *no = emdm->faceNos[i];
-                       
-                       if(efa->v4) {
-                               float *v4 = vertexCos[(int) efa->v4->tmp.l];
-
-                               normal_quad_v3( no,v1, v2, v3, v4);
-                               add_v3_v3(emdm->vertexNos[(int) efa->v4->tmp.l], no);
-                       }
-                       else {
-                               normal_tri_v3( no,v1, v2, v3);
-                       }
-
-                       add_v3_v3(emdm->vertexNos[(int) efa->v1->tmp.l], no);
-                       add_v3_v3(emdm->vertexNos[(int) efa->v2->tmp.l], no);
-                       add_v3_v3(emdm->vertexNos[(int) efa->v3->tmp.l], no);
-               }
-
-               for(i=0, eve= em->verts.first; eve; i++, eve=eve->next) {
-                       float *no = emdm->vertexNos[i];
-                       /* following Mesh convention; we use vertex coordinate itself
-                        * for normal in this case */
-                       if (normalize_v3(no) == 0.0f) {
-                               normalize_v3_v3(no, vertexCos[i]);
-                       }
-               }
-       }
-
-       return (DerivedMesh*) emdm;
-}
-
-/***/
-
 DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, ModifierData *md)
 {
        Mesh *me = ob->data;
@@ -3011,7 +1837,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
 
        /* ugly hack, editmesh derivedmesh doesn't copy face data, this way we
         * can use offsets instead */
-       if(dm->release == emDM_release)
+       if(dm->type == DM_TYPE_EDITMESH)
                tfdata = &((EditMeshDerivedMesh*)dm)->em->fdata;
        else
                tfdata = fdata;
@@ -3168,9 +1994,14 @@ static void navmesh_drawColored(DerivedMesh *dm)
        glEnable(GL_LIGHTING);
 }
 
-static void navmesh_DM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr))
+static void navmesh_DM_drawFacesTex(DerivedMesh *dm,
+                       int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr),
+                       int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
+                       void *userData)
 {
        (void) setDrawOptions;
+       (void) compareDrawOptions;
+       (void) userData;
 
        navmesh_drawColored(dm);
 }
index 5fb03b7bbd00dd5199269a88ce1fc9b36ab3375a..767401a55ef70e1a1059f0e6f383ed20be2b045c 100644 (file)
@@ -92,8 +92,8 @@ bAction *add_empty_action(const char name[])
 
 /* temp data for make_local_action */
 typedef struct tMakeLocalActionContext {
-       bAction *act;    /* original action */
-       bAction *actn;   /* new action */
+       bAction *act;       /* original action */
+       bAction *act_new;   /* new action */
        
        int is_lib;         /* some action users were libraries */
        int is_local;       /* some action users were not libraries */
@@ -117,9 +117,9 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr)
        
        if (adt->action == mlac->act) {
                if (id->lib == NULL) {
-                       adt->action = mlac->actn;
+                       adt->action = mlac->act_new;
                        
-                       id_us_plus(&mlac->actn->id);
+                       id_us_plus(&mlac->act_new->id);
                        id_us_min(&mlac->act->id);
                }
        }
@@ -146,10 +146,10 @@ void make_local_action(bAction *act)
                id_clear_lib_data(bmain, &act->id);
        }
        else if (mlac.is_local && mlac.is_lib) {
-               mlac.actn= copy_action(act);
-               mlac.actn->id.us= 0;
+               mlac.act_new= copy_action(act);
+               mlac.act_new->id.us= 0;
 
-               BKE_id_lib_local_paths(bmain, &mlac.actn->id);
+               BKE_id_lib_local_paths(bmain, act->id.lib, &mlac.act_new->id);
 
                BKE_animdata_main_cb(bmain, make_localact_apply_cb, &mlac);
        }
index 36df1101a24aa991cb19089761d487743589bf81..0cd8845c53b44ff0265b72a7160f6e1687dfbe9e 100644 (file)
@@ -757,7 +757,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
 static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated)
 {
        extern int enable_cu_speed;     /* object.c */
-       Object copyob = {{NULL}};
+       Object copyob;
        int cfrao = scene->r.cfra;
        int dupend = ob->dupend;
        
@@ -1030,27 +1030,17 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
        
        em = BKE_mesh_get_editmesh(me);
        if(em) {
-               int totvert;
-               
                dm= editmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
-               
-               totface= dm->getNumFaces(dm);
-               mface= MEM_mallocN(sizeof(MFace)*totface, "mface temp");
-               dm->copyFaceArray(dm, mface);
-               totvert= dm->getNumVerts(dm);
-               mvert= MEM_mallocN(sizeof(MVert)*totvert, "mvert temp");
-               dm->copyVertArray(dm, mvert);
-
                BKE_mesh_end_editmesh(me, em);
        }
        else {
                dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
-               
-               totface= dm->getNumFaces(dm);
-               mface= dm->getFaceArray(dm);
-               mvert= dm->getVertArray(dm);
        }
 
+       totface= dm->getNumFaces(dm);
+       mface= dm->getFaceArray(dm);
+       mvert= dm->getVertArray(dm);
+
        if(G.rendering) {
 
                orco= (float(*)[3])get_mesh_orco_verts(par);
@@ -1189,11 +1179,6 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                if (sce)        base= base->next;       /* scene loop */
                else            go= go->next;           /* group loop */
        }
-       
-       if(em) {
-               MEM_freeN(mface);
-               MEM_freeN(mvert);
-       }
 
        if(orco)
                MEM_freeN(orco);
index a9c29728650902c162f0df47ee8e90970d8d0f34..2157bd5999bb29f9b482084c8c4f378e3cd8840a 100644 (file)
@@ -158,17 +158,17 @@ void make_local_armature(bArmature *arm)
                id_clear_lib_data(bmain, &arm->id);
        }
        else if(is_local && is_lib) {
-               bArmature *armn= copy_armature(arm);
-               armn->id.us= 0;
+               bArmature *arm_new= copy_armature(arm);
+               arm_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &armn->id);
+               BKE_id_lib_local_paths(bmain, arm->id.lib, &arm_new->id);
 
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        if(ob->data == arm) {
                                if(ob->id.lib==NULL) {
-                                       ob->data= armn;
-                                       armn->id.us++;
+                                       ob->data= arm_new;
+                                       arm_new->id.us++;
                                        arm->id.us--;
                                }
                        }
index b114f38cdd549480eb81847213f052788370dc93..d0b03883e6ea59669451ba83ba3a97c573a98cfb 100644 (file)
@@ -9,10 +9,7 @@
  * 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this. 
+ * 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
index 5303baddbca2453fed3a43d0d58bb116f184a742..7fac273ef77e4ccd666262b4045ecefdaf8035a7 100644 (file)
@@ -224,17 +224,17 @@ void make_local_brush(Brush *brush)
                }
        }
        else if(is_local && is_lib) {
-               Brush *brushn= copy_brush(brush);
-               brushn->id.us= 1; /* only keep fake user */
-               brushn->id.flag |= LIB_FAKEUSER;
+               Brush *brush_new= copy_brush(brush);
+               brush_new->id.us= 1; /* only keep fake user */
+               brush_new->id.flag |= LIB_FAKEUSER;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &brush->id);
+               BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id);
                
                for(scene= bmain->scene.first; scene; scene=scene->id.next) {
                        if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
                                if(scene->id.lib==NULL) {
-                                       paint_brush_set(&scene->toolsettings->imapaint.paint, brushn);
+                                       paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new);
                                }
                        }
                }
index 08e8a80750e6865611cf5255c4a4249ae2f894e8..2bd973d779968f4a18e99d68a7dc2580cd64341f 100644 (file)
@@ -108,18 +108,18 @@ void make_local_camera(Camera *cam)
                id_clear_lib_data(bmain, &cam->id);
        }
        else if(is_local && is_lib) {
-               Camera *camn= copy_camera(cam);
+               Camera *cam_new= copy_camera(cam);
 
-               camn->id.us= 0;
+               cam_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &camn->id);
+               BKE_id_lib_local_paths(bmain, cam->id.lib, &cam_new->id);
 
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        if(ob->data == cam) {
                                if(ob->id.lib==NULL) {
-                                       ob->data= camn;
-                                       camn->id.us++;
+                                       ob->data= cam_new;
+                                       cam_new->id.us++;
                                        cam->id.us--;
                                }
                        }
index 0f9033ca461130212fb0d0439fa8c86cb831d7cd..aade98ec9da84933b0e24832329aafeb2283a068 100644 (file)
@@ -647,6 +647,7 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha
 static void cdDM_drawFacesTex_common(DerivedMesh *dm,
                           int (*drawParams)(MTFace *tface, int has_mcol, int matnr),
                           int (*drawParamsMapped)(void *userData, int index),
+                          int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
                           void *userData) 
 {
        CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
@@ -771,24 +772,18 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
                }
 
                if( !GPU_buffer_legacy(dm) ) {
-                       /* warning!, this logic is incorrect, see bug [#27175]
-                        * firstly, there are no checks for changes in context, such as texface image.
-                        * secondly, drawParams() sets the GL context, so checking if there is a change
-                        * from lastFlag is too late once glDrawArrays() runs, since drawing the arrays
-                        * will use the modified, OpenGL settings.
-                        * 
-                        * However its tricky to fix this without duplicating the internal logic
-                        * of drawParams(), perhaps we need an argument like...
-                        * drawParams(..., keep_gl_state_but_return_when_changed) ?.
-                        *
-                        * We could also just disable VBO's here, since texface may be deprecated - campbell.
-                        */
-                       
+                       int tottri = dm->drawObject->tot_triangle_point/3;
+                       int next_actualFace= dm->drawObject->triangle_to_mface[0];
+
                        glShadeModel( GL_SMOOTH );
                        lastFlag = 0;
-                       for(i = 0; i < dm->drawObject->tot_triangle_point/3; i++) {
-                               int actualFace = dm->drawObject->triangle_to_mface[i];
+                       for(i = 0; i < tottri; i++) {
+                               int actualFace = next_actualFace;
                                int flag = 1;
+                               int flush = 0;
+
+                               if(i != tottri-1)
+                                       next_actualFace= dm->drawObject->triangle_to_mface[i+1];
 
                                if(drawParams) {
                                        flag = drawParams(tf? &tf[actualFace]: NULL, (mcol != NULL), mf[actualFace].mat_nr);
@@ -804,27 +799,30 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
                                                if(drawParamsMapped)
                                                        flag = drawParamsMapped(userData, actualFace);
                                }
-                               if( flag != lastFlag ) {
-                                       if( startFace < i ) {
-                                               if( lastFlag != 0 ) { /* if the flag is 0 it means the face is hidden or invisible */
-                                                       if (lastFlag==1 && col)
-                                                               GPU_color_switch(1);
-                                                       else
-                                                               GPU_color_switch(0);
-                                                       glDrawArrays(GL_TRIANGLES,startFace*3,(i-startFace)*3);
-                                               }
-                                       }
-                                       lastFlag = flag;
-                                       startFace = i;
+
+                               /* flush buffer if current triangle isn't drawable or it's last triangle */
+                               flush= !flag || i == tottri - 1;
+
+                               if(!flush && compareDrawOptions) {
+                                       /* also compare draw options and flush buffer if they're different
+                                          need for face selection highlight in edit mode */
+                                       flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
                                }
-                       }
-                       if( startFace < dm->drawObject->tot_triangle_point/3 ) {
-                               if( lastFlag != 0 ) { /* if the flag is 0 it means the face is hidden or invisible */
-                                       if (lastFlag==1 && col)
-                                               GPU_color_switch(1);
-                                       else
-                                               GPU_color_switch(0);
-                                       glDrawArrays(GL_TRIANGLES, startFace*3, dm->drawObject->tot_triangle_point - startFace*3);
+
+                               if(flush) {
+                                       int first= startFace*3;
+                                       int count= (i-startFace+(flag ? 1 : 0))*3; /* Add one to the length if we're drawing at the end of the array */
+
+                                       if(count) {
+                                               if (col)
+                                                       GPU_color_switch(1);
+                                               else
+                                                       GPU_color_switch(0);
+
+                                               glDrawArrays(GL_TRIANGLES, first, count);
+                                       }
+
+                                       startFace = i + 1;
                                }
                        }
                }
@@ -834,13 +832,19 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
        }
 }
 
-static void cdDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr))
+static void cdDM_drawFacesTex(DerivedMesh *dm,
+                          int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr),
+                          int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
+                          void *userData)
 {
-       cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL);
+       cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData);
 }
 
-static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs),
-                       int (*compareDrawOptions)(void *userData, int cur_index, int next_index))
+static void cdDM_drawMappedFaces(DerivedMesh *dm,
+                       int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
+                       int (*setMaterial)(int, void *attribs),
+                       int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
+                       void *userData, int useColors)
 {
        CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
        MVert *mv = cddm->mvert;
@@ -980,15 +984,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
                                        flush|= mf[actualFace].mat_nr != mf[next_actualFace].mat_nr;
 
                                        if(!flush && compareDrawOptions) {
-                                               int next_orig= (index==NULL) ? next_actualFace : index[next_actualFace];
-
-                                               if(orig==ORIGINDEX_NONE || next_orig==ORIGINDEX_NONE) {
-                                                       flush= 1;
-                                               } else {
-                                                       /* also compare draw options and flush buffer if they're different
-                                                          need for face selection highlight in edit mode */
-                                                       flush|= compareDrawOptions(userData, orig, next_orig) == 0;
-                                               }
+                                               flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
                                        }
 
                                        if(flush) {
@@ -1009,9 +1005,12 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
        }
 }
 
-static void cdDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
+static void cdDM_drawMappedFacesTex(DerivedMesh *dm,
+                          int (*setDrawOptions)(void *userData, int index),
+                          int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
+                          void *userData)
 {
-       cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, userData);
+       cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
 }
 
 static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert, int smoothnormal)
@@ -1058,7 +1057,10 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int
        glVertex3fv(mvert[index].co);
 }
 
-static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs), int (*setDrawOptions)(void *userData, int index), void *userData)
+static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
+                          int (*setMaterial)(int, void *attribs),
+                          int (*setDrawOptions)(void *userData, int index),
+                          void *userData)
 {
        CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
        GPUVertexAttribs gattribs;
@@ -1348,7 +1350,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
        glShadeModel(GL_FLAT);
 }
 
-static void cdDM_drawFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs))
+static void cdDM_drawFacesGLSL(DerivedMesh *dm,int (*setMaterial)(int, void *attribs))
 {
        dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
 }
index 358c63b4f9f819384d02a8847f5c14b124eeabcd..0f1c73c59c14ba82ee1c55cc23bbe6cc863d38b5 100644 (file)
@@ -274,16 +274,16 @@ void make_local_curve(Curve *cu)
                extern_local_curve(cu);
        }
        else if(is_local && is_lib) {
-               Curve *cun= copy_curve(cu);
-               cun->id.us= 0;
+               Curve *cu_new= copy_curve(cu);
+               cu_new->id.us= 0;
 
-               BKE_id_lib_local_paths(bmain, &cun->id);
+               BKE_id_lib_local_paths(bmain, cu->id.lib, &cu_new->id);
 
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        if(ob->data==cu) {
                                if(ob->id.lib==NULL) {
-                                       ob->data= cun;
-                                       cun->id.us++;
+                                       ob->data= cu_new;
+                                       cu_new->id.us++;
                                        cu->id.us--;
                                }
                        }
index 0c3c78f6eef5e07eba0dd07e295c7f7c1976975f..1f09d98d697c359d92ed4641a5bcd6371c03095a 100644 (file)
@@ -45,7 +45,7 @@
 #include "BLI_utildefines.h"
 
 
-void defgroup_copy_list (ListBase *outbase, ListBase *inbase)
+void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
 {
        bDeformGroup *defgroup, *defgroupn;
 
@@ -57,7 +57,7 @@ void defgroup_copy_list (ListBase *outbase, ListBase *inbase)
        }
 }
 
-bDeformGroup *defgroup_duplicate (bDeformGroup *ingroup)
+bDeformGroup *defgroup_duplicate(bDeformGroup *ingroup)
 {
        bDeformGroup *outgroup;
 
@@ -65,7 +65,7 @@ bDeformGroup *defgroup_duplicate (bDeformGroup *ingroup)
                return NULL;
 
        outgroup=MEM_callocN(sizeof(bDeformGroup), "copy deformGroup");
-       
+
        /* For now, just copy everything over. */
        memcpy (outgroup, ingroup, sizeof(bDeformGroup));
 
@@ -75,59 +75,85 @@ bDeformGroup *defgroup_duplicate (bDeformGroup *ingroup)
 }
 
 /* copy & overwrite weights */
-void defvert_copy (MDeformVert *dvert_r, const MDeformVert *dvert)
+void defvert_copy(MDeformVert *dvert_dst, const MDeformVert *dvert_src)
 {
-       if(dvert_r->totweight == dvert->totweight) {
-               if(dvert->totweight)
-                       memcpy(dvert_r->dw, dvert->dw, dvert->totweight * sizeof(MDeformWeight));
+       if (dvert_dst->totweight == dvert_src->totweight) {
+               if (dvert_src->totweight)
+                       memcpy(dvert_dst->dw, dvert_src->dw, dvert_src->totweight * sizeof(MDeformWeight));
        }
        else {
-               if(dvert_r->dw)
-                       MEM_freeN(dvert_r->dw);
+               if (dvert_dst->dw)
+                       MEM_freeN(dvert_dst->dw);
 
-               if(dvert->totweight)
-                       dvert_r->dw= MEM_dupallocN(dvert->dw);
+               if (dvert_src->totweight)
+                       dvert_dst->dw= MEM_dupallocN(dvert_src->dw);
                else
-                       dvert_r->dw= NULL;
+                       dvert_dst->dw= NULL;
+
+               dvert_dst->totweight = dvert_src->totweight;
+       }
+}
+
+/* copy an index from one dvert to another
+ * - do nothing if neither are set.
+ * - add destination weight if needed.
+ */
+void defvert_copy_index(MDeformVert *dvert_dst, const MDeformVert *dvert_src, const int defgroup)
+{
+       MDeformWeight *dw_src, *dw_dst;
+
+       dw_src= defvert_find_index(dvert_src, defgroup);
+
+       if (dw_src) {
+               /* source is valid, verify destination */
+               dw_dst= defvert_verify_index(dvert_dst, defgroup);
+               dw_dst->weight= dw_src->weight;
+       }
+       else {
+               /* source was NULL, assign zero, could also remove */
+               dw_dst= defvert_find_index(dvert_dst, defgroup);
 
-               dvert_r->totweight = dvert->totweight;
+               if (dw_dst) {
+                       dw_dst->weight= 0.0f;
+               }
        }
 }
 
 /* only sync over matching weights, don't add or remove groups
  * warning, loop within loop.
  */
-void defvert_sync (MDeformVert *dvert_r, const MDeformVert *dvert, int use_verify)
+void defvert_sync(MDeformVert *dvert_dst, const MDeformVert *dvert_src, int use_verify)
 {
-       if(dvert->totweight && dvert_r->totweight) {
+       if (dvert_src->totweight && dvert_dst->totweight) {
                int i;
-               MDeformWeight *dw;
-               for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) {
-                       MDeformWeight *dw_r;
-                       if(use_verify)  dw_r= defvert_verify_index(dvert_r, dw->def_nr);
-                       else                    dw_r= defvert_find_index(dvert_r, dw->def_nr);
-
-                       if(dw_r) {
-                               dw_r->weight= dw->weight;
+               MDeformWeight *dw_src;
+               for (i=0, dw_src=dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
+                       MDeformWeight *dw_dst;
+                       if (use_verify) dw_dst= defvert_verify_index(dvert_dst, dw_src->def_nr);
+                       else            dw_dst= defvert_find_index(dvert_dst, dw_src->def_nr);
+
+                       if (dw_dst) {
+                               dw_dst->weight= dw_src->weight;
                        }
                }
        }
 }
 
 /* be sure all flip_map values are valid */
-void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, const int *flip_map, const int flip_map_len, const int use_verify)
+void defvert_sync_mapped(MDeformVert *dvert_dst, const MDeformVert *dvert_src,
+                         const int *flip_map, const int flip_map_len, const int use_verify)
 {
-       if (dvert->totweight && dvert_r->totweight) {
+       if (dvert_src->totweight && dvert_dst->totweight) {
                int i;
-               MDeformWeight *dw;
-               for (i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) {
-                       if (dw->def_nr < flip_map_len) {
-                               MDeformWeight *dw_r;
-                               if(use_verify)  dw_r= defvert_verify_index(dvert_r, flip_map[dw->def_nr]);
-                               else                    dw_r= defvert_find_index(dvert_r, flip_map[dw->def_nr]);
-
-                               if(dw_r) {
-                                       dw_r->weight= dw->weight;
+               MDeformWeight *dw_src;
+               for (i=0, dw_src=dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
+                       if (dw_src->def_nr < flip_map_len) {
+                               MDeformWeight *dw_dst;
+                               if (use_verify) dw_dst= defvert_verify_index(dvert_dst, flip_map[dw_src->def_nr]);
+                               else            dw_dst= defvert_find_index(dvert_dst, flip_map[dw_src->def_nr]);
+
+                               if (dw_dst) {
+                                       dw_dst->weight= dw_src->weight;
                                }
                        }
                }
@@ -135,18 +161,18 @@ void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, const
 }
 
 /* be sure all flip_map values are valid */
-void defvert_remap (MDeformVert *dvert, int *map)
+void defvert_remap(MDeformVert *dvert, int *map)
 {
        MDeformWeight *dw;
        int i;
-       for(i=0, dw=dvert->dw; i<dvert->totweight; i++, dw++) {
+       for (i=0, dw=dvert->dw; i<dvert->totweight; i++, dw++) {
                dw->def_nr= map[dw->def_nr];
        }
 }
 
-void defvert_normalize (MDeformVert *dvert)
+void defvert_normalize(MDeformVert *dvert)
 {
-       if(dvert->totweight<=0) {
+       if (dvert->totweight<=0) {
                /* nothing */
        }
        else if (dvert->totweight==1) {
@@ -156,30 +182,30 @@ void defvert_normalize (MDeformVert *dvert)
                int i;
                float tot= 0.0f;
                MDeformWeight *dw;
-               for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++)
+               for (i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++)
                        tot += dw->weight;
 
-               if(tot > 0.0f) {
-                       for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++)
+               if (tot > 0.0f) {
+                       for (i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++)
                                dw->weight /= tot;
                }
        }
 }
 
-void defvert_flip (MDeformVert *dvert, const int *flip_map, const int flip_map_len)
+void defvert_flip(MDeformVert *dvert, const int *flip_map, const int flip_map_len)
 {
        MDeformWeight *dw;
        int i;
 
-       for(dw= dvert->dw, i=0; i<dvert->totweight; dw++, i++) {
-               if((dw->def_nr < flip_map_len) && (flip_map[dw->def_nr] >= 0)) {
+       for (dw= dvert->dw, i=0; i<dvert->totweight; dw++, i++) {
+               if ((dw->def_nr < flip_map_len) && (flip_map[dw->def_nr] >= 0)) {
                        dw->def_nr= flip_map[dw->def_nr];
                }
        }
 }
 
 
-bDeformGroup *defgroup_find_name (Object *ob, const char *name)
+bDeformGroup *defgroup_find_name(Object *ob, const char *name)
 {
        /* return a pointer to the deform group with this name
         * or return NULL otherwise.
@@ -194,7 +220,7 @@ bDeformGroup *defgroup_find_name (Object *ob, const char *name)
        return NULL;
 }
 
-int defgroup_name_index (Object *ob, const char *name)
+int defgroup_name_index(Object *ob, const char *name)
 {
        /* Return the location of the named deform group within the list of
         * deform groups. This function is a combination of defgroup_find_index and
@@ -203,8 +229,8 @@ int defgroup_name_index (Object *ob, const char *name)
         */
        bDeformGroup *curdef;
        int def_nr;
-       
-       if(name && name[0] != '\0') {
+
+       if (name && name[0] != '\0') {
                for (curdef=ob->defbase.first, def_nr=0; curdef; curdef=curdef->next, def_nr++) {
                        if (!strcmp(curdef->name, name))
                                return def_nr;
@@ -214,7 +240,7 @@ int defgroup_name_index (Object *ob, const char *name)
        return -1;
 }
 
-int defgroup_find_index (Object *ob, bDeformGroup *dg)
+int defgroup_find_index(Object *ob, bDeformGroup *dg)
 {
        /* Fetch the location of this deform group
         * within the linked list of deform groups.
@@ -250,7 +276,7 @@ int defgroup_find_index (Object *ob, bDeformGroup *dg)
         * constant for this)
         */
        if (eg == NULL) return -1;
-       
+
        return def_nr;
 }
 
@@ -259,7 +285,7 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default)
 {
        int totdg= *flip_map_len= BLI_countlist(&ob->defbase);
 
-       if(totdg==0) {
+       if (totdg==0) {
                return NULL;
        }
        else {
@@ -272,16 +298,16 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default)
                }
 
                for (dg=ob->defbase.first, i=0; dg; dg=dg->next, i++) {
-                       if(map[i] == -1) { /* may be calculated previously */
+                       if (map[i] == -1) { /* may be calculated previously */
 
                                /* incase no valid value is found, use this */
-                               if(use_default)
+                               if (use_default)
                                        map[i]= i;
 
                                flip_side_name(name, dg->name, FALSE);
-                               if(strcmp(name, dg->name)) {
+                               if (strcmp(name, dg->name)) {
                                        flip_num= defgroup_name_index(ob, name);
-                                       if(flip_num >= 0) {
+                                       if (flip_num >= 0) {
                                                map[i]= flip_num;
                                                map[flip_num]= i; /* save an extra lookup */
                                        }
@@ -297,7 +323,7 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, in
 {
        int totdg= *flip_map_len= BLI_countlist(&ob->defbase);
 
-       if(totdg==0) {
+       if (totdg==0) {
                return NULL;
        }
        else {
@@ -313,10 +339,10 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, in
                dg= BLI_findlink(&ob->defbase, defgroup);
 
                flip_side_name(name, dg->name, FALSE);
-               if(strcmp(name, dg->name)) {
+               if (strcmp(name, dg->name)) {
                        flip_num= defgroup_name_index(ob, name);
 
-                       if(flip_num >= 0) {
+                       if (flip_num >= 0) {
                                map[defgroup]= flip_num;
                                map[flip_num]= defgroup;
                        }
@@ -331,11 +357,11 @@ int defgroup_flip_index(Object *ob, int index, int use_default)
        bDeformGroup *dg= BLI_findlink(&ob->defbase, index);
        int flip_index = -1;
 
-       if(dg) {
+       if (dg) {
                char name[sizeof(dg->name)];
                flip_side_name(name, dg->name, 0);
 
-               if(strcmp(name, dg->name))
+               if (strcmp(name, dg->name))
                        flip_index= defgroup_name_index(ob, name);
        }
 
@@ -345,7 +371,7 @@ int defgroup_flip_index(Object *ob, int index, int use_default)
 static int defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *ob)
 {
        bDeformGroup *curdef;
-       
+
        for (curdef = ob->defbase.first; curdef; curdef=curdef->next) {
                if (dg!=curdef) {
                        if (!strcmp(curdef->name, name)) {
@@ -363,7 +389,7 @@ static int defgroup_unique_check(void *arg, const char *name)
        return defgroup_find_name_dupe(name, data->dg, data->ob);
 }
 
-void defgroup_unique_name (bDeformGroup *dg, Object *ob)
+void defgroup_unique_name(bDeformGroup *dg, Object *ob)
 {
        struct {Object *ob; void *dg;} data;
        data.ob= ob;
@@ -375,7 +401,7 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob)
 /* finds the best possible flipped name. For renaming; check for unique names afterwards */
 /* if strip_number: removes number extensions
  * note: dont use sizeof() for 'name' or 'from_name' */
-void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number)
+void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number)
 {
        int     len;
        char    prefix[MAX_VGROUP_NAME]=  "";   /* The part before the facing */
@@ -385,15 +411,15 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
        char    *index=NULL;
 
        len= BLI_strnlen(from_name, MAX_VGROUP_NAME);
-       if(len<3) return; // we don't do names like .R or .L
+       if (len < 3) return; // we don't do names like .R or .L
 
        BLI_strncpy(name, from_name, MAX_VGROUP_NAME);
 
        /* We first check the case with a .### extension, let's find the last period */
-       if(isdigit(name[len-1])) {
+       if (isdigit(name[len-1])) {
                index= strrchr(name, '.'); // last occurrence
                if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever!
-                       if(strip_number==0)
+                       if (strip_number==0)
                                BLI_strncpy(number, index, sizeof(number));
                        *index= 0;
                        len= BLI_strnlen(name, MAX_VGROUP_NAME);
@@ -405,7 +431,7 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
 #define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_')
 
        /* first case; separator . - _ with extensions r R l L  */
-       ifIS_SEPARATOR(name[len-2]) ) {
+       if (IS_SEPARATOR(name[len-2]) ) {
                switch(name[len-1]) {
                        case 'l':
                                prefix[len-1]= 0;
@@ -426,7 +452,7 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
                }
        }
        /* case; beginning with r R l L , with separator after it */
-       else ifIS_SEPARATOR(name[1]) ) {
+       else if (IS_SEPARATOR(name[1]) ) {
                switch(name[0]) {
                        case 'l':
                                strcpy(replace, "r");
@@ -450,14 +476,14 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
                                break;
                }
        }
-       else if(len > 5) {
+       else if (len > 5) {
                /* hrms, why test for a separator? lets do the rule 'ultimate left or right' */
                index = BLI_strcasestr(prefix, "right");
                if (index==prefix || index==prefix+len-5) {
-                       if(index[0]=='r')
+                       if (index[0]=='r')
                                strcpy (replace, "left");
                        else {
-                               if(index[1]=='I')
+                               if (index[1]=='I')
                                        strcpy (replace, "LEFT");
                                else
                                        strcpy (replace, "Left");
@@ -468,10 +494,10 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
                else {
                        index = BLI_strcasestr(prefix, "left");
                        if (index==prefix || index==prefix+len-4) {
-                               if(index[0]=='l')
+                               if (index[0]=='l')
                                        strcpy (replace, "right");
                                else {
-                                       if(index[1]=='E')
+                                       if (index[1]=='E')
                                                strcpy (replace, "RIGHT");
                                        else
                                                strcpy (replace, "Right");
@@ -487,30 +513,32 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
        BLI_snprintf (name, MAX_VGROUP_NAME, "%s%s%s%s", prefix, replace, suffix, number);
 }
 
-float defvert_find_weight(const struct MDeformVert *dvert, const int group_num)
+float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup)
 {
-       MDeformWeight *dw= defvert_find_index(dvert, group_num);
+       MDeformWeight *dw= defvert_find_index(dvert, defgroup);
        return dw ? dw->weight : 0.0f;
 }
 
-float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int group_num)
+float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup)
 {
-       if(group_num == -1 || dvert == NULL)
+       if (defgroup == -1 || dvert == NULL)
                return 1.0f;
 
-       return defvert_find_weight(dvert+index, group_num);
+       return defvert_find_weight(dvert+index, defgroup);
 }
 
 
 MDeformWeight *defvert_find_index(const MDeformVert *dvert, const int defgroup)
 {
-       if(dvert && defgroup >= 0) {
+       if (dvert && defgroup >= 0) {
                MDeformWeight *dw = dvert->dw;
                int i;
 
-               for(i=dvert->totweight; i>0; i--, dw++)
-                       if(dw->def_nr == defgroup)
+               for (i=dvert->totweight; i>0; i--, dw++) {
+                       if (dw->def_nr == defgroup) {
                                return dw;
+                       }
+               }
        }
 
        return NULL;
@@ -518,30 +546,74 @@ MDeformWeight *defvert_find_index(const MDeformVert *dvert, const int defgroup)
 
 /* Ensures that mv has a deform weight entry for the specified defweight group */
 /* Note this function is mirrored in editmesh_tools.c, for use for editvertices */
-MDeformWeight *defvert_verify_index(MDeformVert *dv, const int defgroup)
+MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup)
 {
-       MDeformWeight *newdw;
+       MDeformWeight *dw_new;
 
        /* do this check always, this function is used to check for it */
-       if(!dv || defgroup < 0)
+       if (!dvert || defgroup < 0)
                return NULL;
 
-       newdw= defvert_find_index(dv, defgroup);
-       if(newdw)
-               return newdw;
+       dw_new= defvert_find_index(dvert, defgroup);
+       if (dw_new)
+               return dw_new;
 
-       newdw= MEM_callocN(sizeof(MDeformWeight)*(dv->totweight+1), "deformWeight");
-       if (dv->dw) {
-               memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight);
-               MEM_freeN(dv->dw);
+       dw_new= MEM_callocN(sizeof(MDeformWeight)*(dvert->totweight+1), "deformWeight");
+       if (dvert->dw) {
+               memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*dvert->totweight);
+               MEM_freeN(dvert->dw);
        }
-       dv->dw= newdw;
-       newdw += dv->totweight;
-       newdw->weight= 0.0f;
-       newdw->def_nr= defgroup;
+       dvert->dw= dw_new;
+       dw_new += dvert->totweight;
+       dw_new->weight= 0.0f;
+       dw_new->def_nr= defgroup;
        /* Group index */
 
-       dv->totweight++;
+       dvert->totweight++;
+
+       return dw_new;
+}
+
+/* Removes the given vertex from the vertex group, specified either by its defgrp_idx,
+ * or directly by its MDeformWeight pointer, if dw is not NULL.
+ * WARNING: This function frees the given MDeformWeight, do not use it afterward! */
+void defvert_remove_index(MDeformVert *dvert, int defgroup, MDeformWeight *dw)
+{
+       MDeformWeight *dw_new;
+       int i;
+
+       /* Get index of removed MDeformWeight. */
+       if (dw == NULL) {
+               dw = dvert->dw;
+               for (i = dvert->totweight; i > 0; i--, dw++) {
+                       if (dw->def_nr == defgroup)
+                               break;
+               }
+               i--;
+       }
+       else {
+               i = dw - dvert->dw;
+               /* Security check! */
+               if(i < 0 || i >= dvert->totweight)
+                       return;
+       }
 
-       return newdw;
+       dvert->totweight--;
+       /* If there are still other deform weights attached to this vert then remove
+        * this deform weight, and reshuffle the others.
+        */
+       if (dvert->totweight) {
+               dw_new = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight), __func__);
+               if (dvert->dw){
+                       memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*i);
+                       memcpy(dw_new+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i));
+                       MEM_freeN(dvert->dw);
+               }
+               dvert->dw = dw_new;
+       }
+       else {
+               /* If there are no other deform weights left then just remove this one. */
+               MEM_freeN(dvert->dw);
+               dvert->dw = NULL;
+       }
 }
index b1e39b1d76862ad2dcdf9c34337b3f2fb10f67f5..4eaf49dc679acdb7535ff663fcbd496b5924ebbb 100644 (file)
@@ -1636,17 +1636,25 @@ void graph_print_adj_list(void)
 
 /* mechanism to allow editors to be informed of depsgraph updates,
    to do their own updates based on changes... */
-static void (*EditorsUpdateCb)(Main *bmain, ID *id)= NULL;
+static void (*EditorsUpdateIDCb)(Main *bmain, ID *id)= NULL;
+static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated)= NULL;
 
-void DAG_editors_update_cb(void (*func)(Main *bmain, ID *id))
+void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_func)(Main *bmain, Scene *scene, int updated))
 {
-       EditorsUpdateCb= func;
+       EditorsUpdateIDCb= id_func;
+       EditorsUpdateSceneCb= scene_func;
 }
 
-static void dag_editors_update(Main *bmain, ID *id)
+static void dag_editors_id_update(Main *bmain, ID *id)
 {
-       if(EditorsUpdateCb)
-               EditorsUpdateCb(bmain, id);
+       if(EditorsUpdateIDCb)
+               EditorsUpdateIDCb(bmain, id);
+}
+
+static void dag_editors_scene_update(Main *bmain, Scene *scene, int updated)
+{
+       if(EditorsUpdateSceneCb)
+               EditorsUpdateSceneCb(bmain, scene, updated);
 }
 
 /* groups with objects in this scene need to be put in the right order as well */
@@ -2460,7 +2468,7 @@ static void dag_id_flush_update(Scene *sce, ID *id)
 
                        /* no point in trying in this cases */
                        if(id && id->us <= 1) {
-                               dag_editors_update(bmain, id);
+                               dag_editors_id_update(bmain, id);
                                id= NULL;
                        }
                }
@@ -2572,7 +2580,7 @@ static void dag_id_flush_update(Scene *sce, ID *id)
                }
 
                /* update editors */
-               dag_editors_update(bmain, id);
+               dag_editors_id_update(bmain, id);
        }
 }
 
@@ -2612,10 +2620,10 @@ void DAG_ids_flush_tagged(Main *bmain)
                DAG_scene_flush_update(bmain, sce, lay, 0);
 }
 
-void DAG_ids_check_recalc(Main *bmain)
+void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time)
 {
        ListBase *lbarray[MAX_LIBARRAY];
-       int a;
+       int a, updated = 0;
 
        /* loop over all ID types */
        a  = set_listbasepointers(bmain, lbarray);
@@ -2627,13 +2635,13 @@ void DAG_ids_check_recalc(Main *bmain)
                /* we tag based on first ID type character to avoid 
                   looping over all ID's in case there are no tags */
                if(id && bmain->id_tag_update[id->name[0]]) {
-                       /* do editors update */
-                       dag_editors_update(bmain, NULL);
-                       return;
+                       updated= 1;
+                       break;
                }
        }
-}
 
+       dag_editors_scene_update(bmain, scene, (updated || time));
+}
 
 void DAG_ids_clear_recalc(Main *bmain)
 {
index 519ac1cf53417068688c6a37b33c5377a23f5f76..59139886fe624ee49431f0d4697038f3f317afd0 100644 (file)
@@ -1693,7 +1693,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                }
 
                                                /* apply weights into a vertex group, if doesnt exists add a new layer */
-                                               if (defgrp_index >= 0 && !dvert && strlen(surface->output_name)>0)
+                                               if (defgrp_index >= 0 && !dvert && (surface->output_name[0] != '\0'))
                                                        dvert = CustomData_add_layer_named(&result->vertData, CD_MDEFORMVERT, CD_CALLOC,
                                                                                                                                NULL, sData->total_points, surface->output_name);
                                                if (defgrp_index >= 0 && dvert) {
@@ -1703,25 +1703,16 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                                MDeformWeight *def_weight = defvert_find_index(dv, defgrp_index);
 
                                                                /* skip if weight value is 0 and no existing weight is found */
-                                                               if (!def_weight && !weight[i])
-                                                                       continue;
-
-                                                               /* if not found, add a weight for it */
-                                                               if (!def_weight) {
-                                                                       MDeformWeight *newdw = MEM_callocN(sizeof(MDeformWeight)*(dv->totweight+1), 
-                                                                                                                "deformWeight");
-                                                                       if(dv->dw){
-                                                                               memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight);
-                                                                               MEM_freeN(dv->dw);
+                                                               if ((def_weight != NULL) || (weight[i] != 0.0f)) {
+
+                                                                       /* if not found, add a weight for it */
+                                                                       if (def_weight == NULL) {
+                                                                               def_weight= defvert_verify_index(dv, defgrp_index);
                                                                        }
-                                                                       dv->dw=newdw;
-                                                                       dv->dw[dv->totweight].def_nr=defgrp_index;
-                                                                       def_weight = &dv->dw[dv->totweight];
-                                                                       dv->totweight++;
-                                                               }
 
-                                                               /* set weight value */
-                                                               def_weight->weight = weight[i];
+                                                                       /* set weight value */
+                                                                       def_weight->weight = weight[i];
+                                                               }
                                                        }
                                                }
                                        }
@@ -1735,11 +1726,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                for (i=0; i<sData->total_points; i++) {
                                                        float normal[3];
                                                        normal_short_to_float_v3(normal, mvert[i].no);
-                                                       normalize_v3(normal);
-
-                                                       mvert[i].co[0] += normal[0]*wPoint[i].height;
-                                                       mvert[i].co[1] += normal[1]*wPoint[i].height;
-                                                       mvert[i].co[2] += normal[2]*wPoint[i].height;
+                                                       madd_v3_v3fl(mvert[i].co, normal, wPoint[i].height);
                                                }
                                                CDDM_calc_normals(result);
                                        }
@@ -2282,10 +2269,10 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
                                                        tPoint->quad = (isInside == 2) ? 1 : 0;         /* quad or tri part*/
 
                                                        /* save vertex indexes  */
-                                                       tPoint->v1 = (isInside == 2) ? mface[i].v1 : mface[i].v1;
+                                                       tPoint->v1 = mface[i].v1; /* (isInside == 2) ? mface[i].v1 : mface[i].v1; */ /* same! */
                                                        tPoint->v2 = (isInside == 2) ? mface[i].v3 : mface[i].v2;
                                                        tPoint->v3 = (isInside == 2) ? mface[i].v4 : mface[i].v3;
-                                                       
+
                                                        sample = 5;     /* make sure we exit sample loop as well */
                                                        break;
                                                }
@@ -3585,7 +3572,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
                                float radius = 0.0f;
                                float strength = 0.0f;
                                float velocity_val = 0.0f;
-                               int part_index;
+                               int part_index= -1;
 
                                /*
                                *       With predefined radius, there is no variation between particles.
@@ -3657,10 +3644,12 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
                                                part_index = nearest[n].index;
 
                                                /* If inside solid range and no disp depth required, no need to seek further */
-                                               if (s_range < 0.0f)
-                                               if (surface->type != MOD_DPAINT_SURFACE_T_DISPLACE &&
-                                                       surface->type != MOD_DPAINT_SURFACE_T_WAVE)
+                                               if ( (s_range < 0.0f) &&
+                                                    (surface->type != MOD_DPAINT_SURFACE_T_DISPLACE) &&
+                                                    (surface->type != MOD_DPAINT_SURFACE_T_WAVE))
+                                               {
                                                        break;
+                                               }
                                        }
 
                                        if (nearest) MEM_freeN(nearest);
@@ -3688,7 +3677,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
                                        float depth = 0.0f;
 
                                        /* apply velocity */
-                                       if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
+                                       if ((brush->flags & MOD_DPAINT_USES_VELOCITY) && (part_index != -1)) {
                                                float velocity[3];
                                                ParticleData *pa = psys->particles + part_index;
                                                mul_v3_v3fl(velocity, pa->state.vel, particle_timestep);
@@ -3700,8 +3689,9 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
                                                velocity_val = len_v3(velocity);
 
                                                /* store brush velocity for smudge */
-                                               if (surface->type == MOD_DPAINT_SURFACE_T_PAINT &&
-                                                       brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity) {
+                                               if ( (surface->type == MOD_DPAINT_SURFACE_T_PAINT) &&
+                                                    (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity))
+                                               {
                                                        copy_v3_v3(&bData->brush_velocity[index*4], velocity);
                                                        mul_v3_fl(&bData->brush_velocity[index*4], 1.0f/velocity_val);
                                                        bData->brush_velocity[index*4+3] = velocity_val;
@@ -3709,12 +3699,11 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
                                        }
 
                                        if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
-                                               paintColor[0] = brush->r;
-                                               paintColor[1] = brush->g;
-                                               paintColor[2] = brush->b;
+                                               copy_v3_v3(paintColor, &brush->r);
                                        }
-                                       else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
-                                                        surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
+                                       else if ( (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) ||
+                                                 (surface->type == MOD_DPAINT_SURFACE_T_WAVE))
+                                       {
                                                 /* get displace depth  */
                                                disp_intersect = (1.0f - sqrtf(disp_intersect / radius)) * radius;
                                                depth = (radius - disp_intersect) / bData->bNormal[index].normal_scale;
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
new file mode 100644 (file)
index 0000000..8eccfd4
--- /dev/null
@@ -0,0 +1,1287 @@
+/*
+ * ***** 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.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/editderivedmesh.c
+ *  \ingroup bke
+ */
+
+#include