Merged changes in the trunk up to revision 42116.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 26 Nov 2011 13:11:55 +0000 (13:11 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 26 Nov 2011 13:11:55 +0000 (13:11 +0000)
267 files changed:
GNUmakefile
build_files/buildbot/master.cfg
build_files/buildbot/slave_pack.py
build_files/scons/tools/Blender.py
build_files/scons/tools/btools.py
doc/python_api/examples/bge.texture.1.py
doc/python_api/rst/gpu.rst
doc/python_api/sphinx_doc_gen.py
extern/libmv/SConscript
extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
intern/cycles/CMakeLists.txt
intern/cycles/SConscript
intern/cycles/blender/CMakeLists.txt
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/addon/xml.py
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/device/device.h
intern/cycles/device/device_cuda.cpp
intern/cycles/device/device_opencl.cpp
intern/cycles/kernel/kernel.cl
intern/cycles/kernel/kernel_bvh.h
intern/cycles/kernel/kernel_camera.h
intern/cycles/kernel/kernel_compat_cpu.h
intern/cycles/kernel/kernel_compat_cuda.h
intern/cycles/kernel/kernel_compat_opencl.h
intern/cycles/kernel/kernel_globals.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/kernel_types.h
intern/cycles/render/filter.cpp
intern/cycles/render/session.cpp
intern/cycles/util/util_math.h
intern/cycles/util/util_path.cpp
intern/cycles/util/util_path.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_WindowCocoa.mm
release/datafiles/fonts/droidsans.ttf.gz
release/scripts/modules/addon_utils.py
release/scripts/modules/bpy/utils.py
release/scripts/modules/console/complete_calltip.py
release/scripts/presets/camera/Nikon_D3S.py [moved from release/scripts/presets/camera/Nikon_D35.py with 100% similarity]
release/scripts/startup/bl_operators/clip.py
release/scripts/startup/bl_operators/uvcalc_lightmap.py
release/scripts/startup/bl_ui/properties_data_mesh.py
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/properties_game.py
release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
release/scripts/startup/bl_ui/properties_render.py
release/scripts/startup/bl_ui/properties_texture.py
release/scripts/startup/bl_ui/space_clip.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenfont/intern/blf_dir.c
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/BKE_material.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/BKE_pointcache.h
source/blender/blenkernel/BKE_writeavi.h
source/blender/blenkernel/intern/CCGSubSurf.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/bmfont.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/movieclip.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/ocean.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenkernel/intern/writeavi.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/BLI_string_utf8.h
source/blender/blenlib/intern/DLRB_tree.c
source/blender/blenlib/intern/math_vector.c
source/blender/blenlib/intern/path_util.c
source/blender/blenlib/intern/pbvh.c
source/blender/blenlib/intern/storage.c
source/blender/blenlib/intern/string_utf8.c
source/blender/blenlib/intern/winstuff.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/readfile.h
source/blender/blenloader/intern/writefile.c
source/blender/collada/GeometryExporter.cpp
source/blender/collada/InstanceWriter.cpp
source/blender/collada/MeshImporter.cpp
source/blender/editors/animation/fmodifier_ui.c
source/blender/editors/gpencil/drawgpencil.c
source/blender/editors/gpencil/gpencil_buttons.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_object.h
source/blender/editors/include/ED_view3d.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/interface_utils.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/loopcut.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_bake.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/physics/physics_pointcache.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_opengl.c
source/blender/editors/render/render_shading.c
source/blender/editors/render/render_update.c
source/blender/editors/screen/screendump.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_buttons/buttons_texture.c
source/blender/editors/space_clip/clip_buttons.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_console/space_console.c
source/blender/editors/space_file/file_panels.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/fsmenu.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_logic/logic_window.c
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/transform/transform.c
source/blender/editors/util/ed_util.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
source/blender/freestyle/intern/python/BPy_Convert.cpp
source/blender/freestyle/intern/python/BPy_Freestyle.cpp
source/blender/gpu/CMakeLists.txt
source/blender/imbuf/IMB_imbuf_types.h
source/blender/imbuf/intern/IMB_filter.h
source/blender/imbuf/intern/IMB_indexer.h
source/blender/imbuf/intern/allocimbuf.c
source/blender/imbuf/intern/filter.c
source/blender/imbuf/intern/imbuf_cocoa.m
source/blender/imbuf/intern/indexer.c
source/blender/imbuf/intern/iris.c
source/blender/imbuf/intern/jp2.c
source/blender/imbuf/intern/jpeg.c
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/imbuf/intern/png.c
source/blender/imbuf/intern/scaling.c
source/blender/imbuf/intern/targa.c
source/blender/imbuf/intern/thumbs.c
source/blender/imbuf/intern/tiff.c
source/blender/makesdna/DNA_curve_types.h
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_define.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_brush.c
source/blender/makesrna/intern/rna_curve.c
source/blender/makesrna/intern/rna_define.c
source/blender/makesrna/intern/rna_dynamicpaint.c
source/blender/makesrna/intern/rna_fluidsim.c
source/blender/makesrna/intern/rna_image.c
source/blender/makesrna/intern/rna_image_api.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_meta.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_property.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/makesrna/intern/rna_sculpt_paint.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_texture_api.c
source/blender/makesrna/intern/rna_tracking.c
source/blender/makesrna/intern/rna_ui_api.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/modifiers/intern/MOD_fluidsim_util.c
source/blender/modifiers/intern/MOD_ocean.c
source/blender/modifiers/intern/MOD_uvproject.c
source/blender/modifiers/intern/MOD_weightvgproximity.c
source/blender/nodes/composite/nodes/node_composite_mixrgb.c
source/blender/nodes/composite/nodes/node_composite_outputFile.c
source/blender/nodes/shader/nodes/node_shader_geom.c
source/blender/nodes/shader/nodes/node_shader_mixRgb.c
source/blender/nodes/texture/nodes/node_texture_bricks.c
source/blender/nodes/texture/nodes/node_texture_mixRgb.c
source/blender/nodes/texture/nodes/node_texture_proc.c
source/blender/nodes/texture/nodes/node_texture_texture.c
source/blender/python/generic/py_capi_utils.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_rna.c
source/blender/python/mathutils/mathutils_Color.c
source/blender/python/mathutils/mathutils_Color.h
source/blender/python/mathutils/mathutils_Euler.c
source/blender/python/mathutils/mathutils_Euler.h
source/blender/python/mathutils/mathutils_Matrix.c
source/blender/python/mathutils/mathutils_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_geometry.c
source/blender/quicktime/apple/qtkit_export.m
source/blender/quicktime/apple/quicktime_export.c
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pixelshading.c
source/blender/render/intern/source/render_texture.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/shadeoutput.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_gesture.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/CMakeLists.txt
source/creator/creator.c
source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ArmatureChannel.cpp
source/gameengine/Expressions/PyObjectPlus.cpp
source/gameengine/GamePlayer/common/bmfont.cpp
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_ObjectActuator.cpp
source/gameengine/Ketsji/KX_PyMath.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/VideoTexture/Texture.cpp
source/tests/pep8.py

index 2ac3439d6aa336c6c92e003ad13460c446a32489..478f0c35a1c826b93293293841a98d6666d6b391 100644 (file)
@@ -92,6 +92,17 @@ CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
                      -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
 
 
+# -----------------------------------------------------------------------------
+# Tool for 'make config'
+
+# X11 spesific
+ifdef DISPLAY
+       CMAKE_CONFIG_TOOL = cmake-gui
+else 
+       CMAKE_CONFIG_TOOL = ccmake
+endif
+
+
 # -----------------------------------------------------------------------------
 # Build Blender
 all:
@@ -115,8 +126,15 @@ lite: all
 headless: all
 bpy: all
 
+
 # -----------------------------------------------------------------------------
-# Helo for build targets
+# Configuration (save some cd'ing around)
+config:
+       $(CMAKE_CONFIG_TOOL) $(BUILD_DIR)
+
+
+# -----------------------------------------------------------------------------
+# Help for build targets
 help:
        @echo ""
        @echo "Convenience targets provided for building blender, (multiple at once can be used)"
@@ -125,6 +143,8 @@ help:
        @echo "  * headless  - build without an interface (renderfarm or server automation)"
        @echo "  * bpy       - build as a python module which can be loaded from python directly"
        @echo ""
+       @echo "  * config    - run cmake configuration tool to set build options"
+       @echo ""
        @echo "  Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
        @echo "  Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments."
        @echo ""
index 5aa5a43abf75785768ea9330572f083f727cfe09..23751f7dcd49a6a072c58a70fac979580cb2d791 100644 (file)
@@ -75,14 +75,14 @@ def svn_step(branch=''):
         return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/blender', mode='update', defaultBranch='trunk', workdir='blender')
 
 
-def lib_svn_step(dir):
-    return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir)
+def lib_svn_step(libdir):
+    return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + libdir, mode='update', defaultBranch='trunk', workdir='lib/' + libdir)
 
 # generic builder
 
 
-def generic_builder(id, libdir='', branch=''):
-    filename = 'buildbot_upload_' + id + '.zip'
+def generic_builder(idname, libdir='', branch=''):
+    filename = 'buildbot_upload_' + idname + '.zip'
     compile_script = '../blender/build_files/buildbot/slave_compile.py'
     test_script = '../blender/build_files/buildbot/slave_test.py'
     pack_script = '../blender/build_files/buildbot/slave_pack.py'
@@ -93,10 +93,10 @@ def generic_builder(id, libdir='', branch=''):
     if libdir != '':
         f.addStep(lib_svn_step(libdir))
 
-    f.addStep(Compile(command=['python', compile_script, id]))
-    f.addStep(Test(command=['python', test_script, id]))
-    f.addStep(ShellCommand(name='package', command=['python', pack_script, id, branch], description='packaging', descriptionDone='packaged'))
-    if id.find('cmake') != -1:
+    f.addStep(Compile(command=['python', compile_script, idname]))
+    f.addStep(Test(command=['python', test_script, idname]))
+    f.addStep(ShellCommand(name='package', command=['python', pack_script, idname, branch], description='packaging', descriptionDone='packaged'))
+    if 'cmake' in idname:
         f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100 * 1024 * 1024))
     else:
         f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100 * 1024 * 1024, workdir='install'))
index af8d99893b4409687529e9fd984e5b2ed2864dc6..94640803aae8e564d86b0a565afaeb13606c091a 100644 (file)
@@ -84,12 +84,12 @@ if builder.find('scons') != -1:
         sys.exit(retcode)
 
 # clean release directory if it already exists
-dir = 'release'
+release_dir = 'release'
 
-if os.path.exists(dir):
-    for f in os.listdir(dir):
-        if os.path.isfile(os.path.join(dir, f)):
-            os.remove(os.path.join(dir, f))
+if os.path.exists(release_dir):
+    for f in os.listdir(release_dir):
+        if os.path.isfile(os.path.join(release_dir, f)):
+            os.remove(os.path.join(release_dir, f))
 
 # create release package
 try:
@@ -99,16 +99,16 @@ except Exception, ex:
     sys.exit(1)
 
 # find release directory, must exist this time
-if not os.path.exists(dir):
-    sys.stderr.write("Failed to find release directory.\n")
+if not os.path.exists(release_dir):
+    sys.stderr.write("Failed to find release directory %r.\n" % release_dir)
     sys.exit(1)
 
 # find release package
 file = None
 filepath = None
 
-for f in os.listdir(dir):
-    rf = os.path.join(dir, f)
+for f in os.listdir(release_dir):
+    rf = os.path.join(release_dir, f)
     if os.path.isfile(rf) and f.startswith('blender'):
         file = f
         filepath = rf
index 809f197c8632af97e94a85dc023a4b2a079362e3..a63dfaa3fc92f80c52011781b546e5f2a11e8cb6 100644 (file)
@@ -319,20 +319,11 @@ def creator(env):
     incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', '#/source/blender/freestyle', env['BF_OPENGL_INC']]
 
     defs = []
-    if env['WITH_BF_QUICKTIME']:
-        incs.append(env['BF_QUICKTIME_INC'])
-        defs.append('WITH_QUICKTIME')
 
     if env['WITH_BF_BINRELOC']:
         incs.append('#/extern/binreloc/include')
         defs.append('WITH_BINRELOC')
 
-    if env['WITH_BF_OPENEXR']:
-        defs.append('WITH_OPENEXR')
-
-    if env['WITH_BF_TIFF']:
-        defs.append('WITH_TIFF')
-
     if env['WITH_BF_SDL']:
         defs.append('WITH_SDL')
 
index 4c826b12e89b850f094913d05cd57a5602b5efad..1ddbfcb96082332980b56f6195f3846e640e021d 100644 (file)
@@ -544,6 +544,7 @@ 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_OIIO', 'Build with OpenImageIO', False)),
         (BoolVariable('WITH_BF_STATICOIIO', 'Staticly link to OpenImageIO', False)),
index 4be6f51de67cf2aefed4333f3f15e7bdcfe891ec..918ffc9772d66e9a8ae33d09841588c424651b5a 100644 (file)
@@ -11,13 +11,13 @@ from bge import texture
 
 def createTexture(cont):
     """Create a new Dynamic Texture"""
-    object = cont.owner
+    obj = cont.owner
 
     # get the reference pointer (ID) of the internal texture
-    ID = texture.materialID(object, 'IMoriginal.png')
+    ID = texture.materialID(obj, 'IMoriginal.png')
 
     # create a texture object
-    object_texture = texture.Texture(object, ID)
+    object_texture = texture.Texture(obj, ID)
 
     # create a new source with an external image
     url = logic.expandPath("//newtexture.jpg")
index 2ca7fdda9d5225809402ea9fa9ba03878996c4ba..2400e0476b3b85aad2f1b9939d864076f7da0cd3 100644 (file)
@@ -278,7 +278,7 @@ layer that contains the vertex attribute.
 
 .. data:: CD_MTFACE
 
-    Vertex attribute is a UV layer. Data type is vector of 2 float.
+    Vertex attribute is a UV Map. Data type is vector of 2 float.
 
     There can be more than one attribute of that type, they are differenciated by name.
     In blender, you can retrieve the attribute data with:
@@ -495,10 +495,10 @@ Functions
         for uniform in shader['uniforms']:
             if uniform['type'] == gpu.GPU_DYNAMIC_SAMPLER_2DIMAGE:
                 print("uniform {0} is using image {1}".format(uniform['varname'], uniform['image'].filepath))
-        # scan the attribute list and find the UV layer used in the shader
+        # scan the attribute list and find the UV Map used in the shader
         for attribute in shader['attributes']:
             if attribute['type'] == gpu.CD_MTFACE:
-                print("attribute {0} is using UV layer {1}".format(attribute['varname'], attribute['name']))
+                print("attribute {0} is using UV Map {1}".format(attribute['varname'], attribute['name']))
 
 *****
 Notes
index 4959fc8a664a665186c333ba13268a070f1c3b68..0a07e03b9ae7c627a922746f92cd548952823206 100644 (file)
@@ -111,6 +111,12 @@ INFO_DOCS = (
     ("info_gotcha.rst", "Gotcha's: some of the problems you may come up against when writing scripts"),
     )
 
+# only support for properties atm.
+RNA_BLACKLIST = {
+    # messes up PDF!, really a bug but for now just workaround.
+    "UserPreferencesSystem": {"language", },
+    }
+
 
 # -----------------------------------------------------------------------------
 # configure compile time options
@@ -765,22 +771,23 @@ def pyrna2sphinx(BASEPATH):
         fw = file.write
 
         base_id = getattr(struct.base, "identifier", "")
+        struct_id = struct.identifier
 
         if _BPY_STRUCT_FAKE:
             if not base_id:
                 base_id = _BPY_STRUCT_FAKE
 
         if base_id:
-            title = "%s(%s)" % (struct.identifier, base_id)
+            title = "%s(%s)" % (struct_id, base_id)
         else:
-            title = struct.identifier
+            title = struct_id
 
         write_title(fw, title, "=")
 
         fw(".. module:: bpy.types\n\n")
 
         # docs first?, ok
-        write_example_ref("", fw, "bpy.types.%s" % struct.identifier)
+        write_example_ref("", fw, "bpy.types.%s" % struct_id)
 
         base_ids = [base.identifier for base in struct.get_bases()]
 
@@ -809,9 +816,9 @@ def pyrna2sphinx(BASEPATH):
                 base_id = _BPY_STRUCT_FAKE
 
         if base_id:
-            fw(".. class:: %s(%s)\n\n" % (struct.identifier, base_id))
+            fw(".. class:: %s(%s)\n\n" % (struct_id, base_id))
         else:
-            fw(".. class:: %s\n\n" % struct.identifier)
+            fw(".. class:: %s\n\n" % struct_id)
 
         fw("   %s\n\n" % struct.description)
 
@@ -819,7 +826,15 @@ def pyrna2sphinx(BASEPATH):
         sorted_struct_properties = struct.properties[:]
         sorted_struct_properties.sort(key=lambda prop: prop.identifier)
 
+        # support blacklisting props
+        struct_blacklist = RNA_BLACKLIST.get(struct_id, ())
+
         for prop in sorted_struct_properties:
+
+            # support blacklisting props
+            if prop.identifier in struct_blacklist:
+                continue
+
             type_descr = prop.get_type_description(class_fmt=":class:`%s`", collection_id=_BPY_PROP_COLLECTION_ID)
             # readonly properties use "data" directive, variables properties use "attribute" directive
             if 'readonly' in type_descr:
@@ -868,7 +883,7 @@ def pyrna2sphinx(BASEPATH):
                         descr = prop.name
                     fw("         `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr))
 
-            write_example_ref("      ", fw, "bpy.types." + struct.identifier + "." + func.identifier)
+            write_example_ref("      ", fw, "bpy.types." + struct_id + "." + func.identifier)
 
             fw("\n")
 
@@ -884,7 +899,7 @@ def pyrna2sphinx(BASEPATH):
         py_func = None
 
         for identifier, py_func in py_funcs:
-            py_c_func2sphinx("   ", fw, "bpy.types", struct.identifier, identifier, py_func, is_class=True)
+            py_c_func2sphinx("   ", fw, "bpy.types", struct_id, identifier, py_func, is_class=True)
 
         lines = []
 
@@ -963,7 +978,7 @@ def pyrna2sphinx(BASEPATH):
             fw("\n")
 
         # docs last?, disable for now
-        # write_example_ref("", fw, "bpy.types.%s" % struct.identifier)
+        # write_example_ref("", fw, "bpy.types.%s" % struct_id)
         file.close()
 
     if "bpy.types" not in EXCLUDE_MODULES:
index 60705e913f78b5ae51561e5fcc6c4d7a9f077f74..9c134934fa0f81e60a623ba1285cbd1c2d689d87 100644 (file)
@@ -46,16 +46,16 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
             defs.append('NDEBUG')
     else:
         if not env['BF_DEBUG']:
-            cflags_libmv = Split(env['REL_CFLAGS'])
-            ccflags_libmv = Split(env['REL_CCFLAGS'])
-            cxxflags_libmv = Split(env['REL_CXXFLAGS'])
+            cflags_libmv += Split(env['REL_CFLAGS'])
+            ccflags_libmv += Split(env['REL_CCFLAGS'])
+            cxxflags_libmv += Split(env['REL_CXXFLAGS'])
 else:
     src += env.Glob("third_party/glog/src/*.cc")
     incs += ' ./third_party/glog/src'
     if not env['BF_DEBUG']:
-        cflags_libmv = Split(env['REL_CFLAGS'])
-        ccflags_libmv = Split(env['REL_CCFLAGS'])
-        cxxflags_libmv = Split(env['REL_CXXFLAGS'])
+        cflags_libmv += Split(env['REL_CFLAGS'])
+        ccflags_libmv += Split(env['REL_CCFLAGS'])
+        cxxflags_libmv += Split(env['REL_CXXFLAGS'])
 
 incs += ' ./third_party/ssba ./third_party/ldl/Include ../colamd/Include'
 
index ba88ce7676d0a3739c3dab93cccf5c9712cff579..ab9b21d6dfd1208a6427e6f1e993b1ff77036569 100644 (file)
@@ -201,6 +201,8 @@ void CameraIntrinsics::ComputeLookupGrid(Grid* grid, int width, int height, doub
       warp_y = warp_y*aspy + 0.5 * overscan * h;
       int ix = int(warp_x), iy = int(warp_y);
       int fx = round((warp_x-ix)*256), fy = round((warp_y-iy)*256);
+      if(fx == 256) { fx=0; ix++; }
+      if(fy == 256) { fy=0; iy++; }
       // Use nearest border pixel
       if( ix < 0 ) { ix = 0, fx = 0; }
       if( iy < 0 ) { iy = 0, fy = 0; }
index a85b2ba8c2a14e4d3cc4ccc3ef0510dd02df7647..c5c4f6b22a6a46639bf36618747fa920c18b89d3 100644 (file)
@@ -12,9 +12,9 @@ if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
        set(WITH_CYCLES_OPTIMIZED_KERNEL ON)
 
        if(WIN32 AND MSVC)
-               set(CYCLES_OPTIMIZED_KERNEL_FLAGS "/Ox /Ot /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /EHsc /fp:fast")
+               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 -DGOGOGO")
+               set(CYCLES_OPTIMIZED_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3")
        endif()
 endif()
 
index 4d45a6875a97f097b0c5d1912a09fd7f88c5ead4..ecd22f654e8fc6030ebdac5bf9b9ac35c8d9fe22 100644 (file)
@@ -22,6 +22,9 @@ defs.append('WITH_OPENCL')
 defs.append('WITH_MULTI')
 defs.append('WITH_CUDA')
 
+if env['WITH_BF_CYCLES_BINARIES']:
+    defs.append('WITH_CUDA_BINARIES')
+
 incs.extend('. bvh render device kernel kernel/osl kernel/svm util subd'.split())
 incs.extend('#intern/guardedalloc #source/blender/makesrna #source/blender/makesdna'.split())
 incs.extend('#source/blender/blenloader ../../source/blender/makesrna/intern'.split())
index e81f02f2090f7287520feb848ba22e5ba4989b99..b96048acf054fb1db502b5e21465dc759cb0afbb 100644 (file)
@@ -6,7 +6,7 @@ set(INC
        ../kernel/svm
        ../util
        ../subd
-       ../../../intern/guardedalloc
+       ../../guardedalloc
        ../../../source/blender/makesdna
        ../../../source/blender/makesrna
        ../../../source/blender/blenloader
index ccb04eea0a882e33e5b9fcad9ad9d9ce39a5b672..a7a8a74bf38b3cba0e70e31d0e91720ec619d563 100644 (file)
@@ -43,7 +43,7 @@ from cycles import presets
 
 class CyclesRender(bpy.types.RenderEngine):
     bl_idname = 'CYCLES'
-    bl_label = "Cycles"
+    bl_label = "Cycles Render"
     bl_use_shading_nodes = True
 
     def __init__(self):
index 0c7deb01ed8c4ab25edee700fc734edc37796886..95f898f3ca5482b2c435279a1c4c0c4826e8633d 100644 (file)
 # <pep8 compliant>
 
 import bpy
-from bpy.props import *
+from bpy.props import (BoolProperty,
+                       EnumProperty,
+                       FloatProperty,
+                       IntProperty,
+                       PointerProperty)
 
 import math
 
index f3ed3b677fb5f35055181c615aef2e4b16781cdd..224e44c287aa2c0785006d0f14da413aa3435bae 100644 (file)
@@ -349,7 +349,7 @@ def find_node(material, nodetype):
         ntree = material.node_tree
 
         for node in ntree.nodes:
-            if hasattr(node, 'type') and node.type == nodetype:
+            if getattr(node, "type", None) == nodetype:
                 return node
 
     return None
@@ -363,14 +363,14 @@ def find_node_input(node, name):
     return None
 
 
-def panel_node_draw(layout, id, output_type, input_name):
-    if not id.node_tree:
-        layout.prop(id, "use_nodes", icon='NODETREE')
+def panel_node_draw(layout, id_data, output_type, input_name):
+    if not id_data.node_tree:
+        layout.prop(id_data, "use_nodes", icon='NODETREE')
         return False
 
-    ntree = id.node_tree
+    ntree = id_data.node_tree
 
-    node = find_node(id, output_type)
+    node = find_node(id_data, output_type)
     if not node:
         layout.label(text="No output node.")
     else:
index e64023f046b8031a11c85e7db7861daa56f9ce5f..f17051d92dc18a5d97d0eb31576600301953bbdd 100644 (file)
@@ -61,12 +61,12 @@ class ExportCyclesXML(bpy.types.Operator, ExportHelper):
 
         # get mesh
         scene = context.scene
-        object = context.object
+        obj = context.object
 
-        if not object:
+        if not obj:
             raise Exception("No active object")
 
-        mesh = object.to_mesh(scene, True, 'PREVIEW')
+        mesh = obj.to_mesh(scene, True, 'PREVIEW')
 
         if not mesh:
             raise Exception("No mesh data in active object")
index 56e8561d64b56b00d396683908df69d7ec81d1b3..2bc79224e087dbf9f7899f2d85bf989ca243172b 100644 (file)
@@ -144,7 +144,7 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
                }
        }
 
-       /* create uv layer attributes */
+       /* create uv map attributes */
        {
                BL::Mesh::uv_textures_iterator l;
 
index a6ce0e9bfa83b4fb6fa33fcc39dd9c7df49ccc0a..cf8527b9760dc36a89cde5a65145dd03a1fb7172 100644 (file)
@@ -99,6 +99,9 @@ static float get_node_output_value(BL::Node b_node, const string& name)
 
 static void get_tex_mapping(TextureMapping *mapping, BL::TexMapping b_mapping)
 {
+       if(!b_mapping)
+               return;
+
        mapping->translation = get_float3(b_mapping.location());
        mapping->rotation = get_float3(b_mapping.rotation());
        mapping->scale = get_float3(b_mapping.scale());
@@ -110,6 +113,9 @@ static void get_tex_mapping(TextureMapping *mapping, BL::TexMapping b_mapping)
 
 static void get_tex_mapping(TextureMapping *mapping, BL::ShaderNodeMapping b_mapping)
 {
+       if(!b_mapping)
+               return;
+
        mapping->translation = get_float3(b_mapping.location());
        mapping->rotation = get_float3(b_mapping.rotation());
        mapping->scale = get_float3(b_mapping.scale());
index 5d6ac10dc407e48e9c7957dcfea0d075a331d5c3..5552e6ab7e22210bd6f7b3e553202afc739c47fd 100644 (file)
@@ -76,6 +76,7 @@ protected:
        Device() {}
 
        bool background;
+       string error_msg;
 
 public:
        virtual ~Device() {}
@@ -84,6 +85,7 @@ public:
 
        /* info */
        virtual string description() = 0;
+       const string& error_message() { return error_msg; }
 
        /* regular memory */
        virtual void mem_alloc(device_memory& mem, MemoryType type) = 0;
index 1158cc6c77cd864194dae9bd58afbf96266226b8..e32cbfcc8a7b7272b5eb1107f84f3feb27624527 100644 (file)
@@ -122,7 +122,10 @@ public:
                CUresult result = stmt; \
                \
                if(result != CUDA_SUCCESS) { \
-                       fprintf(stderr, "CUDA error: %s in %s\n", cuda_error_string(result), #stmt); \
+                       string message = string_printf("CUDA error: %s in %s", cuda_error_string(result), #stmt); \
+                       if(error_msg == "") \
+                               error_msg = message; \
+                       fprintf(stderr, "%s\n", message.c_str()); \
                        cuda_abort(); \
                } \
        }
@@ -132,10 +135,20 @@ public:
                if(result == CUDA_SUCCESS)
                        return false;
 
-               fprintf(stderr, "CUDA error: %s\n", cuda_error_string(result));
+               string message = string_printf("CUDA error: %s", cuda_error_string(result));
+               if(error_msg == "")
+                       error_msg = message;
+               fprintf(stderr, "%s\n", message.c_str());
                return true;
        }
 
+       void cuda_error(const string& message)
+       {
+               if(error_msg == "")
+                       error_msg = message;
+               fprintf(stderr, "%s\n", message.c_str());
+       }
+
        void cuda_push_context()
        {
                cuda_assert(cuCtxSetCurrent(cuContext))
@@ -224,14 +237,14 @@ public:
                        return cubin;
 
 #ifdef WITH_CUDA_BINARIES
-               fprintf(stderr, "CUDA binary kernel for this graphics card not found.\n");
+               cuda_error("CUDA binary kernel for this graphics card not found.");
                return "";
 #else
                /* if not, find CUDA compiler */
                string nvcc = cuCompilerPath();
 
                if(nvcc == "") {
-                       fprintf(stderr, "CUDA nvcc compiler not found. Install CUDA toolkit in default location.\n");
+                       cuda_error("CUDA nvcc compiler not found. Install CUDA toolkit in default location.");
                        return "";
                }
 
@@ -251,13 +264,13 @@ public:
                        nvcc.c_str(), major, minor, machine, kernel.c_str(), cubin.c_str(), maxreg, include.c_str());
 
                if(system(command.c_str()) == -1) {
-                       fprintf(stderr, "Failed to execute compilation command.\n");
+                       cuda_error("Failed to execute compilation command, see console for details.");
                        return "";
                }
 
                /* verify if compilation succeeded */
                if(!path_exists(cubin)) {
-                       fprintf(stderr, "CUDA kernel compilation failed.\n");
+                       cuda_error("CUDA kernel compilation failed, see console for details.");
                        return "";
                }
 
@@ -284,7 +297,7 @@ public:
 
                CUresult result = cuModuleLoad(&cuModule, cubin.c_str());
                if(cuda_error(result))
-                       fprintf(stderr, "Failed loading CUDA kernel %s.\n", cubin.c_str());
+                       cuda_error(string_printf("Failed loading CUDA kernel %s.", cubin.c_str()));
 
                cuda_pop_context();
 
index c96d4617ffb35f4c6d45f811667d60fc1ffdb7d0..d783ae6c174f522dbc6d47a9a418c27bc0a8e027 100644 (file)
@@ -109,17 +109,30 @@ public:
        bool opencl_error(cl_int err)
        {
                if(err != CL_SUCCESS) {
-                       fprintf(stderr, "OpenCL error (%d): %s\n", err, opencl_error_string(err));
+                       string message = string_printf("OpenCL error (%d): %s", err, opencl_error_string(err));
+                       if(error_msg == "")
+                               error_msg = message;
+                       fprintf(stderr, "%s\n", message.c_str());
                        return true;
                }
 
                return false;
        }
 
+       void opencl_error(const string& message)
+       {
+               if(error_msg == "")
+                       error_msg = message;
+               fprintf(stderr, "%s\n", message.c_str());
+       }
+
        void opencl_assert(cl_int err)
        {
                if(err != CL_SUCCESS) {
-                       fprintf(stderr, "OpenCL error (%d): %s\n", err, opencl_error_string(err));
+                       string message = string_printf("OpenCL error (%d): %s", err, opencl_error_string(err));
+                       if(error_msg == "")
+                               error_msg = message;
+                       fprintf(stderr, "%s\n", message.c_str());
 #ifndef NDEBUG
                        abort();
 #endif
@@ -147,7 +160,7 @@ public:
                        return;
 
                if(num_platforms == 0) {
-                       fprintf(stderr, "OpenCL: no platforms found.\n");
+                       opencl_error("OpenCL: no platforms found.");
                        return;
                }
 
@@ -183,24 +196,24 @@ public:
                clGetPlatformInfo(cpPlatform, CL_PLATFORM_VERSION, sizeof(version), &version, NULL);
 
                if(sscanf(version, "OpenCL %d.%d", &major, &minor) < 2) {
-                       fprintf(stderr, "OpenCL: failed to parse platform version string (%s).", version);
+                       opencl_error(string_printf("OpenCL: failed to parse platform version string (%s).", version));
                        return false;
                }
 
                if(!((major == req_major && minor >= req_minor) || (major > req_major))) {
-                       fprintf(stderr, "OpenCL: platform version 1.1 or later required, found %d.%d\n", major, minor);
+                       opencl_error(string_printf("OpenCL: platform version 1.1 or later required, found %d.%d", major, minor));
                        return false;
                }
 
                clGetDeviceInfo(cdDevice, CL_DEVICE_OPENCL_C_VERSION, sizeof(version), &version, NULL);
 
                if(sscanf(version, "OpenCL C %d.%d", &major, &minor) < 2) {
-                       fprintf(stderr, "OpenCL: failed to parse OpenCL C version string (%s).", version);
+                       opencl_error(string_printf("OpenCL: failed to parse OpenCL C version string (%s).", version));
                        return false;
                }
 
                if(!((major == req_major && minor >= req_minor) || (major > req_major))) {
-                       fprintf(stderr, "OpenCL: C version 1.1 or later required, found %d.%d\n", major, minor);
+                       opencl_error(string_printf("OpenCL: C version 1.1 or later required, found %d.%d", major, minor));
                        return false;
                }
 
@@ -216,7 +229,7 @@ public:
                vector<uint8_t> binary;
 
                if(!path_read_binary(clbin, binary)) {
-                       fprintf(stderr, "OpenCL failed to read cached binary %s.\n", clbin.c_str());
+                       opencl_error(string_printf("OpenCL failed to read cached binary %s.", clbin.c_str()));
                        return false;
                }
 
@@ -229,7 +242,7 @@ public:
                        &size, &bytes, &status, &ciErr);
 
                if(opencl_error(status) || opencl_error(ciErr)) {
-                       fprintf(stderr, "OpenCL failed create program from cached binary %s.\n", clbin.c_str());
+                       opencl_error(string_printf("OpenCL failed create program from cached binary %s.", clbin.c_str()));
                        return false;
                }
 
@@ -253,19 +266,16 @@ public:
                clGetProgramInfo(cpProgram, CL_PROGRAM_BINARIES, sizeof(uint8_t*), &bytes, NULL);
 
                if(!path_write_binary(clbin, binary)) {
-                       fprintf(stderr, "OpenCL failed to write cached binary %s.\n", clbin.c_str());
+                       opencl_error(string_printf("OpenCL failed to write cached binary %s.", clbin.c_str()));
                        return false;
                }
 
                return true;
        }
 
-       bool build_kernel(const string& kernel_path)
+       string kernel_build_options()
        {
-               string build_options = "";
-
-               build_options += "-I " + kernel_path + ""; /* todo: escape path */
-               build_options += " -cl-fast-relaxed-math ";
+               string build_options = " -cl-fast-relaxed-math ";
                
                /* Full Shading only on NVIDIA cards at the moment */
                char vendor[256];
@@ -273,14 +283,16 @@ public:
                clGetPlatformInfo(cpPlatform, CL_PLATFORM_NAME, sizeof(vendor), &vendor, NULL);
                string name = vendor;
                
-               if (name == "NVIDIA CUDA") {
-                       build_options += "-D __SVM__ ";
-                       build_options += "-D __EMISSION__ ";
-                       build_options += "-D __TEXTURES__ ";
-                       build_options += "-D __HOLDOUT__ ";
-                       build_options += "-D __MULTI_CLOSURE__ ";
-               }
+               if(name == "NVIDIA CUDA")
+                       build_options += "-D__KERNEL_SHADING__ -D__MULTI_CLOSURE__ ";
+
+               return build_options;
+       }
 
+       bool build_kernel(const string& kernel_path)
+       {
+               string build_options = kernel_build_options();
+       
                ciErr = clBuildProgram(cpProgram, 0, NULL, build_options.c_str(), NULL, NULL);
 
                if(ciErr != CL_SUCCESS) {
@@ -294,7 +306,8 @@ public:
                        clGetProgramBuildInfo(cpProgram, cdDevice, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
 
                        build_log[ret_val_size] = '\0';
-                       fprintf(stderr, "OpenCL build failed:\n %s\n", build_log);
+                       opencl_error("OpenCL build failed: errors in console");
+                       fprintf(stderr, "%s\n", build_log);
 
                        delete[] build_log;
 
@@ -310,6 +323,8 @@ public:
                   kernel caches do not seem to recognize changes in included files.
                   so we force recompile on changes by adding the md5 hash of all files */
                string source = "#include \"kernel.cl\" // " + kernel_md5 + "\n";
+               source = path_source_replace_includes(source, kernel_path);
+
                size_t source_len = source.size();
                const char *source_str = source.c_str();
 
@@ -344,6 +359,9 @@ public:
                md5.append((uint8_t*)name, strlen(name));
                md5.append((uint8_t*)driver, strlen(driver));
 
+               string options = kernel_build_options();
+               md5.append((uint8_t*)options.c_str(), options.size());
+
                return md5.get_hex();
        }
 
@@ -563,24 +581,20 @@ public:
        cl_int set_kernel_arg_mem(cl_kernel kernel, int *narg, const char *name)
        {
                cl_mem ptr;
-               cl_int size, err = 0;
+               cl_int err = 0;
 
                if(mem_map.find(name) != mem_map.end()) {
                        device_memory *mem = mem_map[name];
                
                        ptr = CL_MEM_PTR(mem->device_pointer);
-                       size = mem->data_width;
                }
                else {
                        /* work around NULL not working, even though the spec says otherwise */
                        ptr = CL_MEM_PTR(null_mem);
-                       size = 1;
                }
                
                err |= clSetKernelArg(kernel, (*narg)++, sizeof(ptr), (void*)&ptr);
                opencl_assert(err);
-               err |= clSetKernelArg(kernel, (*narg)++, sizeof(size), (void*)&size);
-               opencl_assert(err);
 
                return err;
        }
index 48bee8eef9725489c2d513e0810c069a48f5441b..c00bc3fe9579317130eaf0db0da164ba771864cf 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "kernel_film.h"
 #include "kernel_path.h"
-//#include "kernel_displace.h"
 
 __kernel void kernel_ocl_path_trace(
        __constant KernelData *data,
@@ -33,8 +32,7 @@ __kernel void kernel_ocl_path_trace(
        __global uint *rng_state,
 
 #define KERNEL_TEX(type, ttype, name) \
-       __global type *name, \
-       int name##_width,
+       __global type *name,
 #include "kernel_textures.h"
 
        int sample,
@@ -45,8 +43,7 @@ __kernel void kernel_ocl_path_trace(
        kg->data = data;
 
 #define KERNEL_TEX(type, ttype, name) \
-       kg->name = name; \
-       kg->name##_width = name##_width;
+       kg->name = name;
 #include "kernel_textures.h"
 
        int x = sx + get_global_id(0);
@@ -62,8 +59,7 @@ __kernel void kernel_ocl_tonemap(
        __global float4 *buffer,
 
 #define KERNEL_TEX(type, ttype, name) \
-       __global type *name, \
-       int name##_width,
+       __global type *name,
 #include "kernel_textures.h"
 
        int sample, int resolution,
@@ -74,8 +70,7 @@ __kernel void kernel_ocl_tonemap(
        kg->data = data;
 
 #define KERNEL_TEX(type, ttype, name) \
-       kg->name = name; \
-       kg->name##_width = name##_width;
+       kg->name = name;
 #include "kernel_textures.h"
 
        int x = sx + get_global_id(0);
index b5f59b945166972f0b5b9eb162d8a9a43a572552..e98bb158f6edbd60eca3375588d6f1a9cbafb3b6 100644 (file)
@@ -97,11 +97,7 @@ __device_inline void bvh_node_intersect(KernelGlobals *kg,
        float c1loz = nz.z * idir.z - ood.z;
        float c1hiz = nz.w * idir.z - ood.z;
 
-       float c0min_x = min(c0lox, c0hix);
-       float c0min_y = min(c0loy, c0hiy);
-       float c0min_z = min(c0loz, c0hiz);
-
-       float c0min = max4(c0min_x, c0min_y, c0min_z, 0.0f);
+       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;
index c2828c20eee491c4a3fd8f927dce542915341ffe..9cdc2f1f8659f56cb6396175b531fafcca99847c 100644 (file)
@@ -127,8 +127,8 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa
 __device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v, float lens_u, float lens_v, Ray *ray)
 {
        /* pixel filter */
-       float raster_x = x + kernel_tex_interp(__filter_table, filter_u);
-       float raster_y = y + kernel_tex_interp(__filter_table, filter_v);
+       float raster_x = x + kernel_tex_interp(__filter_table, filter_u, FILTER_TABLE_SIZE);
+       float raster_y = y + kernel_tex_interp(__filter_table, filter_v, FILTER_TABLE_SIZE);
 
        /* motion blur */
        //ray->time = lerp(time_t, kernel_data.cam.shutter_open, kernel_data.cam.shutter_close);
index fd96148968fb4130d0c4100e804ec46c5dc0004c..783ae5198455544c98f3ef9b7139007a7b235b01 100644 (file)
@@ -55,8 +55,10 @@ template<typename T> struct texture  {
                return ((__m128i*)data)[index];
        }*/
 
-       float interp(float x)
+       float interp(float x, int size)
        {
+               kernel_assert(size == width);
+
                x = clamp(x, 0.0f, 1.0f)*width;
 
                int index = min((int)x, width-1);
@@ -151,7 +153,7 @@ typedef texture_image<uchar4> texture_image_uchar4;
 #define kernel_tex_fetch(tex, index) (kg->tex.fetch(index))
 #define kernel_tex_fetch_m128(tex, index) (kg->tex.fetch_m128(index))
 #define kernel_tex_fetch_m128i(tex, index) (kg->tex.fetch_m128i(index))
-#define kernel_tex_interp(tex, t) (kg->tex.interp(t))
+#define kernel_tex_interp(tex, t, size) (kg->tex.interp(t, size))
 #define kernel_tex_image_interp(tex, x, y) (kg->tex.interp(x, y))
 
 #define kernel_data (kg->__data)
index 72aef463cab125f38d8d273514919015bb0457e2..40129a2f68f5e7cf831771d28a10fd40a5a1d59c 100644 (file)
@@ -55,7 +55,7 @@ typedef texture<uchar4, 2, cudaReadModeNormalizedFloat> texture_image_uchar4;
 /* Macros to handle different memory storage on different devices */
 
 #define kernel_tex_fetch(t, index) tex1Dfetch(t, index)
-#define kernel_tex_interp(t, x) tex1D(t, x)
+#define kernel_tex_interp(t, x, size) tex1D(t, x)
 #define kernel_tex_image_interp(t, x, y) tex2D(t, x, y)
 
 #define kernel_data __data
index 287bf3208813c3ce51efc59f2995558e1fe695a4..5515966807b399059a7a7f9b13efb54ac7d6479f 100644 (file)
@@ -100,7 +100,7 @@ __device float kernel_tex_interp_(__global float *data, int width, float x)
 
 /* data lookup defines */
 #define kernel_data (*kg->data)
-#define kernel_tex_interp(t, x) kernel_tex_interp_(kg->t, kg->t##_width, x)
+#define kernel_tex_interp(t, x, size) kernel_tex_interp_(kg->t, size, x)
 #define kernel_tex_fetch(t, index) kg->t[index]
 
 /* define NULL */
index ea866221487988f192245c7eec80fcf7ed6dd706..1f2fc97e6854bf1f8c58f7ed786658137b3d36f1 100644 (file)
@@ -77,8 +77,7 @@ typedef struct KernelGlobals {
        __constant KernelData *data;
 
 #define KERNEL_TEX(type, ttype, name) \
-       __global type *name; \
-       int name##_width;
+       __global type *name;
 #include "kernel_textures.h"
 } KernelGlobals;
 
index 1647504207a5ff48a5c5202dc24415ea9bc7dd40..570e0721268a57fe57a09a73b47e43f02b42007b 100644 (file)
@@ -226,7 +226,7 @@ __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
        Ng = triangle_normal_MT(kg, prim, &shader);
 
        /* force smooth shading for displacement */
-       sd->shader |= SHADER_SMOOTH_NORMAL;
+       shader |= SHADER_SMOOTH_NORMAL;
 
        /* watch out: no instance transform currently */
 
index 46cdcd1151e1f67ea0f19264713704576d49ec24..d9bd645b16d35320f5b0841be4d29e6e3be7497f 100644 (file)
 
 CCL_NAMESPACE_BEGIN
 
-#define OBJECT_SIZE 16
-#define LIGHT_SIZE     4
+/* constants */
+#define OBJECT_SIZE            16
+#define LIGHT_SIZE                     4
+#define FILTER_TABLE_SIZE      256
 
+/* device capabilities */
+#ifdef __KERNEL_CPU__
+#define __KERNEL_SHADING__
+#define __KERNEL_ADV_SHADING__
+#endif
+
+#ifdef __KERNEL_CUDA__
+#define __KERNEL_SHADING__
+#if __CUDA_ARCH__ >= 200
+#define __KERNEL_ADV_SHADING__
+#endif
+#endif
+
+#ifdef __KERNEL_OPENCL__
+//#define __KERNEL_SHADING__
+//#define __KERNEL_ADV_SHADING__
+#endif
+
+/* kernel features */
 #define __SOBOL__
 #define __INSTANCING__
 #define __DPDU__
@@ -39,27 +60,20 @@ CCL_NAMESPACE_BEGIN
 #define __CAMERA_CLIPPING__
 #define __INTERSECTION_REFINE__
 
-#ifndef __KERNEL_OPENCL__
+#ifdef __KERNEL_SHADING__
 #define __SVM__
 #define __EMISSION__
 #define __TEXTURES__
 #define __HOLDOUT__
-//#define __MULTI_LIGHT__
 #endif
 
-#ifdef __KERNEL_CPU__
+#ifdef __KERNEL_ADV_SHADING__
 #define __MULTI_CLOSURE__
 #define __TRANSPARENT_SHADOWS__
-//#define __OSL__
-#endif
-
-#ifdef __KERNEL_CUDA__
-#if __CUDA_ARCH__ >= 200
-#define __MULTI_CLOSURE__
-#define __TRANSPARENT_SHADOWS__
-#endif
 #endif
 
+//#define __MULTI_LIGHT__
+//#define __OSL__
 //#define __SOBOL_FULL_SCREEN__
 //#define __MODIFY_TP__
 //#define __QBVH__
index 4925521e4a51ea9e2bc05739b4d9a23fb811ac76..9bcf57b5a274f91b005a8aa2afc04d69a0486283 100644 (file)
@@ -21,6 +21,8 @@
 #include "filter.h"
 #include "scene.h"
 
+#include "kernel_types.h"
+
 #include "util_algorithm.h"
 #include "util_debug.h"
 #include "util_math.h"
@@ -51,7 +53,7 @@ static float filter_func_gaussian(float v, float width)
 
 static vector<float> filter_table(FilterType type, float width)
 {
-       const int filter_table_size = 256;
+       const int filter_table_size = FILTER_TABLE_SIZE-1;
        vector<float> filter_table_cdf(filter_table_size+1);
        vector<float> filter_table(filter_table_size+1);
        float (*filter_func)(float, float) = NULL;
index 2deb83674cca58ff4be9cf07ceae9555e7ca5b53..73ac033623dd4ba502b16f658da16d751327b3f7 100644 (file)
@@ -203,6 +203,10 @@ void Session::run_gpu()
                if(!no_tiles) {
                        /* update scene */
                        update_scene();
+
+                       if(device->error_message() != "")
+                               progress.set_cancel(device->error_message());
+
                        if(progress.get_cancel())
                                break;
                }
@@ -222,6 +226,9 @@ void Session::run_gpu()
 
                                device->task_wait();
 
+                               if(device->error_message() != "")
+                                       progress.set_cancel(device->error_message());
+
                                if(progress.get_cancel())
                                        break;
                        }
@@ -243,6 +250,9 @@ void Session::run_gpu()
                                }
                        }
 
+                       if(device->error_message() != "")
+                               progress.set_cancel(device->error_message());
+
                        if(progress.get_cancel())
                                break;
                }
@@ -345,6 +355,10 @@ void Session::run_cpu()
 
                        /* update scene */
                        update_scene();
+
+                       if(device->error_message() != "")
+                               progress.set_cancel(device->error_message());
+
                        if(progress.get_cancel())
                                break;
 
@@ -360,6 +374,9 @@ void Session::run_cpu()
 
                        if(!params.background)
                                need_tonemap = true;
+
+                       if(device->error_message() != "")
+                               progress.set_cancel(device->error_message());
                }
 
                device->task_wait();
@@ -379,6 +396,9 @@ void Session::run_cpu()
                                   want to show the result of an incomplete sample*/
                                tonemap();
                        }
+
+                       if(device->error_message() != "")
+                               progress.set_cancel(device->error_message());
                }
 
                progress.set_update();
@@ -391,7 +411,11 @@ void Session::run()
        progress.set_status("Loading render kernels (may take a few minutes the first time)");
 
        if(!device->load_kernels()) {
-               progress.set_status("Failed loading render kernel, see console for errors");
+               string message = device->error_message();
+               if(message == "")
+                       message = "Failed loading render kernel, see console for errors";
+
+               progress.set_status("Error", message);
                progress.set_update();
                return;
        }
@@ -409,7 +433,7 @@ void Session::run()
 
        /* progress update */
        if(progress.get_cancel())
-               progress.set_status(progress.get_cancel_message());
+               progress.set_status("Cancel", progress.get_cancel_message());
        else
                progress.set_update();
 }
index c0dd627a606386faac9889da5b5c6797664b34c8..2f9e00dbfcbab08e7159b8f8f32a1ae781d01865 100644 (file)
@@ -115,12 +115,12 @@ __device_inline double min(double a, double b)
 
 __device_inline float min4(float a, float b, float c, float d)
 {
-       return min(min(min(a, b), c), d);
+       return min(min(a, b), min(c, d));
 }
 
 __device_inline float max4(float a, float b, float c, float d)
 {
-       return max(max(max(a, b), c), d);
+       return max(max(a, b), max(c, d));
 }
 
 #ifndef __KERNEL_OPENCL__
index 55e6a95b54a00f067a1ce58b1d2ba27f941b8312..69069a3bbce4929884fdc60b6d2d7ebffc8a0151 100644 (file)
@@ -162,5 +162,46 @@ bool path_read_binary(const string& path, vector<uint8_t>& binary)
        return true;
 }
 
+static bool path_read_text(const string& path, string& text)
+{
+       vector<uint8_t> binary;
+
+       if(!path_exists(path) || !path_read_binary(path, binary))
+               return false;
+       
+       const char *str = (const char*)&binary[0];
+       size_t size = binary.size();
+       text = string(str, size);
+
+       return true;
+}
+
+string path_source_replace_includes(const string& source_, const string& path)
+{
+       /* our own little c preprocessor that replaces #includes with the file
+          contents, to work around issue of opencl drivers not supporting
+          include paths with spaces in them */
+       string source = source_;
+       const string include = "#include \"";
+       size_t n, pos = 0;
+
+       while((n = source.find(include, pos)) != string::npos) {
+               size_t n_start = n + include.size();
+               size_t n_end = source.find("\"", n_start);
+               string filename = source.substr(n_start, n_end - n_start);
+
+               string text, filepath = path_join(path, filename);
+
+               if(path_read_text(filepath, text)) {
+                       text = path_source_replace_includes(text, path_dirname(filepath));
+                       source.replace(n, n_end + 1 - n, "\n" + text + "\n");
+               }
+               else
+                       pos = n_end;
+       }
+
+       return source;
+}
+
 CCL_NAMESPACE_END
 
index 4a9d45ec5940b934f7d9e588359e4b1918a77950..6cba6a3158f0f2d5c75f9b018f7f4b8b3743b27c 100644 (file)
@@ -46,6 +46,8 @@ void path_create_directories(const string& path);
 bool path_write_binary(const string& path, const vector<uint8_t>& binary);
 bool path_read_binary(const string& path, vector<uint8_t>& binary);
 
+string path_source_replace_includes(const string& source, const string& path);
+
 CCL_NAMESPACE_END
 
 #endif
index 03c3427045db4a67c6767e43125f861b6de41707..12a732e59ef29d83042e4f062c07439a934c855b 100644 (file)
@@ -1765,7 +1765,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const
                return NULL;
        }
        
-       pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
+       pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
        
        temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1); 
 
@@ -1774,7 +1774,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const
                return NULL;
        }
        
-       strncpy((char*)temp_buff, [textPasted cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize);
+       strncpy((char*)temp_buff, [textPasted cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize);
        
        temp_buff[pastedTextSize] = '\0';
        
@@ -1806,7 +1806,7 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
        
        [pasteBoard declareTypes:supportedTypes owner:nil];
        
-       textToCopy = [NSString stringWithCString:buffer encoding:NSISOLatin1StringEncoding];
+       textToCopy = [NSString stringWithCString:buffer encoding:NSUTF8StringEncoding];
        
        [pasteBoard setString:textToCopy forType:NSStringPboardType];
        
index 7bb1913d872d58c7d7445390f807dacc6cbaf21a..01217dfd17a799da4b3533b6bcfbfa7b47d7cf09 100644 (file)
@@ -238,10 +238,13 @@ extern "C" {
 
 #pragma mark NSOpenGLView subclass
 //We need to subclass it in order to give Cocoa the feeling key events are trapped
-@interface CocoaOpenGLView : NSOpenGLView
+@interface CocoaOpenGLView : NSOpenGLView <NSTextInput>
 {
        GHOST_SystemCocoa *systemCocoa;
        GHOST_WindowCocoa *associatedWindow;
+
+       bool composing;
+       NSString *composing_text;
 }
 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa;
 @end
@@ -251,6 +254,9 @@ extern "C" {
 {
        systemCocoa = sysCocoa;
        associatedWindow = winCocoa;
+
+       composing = false;
+       composing_text = nil;
 }
 
 - (BOOL)acceptsFirstResponder
@@ -258,9 +264,26 @@ extern "C" {
     return YES;
 }
 
-//The trick to prevent Cocoa from complaining (beeping)
-- (void)keyDown:(NSEvent *)theEvent
-{}
+// The trick to prevent Cocoa from complaining (beeping)
+- (void)keyDown:(NSEvent *)event
+{
+       // Start or continue composing?
+       if([[event characters] length] == 0  ||
+          [[event charactersIgnoringModifiers] length] == 0 ||
+          composing) {
+               composing = YES;
+               // interpret event to call insertText
+               NSMutableArray *events;
+               events = [[NSMutableArray alloc] initWithCapacity:1];
+               [events addObject:event];
+               [self interpretKeyEvents:events]; // calls insertText
+               [events removeObject:event];
+               [events release];
+
+               return;
+       }
+}
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
 //Cmd+key are handled differently before 10.5
@@ -306,8 +329,99 @@ extern "C" {
     }
 }
 
-@end
+// Text input
+
+- (void)composing_free
+{
+       composing = NO;
+
+       if(composing_text) {
+               [composing_text release];
+               composing_text = nil;
+       }
+}
+
+- (void)insertText:(id)chars
+{
+       [self composing_free];
+}
+
+- (void)setMarkedText:(id)chars selectedRange:(NSRange)range
+{
+       [self composing_free];
+       if([chars length] == 0)
+               return;
+       
+       // start composing
+       composing = YES;
+       composing_text = [chars copy];
+
+       // if empty, cancel
+       if([composing_text length] == 0)
+               [self composing_free];
+}
+
+- (void)unmarkText
+{
+       [self composing_free];
+}
+
+- (BOOL)hasMarkedText
+{
+       return (composing)? YES: NO;
+}
+
+- (void)doCommandBySelector:(SEL)selector
+{
+}
+
+- (BOOL)isComposing
+{
+       return composing;
+}
+
+- (NSInteger)conversationIdentifier
+{
+       return (NSInteger)self;
+}
+
+- (NSAttributedString *)attributedSubstringFromRange:(NSRange)range
+{
+       return [NSAttributedString new]; // XXX does this leak?
+}
+
+- (NSRange)markedRange
+{
+       unsigned int length = (composing_text)? [composing_text length]: 0;
+
+       if(composing)
+               return NSMakeRange(0, length);
+
+       return NSMakeRange(NSNotFound, 0);
+}
 
+- (NSRange)selectedRange
+{
+       unsigned int length = (composing_text)? [composing_text length]: 0;
+       return NSMakeRange(0, length);
+}
+
+- (NSRect)firstRectForCharacterRange:(NSRange)range
+{
+       return NSZeroRect;
+}
+
+- (NSUInteger)characterIndexForPoint:(NSPoint)point
+{
+       return NSNotFound;
+}
+
+- (NSArray*)validAttributesForMarkedText
+{
+       return [NSArray array]; // XXX does this leak?
+}
+
+@end
 
 #pragma mark initialization / finalization
 
index 1701612d31352c7c86e367c27d196733f0d689c7..fdf92f669c41bd8870bbf85644ff8518a29c1973 100644 (file)
Binary files a/release/datafiles/fonts/droidsans.ttf.gz and b/release/datafiles/fonts/droidsans.ttf.gz differ
index 1bd218ad92aa7cf6192115e221cd351a76d5dde3..de662b47c4dc65444724c6f38d7daccefd34c22d 100644 (file)
@@ -146,7 +146,10 @@ def modules(module_cache):
     for path in path_list:
 
         # force all contrib addons to be 'TESTING'
-        force_support = 'TESTING' if path.endswith("addons_contrib") else None
+        if path.endswith("addons_contrib") or path.endswith("addons_extern"):
+            force_support = 'TESTING'
+        else:
+            force_support = None
 
         for mod_name, mod_path in _bpy.path.module_names(path):
             modules_stale -= {mod_name}
@@ -168,7 +171,9 @@ def modules(module_cache):
                     mod = None
 
             if mod is None:
-                mod = fake_module(mod_name, mod_path, force_support=force_support)
+                mod = fake_module(mod_name,
+                                  mod_path,
+                                  force_support=force_support)
                 if mod:
                     module_cache[mod_name] = mod
 
index 6eb16bd7e7ac53cbc719ad3c83c6e0fdf8ae9c9a..cf3e92bdcbfe7834864bc5b7aa821e0fc5798e63 100644 (file)
@@ -263,7 +263,7 @@ def user_script_path():
         return None
 
 
-def script_paths(subdir=None, user_pref=True, all=False):
+def script_paths(subdir=None, user_pref=True, check_all=False):
     """
     Returns a list of valid script paths.
 
@@ -271,9 +271,9 @@ def script_paths(subdir=None, user_pref=True, all=False):
     :type subdir: string
     :arg user_pref: Include the user preference script path.
     :type user_pref: bool
-    :arg all: Include local, user and system paths rather just the paths
+    :arg check_all: Include local, user and system paths rather just the paths
        blender uses.
-    :type all: bool
+    :type check_all: bool
     :return: script paths.
     :rtype: list
     """
@@ -286,7 +286,7 @@ def script_paths(subdir=None, user_pref=True, all=False):
     else:
         user_script_path = None
 
-    if all:
+    if check_all:
         # all possible paths
         base_paths = tuple(_os.path.join(resource_path(res), "scripts")
                            for res in ('LOCAL', 'USER', 'SYSTEM'))
@@ -343,7 +343,7 @@ def preset_paths(subdir):
     :rtype: list
     """
     dirs = []
-    for path in script_paths("presets", all=True):
+    for path in script_paths("presets", check_all=True):
         directory = _os.path.join(path, subdir)
         if not directory.startswith(path):
             raise Exception("invalid subdir given %r" % subdir)
@@ -432,9 +432,9 @@ def keyconfig_set(filepath):
     keyconfigs_old = keyconfigs[:]
 
     try:
-        file = open(filepath)
-        exec(compile(file.read(), filepath, 'exec'), {"__file__": filepath})
-        file.close()
+        keyfile = open(filepath)
+        exec(compile(keyfile.read(), filepath, 'exec'), {"__file__": filepath})
+        keyfile.close()
     except:
         import traceback
         traceback.print_exc()
index 29187297707eafb96d7ee5f3c6ec7efc9f043a04..3404bb792faad8b92583cb557ce1cd34df78ef18 100644 (file)
@@ -72,7 +72,7 @@ def reduce_spaces(text):
     return RE_SPACE.sub(' ', text)
 
 
-def get_doc(object):
+def get_doc(obj):
     """Get the doc string or comments for an object.
 
     :param object: object
@@ -82,7 +82,7 @@ def get_doc(object):
     >>> get_doc(abs)
     'abs(number) -> number\\n\\nReturn the absolute value of the argument.'
     """
-    result = inspect.getdoc(object) or inspect.getcomments(object)
+    result = inspect.getdoc(obj) or inspect.getcomments(obj)
     return result and RE_EMPTY_LINE.sub('', result.rstrip()) or ''
 
 
index 59c4f88251d39cd4b1245f9fc23b0aa1cf916dc3..269871b72305b5e5afc12892c5b20bad2330e2d2 100644 (file)
 # <pep8 compliant>
 import bpy
 import os
-import shutil
 from bpy.types import Operator
-from bpy_extras.io_utils import unpack_list
+
+from mathutils import Vector, Matrix
+
+
+def CLIP_spacees_walk(context, all_screens, tarea, tspace, callback, *args):
+    screens = bpy.data.screens if all_screens else [context.screen]
+
+    for screen in screens:
+        for area in screen.areas:
+            if area.type == tarea:
+                for space in area.spaces:
+                    if space.type == tspace:
+                        callback(space, *args)
+
+
+def CLIP_set_viewport_background(context, all_screens, clip, clip_user):
+    def set_background(space_v3d, clip, user):
+        bgpic = None
+
+        for x in space_v3d.background_images:
+            if x.source == 'MOVIE':
+                bgpic = x
+                break
+
+        if not bgpic:
+            bgpic = space_v3d.background_images.new()
+
+        bgpic.source = 'MOVIE'
+        bgpic.clip = clip
+        bgpic.clip_user.proxy_render_size = user.proxy_render_size
+        bgpic.clip_user.use_render_undistorted = True
+        bgpic.use_camera_clip = False
+        bgpic.view_axis = 'CAMERA'
+
+        space_v3d.show_background_images = True
+
+    CLIP_spacees_walk(context, all_screens, 'VIEW_3D', 'VIEW_3D',
+                      set_background, clip, clip_user)
 
 
 def CLIP_track_view_selected(sc, track):
@@ -51,8 +87,8 @@ class CLIP_OT_track_to_empty(Operator):
 
         ob = bpy.data.objects.new(name=track.name, object_data=None)
         ob.select = True
-        bpy.context.scene.objects.link(ob)
-        bpy.context.scene.objects.active = ob
+        context.scene.objects.link(ob)
+        context.scene.objects.active = ob
 
         for con in ob.constraints:
             if con.type == 'FOLLOW_TRACK':
@@ -77,11 +113,11 @@ class CLIP_OT_track_to_empty(Operator):
         return {'FINISHED'}
 
 
-class CLIP_OT_tracks_to_mesh(Operator):
-    """Create vertex cloud using coordinates of tracks"""
+class CLIP_OT_bundles_to_mesh(Operator):
+    """Create vertex cloud using coordinates of reconstructed tracks"""
 
-    bl_idname = "clip.tracks_to_mesh"
-    bl_label = "Tracks to Mesh"
+    bl_idname = "clip.bundles_to_mesh"
+    bl_label = "3D Markers to Mesh"
     bl_options = {'UNDO', 'REGISTER'}
 
     @classmethod
@@ -90,6 +126,8 @@ class CLIP_OT_tracks_to_mesh(Operator):
         return (sc.type == 'CLIP_EDITOR') and sc.clip
 
     def execute(self, context):
+        from bpy_extras.io_utils import unpack_list
+
         sc = context.space_data
         clip = sc.clip
 
@@ -106,7 +144,7 @@ class CLIP_OT_tracks_to_mesh(Operator):
 
         ob = bpy.data.objects.new(name="Tracks", object_data=mesh)
 
-        bpy.context.scene.objects.link(ob)
+        context.scene.objects.link(ob)
 
         return {'FINISHED'}
 
@@ -133,6 +171,8 @@ class CLIP_OT_delete_proxy(Operator):
         return wm.invoke_confirm(self, event)
 
     def _rmproxy(self, abspath):
+        import shutil
+
         if not os.path.exists(abspath):
             return
 
@@ -202,35 +242,9 @@ class CLIP_OT_set_viewport_background(Operator):
 
         return sc.clip
 
-    def _set_background(self, space_v3d, clip, user):
-        bgpic = None
-
-        for x in space_v3d.background_images:
-            if x.source == 'MOVIE':
-                bgpic = x
-                break
-
-        if not bgpic:
-            bgpic = space_v3d.background_images.new()
-
-        bgpic.source = 'MOVIE'
-        bgpic.clip = clip
-        bgpic.clip_user.proxy_render_size = user.proxy_render_size
-        bgpic.clip_user.use_render_undistorted = user.use_render_undistorted
-        bgpic.use_camera_clip = False
-        bgpic.view_axis = 'CAMERA'
-
-        space_v3d.show_background_images = True
-
     def execute(self, context):
         sc = context.space_data
-        clip = sc.clip
-
-        for area in context.window.screen.areas:
-            if area.type == 'VIEW_3D':
-                for space in area.spaces:
-                    if space.type == 'VIEW_3D':
-                        self._set_background(space, clip, sc.clip_user)
+        CLIP_set_viewport_background(context, False, sc.clip, sc.clip_user)
 
         return {'FINISHED'}
 
@@ -332,3 +346,432 @@ object's movement caused by this constraint"""
                 self._bake_object(scene, ob)
 
         return {'FINISHED'}
+
+
+class CLIP_OT_setup_tracking_scene(Operator):
+    """Prepare scene for compositing 3D objects into this footage"""
+
+    bl_idname = "clip.setup_tracking_scene"
+    bl_label = "Setup Tracking Scene"
+    bl_options = {'UNDO', 'REGISTER'}
+
+    @classmethod
+    def poll(cls, context):
+        sc = context.space_data
+
+        if sc.type != 'CLIP_EDITOR':
+            return False
+
+        clip = sc.clip
+
+        return clip and clip.tracking.reconstruction.is_valid
+
+    @staticmethod
+    def _setupScene(context):
+        scene = context.scene
+        scene.active_clip = context.space_data.clip
+
+    @staticmethod
+    def _setupWorld(context):
+        scene = context.scene
+        world = scene.world
+
+        if not world:
+            world = bpy.data.worlds.new(name="World")
+            scene.world = world
+
+        world.light_settings.use_ambient_occlusion = True
+        world.light_settings.ao_blend_type = 'MULTIPLY'
+
+        world.light_settings.use_environment_light = True
+        world.light_settings.environment_energy = 0.1
+
+        world.light_settings.distance = 1.0
+        world.light_settings.sample_method = 'ADAPTIVE_QMC'
+        world.light_settings.samples = 7
+        world.light_settings.threshold = 0.005
+
+    @staticmethod
+    def _findOrCreateCamera(context):
+        scene = context.scene
+
+        if scene.camera:
+            return scene.camera
+
+        cam = bpy.data.cameras.new(name="Camera")
+        camob = bpy.data.objects.new(name="Camera", object_data=cam)
+        scene.objects.link(camob)
+
+        scene.camera = camob
+
+        camob.matrix_local = (Matrix.Translation((7.481, -6.508, 5.344)) *
+            Matrix.Rotation(0.815, 4, 'Z') *
+            Matrix.Rotation(0.011, 4, 'Y') *
+            Matrix.Rotation(1.109, 4, 'X'))
+
+        return camob
+
+    @staticmethod
+    def _setupCamera(context):
+        camob = CLIP_OT_setup_tracking_scene._findOrCreateCamera(context)
+
+        # Remove all constraints to be sure motion is fine
+        camob.constraints.clear()
+
+        # Append camera solver constraint
+        con = camob.constraints.new(type='CAMERA_SOLVER')
+        con.use_active_clip = True
+        con.influence = 1.0
+
+    @staticmethod
+    def _setupViewport(context):
+        sc = context.space_data
+        CLIP_set_viewport_background(context, True, sc.clip, sc.clip_user)
+
+    @staticmethod
+    def _setupRenderLayers(context):
+        scene = context.scene
+        rlayers = scene.render.layers
+
+        if not scene.render.layers.get("Foreground"):
+            if len(rlayers) == 1:
+                fg = rlayers[0]
+                fg.name = 'Foreground'
+            else:
+                fg = scene.render.layers.new('Foreground')
+
+            fg.use_sky = False
+            fg.layers = [True] + [False] * 19
+            fg.layers_zmask = [False] * 10 + [True] + [False] * 9
+            fg.use_pass_vector = True
+
+        if not scene.render.layers.get("Background"):
+            bg = scene.render.layers.new('Background')
+            bg.use_pass_shadow = True
+            bg.use_pass_ambient_occlusion = True
+            bg.layers = [False] * 10 + [True] + [False] * 9
+
+    @staticmethod
+    def _findNode(tree, type):
+        for node in tree.nodes:
+            if node.type == type:
+                return node
+
+        return None
+
+    @staticmethod
+    def _findOrCreateNode(tree, type):
+        node = CLIP_OT_setup_tracking_scene._findNode(tree, type)
+
+        if not node:
+            node = tree.nodes.new(type=type)
+
+        return node
+
+    @staticmethod
+    def _needSetupNodes(context):
+        scene = context.scene
+        tree = scene.node_tree
+
+        if not tree:
+            # No compositor node tree found, time to create it!
+            return True
+
+        for node in tree.nodes:
+            if node.type in {'MOVIECLIP', 'MOVIEDISTORTION'}:
+                return False
+
+        return True
+
+    @staticmethod
+    def _offsetNodes(tree):
+        for a in tree.nodes:
+            for b in tree.nodes:
+                if a != b and a.location == b.location:
+                    b.location += Vector((40.0, 20.0))
+
+    def _setupNodes(self, context):
+        if not self._needSetupNodes(context):
+            # compositor nodes were already setup or even changes already
+            # do nothing to prevent nodes damage
+            return
+
+        # Enable backdrop for all compositor spaces
+        def setup_space(space):
+            space.show_backdrop = True
+
+        CLIP_spacees_walk(context, True, 'NODE_EDITOR', 'NODE_EDITOR',
+                          setup_space)
+
+        sc = context.space_data
+        scene = context.scene
+        scene.use_nodes = True
+        tree = scene.node_tree
+        clip = sc.clip
+
+        need_stabilization = False
+
+        # create nodes
+        rlayer_fg = self._findOrCreateNode(tree, 'R_LAYERS')
+        rlayer_bg = tree.nodes.new(type='R_LAYERS')
+        composite = self._findOrCreateNode(tree, 'COMPOSITE')
+
+        movieclip = tree.nodes.new(type='MOVIECLIP')
+        distortion = tree.nodes.new(type='MOVIEDISTORTION')
+
+        if need_stabilization:
+            stabilize = tree.nodes.new(type='STABILIZE2D')
+
+        scale = tree.nodes.new(type='SCALE')
+        invert = tree.nodes.new(type='INVERT')
+        add_ao = tree.nodes.new(type='MIX_RGB')
+        add_shadow = tree.nodes.new(type='MIX_RGB')
+        mul_shadow = tree.nodes.new(type='MIX_RGB')
+        mul_image = tree.nodes.new(type='MIX_RGB')
+        vector_blur = tree.nodes.new(type='VECBLUR')
+        alphaover = tree.nodes.new(type='ALPHAOVER')
+        viewer = tree.nodes.new(type='VIEWER')
+
+        # setup nodes
+        movieclip.clip = clip
+
+        distortion.clip = clip
+        distortion.distortion_type = 'UNDISTORT'
+
+        if need_stabilization:
+            stabilize.clip = clip
+
+        scale.space = 'RENDER_SIZE'
+
+        rlayer_bg.scene = scene
+        rlayer_bg.layer = "Background"
+
+        rlayer_fg.scene = scene
+        rlayer_fg.layer = "Foreground"
+
+        add_ao.blend_type = 'ADD'
+        add_shadow.blend_type = 'ADD'
+
+        mul_shadow.blend_type = 'MULTIPLY'
+        mul_shadow.inputs['Fac'].default_value = 0.8
+
+        mul_image.blend_type = 'MULTIPLY'
+        mul_image.inputs['Fac'].default_value = 0.8
+
+        vector_blur.factor = 0.75
+
+        # create links
+        tree.links.new(movieclip.outputs['Image'], distortion.inputs['Image'])
+
+        if need_stabilization:
+            tree.links.new(distortion.outputs['Image'],
+                stabilize.inputs['Image'])
+            tree.links.new(stabilize.outputs['Image'], scale.inputs['Image'])
+        else:
+            tree.links.new(distortion.outputs['Image'], scale.inputs['Image'])
+
+        tree.links.new(rlayer_bg.outputs['Alpha'], invert.inputs['Color'])
+
+        tree.links.new(invert.outputs['Color'], add_shadow.inputs[1])
+        tree.links.new(rlayer_bg.outputs['Shadow'], add_shadow.inputs[2])
+
+        tree.links.new(invert.outputs['Color'], add_ao.inputs[1])
+        tree.links.new(rlayer_bg.outputs['AO'], add_ao.inputs[2])
+
+        tree.links.new(add_ao.outputs['Image'], mul_shadow.inputs[1])
+        tree.links.new(add_shadow.outputs['Image'], mul_shadow.inputs[2])
+
+        tree.links.new(scale.outputs['Image'], mul_image.inputs[1])
+        tree.links.new(mul_shadow.outputs['Image'], mul_image.inputs[2])
+
+        tree.links.new(rlayer_fg.outputs['Image'], vector_blur.inputs['Image'])
+        tree.links.new(rlayer_fg.outputs['Z'], vector_blur.inputs['Z'])
+        tree.links.new(rlayer_fg.outputs['Speed'], vector_blur.inputs['Speed'])
+
+        tree.links.new(mul_image.outputs['Image'], alphaover.inputs[1])
+        tree.links.new(vector_blur.outputs['Image'], alphaover.inputs[2])
+
+        tree.links.new(alphaover.outputs['Image'], composite.inputs['Image'])
+        tree.links.new(alphaover.outputs['Image'], viewer.inputs['Image'])
+
+        # place nodes
+        movieclip.location = Vector((-300.0, 350.0))
+
+        distortion.location = movieclip.location
+        distortion.location += Vector((200.0, 0.0))
+
+        if need_stabilization:
+            stabilize.location = distortion.location
+            stabilize.location += Vector((200.0, 0.0))
+
+            scale.location = stabilize.location
+            scale.location += Vector((200.0, 0.0))
+        else:
+            scale.location = distortion.location
+            scale.location += Vector((200.0, 0.0))
+
+        rlayer_bg.location = movieclip.location
+        rlayer_bg.location -= Vector((0.0, 350.0))
+
+        invert.location = rlayer_bg.location
+        invert.location += Vector((250.0, 50.0))
+
+        add_ao.location = invert.location
+        add_ao.location[0] += 200
+        add_ao.location[1] = rlayer_bg.location[1]
+
+        add_shadow.location = add_ao.location
+        add_shadow.location -= Vector((0.0, 250.0))
+
+        mul_shadow.location = add_ao.location
+        mul_shadow.location += Vector((200.0, -50.0))
+
+        mul_image.location = mul_shadow.location
+        mul_image.location += Vector((300.0, 200.0))
+
+        rlayer_fg.location = rlayer_bg.location
+        rlayer_fg.location -= Vector((0.0, 500.0))
+
+        vector_blur.location[0] = mul_image.location[0]
+        vector_blur.location[1] = rlayer_fg.location[1]
+
+        alphaover.location[0] = vector_blur.location[0] + 350
+        alphaover.location[1] = \
+            (vector_blur.location[1] + mul_image.location[1]) / 2
+
+        composite.location = alphaover.location
+        composite.location += Vector((200.0, -100.0))
+
+        viewer.location = composite.location
+        composite.location += Vector((0.0, 200.0))
+
+        # ensure no nodes were creates on position of existing node
+        self._offsetNodes(tree)
+
+    @staticmethod
+    def _createMesh(scene, name, vertices, faces):
+        from bpy_extras.io_utils import unpack_list, unpack_face_list
+
+        mesh = bpy.data.meshes.new(name=name)
+
+        mesh.vertices.add(len(vertices))
+        mesh.vertices.foreach_set("co", unpack_list(vertices))
+
+        mesh.faces.add(len(faces))
+        mesh.faces.foreach_set("vertices_raw", unpack_face_list(faces))
+
+        mesh.update(calc_edges=True)
+
+        ob = bpy.data.objects.new(name=name, object_data=mesh)
+
+        scene.objects.link(ob)
+
+        return ob
+
+    @staticmethod
+    def _getPlaneVertices(half_size, z):
+
+        return [(-half_size, -half_size, z),
+                (-half_size, half_size, z),
+                (half_size, half_size, z),
+                (half_size, -half_size, z)]
+
+    def _createGround(self, scene):
+        vertices = self._getPlaneVertices(4.0, 0.0)
+        faces = [(0, 1, 2, 3)]
+
+        ob = self._createMesh(scene, "Ground", vertices, faces)
+        ob["is_ground"] = True
+
+        return ob
+
+    @staticmethod
+    def _findGround(context):
+        scene = context.scene
+
+        for ob in scene.objects:
+            if ob.type == 'MESH' and "is_ground" in ob:
+                return ob
+
+        return None
+
+    @staticmethod
+    def _mergeLayers(layers_a, layers_b):
+
+        return [(layers_a[i] | layers_b[i]) for i in range(len(layers_a))]
+
+    @staticmethod
+    def _createLamp(scene):
+        lamp = bpy.data.lamps.new(name="Lamp", type='POINT')
+        lampob = bpy.data.objects.new(name="Lamp", object_data=lamp)
+        scene.objects.link(lampob)
+
+        lampob.matrix_local = Matrix.Translation((4.076, 1.005, 5.904))
+
+        lamp.distance = 30
+        lamp.shadow_method = 'RAY_SHADOW'
+
+        return lampob
+
+    def _createSampleObject(self, scene):
+        vertices = self._getPlaneVertices(1.0, -1.0) + \
+            self._getPlaneVertices(1.0, 1.0)
+        faces = ((0, 1, 2, 3),
+                 (4, 7, 6, 5),
+                 (0, 4, 5, 1),
+                 (1, 5, 6, 2),
+                 (2, 6, 7, 3),
+                 (3, 7, 4, 0))
+
+        return self._createMesh(scene, "Cube", vertices, faces)
+
+    def _setupObjects(self, context):
+        scene = context.scene
+
+        fg = scene.render.layers.get("Foreground")
+        bg = scene.render.layers.get("Background")
+
+        all_layers = self._mergeLayers(fg.layers, bg.layers)
+
+        # enshure all lamps are active on foreground and background
+        has_lamp = False
+        has_mesh = False
+        for ob in scene.objects:
+            if ob.type == 'LAMP':
+                ob.layers = all_layers
+                has_lamp = True
+            elif ob.type == 'MESH' and "is_ground" not in ob:
+                has_mesh = True
+
+        # create sample lamp if there's no lamps in the scene
+        if not has_lamp:
+            lamp = self._createLamp(scene)
+            lamp.layers = all_layers
+
+        # create sample object if there's no meshes in the scene
+        if not has_mesh:
+            ob = self._createSampleObject(scene)
+            ob.layers = fg.layers
+
+        # create ground object if needed
+        ground = self._findGround(context)
+        if not ground:
+            ground = self._createGround(scene)
+            ground.layers = bg.layers
+        else:
+            # make sure ground is available on Background layer
+            ground.layers = self._mergeLayers(ground.layers, bg.layers)
+
+        # layers with background and foreground should be rendered
+        scene.layers = self._mergeLayers(scene.layers, all_layers)
+
+    def execute(self, context):
+        self._setupScene(context)
+        self._setupWorld(context)
+        self._setupCamera(context)
+        self._setupViewport(context)
+        self._setupRenderLayers(context)
+        self._setupNodes(context)
+        self._setupObjects(context)
+
+        return {'FINISHED'}
index ae4add72a084454175208470abf48433324fbbd3..99a492fab4af6598b9a56d6d52e885d3c670ae19 100644 (file)
@@ -566,8 +566,8 @@ class LightMapPack(Operator):
             default=True,
             )
     PREF_NEW_UVLAYER = BoolProperty(
-            name="New UV Layer",
-            description="Create a new UV layer for every mesh packed",
+            name="New UV Map",
+            description="Create a new UV map for every mesh packed",
             default=False,
             )
     PREF_APPLY_IMAGE = BoolProperty(
index 425b7a601c8190bf02876e8d22612d6ebb48b299..4e52aeb03d2f5cd1832fcb9a346bea9b8cc31f12 100644 (file)
@@ -265,7 +265,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
 
 
 class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
-    bl_label = "UV Texture"
+    bl_label = "UV Maps"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def draw(self, context):
index 288f04b084e5340e2d93b7a279a36c0f33dc9987..5e9f863d22bccb7d113b89cbb3f5abae74797e54 100644 (file)
@@ -454,15 +454,15 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         layout.separator()
 
         layout.prop(md, "use_normals")
-        
+
         split = layout.split()
-        
+
         col = split.column()
         col.prop(md, "use_foam")
         sub = col.row()
         sub.active = md.use_foam
         sub.prop(md, "foam_coverage", text="Coverage")
-        
+
         col = split.column()
         col.active = md.use_foam
         col.label("Foam Data Layer Name:")
@@ -692,7 +692,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "image", text="")
 
         col = split.column()
-        col.label(text="UV Layer:")
+        col.label(text="UV Map:")
         col.prop_search(md, "uv_layer", ob.data, "uv_textures", text="")
 
         split = layout.split()
index 877b6c0893d9423b243683696a3255cf3be67644..db65b0ff669cb800dced57aeddae3e386a0ac81a 100644 (file)
@@ -408,7 +408,7 @@ class SceneButtonsPanel():
 
 class SCENE_PT_game_navmesh(SceneButtonsPanel, Panel):
     bl_label = "Navigation mesh"
-    bl_default_closed = True
+    bl_options = {'DEFAULT_CLOSED'}
     COMPAT_ENGINES = {'BLENDER_GAME'}
 
     @classmethod
index 68fa0cedaa319d5b116f2679929a5a644abc4d47..3797d7f363c6590935966a2b1220015f2406b03e 100644 (file)
@@ -242,7 +242,7 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
         # image format outputs
         if surface.surface_format == 'IMAGE':
             layout.operator("dpaint.bake", text="Bake Image Sequence", icon='MOD_DYNAMICPAINT')
-            layout.prop_search(surface, "uv_layer", ob.data, "uv_textures", text="UV layer:")
+            layout.prop_search(surface, "uv_layer", ob.data, "uv_textures", text="UV Map:")
             layout.separator()
 
             layout.prop(surface, "image_output_path", text="")
@@ -300,7 +300,7 @@ class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel):
 
         elif surface.init_color_type == 'TEXTURE':
             layout.prop(surface, "init_texture")
-            layout.prop_search(surface, "init_layername", ob.data, "uv_textures", text="UV Layer:")
+            layout.prop_search(surface, "init_layername", ob.data, "uv_textures", text="UV Map:")
 
         elif surface.init_color_type == 'VERTEX_COLOR':
             layout.prop_search(surface, "init_layername", ob.data, "vertex_colors", text="Color Layer: ")
index 85b5f3f0dd47cd18b96d74f4616a080dd98e622d..aa6e2ce7cffaf37043de148000bbad14b89926e6 100644 (file)
@@ -972,66 +972,19 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
         layout = self.layout
 
         rd = context.scene.render
-        file_format = rd.file_format
+        image_settings = rd.image_settings
+        file_format = rd.image_settings.file_format
 
         layout.prop(rd, "filepath", text="")
 
-        split = layout.split()
-
-        col = split.column()
-        col.prop(rd, "file_format", text="")
-        col.row().prop(rd, "color_mode", text="Color", expand=True)
-
-        col = split.column()
-        col.prop(rd, "use_file_extension")
-        col.prop(rd, "use_overwrite")
-        col.prop(rd, "use_placeholder")
-
-        if file_format in {'AVI_JPEG', 'JPEG'}:
-            layout.prop(rd, "file_quality", slider=True)
-
-        if file_format == 'PNG':
-            layout.prop(rd, "file_quality", slider=True, text="Compression")
-
-        if file_format in {'OPEN_EXR', 'MULTILAYER'}:
-            row = layout.row()
-            row.prop(rd, "exr_codec", text="Codec")
-
-            if file_format == 'OPEN_EXR':
-                row = layout.row()
-                row.prop(rd, "use_exr_half")
-                row.prop(rd, "exr_zbuf")
-                row.prop(rd, "exr_preview")
-
-        elif file_format == 'JPEG2000':
-            split = layout.split()
-            col = split.column()
-            col.label(text="Depth:")
-            col.row().prop(rd, "jpeg2k_depth", expand=True)
-
-            col = split.column()
-            col.prop(rd, "jpeg2k_preset", text="")
-            col.prop(rd, "jpeg2k_ycc")
-
-        elif file_format in {'CINEON', 'DPX'}:
-
-            split = layout.split()
-            split.label("FIXME: hard coded Non-Linear, Gamma:1.0")
-            '''
-            col = split.column()
-            col.prop(rd, "use_cineon_log", text="Convert to Log")
-
-            col = split.column(align=True)
-            col.active = rd.use_cineon_log
-            col.prop(rd, "cineon_black", text="Black")
-            col.prop(rd, "cineon_white", text="White")
-            col.prop(rd, "cineon_gamma", text="Gamma")
-            '''
+        flow = layout.column_flow()
+        flow.prop(rd, "use_overwrite")
+        flow.prop(rd, "use_placeholder")
+        flow.prop(rd, "use_file_extension")
 
-        elif file_format == 'TIFF':
-            layout.prop(rd, "use_tiff_16bit")
+        layout.template_image_settings(rd.image_settings)
 
-        elif file_format == 'QUICKTIME_CARBON':
+        if file_format == 'QUICKTIME_CARBON':
             layout.operator("scene.render_data_set_quicktime_codec")
 
         elif file_format == 'QUICKTIME_QTKIT':
@@ -1072,7 +1025,7 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         rd = context.scene.render
-        return rd.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
+        return rd.image_settings.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
 
     def draw(self, context):
         layout = self.layout
index 6b4cfa8fb9587b38d18fd2e877f457dac5e89d3b..9f67edd76532f58c2f221d3f069e8fc256e229be 100644 (file)
@@ -831,7 +831,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
                 """
             elif tex.texture_coords == 'UV':
                 split = layout.split(percentage=0.3)
-                split.label(text="Layer:")
+                split.label(text="Map:")
                 ob = context.object
                 if ob and ob.type == 'MESH':
                     split.prop_search(tex, "uv_layer", ob.data, "uv_textures", text="")
index a70d632e8b0691b57b6cffa0ddc968e238742ca1..b04d81b6b2a6aeaab2b24bb3e239796a30ac8a7e 100644 (file)
@@ -210,7 +210,7 @@ class CLIP_PT_tools_geometry(Panel):
     def draw(self, context):
         layout = self.layout
 
-        layout.operator("clip.tracks_to_mesh")
+        layout.operator("clip.bundles_to_mesh")
         layout.operator("clip.track_to_empty")
 
 
@@ -402,15 +402,15 @@ class CLIP_PT_display(Panel):
         col.prop(sc, "show_marker_search", text="Search")
         col.prop(sc, "show_pyramid_levels", text="Pyramid")
 
-        col.prop(sc, "show_track_path", text="Track Path")
+        col.prop(sc, "show_track_path", text="Path")
         row = col.row()
         row.active = sc.show_track_path
         row.prop(sc, "path_length", text="Length")
 
         col.prop(sc, "show_disabled", "Disabled Tracks")
-        col.prop(sc, "show_bundles", text="Bundles")
+        col.prop(sc, "show_bundles", text="3D Markers")
 
-        col.prop(sc, "show_names", text="Track Names and Status")
+        col.prop(sc, "show_names", text="Names and Status")
         col.prop(sc, "show_tiny_markers", text="Compact Markers")
 
         col.prop(sc, "show_grease_pencil", text="Grease Pencil")
@@ -475,7 +475,7 @@ class CLIP_PT_stabilization(Panel):
 
     def draw_header(self, context):
         stab = context.space_data.clip.tracking.stabilization
-        
+
         self.layout.prop(stab, "use_2d_stabilization", text="")
 
     def draw(self, context):
@@ -640,6 +640,7 @@ class CLIP_PT_tools_clip(Panel):
         layout = self.layout
 
         layout.operator("clip.set_viewport_background")
+        layout.operator("clip.setup_tracking_scene")
 
 
 class CLIP_MT_view(Menu):
index 0753b49f69fe383a00f9f81e112cc7fd349a1d4e..67a8c28ddb815a00e452be1c91a016acce27b3bb 100644 (file)
@@ -262,6 +262,7 @@ class VIEW3D_MT_uv_map(Menu):
 
         layout.separator()
 
+        layout.operator_context = 'EXEC_REGION_WIN'
         layout.operator("uv.project_from_view")
         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
 
@@ -1767,7 +1768,7 @@ class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
         edit_object = context.edit_object
 
         if edit_object.type == 'CURVE':
-            layout.operator("transform.transform", text="Tilt").mode = 'TILT'
+            layout.operator("transform.tilt")
             layout.operator("curve.tilt_clear")
             layout.operator("curve.separate")
 
@@ -2213,7 +2214,7 @@ class VIEW3D_PT_view3d_motion_tracking(Panel):
 
         col = layout.column()
         col.active = view.show_reconstruction
-        col.prop(view, "show_tracks_name")
+        col.prop(view, "show_bundle_names")
         col.prop(view, "show_camera_path")
         col.label(text="Tracks:")
         col.prop(view, "tracks_draw_type", text="")
index 5bcdbc1efe8f81ae2754d08b2d0d10ffe3fe2ac6..ddea7bd00fdeff6e719e7190ed3be1afac7c2f24 100644 (file)
@@ -88,7 +88,7 @@ class VIEW3D_PT_tools_objectmode(View3DPanel, Panel):
         col.operator("object.join")
 
         active_object = context.active_object
-        if active_object and active_object.type == 'MESH':
+        if active_object and active_object.type in {'MESH', 'CURVE', 'SURFACE'}:
 
             col = layout.column(align=True)
             col.label(text="Shading:")
index 4da67f59ff75f8fb08924d38cbd74d60c2b6cfe1..b82393fad92d4547ddd681b67365d00823ebd87f 100644 (file)
@@ -129,7 +129,7 @@ void BLF_dir_free(char **dirs, int count)
 char *blf_dir_search(const char *file)
 {
        DirBLF *dir;
-       char full_path[FILE_MAXDIR+FILE_MAXFILE];
+       char full_path[FILE_MAX];
        char *s= NULL;
 
        for(dir=global_font_dir.first; dir; dir= dir->next) {
index 15fdc2fe30759e921f8fbc4ad6f5cbb29eba988d..84f1bf75a3f2e64ed69b4cdbc9c323a822512e58 100644 (file)
@@ -526,7 +526,7 @@ int editmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct E
 int sculpt_get_deform_matrices(struct Scene *scene, struct Object *ob,
                                                                float (**deformmats)[3][3], float (**deformcos)[3]);
 
-void weight_to_rgb(float input, float *fr, float *fg, float *fb);
+void weight_to_rgb(float r_rgb[3], const float weight);
 
 /* convert layers requested by a GLSL material to actually available layers in
  * the DerivedMesh, with both a pointer for arrays and an offset for editmesh */
index a3e0b5b6d5a9dfe221ed69ce2b9e97ca709759fe..c829fc69b051b0b493234c18938991257acb7fd0 100644 (file)
@@ -43,6 +43,7 @@ struct Tex;
 struct anim;
 struct Scene;
 struct Object;
+struct ImageFormatData;
 
 /* call from library */
 void   free_image(struct Image *me);
@@ -50,13 +51,22 @@ void        free_image(struct Image *me);
 void   BKE_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf);
 void   BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels);
 int            BKE_alphatest_ibuf(struct ImBuf *ibuf);
-int            BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
-int            BKE_write_ibuf(struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
-void   BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, int imtype, const short use_ext, const short use_frames);
-int            BKE_add_image_extension(char *string, int imtype);
-int            BKE_ftype_to_imtype(int ftype);
-int            BKE_imtype_to_ftype(int imtype);
-int            BKE_imtype_is_movie(int imtype);
+int            BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
+int            BKE_write_ibuf(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
+int     BKE_write_ibuf_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const short is_copy);
+void   BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, char imtype, const short use_ext, const short use_frames);
+int            BKE_add_image_extension(char *string, const char imtype);
+char   BKE_ftype_to_imtype(const int ftype);
+int            BKE_imtype_to_ftype(char imtype);
+
+int            BKE_imtype_is_movie(const char imtype);
+int            BKE_imtype_supports_zbuf(const char imtype);
+int            BKE_imtype_supports_compress(const char imtype);
+int            BKE_imtype_supports_quality(const char imtype);
+char    BKE_imtype_valid_channels(const char imtype);
+char   BKE_imtype_valid_depths(const char imtype);
+
+char    BKE_imtype_from_arg(const char *arg);
 
 struct anim *openanim(const char *name, int flags, int streamindex);
 
@@ -105,6 +115,10 @@ struct RenderResult;
        /* image-user gets a new image, check settings */
 #define IMA_SIGNAL_USER_NEW_IMAGE      6
 
+#define IMA_CHAN_FLAG_BW    1
+#define IMA_CHAN_FLAG_RGB   2
+#define IMA_CHAN_FLAG_ALPHA 4
+
 /* depending Image type, and (optional) ImageUser setting it returns ibuf */
 /* always call to make signals work */
 struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser);
index 8e7645d721ead589c6ad6d82c06f2ef09a1c303f..0079ecb7d9c37739de541be9364c5c4ee97c1439 100644 (file)
@@ -91,7 +91,7 @@ void end_render_materials(struct Main *);
 
 int material_in_material(struct Material *parmat, struct Material *mat);
 
-void ramp_blend(int type, float *r, float *g, float *b, float fac, const float col[3]);
+void   ramp_blend(int type, float r_col[3], const float fac, const float col[3]);
 
 /* copy/paste */
 void clear_matcopybuf(void);
index c66e49f29069e499cc1964e18aae1902048da0b6..f491761f3f2abd64e12fc6266f36b8b38f6d6f8f 100644 (file)
@@ -217,7 +217,7 @@ typedef struct ParticleDrawData {
        float *ndata, *nd;              /* normal data */
        float *cdata, *cd;              /* color data */
        float *vedata, *ved;    /* velocity data */
-       float *ma_r, *ma_g, *ma_b;
+       float *ma_col;
        int tot_vec_size, flag;
        int totpoint, totve;
 } ParticleDrawData;
index 9f4fae7dc2e3bfbf9c2198bf2e4919c2db1dfecc..d1b0acf7142d5b36ab7c2251a33d922891c64fda 100644 (file)
@@ -127,6 +127,9 @@ typedef struct PTCacheID {
        unsigned int stack_index;
        unsigned int flag;
 
+       unsigned int default_step;
+       unsigned int max_step;
+
        /* flags defined in DNA_object_force.h */
        unsigned int data_types, info_types;
 
index f2502cf25f7329e7c62cc7e9f0c7322a69fd6727..01a16be18ca2985cbbe827dfb001a270f9a70717 100644 (file)
@@ -50,7 +50,7 @@ typedef struct bMovieHandle {
        void (*get_movie_path)(char *string, struct RenderData *rd); /* optional */
 } bMovieHandle;
 
-bMovieHandle *BKE_get_movie_handle(int imtype);
+bMovieHandle *BKE_get_movie_handle(const char imtype);
 void BKE_makeanimstring(char *string, struct RenderData *rd);
 
 #ifdef __cplusplus
index 4793e83df53f1a308dce5f235878e695573f56f3..140f596f78c0a3f052f8d1ffa6494c67a60636b1 100644 (file)
@@ -2301,14 +2301,16 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
        /* zero */
        for (i=0; i<numEffectedV; i++) {
                CCGVert *v = effectedV[i];
-               VertDataZero(VERT_getCo(v, lvl));
+               if(v->numFaces)
+                       VertDataZero(VERT_getCo(v, lvl));
        }
 
        for (i=0; i<numEffectedE; i++) {
                CCGEdge *e = effectedE[i];
 
-               for (x=0; x<edgeSize; x++)
-                       VertDataZero(EDGE_getCo(e, lvl, x));
+               if(e->numFaces)
+                       for (x=0; x<edgeSize; x++)
+                               VertDataZero(EDGE_getCo(e, lvl, x));
        }
 
        /* add */
@@ -2349,7 +2351,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
        /* average */
        for (i=0; i<numEffectedV; i++) {
                CCGVert *v = effectedV[i];
-               VertDataMulN(VERT_getCo(v, lvl), 1.0f/v->numFaces);
+               if(v->numFaces)
+                       VertDataMulN(VERT_getCo(v, lvl), 1.0f/v->numFaces);
        }
 
        for (i=0; i<numEffectedE; i++) {
@@ -2358,8 +2361,9 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
                VertDataCopy(EDGE_getCo(e, lvl, 0), VERT_getCo(e->v0, lvl));
                VertDataCopy(EDGE_getCo(e, lvl, edgeSize-1), VERT_getCo(e->v1, lvl));
 
-               for (x=1; x<edgeSize-1; x++)
-                       VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f/e->numFaces);
+               if(e->numFaces)
+                       for (x=1; x<edgeSize-1; x++)
+                               VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f/e->numFaces);
        }
 
        /* copy */
index a76ea1852ded4f636c20712ff65c2bc05e86d3ba..216dbf8b2c269f40a55c1ff2385df5b56a1c6cf3 100644 (file)
@@ -1777,31 +1777,29 @@ static void add_orco_dm(Object *ob, EditMesh *em, DerivedMesh *dm, DerivedMesh *
  * happens on enter/exit wpaint.
  */
 
-void weight_to_rgb(float input, float *fr, float *fg, float *fb)
+void weight_to_rgb(float r_rgb[3], const float weight)
 {
-       float blend;
-       
-       blend= ((input/2.0f)+0.5f);
-       
-       if (input<=0.25f){      // blue->cyan
-               *fr= 0.0f;
-               *fg= blend*input*4.0f;
-               *fb= blend;
+       const float blend= ((weight/2.0f)+0.5f);
+
+       if (weight<=0.25f){     // blue->cyan
+               r_rgb[0]= 0.0f;
+               r_rgb[1]= blend*weight*4.0f;
+               r_rgb[2]= blend;
        }
-       else if (input<=0.50f){ // cyan->green
-               *fr= 0.0f;
-               *fg= blend;
-               *fb= blend*(1.0f-((input-0.25f)*4.0f)); 
+       else if (weight<=0.50f){        // cyan->green
+               r_rgb[0]= 0.0f;
+               r_rgb[1]= blend;
+               r_rgb[2]= blend*(1.0f-((weight-0.25f)*4.0f));
        }
-       else if (input <= 0.75f){       // green->yellow
-               *fr= blend * ((input-0.50f)*4.0f);
-               *fg= blend;
-               *fb= 0.0f;
+       else if (weight <= 0.75f){      // green->yellow
+               r_rgb[0]= blend * ((weight-0.50f)*4.0f);
+               r_rgb[1]= blend;
+               r_rgb[2]= 0.0f;
        }
-       else if (input <= 1.0f){ // yellow->red
-               *fr= blend;
-               *fg= blend * (1.0f-((input-0.75f)*4.0f)); 
-               *fb= 0.0f;
+       else if (weight <= 1.0f){ // yellow->red
+               r_rgb[0]= blend;
+               r_rgb[1]= blend * (1.0f-((weight-0.75f)*4.0f));
+               r_rgb[2]= 0.0f;
        }
 }
 
@@ -1866,7 +1864,7 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u
        if(coba)
                do_colorband(coba, input, colf);
        else
-               weight_to_rgb(input, colf, colf+1, colf+2);
+               weight_to_rgb(colf, input);
        
        col[3] = (unsigned char)(colf[0] * 255.0f);
        col[2] = (unsigned char)(colf[1] * 255.0f);
@@ -2131,9 +2129,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                                        DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
                                        DM_add_face_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
 
-                                       range_vni(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0);
-                                       range_vni(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0);
-                                       range_vni(DM_get_face_data_layer(dm, CD_ORIGINDEX), dm->numFaceData, 0);
+                                       range_vn_i(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0);
+                                       range_vn_i(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0);
+                                       range_vn_i(DM_get_face_data_layer(dm, CD_ORIGINDEX), dm->numFaceData, 0);
                                }
                        }
 
index 0e8d598da3d5ac63107bf498680aeba33941c5e0..a8644618945ee58aa459f77b24b545b5e0c0d26e 100644 (file)
@@ -451,7 +451,7 @@ int blender_test_break(void)
 #define MAXUNDONAME    64
 typedef struct UndoElem {
        struct UndoElem *next, *prev;
-       char str[FILE_MAXDIR+FILE_MAXFILE];
+       char str[FILE_MAX];
        char name[MAXUNDONAME];
        MemFile memfile;
        uintptr_t undosize;
@@ -536,7 +536,7 @@ void BKE_write_undo(bContext *C, const char *name)
        /* disk save version */
        if(UNDO_DISK) {
                static int counter= 0;
-               char filepath[FILE_MAXDIR+FILE_MAXFILE];
+               char filepath[FILE_MAX];
                char numstr[32];
                int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
 
@@ -702,7 +702,7 @@ void BKE_undo_save_quit(void)
        UndoElem *uel;
        MemFileChunk *chunk;
        int file;
-       char str[FILE_MAXDIR+FILE_MAXFILE];
+       char str[FILE_MAX];
        
        if( (U.uiflag & USER_GLOBALUNDO)==0) return;
        
index f1e6de9a0c482ebede89992a80b57b637e773ee7..0211dcdf42c067acff2d5f08cc5ccd7dc57b1052 100644 (file)
@@ -159,7 +159,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step)
                ibuf->userdata = bmfont;
                ibuf->userflags |= IB_BITMAPFONT;
 
-               if (ibuf->depth < 32) {
+               if (ibuf->planes < 32) {
                        // we're going to fake alpha here:
                        calcAlpha(ibuf);
                }
index 8a6e8faf29af2055e15715ab6c397d8fa4266460..358c63b4f9f819384d02a8847f5c14b124eeabcd 100644 (file)
@@ -169,6 +169,7 @@ Curve *add_curve(const char *name, int type)
        cu->texflag= CU_AUTOSPACE;
        cu->smallcaps_scale= 0.75f;
        cu->twist_mode= CU_TWIST_MINIMUM;       // XXX: this one seems to be the best one in most cases, at least for curve deform...
+       cu->type= type;
        
        cu->bb= unit_boundbox();
        
@@ -303,16 +304,23 @@ ListBase *curve_editnurbs(Curve *cu)
 short curve_type(Curve *cu)
 {
        Nurb *nu;
+       int type= cu->type;
+
        if(cu->vfont) {
                return OB_FONT;
        }
-       for (nu= cu->nurb.first; nu; nu= nu->next) {
-               if(nu->pntsv>1) {
-                       return OB_SURF;
+
+       if(!cu->type) {
+               type= OB_CURVE;
+
+               for (nu= cu->nurb.first; nu; nu= nu->next) {
+                       if(nu->pntsv>1) {
+                               type= OB_SURF;
+                       }
                }
        }
-       
-       return OB_CURVE;
+
+       return type;
 }
 
 void update_curve_dimension(Curve *cu)
index 9cbed451c09ff5e730b637a2b3a2ed2e199e50a5..6efd0a2727f71b81215eaa734b721e9fbbeee8db 100644 (file)
@@ -818,7 +818,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        /* 4: CD_MFACE */
        {sizeof(MFace), "MFace", 1, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 5: CD_MTFACE */
-       {sizeof(MTFace), "MTFace", 1, "UVTex", layerCopy_tface, NULL,
+       {sizeof(MTFace), "MTFace", 1, "UVMap", layerCopy_tface, NULL,
         layerInterp_tface, layerSwap_tface, layerDefault_tface},
        /* 6: CD_MCOL */
        /* 4 MCol structs per face */
@@ -838,7 +838,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        /* 12: CD_PROP_STR */
        {sizeof(MStringProperty), "MStringProperty",1,"String",NULL,NULL,NULL,NULL},
        /* 13: CD_ORIGSPACE */
-       {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVTex", layerCopy_origspace_face, NULL,
+       {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVMap", layerCopy_origspace_face, NULL,
         layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face},
        /* 14: CD_ORCO */
        {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
index 36ae764198a6935d117f016dcd21ec5015fc06da..519ac1cf53417068688c6a37b33c5377a23f5f76 100644 (file)
@@ -976,7 +976,7 @@ struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett
        surface->wave_timescale = 1.0f;
        surface->wave_spring = 0.20f;
 
-       modifier_path_init(surface->image_output_path, sizeof(surface->image_output_path), "dynamicpaint");
+       modifier_path_init(surface->image_output_path, sizeof(surface->image_output_path), "cache_dynamicpaint");
 
        dynamicPaintSurface_setUniqueName(surface, "Surface");
 
@@ -1307,7 +1307,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
 
                if (!tex) return;
 
-               /* get uv layer */
+               /* get uv map */
                CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, surface->init_layername, uvname);
                tface = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname);
                if (!tface) return;
@@ -1681,7 +1681,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                                        for (; j<((mface[i].v4)?4:3); j++) {
                                                                                int index = (j==0)?mface[i].v1: (j==1)?mface[i].v2: (j==2)?mface[i].v3: mface[i].v4;
 
-                                                                               weight_to_rgb(weight[index], temp_color, temp_color+1, temp_color+2);
+                                                                               weight_to_rgb(temp_color, weight[index]);
                                                                                col[i*4+j].r = FTOCHAR(temp_color[2]);
                                                                                col[i*4+j].g = FTOCHAR(temp_color[1]);
                                                                                col[i*4+j].b = FTOCHAR(temp_color[0]);
@@ -2094,7 +2094,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
        numOfFaces = dm->getNumFaces(dm);
        mface = dm->getFaceArray(dm);
 
-       /* get uv layer */
+       /* get uv map */
        CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, surface->uvlayer_name, uvname);
        tface = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname);
 
@@ -2527,13 +2527,13 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam
        PaintSurfaceData *sData = surface->data;
        ImgSeqFormatData *f_data = (ImgSeqFormatData*)sData->format_data;
        /* OpenEXR or PNG       */
-       int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_OPENEXR : R_PNG;
+       int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_IMF_IMTYPE_OPENEXR : R_IMF_IMTYPE_PNG;
        char output_file[FILE_MAX];
 
        if (!sData || !sData->type_data) {setError(surface->canvas, "Image save failed: Invalid surface.");return;}
        /* if selected format is openexr, but current build doesnt support one */
        #ifndef WITH_OPENEXR
-       if (format == R_OPENEXR) format = R_PNG;
+       if (format == R_IMF_IMTYPE_OPENEXR) format = R_IMF_IMTYPE_PNG;
        #endif
        BLI_strncpy(output_file, filename, sizeof(output_file));
        BKE_add_image_extension(output_file, format);
@@ -2622,7 +2622,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam
        /* Set output format, png in case exr isnt supported */
        ibuf->ftype= PNG|95;
 #ifdef WITH_OPENEXR
-       if (format == R_OPENEXR) {      /* OpenEXR 32-bit float */
+       if (format == R_IMF_IMTYPE_OPENEXR) {   /* OpenEXR 32-bit float */
                ibuf->ftype = OPENEXR | OPENEXR_COMPRESS;
        }
 #endif
index a61ae70502024a8ee9b6bab442b9b6f7aecca8a7..c7f74f37a2d83604561c50f9212ff716fcf0788c 100644 (file)
@@ -556,13 +556,13 @@ Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *n
        if (ima) {
                ImBuf *ibuf;
                
-               BLI_strncpy(ima->name, name, FILE_MAX);
+               /* BLI_strncpy(ima->name, name, FILE_MAX); */ /* dont do this, this writes in ain invalid filepath! */
                ima->gen_x= width;
                ima->gen_y= height;
                ima->gen_type= uvtestgrid;
                ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
                
-               ibuf= add_ibuf_size(width, height, name, depth, floatbuf, uvtestgrid, color);
+               ibuf= add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color);
                image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
                
                ima->ok= IMA_OK_LOADED;
@@ -601,7 +601,7 @@ void BKE_image_memorypack(Image *ima)
        }
        
        ibuf->ftype= PNG;
-       ibuf->depth= 32;
+       ibuf->planes= R_IMF_PLANES_RGBA;
        
        IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem);
        if(ibuf->encodedbuffer==NULL) {
@@ -800,175 +800,302 @@ void BKE_image_all_free_anim_ibufs(int cfra)
 
 /* *********** READ AND WRITE ************** */
 
-int BKE_imtype_to_ftype(int imtype)
+int BKE_imtype_to_ftype(const char imtype)
 {
-       if(imtype==R_TARGA)
+       if(imtype==R_IMF_IMTYPE_TARGA)
                return TGA;
-       else if(imtype==R_RAWTGA)
+       else if(imtype==R_IMF_IMTYPE_RAWTGA)
                return RAWTGA;
-       else if(imtype== R_IRIS) 
+       else if(imtype== R_IMF_IMTYPE_IRIS) 
                return IMAGIC;
 #ifdef WITH_HDR
-       else if (imtype==R_RADHDR)
+       else if (imtype==R_IMF_IMTYPE_RADHDR)
                return RADHDR;
 #endif
-       else if (imtype==R_PNG)
+       else if (imtype==R_IMF_IMTYPE_PNG)
                return PNG;
 #ifdef WITH_DDS
-       else if (imtype==R_DDS)
+       else if (imtype==R_IMF_IMTYPE_DDS)
                return DDS;
 #endif
-       else if (imtype==R_BMP)
+       else if (imtype==R_IMF_IMTYPE_BMP)
                return BMP;
 #ifdef WITH_TIFF
-       else if (imtype==R_TIFF)
+       else if (imtype==R_IMF_IMTYPE_TIFF)
                return TIF;
 #endif
-       else if (imtype==R_OPENEXR || imtype==R_MULTILAYER)
+       else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER)
                return OPENEXR;
 #ifdef WITH_CINEON
-       else if (imtype==R_CINEON)
+       else if (imtype==R_IMF_IMTYPE_CINEON)
                return CINEON;
-       else if (imtype==R_DPX)
+       else if (imtype==R_IMF_IMTYPE_DPX)
                return DPX;
 #endif
 #ifdef WITH_OPENJPEG
-       else if(imtype==R_JP2)
+       else if(imtype==R_IMF_IMTYPE_JP2)
                return JP2;
 #endif
        else
                return JPG|90;
 }
 
-int BKE_ftype_to_imtype(int ftype)
+char BKE_ftype_to_imtype(const int ftype)
 {
        if(ftype==0)
-               return TGA;
+               return R_IMF_IMTYPE_TARGA;
        else if(ftype == IMAGIC) 
-               return R_IRIS;
+               return R_IMF_IMTYPE_IRIS;
 #ifdef WITH_HDR
        else if (ftype & RADHDR)
-               return R_RADHDR;
+               return R_IMF_IMTYPE_RADHDR;
 #endif
        else if (ftype & PNG)
-               return R_PNG;
+               return R_IMF_IMTYPE_PNG;
 #ifdef WITH_DDS
        else if (ftype & DDS)
-               return R_DDS;
+               return R_IMF_IMTYPE_DDS;
 #endif
        else if (ftype & BMP)
-               return R_BMP;
+               return R_IMF_IMTYPE_BMP;
 #ifdef WITH_TIFF
        else if (ftype & TIF)
-               return R_TIFF;
+               return R_IMF_IMTYPE_TIFF;
 #endif
        else if (ftype & OPENEXR)
-               return R_OPENEXR;
+               return R_IMF_IMTYPE_OPENEXR;
 #ifdef WITH_CINEON
        else if (ftype & CINEON)
-               return R_CINEON;
+               return R_IMF_IMTYPE_CINEON;
        else if (ftype & DPX)
-               return R_DPX;
+               return R_IMF_IMTYPE_DPX;
 #endif
        else if (ftype & TGA)
-               return R_TARGA;
+               return R_IMF_IMTYPE_TARGA;
        else if(ftype & RAWTGA)
-               return R_RAWTGA;
+               return R_IMF_IMTYPE_RAWTGA;
 #ifdef WITH_OPENJPEG
        else if(ftype & JP2)
-               return R_JP2;
+               return R_IMF_IMTYPE_JP2;
 #endif
        else
-               return R_JPEG90;
+               return R_IMF_IMTYPE_JPEG90;
+}
+
+
+int BKE_imtype_is_movie(const char imtype)
+{
+       switch(imtype) {
+       case R_IMF_IMTYPE_AVIRAW:
+       case R_IMF_IMTYPE_AVIJPEG:
+       case R_IMF_IMTYPE_AVICODEC:
+       case R_IMF_IMTYPE_QUICKTIME:
+       case R_IMF_IMTYPE_FFMPEG:
+       case R_IMF_IMTYPE_H264:
+       case R_IMF_IMTYPE_THEORA:
+       case R_IMF_IMTYPE_XVID:
+       case R_IMF_IMTYPE_FRAMESERVER:
+                       return 1;
+       }
+       return 0;
+}
+
+int BKE_imtype_supports_zbuf(const char imtype)
+{
+       switch(imtype) {
+       case R_IMF_IMTYPE_IRIZ:
+       case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
+                       return 1;
+       }
+       return 0;
 }
 
+int BKE_imtype_supports_compress(const char imtype)
+{
+       switch(imtype) {
+       case R_IMF_IMTYPE_PNG:
+                       return 1;
+       }
+       return 0;
+}
 
-int BKE_imtype_is_movie(int imtype)
+int BKE_imtype_supports_quality(const char imtype)
 {
        switch(imtype) {
-       case R_AVIRAW:
-       case R_AVIJPEG:
-       case R_AVICODEC:
-       case R_QUICKTIME:
-       case R_FFMPEG:
-       case R_H264:
-       case R_THEORA:
-       case R_XVID:
-       case R_FRAMESERVER:
+       case R_IMF_IMTYPE_JPEG90:
+       case R_IMF_IMTYPE_JP2:
+       case R_IMF_IMTYPE_AVIJPEG:
                        return 1;
        }
        return 0;
 }
 
-int BKE_add_image_extension(char *string, int imtype)
+char BKE_imtype_valid_channels(const char imtype)
+{
+       char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */
+
+       /* alpha */
+       switch(imtype) {
+       case R_IMF_IMTYPE_TARGA:
+       case R_IMF_IMTYPE_IRIS:
+       case R_IMF_IMTYPE_PNG:
+       /* case R_IMF_IMTYPE_BMP: */ /* read but not write */
+       case R_IMF_IMTYPE_RADHDR:
+       case R_IMF_IMTYPE_TIFF:
+       case R_IMF_IMTYPE_OPENEXR:
+       case R_IMF_IMTYPE_MULTILAYER:
+       case R_IMF_IMTYPE_DDS:
+       case R_IMF_IMTYPE_JP2:
+                       chan_flag |= IMA_CHAN_FLAG_ALPHA;
+       }
+
+       /* bw */
+       switch(imtype) {
+       case R_IMF_IMTYPE_PNG:
+       case R_IMF_IMTYPE_JPEG90:
+       case R_IMF_IMTYPE_TARGA:
+       case R_IMF_IMTYPE_RAWTGA:
+       case R_IMF_IMTYPE_TIFF:
+       case R_IMF_IMTYPE_IRIS:
+                       chan_flag |= IMA_CHAN_FLAG_BW;
+       }
+
+       return chan_flag;
+}
+
+char BKE_imtype_valid_depths(const char imtype)
+{
+       switch (imtype) {
+       case R_IMF_IMTYPE_RADHDR:
+               return R_IMF_CHAN_DEPTH_32;
+       case R_IMF_IMTYPE_TIFF:
+               return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16;
+       case R_IMF_IMTYPE_OPENEXR:
+               return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32;
+       case R_IMF_IMTYPE_MULTILAYER:
+               return R_IMF_CHAN_DEPTH_32;
+       /* eeh, cineone does some strange 10bits per channel */
+       case R_IMF_IMTYPE_DPX:
+       case R_IMF_IMTYPE_CINEON:
+               return R_IMF_CHAN_DEPTH_12;
+       case R_IMF_IMTYPE_JP2:
+               return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
+       /* most formats are 8bit only */
+       default:
+               return R_IMF_CHAN_DEPTH_8;
+       }
+}
+
+
+/* string is from command line --render-format arg, keep in sync with
+ * creator.c help info */
+char BKE_imtype_from_arg(const char *imtype_arg)
+{
+       if      (!strcmp(imtype_arg,"TGA")) return R_IMF_IMTYPE_TARGA;
+       else if (!strcmp(imtype_arg,"IRIS")) return R_IMF_IMTYPE_IRIS;
+#ifdef WITH_DDS
+       else if (!strcmp(imtype_arg,"DDS")) return R_IMF_IMTYPE_DDS;
+#endif
+       else if (!strcmp(imtype_arg,"JPEG")) return R_IMF_IMTYPE_JPEG90;
+       else if (!strcmp(imtype_arg,"IRIZ")) return R_IMF_IMTYPE_IRIZ;
+       else if (!strcmp(imtype_arg,"RAWTGA")) return R_IMF_IMTYPE_RAWTGA;
+       else if (!strcmp(imtype_arg,"AVIRAW")) return R_IMF_IMTYPE_AVIRAW;
+       else if (!strcmp(imtype_arg,"AVIJPEG")) return R_IMF_IMTYPE_AVIJPEG;
+       else if (!strcmp(imtype_arg,"PNG")) return R_IMF_IMTYPE_PNG;
+       else if (!strcmp(imtype_arg,"AVICODEC")) return R_IMF_IMTYPE_AVICODEC;
+       else if (!strcmp(imtype_arg,"QUICKTIME")) return R_IMF_IMTYPE_QUICKTIME;
+       else if (!strcmp(imtype_arg,"BMP")) return R_IMF_IMTYPE_BMP;
+#ifdef WITH_HDR
+       else if (!strcmp(imtype_arg,"HDR")) return R_IMF_IMTYPE_RADHDR;
+#endif
+#ifdef WITH_TIFF
+       else if (!strcmp(imtype_arg,"TIFF")) return R_IMF_IMTYPE_TIFF;
+#endif
+#ifdef WITH_OPENEXR
+       else if (!strcmp(imtype_arg,"EXR")) return R_IMF_IMTYPE_OPENEXR;
+       else if (!strcmp(imtype_arg,"MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER;
+#endif
+       else if (!strcmp(imtype_arg,"MPEG")) return R_IMF_IMTYPE_FFMPEG;
+       else if (!strcmp(imtype_arg,"FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER;
+#ifdef WITH_CINEON
+       else if (!strcmp(imtype_arg,"CINEON")) return R_IMF_IMTYPE_CINEON;
+       else if (!strcmp(imtype_arg,"DPX")) return R_IMF_IMTYPE_DPX;
+#endif
+#ifdef WITH_OPENJPEG
+       else if (!strcmp(imtype_arg,"JP2")) return R_IMF_IMTYPE_JP2;
+#endif
+       else return R_IMF_IMTYPE_INVALID;
+}
+
+int BKE_add_image_extension(char *string, const char imtype)
 {
        const char *extension= NULL;
        
-       if(imtype== R_IRIS) {
+       if(imtype== R_IMF_IMTYPE_IRIS) {
                if(!BLI_testextensie(string, ".rgb"))
                        extension= ".rgb";
        }
-       else if(imtype==R_IRIZ) {
+       else if(imtype==R_IMF_IMTYPE_IRIZ) {
                if(!BLI_testextensie(string, ".rgb"))
                        extension= ".rgb";
        }
 #ifdef WITH_HDR
-       else if(imtype==R_RADHDR) {
+       else if(imtype==R_IMF_IMTYPE_RADHDR) {
                if(!BLI_testextensie(string, ".hdr"))
                        extension= ".hdr";
        }
 #endif
-       else if (ELEM5(imtype, R_PNG, R_FFMPEG, R_H264, R_THEORA, R_XVID)) {
+       else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) {
                if(!BLI_testextensie(string, ".png"))
                        extension= ".png";
        }
 #ifdef WITH_DDS
-       else if(imtype==R_DDS) {
+       else if(imtype==R_IMF_IMTYPE_DDS) {
                if(!BLI_testextensie(string, ".dds"))
                        extension= ".dds";
        }
 #endif
-       else if(imtype==R_RAWTGA) {
+       else if(imtype==R_IMF_IMTYPE_RAWTGA) {
                if(!BLI_testextensie(string, ".tga"))
                        extension= ".tga";
        }
-       else if(imtype==R_BMP) {
+       else if(imtype==R_IMF_IMTYPE_BMP) {
                if(!BLI_testextensie(string, ".bmp"))
                        extension= ".bmp";
        }
 #ifdef WITH_TIFF
-       else if(imtype==R_TIFF) {
+       else if(imtype==R_IMF_IMTYPE_TIFF) {
                if(!BLI_testextensie(string, ".tif") && 
                        !BLI_testextensie(string, ".tiff")) extension= ".tif";
        }
 #endif
 #ifdef WITH_OPENEXR
-       else if( ELEM(imtype, R_OPENEXR, R_MULTILAYER)) {
+       else if( ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
                if(!BLI_testextensie(string, ".exr"))
                        extension= ".exr";
        }
 #endif
 #ifdef WITH_CINEON
-       else if(imtype==R_CINEON){
+       else if(imtype==R_IMF_IMTYPE_CINEON){
                if (!BLI_testextensie(string, ".cin"))
                        extension= ".cin";
        }
-       else if(imtype==R_DPX){
+       else if(imtype==R_IMF_IMTYPE_DPX){
                if (!BLI_testextensie(string, ".dpx"))
                        extension= ".dpx";
        }
 #endif
-       else if(imtype==R_TARGA) {
+       else if(imtype==R_IMF_IMTYPE_TARGA) {
                if(!BLI_testextensie(string, ".tga"))
                        extension= ".tga";
        }
 #ifdef WITH_OPENJPEG
-       else if(imtype==R_JP2) {
+       else if(imtype==R_IMF_IMTYPE_JP2) {
                if(!BLI_testextensie(string, ".jp2"))
                        extension= ".jp2";
        }
 #endif
-       else { //   R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc
+       else { //   R_IMF_IMTYPE_AVICODEC, R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90, R_IMF_IMTYPE_QUICKTIME etc
                if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg")))
                        extension= ".jpg";
        }
@@ -1371,98 +1498,102 @@ int BKE_alphatest_ibuf(ImBuf *ibuf)
        return FALSE;
 }
 
-int BKE_write_ibuf(ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality)
+/* note: imf->planes is ignored here, its assumed the image channels
+ * are already set */
+int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
 {
+       char imtype= imf->imtype;
+       char compress= imf->compress;
+       char quality= imf->quality;
+
        int ok;
-       (void)subimtype; /* quies unused warnings */
 
        if(imtype == -1) {
                /* use whatever existing image type is set by 'ibuf' */
        }
-       else if(imtype== R_IRIS) {
+       else if(imtype== R_IMF_IMTYPE_IRIS) {
                ibuf->ftype= IMAGIC;
        }
 #ifdef WITH_HDR
-       else if (imtype==R_RADHDR) {
+       else if (imtype==R_IMF_IMTYPE_RADHDR) {
                ibuf->ftype= RADHDR;
        }
 #endif
-       else if (ELEM5(imtype, R_PNG, R_FFMPEG, R_H264, R_THEORA, R_XVID)) {
+       else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) {
                ibuf->ftype= PNG;
 
-               if(imtype==R_PNG)
-                       ibuf->ftype |= quality;  /* quality is actually compression 0-100 --> 0-9 */
+               if(imtype==R_IMF_IMTYPE_PNG)
+                       ibuf->ftype |= compress;
 
        }
 #ifdef WITH_DDS
-       else if (imtype==R_DDS) {
+       else if (imtype==R_IMF_IMTYPE_DDS) {
                ibuf->ftype= DDS;
        }
 #endif
-       else if (imtype==R_BMP) {
+       else if (imtype==R_IMF_IMTYPE_BMP) {
                ibuf->ftype= BMP;
        }
 #ifdef WITH_TIFF
-       else if (imtype==R_TIFF) {
+       else if (imtype==R_IMF_IMTYPE_TIFF) {
                ibuf->ftype= TIF;
 
-               if(subimtype & R_TIFF_16BIT)
+               if(imf->depth == R_IMF_CHAN_DEPTH_16)
                        ibuf->ftype |= TIF_16BIT;
        }
 #endif
 #ifdef WITH_OPENEXR
-       else if (imtype==R_OPENEXR || imtype==R_MULTILAYER) {
+       else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER) {
                ibuf->ftype= OPENEXR;
-               if(subimtype & R_OPENEXR_HALF)
+               if(imf->depth == R_IMF_CHAN_DEPTH_16)
                        ibuf->ftype |= OPENEXR_HALF;
                ibuf->ftype |= (quality & OPENEXR_COMPRESS);
                
-               if(!(subimtype & R_OPENEXR_ZBUF))
+               if(!(imf->flag & R_IMF_FLAG_ZBUF))
                        ibuf->zbuf_float = NULL;        /* signal for exr saving */
                
        }
 #endif
 #ifdef WITH_CINEON
-       else if (imtype==R_CINEON) {
+       else if (imtype==R_IMF_IMTYPE_CINEON) {
                ibuf->ftype = CINEON;
        }
-       else if (imtype==R_DPX) {
+       else if (imtype==R_IMF_IMTYPE_DPX) {
                ibuf->ftype = DPX;
        }
 #endif
-       else if (imtype==R_TARGA) {
+       else if (imtype==R_IMF_IMTYPE_TARGA) {
                ibuf->ftype= TGA;
        }
-       else if(imtype==R_RAWTGA) {
+       else if(imtype==R_IMF_IMTYPE_RAWTGA) {
                ibuf->ftype= RAWTGA;
        }
 #ifdef WITH_OPENJPEG
-       else if(imtype==R_JP2) {
+       else if(imtype==R_IMF_IMTYPE_JP2) {
                if(quality < 10) quality= 90;
                ibuf->ftype= JP2|quality;
                
-               if (subimtype & R_JPEG2K_16BIT) {
+               if (imf->depth == R_IMF_CHAN_DEPTH_16) {
                        ibuf->ftype |= JP2_16BIT;
-               } else if (subimtype & R_JPEG2K_12BIT) {
+               } else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
                        ibuf->ftype |= JP2_12BIT;
                }
                
-               if (subimtype & R_JPEG2K_YCC) {
+               if (imf->jp2_flag & R_IMF_JP2_FLAG_YCC) {
                        ibuf->ftype |= JP2_YCC;
                }
-               
-               if (subimtype & R_JPEG2K_CINE_PRESET) {
+
+               if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_PRESET) {
                        ibuf->ftype |= JP2_CINE;
-                       if (subimtype & R_JPEG2K_CINE_48FPS)
+                       if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_48)
                                ibuf->ftype |= JP2_CINE_48FPS;
                }
        }
 #endif
        else {
-               /* R_JPEG90, etc. default we save jpegs */
+               /* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */
                if(quality < 10) quality= 90;
                ibuf->ftype= JPG|quality;
-               if(ibuf->depth==32) ibuf->depth= 24;    /* unsupported feature only confuses other s/w */
        }
        
        BLI_make_existing_file(name);
@@ -1475,16 +1606,39 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, int imtype, int subimtype, int
        return(ok);
 }
 
-int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality)
+/* same as BKE_write_ibuf_as but crappy workaround not to perminantly modify
+ * _some_, values in the imbuf */
+int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf,
+                      const short save_copy)
+{
+       ImBuf ibuf_back= *ibuf;
+       int ok;
+
+       /* all data is rgba anyway,
+        * this just controls how to save for some formats */
+       ibuf->planes= imf->planes;
+
+       ok= BKE_write_ibuf(ibuf, name, imf);
+
+       if (save_copy) {
+               /* note that we are not restoring _all_ settings */
+               ibuf->planes= ibuf_back.planes;
+               ibuf->ftype=  ibuf_back.ftype;
+       }
+
+       return ok;
+}
+
+int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, struct ImageFormatData *imf)
 {
        if(scene && scene->r.stamp & R_STAMP_ALL)
                BKE_stamp_info(scene, camera, ibuf);
 
-       return BKE_write_ibuf(ibuf, name, imtype, subimtype, quality);
+       return BKE_write_ibuf(ibuf, name, imf);
 }
 
 
-void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, int imtype, const short use_ext, const short use_frames)
+void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, const char imtype, const short use_ext, const short use_frames)
 {
        if (string==NULL) return;
        BLI_strncpy(string, base, FILE_MAX - 10);       /* weak assumption */
@@ -2414,13 +2568,13 @@ int BKE_image_has_alpha(struct Image *image)
 {
        ImBuf *ibuf;
        void *lock;
-       int depth;
+       int planes;
        
        ibuf= BKE_image_acquire_ibuf(image, NULL, &lock);
-       depth = (ibuf?ibuf->depth:0);
+       planes = (ibuf?ibuf->planes:0);
        BKE_image_release_ibuf(image, lock);
 
-       if (depth == 32)
+       if (planes == 32)
                return 1;
        else
                return 0;
index 6c8a72825c794f2585dcb24137fde95a2f48b33f..9d196a1104bc756cc93aee66f012f9586957e64c 100644 (file)
@@ -1181,129 +1181,129 @@ int object_remove_material_slot(Object *ob)
 
 /* r g b = current value, col = new value, fac==0 is no change */
 /* if g==NULL, it only does r channel */
-void ramp_blend(int type, float *r, float *g, float *b, float fac, const float col[3])
+void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
 {
        float tmp, facm= 1.0f-fac;
        
        switch (type) {
                case MA_RAMP_BLEND:
-                       *r = facm*(*r) + fac*col[0];
-                       if(g) {
-                               *g = facm*(*g) + fac*col[1];
-                               *b = facm*(*b) + fac*col[2];
+                       r_col[0] = facm*(r_col[0]) + fac*col[0];
+                       if(r_col[1]) {
+                               r_col[1] = facm*(r_col[1]) + fac*col[1];
+                               r_col[2] = facm*(r_col[2]) + fac*col[2];
                        }
                                break;
                case MA_RAMP_ADD:
-                       *r += fac*col[0];
-                       if(g) {
-                               *g += fac*col[1];
-                               *b += fac*col[2];
+                       r_col[0] += fac*col[0];
+                       if(r_col[1]) {
+                               r_col[1] += fac*col[1];
+                               r_col[2] += fac*col[2];
                        }
                                break;
                case MA_RAMP_MULT:
-                       *r *= (facm + fac*col[0]);
-                       if(g) {
-                               *g *= (facm + fac*col[1]);
-                               *b *= (facm + fac*col[2]);
+                       r_col[0] *= (facm + fac*col[0]);
+                       if(r_col[1]) {
+                               r_col[1] *= (facm + fac*col[1]);
+                               r_col[2] *= (facm + fac*col[2]);
                        }
                                break;
                case MA_RAMP_SCREEN:
-                       *r = 1.0f - (facm + fac*(1.0f - col[0])) * (1.0f - *r);
-                       if(g) {
-                               *g = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - *g);
-                               *b = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - *b);
+                       r_col[0] = 1.0f - (facm + fac*(1.0f - col[0])) * (1.0f - r_col[0]);
+                       if(r_col[1]) {
+                               r_col[1] = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - r_col[1]);
+                               r_col[2] = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - r_col[2]);
                        }
                                break;
                case MA_RAMP_OVERLAY:
-                       if(*r < 0.5f)
-                               *r *= (facm + 2.0f*fac*col[0]);
+                       if(r_col[0] < 0.5f)
+                               r_col[0] *= (facm + 2.0f*fac*col[0]);
                        else
-                               *r = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - *r);
-                       if(g) {
-                               if(*g < 0.5f)
-                                       *g *= (facm + 2.0f*fac*col[1]);
+                               r_col[0] = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - r_col[0]);
+                       if(r_col[1]) {
+                               if(r_col[1] < 0.5f)
+                                       r_col[1] *= (facm + 2.0f*fac*col[1]);
                                else
-                                       *g = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - *g);
-                               if(*b < 0.5f)
-                                       *b *= (facm + 2.0f*fac*col[2]);
+                                       r_col[1] = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - r_col[1]);
+                               if(r_col[2] < 0.5f)
+                                       r_col[2] *= (facm + 2.0f*fac*col[2]);
                                else
-                                       *b = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - *b);
+                                       r_col[2] = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - r_col[2]);
                        }
                                break;
                case MA_RAMP_SUB:
-                       *r -= fac*col[0];
-                       if(g) {
-                               *g -= fac*col[1];
-                               *b -= fac*col[2];
+                       r_col[0] -= fac*col[0];
+                       if(r_col[1]) {
+                               r_col[1] -= fac*col[1];
+                               r_col[2] -= fac*col[2];
                        }
                                break;
                case MA_RAMP_DIV:
                        if(col[0]!=0.0f)
-                               *r = facm*(*r) + fac*(*r)/col[0];
-                       if(g) {
+                               r_col[0] = facm*(r_col[0]) + fac*(r_col[0])/col[0];
+                       if(r_col[1]) {
                                if(col[1]!=0.0f)
-                                       *g = facm*(*g) + fac*(*g)/col[1];
+                                       r_col[1] = facm*(r_col[1]) + fac*(r_col[1])/col[1];
                                if(col[2]!=0.0f)
-                                       *b = facm*(*b) + fac*(*b)/col[2];
+                                       r_col[2] = facm*(r_col[2]) + fac*(r_col[2])/col[2];
                        }
                                break;
                case MA_RAMP_DIFF:
-                       *r = facm*(*r) + fac*fabsf(*r-col[0]);
-                       if(g) {
-                               *g = facm*(*g) + fac*fabsf(*g-col[1]);
-                               *b = facm*(*b) + fac*fabsf(*b-col[2]);
+                       r_col[0] = facm*(r_col[0]) + fac*fabsf(r_col[0]-col[0]);
+                       if(r_col[1]) {
+                               r_col[1] = facm*(r_col[1]) + fac*fabsf(r_col[1]-col[1]);
+                               r_col[2] = facm*(r_col[2]) + fac*fabsf(r_col[2]-col[2]);
                        }
                                break;
                case MA_RAMP_DARK:
                        tmp=col[0]+((1-col[0])*facm); 
-                       if(tmp < *r) *r= tmp; 
-                       if(g) { 
+                       if(tmp < r_col[0]) r_col[0]= tmp;
+                       if(r_col[1]) {
                                tmp=col[1]+((1-col[1])*facm); 
-                               if(tmp < *g) *g= tmp; 
+                               if(tmp < r_col[1]) r_col[1]= tmp;
                                tmp=col[2]+((1-col[2])*facm); 
-                               if(tmp < *b) *b= tmp; 
+                               if(tmp < r_col[2]) r_col[2]= tmp;
                        } 
                                break; 
                case MA_RAMP_LIGHT:
                        tmp= fac*col[0];
-                       if(tmp > *r) *r= tmp; 
-                               if(g) {
+                       if(tmp > r_col[0]) r_col[0]= tmp;
+                               if(r_col[1]) {
                                        tmp= fac*col[1];
-                                       if(tmp > *g) *g= tmp; 
+                                       if(tmp > r_col[1]) r_col[1]= tmp;
                                        tmp= fac*col[2];
-                                       if(tmp > *b) *b= tmp; 
+                                       if(tmp > r_col[2]) r_col[2]= tmp;
                                }
                                        break;  
                case MA_RAMP_DODGE:                     
                        
                                
-                       if(*r !=0.0f){
+                       if(r_col[0] !=0.0f){
                                tmp = 1.0f - fac*col[0];
                                if(tmp <= 0.0f)
-                                       *r = 1.0f;
-                               else if ((tmp = (*r) / tmp)> 1.0f)
-                                       *r = 1.0f;
+                                       r_col[0] = 1.0f;
+                               else if ((tmp = (r_col[0]) / tmp)> 1.0f)
+                                       r_col[0] = 1.0f;
                                else 
-                                       *r = tmp;
+                                       r_col[0] = tmp;
                        }
-                       if(g) {
-                               if(*g !=0.0f){
+                       if(r_col[1]) {
+                               if(r_col[1] !=0.0f){
                                        tmp = 1.0f - fac*col[1];
                                        if(tmp <= 0.0f )
-                                               *g = 1.0f;
-                                       else if ((tmp = (*g) / tmp) > 1.0f )
-                                               *g = 1.0f;
+                                               r_col[1] = 1.0f;
+                                       else if ((tmp = (r_col[1]) / tmp) > 1.0f )
+                                               r_col[1] = 1.0f;
                                        else
-                                               *g = tmp;
+                                               r_col[1] = tmp;
                                }
-                               if(*b !=0.0f){
+                               if(r_col[2] !=0.0f){
                                        tmp = 1.0f - fac*col[2];
                                        if(tmp <= 0.0f)
-                                               *b = 1.0f;
-                                       else if ((tmp = (*b) / tmp) > 1.0f )
-                                               *b = 1.0f;
+                                               r_col[2] = 1.0f;
+                                       else if ((tmp = (r_col[2]) / tmp) > 1.0f )
+                                               r_col[2] = 1.0f;
                                        else
-                                               *b = tmp;
+                                               r_col[2] = tmp;
                                }
 
                        }
@@ -1313,114 +1313,114 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, const float c
                        tmp = facm + fac*col[0];
                        
                        if(tmp <= 0.0f)
-                               *r = 0.0f;
-                       else if (( tmp = (1.0f - (1.0f - (*r)) / tmp )) < 0.0f)
-                                       *r = 0.0f;
+                               r_col[0] = 0.0f;
+                       else if (( tmp = (1.0f - (1.0f - (r_col[0])) / tmp )) < 0.0f)
+                                       r_col[0] = 0.0f;
                        else if (tmp > 1.0f)
-                               *r=1.0f;
+                               r_col[0]=1.0f;
                        else 
-                               *r = tmp; 
+                               r_col[0] = tmp;
 
-                       if(g) {
+                       if(r_col[1]) {
                                tmp = facm + fac*col[1];
                                if(tmp <= 0.0f)
-                                       *g = 0.0f;
-                               else if (( tmp = (1.0f - (1.0f - (*g)) / tmp )) < 0.0f )
-                                               *g = 0.0f;
+                                       r_col[1] = 0.0f;
+                               else if (( tmp = (1.0f - (1.0f - (r_col[1])) / tmp )) < 0.0f )
+                                               r_col[1] = 0.0f;
                                else if(tmp >1.0f)
-                                       *g=1.0f;
+                                       r_col[1]=1.0f;
                                else
-                                       *g = tmp;
+                                       r_col[1] = tmp;
 
                                        tmp = facm + fac*col[2];
                                        if(tmp <= 0.0f)
-                                       *b = 0.0f;
-                               else if (( tmp = (1.0f - (1.0f - (*b)) / tmp )) < 0.0f  )
-                                               *b = 0.0f;
+                                       r_col[2] = 0.0f;
+                               else if (( tmp = (1.0f - (1.0f - (r_col[2])) / tmp )) < 0.0f  )
+                                               r_col[2] = 0.0f;
                                else if(tmp >1.0f)
-                                       *b= 1.0f;
+                                       r_col[2]= 1.0f;
                                else
-                                       *b = tmp;
+                                       r_col[2] = tmp;
                        }
                                break;
                case MA_RAMP_HUE:               
-                       if(g){
+                       if(r_col[1]){
                                float rH,rS,rV;
                                float colH,colS,colV; 
                                float tmpr,tmpg,tmpb;
                                rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
                                if(colS!=0 ){
-                                       rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
+                                       rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
                                        hsv_to_rgb( colH , rS, rV, &tmpr, &tmpg, &tmpb);
-                                       *r = facm*(*r) + fac*tmpr;  
-                                       *g = facm*(*g) + fac*tmpg; 
-                                       *b = facm*(*b) + fac*tmpb;
+                                       r_col[0] = facm*(r_col[0]) + fac*tmpr;
+                                       r_col[1] = facm*(r_col[1]) + fac*tmpg;
+                                       r_col[2] = facm*(r_col[2]) + fac*tmpb;
                                }
                        }
                                break;
                case MA_RAMP_SAT:               
-                       if(g){
+                       if(r_col[1]){
                                float rH,rS,rV;
                                float colH,colS,colV;
-                               rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
+                               rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
                                if(rS!=0){
                                        rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
-                                       hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r, g, b);
+                                       hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2);
                                }
                        }
                                break;
                case MA_RAMP_VAL:               
-                       if(g){
+                       if(r_col[1]){
                                float rH,rS,rV;
                                float colH,colS,colV;
-                               rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
+                               rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
                                rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
-                               hsv_to_rgb( rH, rS, (facm*rV +fac*colV), r, g, b);
+                               hsv_to_rgb( rH, rS, (facm*rV +fac*colV), r_col+0, r_col+1, r_col+2);
                        }
                                break;
                case MA_RAMP_COLOR:             
-                       if(g){
+                       if(r_col[1]){
                                float rH,rS,rV;
                                float colH,colS,colV;
                                float tmpr,tmpg,tmpb;
                                rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
                                if(colS!=0){
-                                       rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
+                                       rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
                                        hsv_to_rgb( colH, colS, rV, &tmpr, &tmpg, &tmpb);
-                                       *r = facm*(*r) + fac*tmpr;
-                                       *g = facm*(*g) + fac*tmpg;
-                                       *b = facm*(*b) + fac*tmpb;
+                                       r_col[0] = facm*(r_col[0]) + fac*tmpr;
+                                       r_col[1] = facm*(r_col[1]) + fac*tmpg;
+                                       r_col[2] = facm*(r_col[2]) + fac*tmpb;
                                }
                        }
                                break;
                case MA_RAMP_SOFT: 
-                       if (g){ 
+                       if (r_col[1]){
                                float scr, scg, scb; 
 
                                /* first calculate non-fac based Screen mix */ 
-                               scr = 1.0f - (1.0f - col[0]) * (1.0f - *r); 
-                               scg = 1.0f - (1.0f - col[1]) * (1.0f - *g); 
-                               scb = 1.0f - (1.0f - col[2]) * (1.0f - *b); 
+                               scr = 1.0f - (1.0f - col[0]) * (1.0f - r_col[0]);
+                               scg = 1.0f - (1.0f - col[1]) * (1.0f - r_col[1]);
+                               scb = 1.0f - (1.0f - col[2]) * (1.0f - r_col[2]);
 
-                               *r = facm*(*r) + fac*(((1.0f - *r) * col[0] * (*r)) + (*r * scr)); 
-                               *g = facm*(*g) + fac*(((1.0f - *g) * col[1] * (*g)) + (*g * scg)); 
-                               *b = facm*(*b) + fac*(((1.0f - *b) * col[2] * (*b)) + (*b * scb)); 
+                               r_col[0] = facm*(r_col[0]) + fac*(((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr));
+                               r_col[1] = facm*(r_col[1]) + fac*(((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg));
+                               r_col[2] = facm*(r_col[2]) + fac*(((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb));
                        } 
                                break; 
                case MA_RAMP_LINEAR: 
                        if (col[0] > 0.5f)  
-                               *r = *r + fac*(2.0f*(col[0]-0.5f)); 
+                               r_col[0] = r_col[0] + fac*(2.0f*(col[0]-0.5f));
                        else  
-                               *r = *r + fac*(2.0f*(col[0]) - 1.0f); 
-                       if (g){ 
+                               r_col[0] = r_col[0] + fac*(2.0f*(col[0]) - 1.0f);
+                       if (r_col[1]){
                                if (col[1] > 0.5f)  
-                                       *g = *g + fac*(2.0f*(col[1]-0.5f)); 
+                                       r_col[1] = r_col[1] + fac*(2.0f*(col[1]-0.5f));
                                else  
-                                       *g = *g + fac*(2.0f*(col[1]) -1.0f); 
+                                       r_col[1] = r_col[1] + fac*(2.0f*(col[1]) -1.0f);
                                if (col[2] > 0.5f)  
-                                       *b = *b + fac*(2.0f*(col[2]-0.5f)); 
+                                       r_col[2] = r_col[2] + fac*(2.0f*(col[2]-0.5f));
                                else  
-                                       *b = *b + fac*(2.0f*(col[2]) - 1.0f); 
+                                       r_col[2] = r_col[2] + fac*(2.0f*(col[2]) - 1.0f);
                        } 
                                break; 
        }       
index 540d757f0c9d037d1bd3c5175dd12ddd5150bef1..382e1d7038723cb2ebb75fb485aa2b6462fe115f 100644 (file)
@@ -895,7 +895,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
 
 static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, int proxy_render_size, int undistorted)
 {
-       char name[FILE_MAXFILE+FILE_MAXDIR];
+       char name[FILE_MAX];
        int quality, rectx, recty;
        int size= size= rendersize_to_number(proxy_render_size);
        ImBuf *scaleibuf;
@@ -913,8 +913,8 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i
        scaleibuf->ftype= JPG | quality;
 
        /* unsupported feature only confuses other s/w */
-       if(scaleibuf->depth==32)
-               scaleibuf->depth= 24;
+       if(scaleibuf->planes==32)
+               scaleibuf->planes= 24;
 
        BLI_lock_thread(LOCK_MOVIECLIP);
 
index b25c130590e3391ce01db03fb727c0ecabb3ae11..d0858ea032a304c90244a49f21872ae9772a5864 100644 (file)
@@ -1795,6 +1795,7 @@ static void give_parvert(Object *par, int nr, float *vec)
                                dm->getVertCo(dm, 0, vec);
                        }
                }
+               else fprintf(stderr, "%s: DerivedMesh is needed to solve parenting, object position can be wrong now\n", __func__);
 
                if(em)
                        BKE_mesh_end_editmesh(me, em);
index 85b9b0fbf22bf53cee6ef58a53820371a0f33a07..ae622358fd2192b5c134e46ed5c3ec1b9de789bc 100644 (file)
@@ -313,8 +313,8 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float
        float uu,vv;
 
        // first wrap the texture so 0 <= (u,v) < 1
-       u = fmod(u,1.0f);
-       v = fmod(v,1.0f);
+       u = fmodf(u,1.0f);
+       v = fmodf(v,1.0f);
 
        if (u < 0) u += 1.0f;
        if (v < 0) v += 1.0f;
@@ -1018,7 +1018,23 @@ static void cache_filename(char *string, const char *path, const char *relbase,
 
        BLI_join_dirfile(cachepath, sizeof(cachepath), path, fname);
 
-       BKE_makepicstring(string, cachepath, relbase, frame, R_OPENEXR, 1, TRUE);
+       BKE_makepicstring(string, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, 1, TRUE);
+}
+
+/* silly functions but useful to inline when the args do a lot of indirections */
+MINLINE void rgb_to_rgba_unit_alpha(float r_rgba[4], const float rgb[3])
+{
+       r_rgba[0]= rgb[0];
+       r_rgba[1]= rgb[1];
+       r_rgba[2]= rgb[2];
+       r_rgba[3]= 1.0f;
+}
+MINLINE void value_to_rgba_unit_alpha(float r_rgba[4], const float value)
+{
+       r_rgba[0]= value;
+       r_rgba[1]= value;
+       r_rgba[2]= value;
+       r_rgba[3]= 1.0f;
 }
 
 void BKE_free_ocean_cache(struct OceanCache *och)
@@ -1076,9 +1092,7 @@ void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, in
 
        if (och->ibufs_disp[f]) {
                ibuf_sample(och->ibufs_disp[f], u, v, (1.0f/(float)res_x), (1.0f/(float)res_y), result);
-               ocr->disp[0] = result[0];
-               ocr->disp[1] = result[1];
-               ocr->disp[2] = result[2];
+               copy_v3_v3(ocr->disp, result);
        }
 
        if (och->ibufs_foam[f]) {
@@ -1088,34 +1102,31 @@ void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, in
 
        if (och->ibufs_norm[f]) {
                ibuf_sample(och->ibufs_norm[f], u, v, (1.0f/(float)res_x), (1.0f/(float)res_y), result);
-               ocr->normal[0] = result[0];
-               ocr->normal[1] = result[1];
-               ocr->normal[2] = result[2];
+               copy_v3_v3(ocr->normal, result);
        }
 }
 
 void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j)
 {
-       int res_x = och->resolution_x;
-       int res_y = och->resolution_y;
+       const int res_x = och->resolution_x;
+       const int res_y = och->resolution_y;
 
-       i = abs(i) % res_x;
-       j = abs(j) % res_y;
+       if (i < 0) i= -i;
+       if (j < 0) j= -j;
+
+       i = i % res_x;
+       j = j % res_y;
 
        if (och->ibufs_disp[f]) {
-               ocr->disp[0] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 0];
-               ocr->disp[1] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 1];
-               ocr->disp[2] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 2];
+               copy_v3_v3(ocr->disp, &och->ibufs_disp[f]->rect_float[4*(res_x*j + i)]);
        }
 
        if (och->ibufs_foam[f]) {
-               ocr->foam = och->ibufs_foam[f]->rect_float[4*(res_x*j + i) + 0];
+               ocr->foam = och->ibufs_foam[f]->rect_float[4*(res_x*j + i)];
        }
 
        if (och->ibufs_norm[f]) {
-               ocr->normal[0] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 0];
-               ocr->normal[1] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 1];
-               ocr->normal[2] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 2];
+               copy_v3_v3(ocr->normal, &och->ibufs_norm[f]->rect_float[4*(res_x*j + i)]);
        }
 }
 
@@ -1185,6 +1196,8 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
         * before use - campbell */
        OceanResult ocr;
 
+       ImageFormatData imf= {0};
+
        int f, i=0, x, y, cancel=0;
        float progress;
 
@@ -1201,6 +1214,11 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
 
        BLI_srand(0);
 
+       /* setup image format */
+       imf.imtype= R_IMF_IMTYPE_OPENEXR;
+       imf.depth=  R_IMF_CHAN_DEPTH_16;
+       imf.exr_codec= R_IMF_EXR_CODEC_ZIP;
+
        for (f=och->start, i=0; f<=och->end; f++, i++) {
 
                /* create a new imbuf to store image for this frame */
@@ -1219,10 +1237,7 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
                                BKE_ocean_eval_ij(o, &ocr, x, y);
 
                                /* add to the image */
-                               ibuf_disp->rect_float[4*(res_x*y + x) + 0] = ocr.disp[0];
-                               ibuf_disp->rect_float[4*(res_x*y + x) + 1] = ocr.disp[1];
-                               ibuf_disp->rect_float[4*(res_x*y + x) + 2] = ocr.disp[2];
-                               ibuf_disp->rect_float[4*(res_x*y + x) + 3] = 1.0f;
+                               rgb_to_rgba_unit_alpha(&ibuf_disp->rect_float[4*(res_x*y + x)], ocr.disp);
 
                                if (o->_do_jacobian) {
                                        /* TODO, cleanup unused code - campbell */
@@ -1275,35 +1290,29 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
 
                                        prev_foam[res_x*y + x] = foam_result;
 
-                                       ibuf_foam->rect_float[4*(res_x*y + x) + 0] = foam_result;
-                                       ibuf_foam->rect_float[4*(res_x*y + x) + 1] = foam_result;
-                                       ibuf_foam->rect_float[4*(res_x*y + x) + 2] = foam_result;
-                                       ibuf_foam->rect_float[4*(res_x*y + x) + 3] = 1.0;
+                                       value_to_rgba_unit_alpha(&ibuf_foam->rect_float[4*(res_x*y + x)], foam_result);
                                }
 
                                if (o->_do_normals) {
-                                       ibuf_normal->rect_float[4*(res_x*y + x) + 0] = ocr.normal[0];
-                                       ibuf_normal->rect_float[4*(res_x*y + x) + 1] = ocr.normal[1];
-                                       ibuf_normal->rect_float[4*(res_x*y + x) + 2] = ocr.normal[2];
-                                       ibuf_normal->rect_float[4*(res_x*y + x) + 3] = 1.0;
+                                       rgb_to_rgba_unit_alpha(&ibuf_normal->rect_float[4*(res_x*y + x)], ocr.normal);
                                }
                        }
                }
 
                /* write the images */
                cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE);
-               if(0 == BKE_write_ibuf(ibuf_disp, string, R_OPENEXR, R_OPENEXR_HALF, 2))  // 2 == ZIP exr codec
+               if(0 == BKE_write_ibuf(ibuf_disp, string, &imf))
                        printf("Cannot save Displacement File Output to %s\n", string);
 
                if (o->_do_jacobian) {
                        cache_filename(string, och->bakepath, och->relbase,  f, CACHE_TYPE_FOAM);
-                       if(0 == BKE_write_ibuf(ibuf_foam, string, R_OPENEXR, R_OPENEXR_HALF, 2))  // 2 == ZIP exr codec
+                       if(0 == BKE_write_ibuf(ibuf_foam, string, &imf))
                                printf("Cannot save Foam File Output to %s\n", string);
                }
 
                if (o->_do_normals) {
                        cache_filename(string, och->bakepath,  och->relbase, f, CACHE_TYPE_NORMAL);
-                       if(0 == BKE_write_ibuf(ibuf_normal, string, R_OPENEXR, R_OPENEXR_HALF, 2))  // 2 == ZIP exr codec
+                       if(0 == BKE_write_ibuf(ibuf_normal, string, &imf))
                                printf("Cannot save Normal File Output to %s\n", string);
                }
 
index ea1dbec8a275d3a528a9057c1fd9921db47cb47f..7be8aefc883a2600ed25d8254b8104bbbc026006 100644 (file)
@@ -168,7 +168,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
 {
        PackedFile *pf = NULL;
        int file, filelen;
-       char name[FILE_MAXDIR+FILE_MAXFILE];
+       char name[FILE_MAX];
        void *data;
        
        /* render result has no filename and can be ignored
@@ -245,7 +245,7 @@ void packAll(Main *bmain, ReportList *reports)
 
 static char *find_new_name(char *name)
 {
-       char tempname[FILE_MAXDIR + FILE_MAXFILE];
+       char tempname[FILE_MAX];
        char *newname;
        size_t len;
        
@@ -268,8 +268,8 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
 {
        int file, number, remove_tmp = FALSE;
        int ret_value = RET_OK;
-       char name[FILE_MAXDIR + FILE_MAXFILE];
-       char tempname[FILE_MAXDIR + FILE_MAXFILE];
+       char name[FILE_MAX];
+       char tempname[FILE_MAX];
 /*     void *data; */
        
        if (guimode) {} //XXX  waitcursor(1);
@@ -337,7 +337,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
        struct stat st;
        int ret_val, i, len, file;
        char buf[4096];
-       char name[FILE_MAXDIR + FILE_MAXFILE];
+       char name[FILE_MAX];
        
        BLI_strncpy(name, filename, sizeof(name));
        BLI_path_abs(name, G.main->name);
@@ -394,8 +394,8 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
        char *newname = NULL;
        const char *temp = NULL;
        
-       // char newabs[FILE_MAXDIR + FILE_MAXFILE];
-       // char newlocal[FILE_MAXDIR + FILE_MAXFILE];
+       // char newabs[FILE_MAX];
+       // char newlocal[FILE_MAX];
        
        if (pf != NULL) {
                switch (how) {
@@ -445,7 +445,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
 
 int unpackVFont(ReportList *reports, VFont *vfont, int how)
 {
-       char localname[FILE_MAXDIR + FILE_MAXFILE], fi[FILE_MAXFILE];
+       char localname[FILE_MAX], fi[FILE_MAXFILE];
        char *newname;
        int ret_value = RET_ERROR;
        
index 220068780a7782536e297bb334b4b74e8ff6b850..7c71df9fece0ee65e5d7aeed01e81ac87795067a 100644 (file)
@@ -3170,13 +3170,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
                                float t2;
 
                                if(k==0) {
-                                       weight_to_rgb(pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2);
+                                       weight_to_rgb(ca->col, pind.hkey[1]->weight);
                                } else {
                                        float w1[3], w2[3];
                                        keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
 
-                                       weight_to_rgb(pind.hkey[0]->weight, w1, w1+1, w1+2);
-                                       weight_to_rgb(pind.hkey[1]->weight, w2, w2+1, w2+2);
+                                       weight_to_rgb(w1, pind.hkey[0]->weight);
+                                       weight_to_rgb(w2, pind.hkey[1]->weight);
 
                                        interp_v3_v3v3(ca->col, w1, w2, keytime);
                                }
index dbfda18942a61b557ea3d6978c933f6526741617..5445c990a9bdfeb021eddf2c14c120e149760831 100644 (file)
@@ -770,6 +770,9 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
        pid->info_types= 0;
 
        pid->stack_index = pid->cache->index;
+
+       pid->default_step = 10;
+       pid->max_step = 20;
 }
 void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys)
 {
@@ -820,6 +823,9 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
                pid->data_types|= (1<<BPHYS_DATA_ROTATION);
 
        pid->info_types= (1<<BPHYS_DATA_TIMES);
+
+       pid->default_step = 10;
+       pid->max_step = 20;
 }
 void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd)
 {
@@ -850,6 +856,9 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl
 
        pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY) | (1<<BPHYS_DATA_XCONST);
        pid->info_types= 0;
+
+       pid->default_step = 1;
+       pid->max_step = 1;
 }
 void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd)
 {
@@ -890,6 +899,9 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
                pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW);
        if(sds->wt)
                pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH);
+
+       pid->default_step = 1;
+       pid->max_step = 1;
 }
 
 void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSurface *surface)
@@ -923,6 +935,9 @@ void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSu
        pid->info_types= 0;
 
        pid->stack_index = pid->cache->index;
+
+       pid->default_step = 1;
+       pid->max_step = 1;
 }
 
 void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis)
@@ -1018,7 +1033,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
 */
 
 #define MAX_PTCACHE_PATH FILE_MAX
-#define MAX_PTCACHE_FILE ((FILE_MAXDIR+FILE_MAXFILE)*2)
+#define MAX_PTCACHE_FILE ((FILE_MAX)*2)
 
 static int ptcache_path(PTCacheID *pid, char *filename)
 {
@@ -1112,7 +1127,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
 {
        PTCacheFile *pf;
        FILE *fp = NULL;
-       char filename[(FILE_MAXDIR+FILE_MAXFILE)*2];
+       char filename[(FILE_MAX)*2];
 
 #ifndef DURIAN_POINTCACHE_LIB_OK
        /* don't allow writing for linked objects */
index ae958db3d4a97bac6422012fd8a363aad24225a8..33fb15faa56c1bda15e5505519284745e0abbadc 100644 (file)
@@ -354,9 +354,11 @@ Scene *add_scene(const char *name)
        sce->r.mblur_samples= 1;
        sce->r.filtertype= R_FILTER_MITCH;
        sce->r.size= 50;
-       sce->r.planes= 24;
-       sce->r.imtype= R_PNG;
-       sce->r.quality= 90;
+
+       sce->r.im_format.planes= R_IMF_PLANES_RGB;
+       sce->r.im_format.imtype= R_IMF_IMTYPE_PNG;
+       sce->r.im_format.quality= 90;
+
        sce->r.displaymode= R_OUTPUT_AREA;
        sce->r.framapto= 100;
        sce->r.images= 100;
index 5d35867d9c32fc06279a5325dd34a687510e0507..249555578f0b896b5843a4e2ab7100ea93d3c8a7 100644 (file)
@@ -652,7 +652,7 @@ void calc_sequence(Scene *scene, Sequence *seq)
 /* note: caller should run calc_sequence(scene, seq) after */
 void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
 {
-       char str[FILE_MAXDIR+FILE_MAXFILE];
+       char str[FILE_MAX];
        int prev_startdisp=0, prev_enddisp=0;
        /* note: dont rename the strip, will break animation curves */
 
@@ -1156,7 +1156,7 @@ static IMB_Proxy_Size seq_rendersize_to_proxysize(int size)
 
 static void seq_open_anim_file(Sequence * seq)
 {
-       char name[FILE_MAXDIR+FILE_MAXFILE];
+       char name[FILE_MAX];
        StripProxy * proxy;
 
        if(seq->anim != NULL) {
@@ -1327,8 +1327,8 @@ static void seq_proxy_build_frame(SeqRenderData context,
        ibuf->ftype= JPG | quality;
 
        /* unsupported feature only confuses other s/w */
-       if(ibuf->depth==32)
-               ibuf->depth= 24;
+       if(ibuf->planes==32)
+               ibuf->planes= 24;
 
        BLI_make_existing_file(name);
        
@@ -1729,7 +1729,7 @@ static ImBuf * input_preprocess(
        }
 
        if(seq->flag & SEQ_MAKE_PREMUL) {
-               if(ibuf->depth == 32 && ibuf->zbuf == NULL) {
+               if(ibuf->planes == 32 && ibuf->zbuf == NULL) {
                        IMB_premultiply_alpha(ibuf);
                }
        }
@@ -2057,7 +2057,7 @@ static ImBuf * seq_render_scene_strip_impl(
 static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfra)
 {
        ImBuf * ibuf = NULL;
-       char name[FILE_MAXDIR+FILE_MAXFILE];
+       char name[FILE_MAX];
        int use_preprocess = input_have_to_preprocess(context, seq, cfra);
        float nr = give_stripelem_index(seq, cfra);
        /* all effects are handled similarly with the exception of speed effect */
index 001d2abab01108e7fca993d0e55ba9915e8580b7..1ad811c6580af60a006543742747bf8816e22104 100644 (file)
@@ -1173,8 +1173,6 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
 static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(drawAllEdges)) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
-       CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
-       CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
        int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss);
        int totedge = ccgSubSurf_getNumEdges(ss);
        int gridSize = ccgSubSurf_getGridSize(ss);
@@ -1212,8 +1210,10 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw
        }
 
        if (ccgdm->drawInteriorEdges) {
-               for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
-                       CCGFace *f = ccgFaceIterator_getCurrent(fi);
+               int totface = ccgSubSurf_getNumFaces(ss);
+
+               for(j = 0; j < totface; j++) {
+                       CCGFace *f = ccgdm->faceMap[j].face;
                        int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
 
                        for (S=0; S<numVerts; S++) {
@@ -1238,18 +1238,15 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw
                        }
                }
        }
-
-       ccgFaceIterator_free(fi);
-       ccgEdgeIterator_free(ei);
 }
 static void ccgDM_drawLooseEdges(DerivedMesh *dm) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
-       CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
-       int i, edgeSize = ccgSubSurf_getEdgeSize(ss);
+       int totedge = ccgSubSurf_getNumEdges(ss);
+       int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss);
 
-       for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) {
-               CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
+       for (j=0; j< totedge; j++) {
+               CCGEdge *e = ccgdm->edgeMap[j].edge;
                DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
 
                if (!ccgSubSurf_getEdgeNumFaces(e)) {
@@ -1261,8 +1258,6 @@ static void ccgDM_drawLooseEdges(DerivedMesh *dm) {
                        glEnd();
                }
        }
-
-       ccgEdgeIterator_free(ei);
 }
 
 static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
@@ -1283,10 +1278,11 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
 static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, int (*setMaterial)(int, void *attribs)) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
-       CCGFaceIterator *fi;
        int gridSize = ccgSubSurf_getGridSize(ss);
        char *faceFlags = ccgdm->faceFlags;
        int step = (fast)? gridSize-1: 1;
+       int i, totface = ccgSubSurf_getNumFaces(ss);
+       int drawcurrent = 0, matnr = -1, shademodel = -1;
 
        ccgdm_pbvh_update(ccgdm);
 
@@ -1304,30 +1300,37 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
                return;
        }
 
-       fi = ccgSubSurf_getFaceIterator(ss);
-       for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
-               CCGFace *f = ccgFaceIterator_getCurrent(fi);
+       for(i = 0; i < totface; i++) {
+               CCGFace *f = ccgdm->faceMap[i].face;
                int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
                int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(ss, f));
-               int drawSmooth, mat_nr;
+               int new_matnr, new_shademodel;
 
                if(faceFlags) {
-                       drawSmooth = (faceFlags[index*2] & ME_SMOOTH);
-                       mat_nr= faceFlags[index*2 + 1];
+                       new_shademodel = (faceFlags[index*2] & ME_SMOOTH)? GL_SMOOTH: GL_FLAT;
+                       new_matnr= faceFlags[index*2 + 1];
                }
                else {
-                       drawSmooth = 1;
-                       mat_nr= 0;
+                       new_shademodel = GL_SMOOTH;
+                       new_matnr= 0;
                }
                
-               if (!setMaterial(mat_nr+1, NULL))
+               if(shademodel != new_shademodel || matnr != new_matnr) {
+                       matnr= new_matnr;
+                       shademodel= new_shademodel;
+
+                       drawcurrent= setMaterial(matnr+1, NULL);
+
+                       glShadeModel(shademodel);
+               }
+
+               if(!drawcurrent)
                        continue;
 
-               glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT);
                for (S=0; S<numVerts; S++) {
                        DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
 
-                       if (drawSmooth) {
+                       if (shademodel == GL_SMOOTH) {
                                for (y=0; y<gridSize-1; y+=step) {
                                        glBegin(GL_QUAD_STRIP);
                                        for (x=0; x<gridSize; x+=step) {
@@ -1362,15 +1365,12 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
                        }
                }
        }
-
-       ccgFaceIterator_free(fi);
 }
 
        /* Only used by non-editmesh types */
 static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs), int (*setDrawOptions)(void *userData, int index), void *userData) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
-       CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
        GPUVertexAttribs gattribs;
        DMVertexAttribs attribs= {{{NULL}}};
        /* MTFace *tf = dm->getFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */
@@ -1503,8 +1503,6 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v
        }
 
 #undef PASSATTRIB
-
-       ccgFaceIterator_free(fi);
 }
 
 static void ccgDM_drawFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs)) {
@@ -1515,7 +1513,6 @@ static void ccgDM_drawFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *a
 static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
-       CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
        GPUVertexAttribs gattribs;
        DMVertexAttribs attribs= {{{NULL}}};
        int gridSize = ccgSubSurf_getGridSize(ss);
@@ -1655,18 +1652,15 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
        }
 
 #undef PASSATTRIB
-
-       ccgFaceIterator_free(fi);
 }
 
 
 static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), unsigned char *col1, unsigned char *col2) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
-       CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
        int gridSize = ccgSubSurf_getGridSize(ss);
        unsigned char *cp1, *cp2;
-       int useTwoSide=1;
+       int useTwoSide=1, i, totface;
 
        ccgdm_pbvh_update(ccgdm);
 
@@ -1685,8 +1679,9 @@ static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), uns
        }
 
        glBegin(GL_QUADS);
-       for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
-               CCGFace *f = ccgFaceIterator_getCurrent(fi);
+       totface = ccgSubSurf_getNumFaces(ss);
+       for(i = 0; i < totface; i++) {
+               CCGFace *f = ccgdm->faceMap[i].face;
                int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
 
                for (S=0; S<numVerts; S++) {
@@ -1725,8 +1720,6 @@ static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), uns
                }
        }
        glEnd();
-
-       ccgFaceIterator_free(fi);
 }
 
 static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
index 5735a95764bf6a5ca044cb2e80fe9234e066b6b6..28d68892a2acb349af35da726c23f9e3d9b99770 100644 (file)
@@ -237,12 +237,12 @@ int reopen_text(Text *text)
        int i, llen, len;
        unsigned char *buffer;
        TextLine *tmp;
-       char str[FILE_MAXDIR+FILE_MAXFILE];
+       char str[FILE_MAX];
        struct stat st;
 
        if (!text || !text->name) return 0;
        
-       BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE);
+       BLI_strncpy(str, text->name, FILE_MAX);
        BLI_path_abs(str, G.main->name);
        
        fp= fopen(str, "r");
@@ -334,10 +334,10 @@ Text *add_text(const char *file, const char *relpath)
        unsigned char *buffer;
        TextLine *tmp;
        Text *ta;
-       char str[FILE_MAXDIR+FILE_MAXFILE];
+       char str[FILE_MAX];
        struct stat st;
 
-       BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE);
+       BLI_strncpy(str, file, FILE_MAX);
        if (relpath) /* can be NULL (bg mode) */
                BLI_path_abs(str, relpath);
        
index 49e6d598ea27db6571c5a4301b255d7eca153df1..474b00e626bf0de7cee0a6b12389f520509c313c 100644 (file)
@@ -231,9 +231,12 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, float x, flo
 
 void BKE_tracking_insert_marker(MovieTrackingTrack *track, MovieTrackingMarker *marker)
 {
-       MovieTrackingMarker *old_marker= BKE_tracking_get_marker(track, marker->framenr);
+       MovieTrackingMarker *old_marker= NULL;
 
-       if(old_marker && old_marker->framenr==marker->framenr) {
+       if(track->markersnr)
+               old_marker= BKE_tracking_exact_marker(track, marker->framenr);
+
+       if(old_marker) {
                *old_marker= *marker;
        } else {
                int a= track->markersnr;
@@ -324,7 +327,7 @@ MovieTrackingMarker *BKE_tracking_ensure_marker(MovieTrackingTrack *track, int f
 {
        MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
 
-       if(marker && marker->framenr!=framenr) {
+       if(marker->framenr!=framenr) {
                MovieTrackingMarker marker_new;
 
                marker_new= *marker;
@@ -341,7 +344,7 @@ MovieTrackingMarker *BKE_tracking_exact_marker(MovieTrackingTrack *track, int fr
 {
        MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
 
-       if(marker && marker->framenr!=framenr)
+       if(marker->framenr!=framenr)
                return NULL;
 
        return marker;
@@ -440,7 +443,6 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio
 int BKE_tracking_test_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track)
 {
        int a= 0, b= 0;
-       /* int tot= dst_track->markersnr+src_track->markersnr; */ /* UNUSED */
        int count= 0;
 
        while(a<src_track->markersnr || b<dst_track->markersnr) {
@@ -858,13 +860,11 @@ static unsigned char *get_search_bytebuf(ImBuf *ibuf, MovieTrackingTrack *track,
 static ImBuf *get_frame_ibuf(MovieTrackingContext *context, int framenr)
 {
        ImBuf *ibuf;
-       int framenr_old= context->user.framenr;
-
-       context->user.framenr= framenr;
+       MovieClipUser user= context->user;
 
-       ibuf= BKE_movieclip_get_ibuf_flag(context->clip, &context->user, 0);
+       user.framenr= framenr;
 
-       context->user.framenr= framenr_old;
+       ibuf= BKE_movieclip_get_ibuf_flag(context->clip, &user, 0);
 
        return ibuf;
 }
@@ -1050,9 +1050,9 @@ int BKE_tracking_next(MovieTrackingContext *context)
        for(a= 0; a<context->num_tracks; a++) {
                TrackContext *track_context= &context->track_context[a];
                MovieTrackingTrack *track= track_context->track;
-               MovieTrackingMarker *marker= BKE_tracking_get_marker(track, curfra);
+               MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, curfra);
 
-               if(marker && (marker->flag&MARKER_DISABLED)==0 && marker->framenr==curfra) {
+               if(marker && (marker->flag&MARKER_DISABLED)==0) {
 #ifdef WITH_LIBMV
                        int width, height, origin[2], tracked= 0, need_readjust= 0;
                        float pos[2], margin[2];
@@ -1921,10 +1921,8 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
                while(track) {
                        if(track->flag&TRACK_USE_2D_STAB ||
                           ((stab->flag&TRACKING_STABILIZE_ROTATION) && track==stab->rot_track)) {
-                               if(track->markersnr) {
-                                       sfra= MIN2(sfra, track->markers[0].framenr);
-                                       efra= MAX2(efra, track->markers[track->markersnr-1].framenr);
-                               }
+                               sfra= MIN2(sfra, track->markers[0].framenr);
+                               efra= MAX2(efra, track->markers[track->markersnr-1].framenr);
                        }
 
                        track= track->next;
@@ -2024,7 +2022,7 @@ static ImBuf* stabilize_alloc_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill)
                }
        }
        else {
-               cacheibuf= IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->depth, flags);
+               cacheibuf= IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->planes, flags);
                cacheibuf->profile= srcibuf->profile;
        }
 
index 03091a08c587bd34a0a24e055cf85c5c62ca8bb3..8cd3091284055fa8aafe005165676a686864e951 100644 (file)
@@ -67,7 +67,7 @@ static void filepath_avi(char *string, RenderData *rd);
 
 #include "BKE_writeframeserver.h"
 
-bMovieHandle *BKE_get_movie_handle(int imtype)
+bMovieHandle *BKE_get_movie_handle(const char imtype)
 {
        static bMovieHandle mh;
        
@@ -80,14 +80,14 @@ bMovieHandle *BKE_get_movie_handle(int imtype)
        
        /* do the platform specific handles */
 #if defined(_WIN32) && !defined(FREE_WINDOWS)
-       if (imtype == R_AVICODEC) {             
+       if (imtype == R_IMF_IMTYPE_AVICODEC) {          
                //XXX mh.start_movie= start_avi_codec;
                //XXX mh.append_movie= append_avi_codec;
                //XXX mh.end_movie= end_avi_codec;
        }
 #endif
 #ifdef WITH_QUICKTIME
-       if (imtype == R_QUICKTIME) {
+       if (imtype == R_IMF_IMTYPE_QUICKTIME) {
                mh.start_movie= start_qt;
                mh.append_movie= append_qt;
                mh.end_movie= end_qt;
@@ -95,7 +95,7 @@ bMovieHandle *BKE_get_movie_handle(int imtype)
        }
 #endif
 #ifdef WITH_FFMPEG
-       if (ELEM4(imtype, R_FFMPEG, R_H264, R_XVID, R_THEORA)) {
+       if (ELEM4(imtype, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_XVID, R_IMF_IMTYPE_THEORA)) {
                mh.start_movie = start_ffmpeg;
                mh.append_movie = append_ffmpeg;
                mh.end_movie = end_ffmpeg;
@@ -103,7 +103,7 @@ bMovieHandle *BKE_get_movie_handle(int imtype)
        }
 #endif
 #ifdef WITH_FRAMESERVER
-       if (imtype == R_FRAMESERVER) {
+       if (imtype == R_IMF_IMTYPE_FRAMESERVER) {
                mh.start_movie = start_frameserver;
                mh.append_movie = append_frameserver;
                mh.end_movie = end_frameserver;
@@ -154,7 +154,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL
        x = rectx;
        y = recty;
 
-       quality= rd->quality;
+       quality= rd->im_format.quality;
        framerate= (double) rd->frs_sec / (double) rd->frs_sec_base;
        
        avi = MEM_mallocN (sizeof(AviMovie), "avimovie");
@@ -162,7 +162,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL
        /* RPW 11-21-2002 
        if (rd->imtype != AVI_FORMAT_MJPEG) format = AVI_FORMAT_AVI_RGB;
        */
-       if (rd->imtype != R_AVIJPEG ) format = AVI_FORMAT_AVI_RGB;
+       if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG ) format = AVI_FORMAT_AVI_RGB;
        else format = AVI_FORMAT_MJPEG;
 
        if (AVI_open_compress (name, avi, 1, format) != AVI_ERROR_NONE) {
@@ -233,7 +233,7 @@ static void end_avi(void)
 /* similar to BKE_makepicstring() */
 void BKE_makeanimstring(char *string, RenderData *rd)
 {
-       bMovieHandle *mh= BKE_get_movie_handle(rd->imtype);
+       bMovieHandle *mh= BKE_get_movie_handle(rd->im_format.imtype);
        if(mh->get_movie_path)
                mh->get_movie_path(string, rd);
        else
index 3af724b4e3058ecb09814d27b5c59d74cb23f1bd..aa7d71b1577089a010214cfa755ee92e16d58456 100644 (file)
@@ -1337,7 +1337,7 @@ void ffmpeg_verify_image_type(RenderData *rd)
 {
        int audio= 0;
 
-       if(rd->imtype == R_FFMPEG) {
+       if(rd->imtype == R_IMF_IMTYPE_FFMPEG) {
                if(rd->ffcodecdata.type <= 0 ||
                   rd->ffcodecdata.codec <= 0 ||
                   rd->ffcodecdata.audio_codec <= 0 ||
@@ -1353,19 +1353,19 @@ void ffmpeg_verify_image_type(RenderData *rd)
 
                audio= 1;
        }
-       else if(rd->imtype == R_H264) {
+       else if(rd->imtype == R_IMF_IMTYPE_H264) {
                if(rd->ffcodecdata.codec != CODEC_ID_H264) {
                        ffmpeg_set_preset(rd, FFMPEG_PRESET_H264);
                        audio= 1;
                }
        }
-       else if(rd->imtype == R_XVID) {
+       else if(rd->imtype == R_IMF_IMTYPE_XVID) {
                if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) {
                        ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID);
                        audio= 1;
                }
        }
-       else if(rd->imtype == R_THEORA) {
+       else if(rd->imtype == R_IMF_IMTYPE_THEORA) {
                if(rd->ffcodecdata.codec != CODEC_ID_THEORA) {
                        ffmpeg_set_preset(rd, FFMPEG_PRESET_THEORA);
                        audio= 1;
index 2b9d6d2d6d63cd640cfa2807e4981abee39d7881..d8e880a9dec7d77ad1c11a785c6f45504ea0222b 100644 (file)
@@ -194,17 +194,20 @@ void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]);
 
 /***************************** Array Functions *******************************/
 /* attempted to follow fixed length vertex functions. names could be improved*/
-void range_vni(int *array, const int size, const int start);
+double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size);
+float normalize_vn_vn(float *array_tar, const float *array_src, const int size);
+float normalize_vn(float *array_tar, const int size);
+void range_vn_i(int *array_tar, const int size, const int start);
 void negate_vn(float *array_tar, const int size);
 void negate_vn_vn(float *array_tar, const float *array_src, const int size);
-void mul_vn_fl(float *array, const int size, const float f);
+void mul_vn_fl(float *array_tar, const int size, const float f);
 void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f);
 void add_vn_vn(float *array_tar, const float *array_src, const int size);
 void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size);
 void sub_vn_vn(float *array_tar, const float *array_src, const int size);
 void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size);
-void fill_vni(int *array_tar, const int size, const int val);
-void fill_vn(float *array_tar, const int size, const float val);
+void fill_vn_i(int *array_tar, const int size, const int val);
+void fill_vn_fl(float *array_tar, const int size, const float val);
 
 #ifdef __cplusplus
 }
index 69b5612b1189c758ce577366cefad44ac7b32c2f..6eba7d5eb49aa6539c663fe26d789c032381cd25 100644 (file)
@@ -32,6 +32,7 @@ extern "C" {
 #endif
 
 char        *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy);
+char        *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy);
 int          BLI_utf8_invalid_byte(const char *str, int length);
 int          BLI_utf8_invalid_strip(char *str, int length);
 
index 4507d70e3394facdf68fc2740d08a652db1e84c6..b7df06bbf24442a44b51c2c3065e319457a0daa4 100644 (file)
@@ -287,20 +287,28 @@ static DLRBT_Node *get_grandparent (DLRBT_Node *node)
                return NULL;
 }
 
-/* get the 'uncle' - the sibling of the parent - of the given node */
-static DLRBT_Node *get_uncle (DLRBT_Node *node)
+/* get the sibling node (e.g. if node is left child of parent, return right child of parent) */
+static DLRBT_Node *get_sibling(DLRBT_Node *node)
 {
-       DLRBT_Node *gpn= get_grandparent(node);
-       
-       /* return the child of the grandparent which isn't the node's parent */
-       if (gpn) {
-               if (gpn->left == node->parent)
-                       return gpn->right;
+       if (node && node->parent) {
+               if (node == node->parent->left)
+                       return node->parent->right;
                else
-                       return gpn->left;
+                       return node->parent->left;
        }
+
+       /* sibling not found */
+       return NULL;
+}
+
+/* get the 'uncle' - the sibling of the parent - of the given node */
+static DLRBT_Node *get_uncle (DLRBT_Node *node)
+{
+       if (node)
+               /* return the child of the grandparent which isn't the node's parent */
+               return get_sibling(node->parent);
        
-       /* not found */
+       /* uncle not found */
        return NULL;
 }
 
index 01c3e112cd877f3ee7dff60449a5312795999923..a9ea90ef5556e02b878a5b3df456e2afac5b238d 100644 (file)
@@ -378,7 +378,37 @@ void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
 
 /***************************** Array Functions *******************************/
 
-void range_vni(int *array_tar, const int size, const int start)
+double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size)
+{
+       double d= 0.0f;
+       const float *array_pt_a= array_src_a + (size-1);
+       const float *array_pt_b= array_src_b + (size-1);
+       int i= size;
+       while(i--) { d += *(array_pt_a--) * *(array_pt_b--); }
+       return d;
+}
+
+float normalize_vn_vn(float *array_tar, const float *array_src, const int size)
+{
+       double d= dot_vn_vn(array_tar, array_src, size);
+       float d_sqrt;
+       if (d > 1.0e-35) {
+               d_sqrt= (float)sqrt(d);
+               mul_vn_vn_fl(array_tar, array_src, size, 1.0f/d_sqrt);
+       }
+       else {
+               fill_vn_fl(array_tar, size, 0.0f);
+               d_sqrt= 0.0f;
+       }
+       return d_sqrt;
+}
+
+float normalize_vn(float *array_tar, const int size)
+{
+       return normalize_vn_vn(array_tar, array_tar, size);
+}
+
+void range_vn_i(int *array_tar, const int size, const int start)
 {
        int *array_pt= array_tar + (size-1);
        int j= start + (size-1);
@@ -450,14 +480,14 @@ void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_
        while(i--) { *(tar--) = *(src_a--) - *(src_b--); }
 }
 
-void fill_vni(int *array_tar, const int size, const int val)
+void fill_vn_i(int *array_tar, const int size, const int val)
 {
        int *tar= array_tar + (size-1);
        int i= size;
        while(i--) { *(tar--) = val; }
 }
 
-void fill_vn(float *array_tar, const int size, const float val)
+void fill_vn_fl(float *array_tar, const int size, const float val)
 {
        float *tar= array_tar + (size-1);
        int i= size;
index 08d9dfaeb9ea8a32eb5dc09845b7bcb3c7fe27cd..e79d850caa582ef0b119496c29c297f32d3d3750 100644 (file)
@@ -44,6 +44,7 @@
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
+#include "BLI_string_utf8.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_utildefines.h"
@@ -220,16 +221,25 @@ int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, cons
        }
 
        if(unique_check(arg, name)) {
+               char    numstr[16];
                char    tempname[UNIQUE_NAME_MAX];
                char    left[UNIQUE_NAME_MAX];
                int             number;
                int             len= BLI_split_name_num(left, &number, name, delim);
                do {
-                       int newlen= BLI_snprintf(tempname, name_len, "%s%c%03d", left, delim, ++number);
-                       if(newlen >= name_len) {
-                               len -= ((newlen + 1) - name_len);
-                               if(len < 0) len= number= 0;
-                               left[len]= '\0';
+                       int numlen= BLI_snprintf(numstr, sizeof(numstr), "%c%03d", delim, ++number);
+
+                       /* highly unlikely the string only has enough room for the number
+                        * but support anyway */
+                       if ((len == 0) || (numlen >= name_len)) {
+                               /* number is know not to be utf-8 */
+                               BLI_strncpy(tempname, numstr, name_len);
+                       }
+                       else {
+                               char *tempname_buf;
+                               tempname[0]= '\0';
+                               tempname_buf =BLI_strncat_utf8(tempname, left, name_len - numlen);
+                               memcpy(tempname_buf, numstr, numlen + 1);
                        }
                } while(unique_check(arg, tempname));
 
@@ -416,8 +426,8 @@ void BLI_cleanup_file(const char *relabase, char *dir)
 void BLI_path_rel(char *file, const char *relfile)
 {
        char * lslash;
-       char temp[FILE_MAXDIR+FILE_MAXFILE];
-       char res[FILE_MAXDIR+FILE_MAXFILE];
+       char temp[FILE_MAX];
+       char res[FILE_MAX];
        
        /* if file is already relative, bail out */
        if(file[0]=='/' && file[1]=='/') return;
@@ -435,9 +445,9 @@ void BLI_path_rel(char *file, const char *relfile)
                if (relfile[0] != '\\' && relfile[0] != '/') {
                        ptemp++;
                }
-               BLI_strncpy(ptemp, relfile, FILE_MAXDIR + FILE_MAXFILE-3);
+               BLI_strncpy(ptemp, relfile, FILE_MAX-3);
        } else {
-               BLI_strncpy(temp, relfile, FILE_MAXDIR + FILE_MAXFILE);
+               BLI_strncpy(temp, relfile, FILE_MAX);
        }
 
        if (BLI_strnlen(file, 3) > 2) {
@@ -529,7 +539,7 @@ int BLI_has_parent(char *path)
 int BLI_parent_dir(char *path)
 {
        static char parent_dir[]= {'.', '.', SEP, '\0'}; /* "../" or "..\\" */
-       char tmp[FILE_MAXDIR+FILE_MAXFILE+4];
+       char tmp[FILE_MAX+4];
        BLI_strncpy(tmp, path, sizeof(tmp)-4);
        BLI_add_slash(tmp);
        strcat(tmp, parent_dir);
@@ -734,7 +744,7 @@ int BLI_path_cwd(char *path)
 #endif
        
        if (wasrelative==1) {
-               char cwd[FILE_MAXDIR + FILE_MAXFILE]= "";
+               char cwd[FILE_MAX]= "";
                BLI_current_working_dir(cwd, sizeof(cwd)); /* incase the full path to the blend isnt used */
                
                if (cwd[0] == '\0') {
@@ -747,8 +757,8 @@ int BLI_path_cwd(char *path)
                        * blend file which isnt a feature we want to use in this case since were dealing
                        * with a path from the command line, rather than from inside Blender */
                        
-                       char origpath[FILE_MAXDIR + FILE_MAXFILE];
-                       BLI_strncpy(origpath, path, FILE_MAXDIR + FILE_MAXFILE);
+                       char origpath[FILE_MAX];
+                       BLI_strncpy(origpath, path, FILE_MAX);
                        
                        BLI_make_file_string(NULL, path, cwd, origpath); 
                }
@@ -1246,7 +1256,7 @@ void BLI_make_exist(char *dir)
 
 void BLI_make_existing_file(const char *name)
 {
-       char di[FILE_MAXDIR+FILE_MAXFILE], fi[FILE_MAXFILE];
+       char di[FILE_MAX], fi[FILE_MAXFILE];
 
        BLI_strncpy(di, name, sizeof(di));
        BLI_splitdirstring(di, fi);
@@ -1695,8 +1705,8 @@ static int add_win32_extension(char *name)
        type = BLI_exists(name);
        if ((type == 0) || S_ISDIR(type)) {
 #ifdef _WIN32
-               char filename[FILE_MAXDIR+FILE_MAXFILE];
-               char ext[FILE_MAXDIR+FILE_MAXFILE];
+               char filename[FILE_MAX];
+               char ext[FILE_MAX];
                const char *extensions = getenv("PATHEXT");
                if (extensions) {
                        char *temp;
@@ -1742,7 +1752,7 @@ static int add_win32_extension(char *name)
 */
 static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name)
 {
-       char filename[FILE_MAXDIR+FILE_MAXFILE];
+       char filename[FILE_MAX];
        const char *path = NULL, *temp;
 
 #ifdef _WIN32
index 0ac6e0ba4dfc6d0decba5c201d17af43cac9090a..5c7a29c6277b62e91837a71b1877b959a5c1563f 100644 (file)
@@ -656,12 +656,17 @@ void BLI_pbvh_free(PBVH *bvh)
                        /* if pbvh was deformed, new memory was allocated for verts/faces -- free it */
 
                        MEM_freeN(bvh->verts);
-                       MEM_freeN(bvh->faces);
+                       if(bvh->faces)
+                               MEM_freeN(bvh->faces);
                }
        }
 
-       MEM_freeN(bvh->nodes);
-       MEM_freeN(bvh->prim_indices);
+       if(bvh->nodes)
+               MEM_freeN(bvh->nodes);
+
+       if(bvh->prim_indices)
+               MEM_freeN(bvh->prim_indices);
+
        MEM_freeN(bvh);
 }
 
@@ -1127,6 +1132,9 @@ void BLI_pbvh_update(PBVH *bvh, int flag, float (*face_nors)[3])
        PBVHNode **nodes;
        int totnode;
 
+       if(!bvh->nodes)
+               return;
+
        BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(flag),
                &nodes, &totnode);
 
index 86095e6b90907f3a340bd77b3d37211b04103aaa..1ef254d355f4bf7e7c344d19bbd604451109d65a 100644 (file)
@@ -442,18 +442,18 @@ int BLI_exists(const char *name)
        /*  in Windows stat doesn't recognize dir ending on a slash 
                To not break code where the ending slash is expected we
                don't mess with the argument name directly here - elubie */
-       char tmp[FILE_MAXDIR+FILE_MAXFILE];
+       char tmp[FILE_MAX];
        int len, res;
-       BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE);
+       BLI_strncpy(tmp, name, FILE_MAX);
        len = strlen(tmp);
        if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0';
        res = _stat(tmp, &st);
        if (res == -1) return(0);
 #elif defined(__MINGW32__)
        struct _stati64 st;
-       char tmp[FILE_MAXDIR+FILE_MAXFILE];
+       char tmp[FILE_MAX];
        int len, res;
-       BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE);
+       BLI_strncpy(tmp, name, FILE_MAX);
        len = strlen(tmp);
        if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0';
        res = _stati64(tmp, &st);
index f8cdc3ec873e96c20479f119f2c1007761f42f1c..89136f270e20db1eeb272a371f07412d6b95f07b 100644 (file)
@@ -163,28 +163,46 @@ static const size_t utf8_skip_data[256] = {
     3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
 };
 
+#define BLI_STR_UTF8_CPY(dst, src, maxncpy)                                   \
+       {                                                                         \
+               size_t utf8_size;                                                     \
+               while(*src != '\0' && (utf8_size= utf8_skip_data[*src]) < maxncpy) {  \
+                       maxncpy -= utf8_size;                                             \
+                       switch(utf8_size) {                                               \
+                               case 6: *dst ++ = *src ++;                                    \
+                               case 5: *dst ++ = *src ++;                                    \
+                               case 4: *dst ++ = *src ++;                                    \
+                               case 3: *dst ++ = *src ++;                                    \
+                               case 2: *dst ++ = *src ++;                                    \
+                               case 1: *dst ++ = *src ++;                                    \
+                       }                                                                 \
+               }                                                                     \
+               *dst= '\0';                                                           \
+       }
+
 char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy)
 {
        char *dst_r= dst;
-       size_t utf8_size;
 
        /* note: currently we dont attempt to deal with invalid utf8 chars */
+       BLI_STR_UTF8_CPY(dst, src, maxncpy)
 
-       while(*src != '\0' && (utf8_size= utf8_skip_data[*src]) < maxncpy) {
-               maxncpy -= utf8_size;
-               switch(utf8_size) {
-                       case 6: *dst ++ = *src ++;
-                       case 5: *dst ++ = *src ++;
-                       case 4: *dst ++ = *src ++;
-                       case 3: *dst ++ = *src ++;
-                       case 2: *dst ++ = *src ++;
-                       case 1: *dst ++ = *src ++;
-               }
-       }
-       *dst= '\0';
        return dst_r;
 }
 
+char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy)
+{
+       while (*dst && maxncpy > 0) {
+               dst++;
+               maxncpy--;
+       }
+
+       BLI_STR_UTF8_CPY(dst, src, maxncpy)
+
+       return dst;
+}
+
+#undef BLI_STR_UTF8_CPY
 
 /* --------------------------------------------------------------------------*/
 /* wchar_t / utf8 functions  */
index d3e989c28ae4b64b48656fc9696b2a205951db41..1b5bb60738623c07285b94b99e29dea173025156 100644 (file)
 #define WIN32_SKIP_HKEY_PROTECTION             // need to use HKEY
 #include "BLI_winstuff.h"
 
- /* FILE_MAXDIR + FILE_MAXFILE */
+ /* FILE_MAX */
 
 int BLI_getInstallationDir( char * str ) {
        char dir[FILE_MAXDIR];
        int a;
        
-       GetModuleFileName(NULL,str,FILE_MAXDIR+FILE_MAXFILE);
+       GetModuleFileName(NULL,str,FILE_MAX);
        BLI_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */
        a = strlen(dir);
        if(dir[a-1] == '\\') dir[a-1]=0;
index c96d7f7ffa1e8d3a6e331adcbd1d1c303c905767..9246773bdc1825a8e0f339b98f5653733627b048 100644 (file)
@@ -501,7 +501,7 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *filepat
 {
        Main *m;
        Library *lib;
- &