Merging changes from trunk r58091-58323.
authorMitchell Stokes <mogurijin@gmail.com>
Wed, 17 Jul 2013 01:40:26 +0000 (01:40 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Wed, 17 Jul 2013 01:40:26 +0000 (01:40 +0000)
233 files changed:
CMakeLists.txt
build_files/cmake/Modules/FindPythonLibsUnix.cmake
build_files/cmake/macros.cmake
extern/libredcode/codec.c
extern/libredcode/codec.h
extern/libredcode/debayer.c
extern/libredcode/debayer.h
extern/libredcode/format.c
extern/libredcode/format.h
intern/bsp/CMakeLists.txt
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/kernel/kernel_camera.h
intern/cycles/render/film.cpp
intern/cycles/render/graph.cpp
intern/cycles/render/light.cpp
intern/cycles/render/mesh.cpp
intern/cycles/render/mesh.h
intern/cycles/render/tables.cpp
intern/ghost/intern/GHOST_DropTargetWin32.h
intern/ghost/intern/GHOST_DropTargetX11.cpp
intern/ghost/intern/GHOST_DropTargetX11.h
intern/iksolver/CMakeLists.txt
intern/smoke/CMakeLists.txt
release/scripts/modules/bl_i18n_utils/utils_spell_check.py
source/blender/blenfont/intern/blf_font.c
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_dynamicpaint.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/boids.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/linestyle.c
source/blender/blenkernel/intern/mask_rasterize.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/movieclip.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenkernel/intern/unit.c
source/blender/blenlib/BLI_listbase.h
source/blender/blenlib/BLI_math_geom.h
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/BLI_string.h
source/blender/blenlib/BLI_string_utf8.h
source/blender/blenlib/intern/fileops.c
source/blender/blenlib/intern/listbase.c
source/blender/blenlib/intern/math_geom.c
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/math_vector.c
source/blender/blenlib/intern/string.c
source/blender/blenlib/intern/string_utf8.c
source/blender/blenloader/intern/versioning_legacy.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_construct.h
source/blender/bmesh/intern/bmesh_core.c
source/blender/bmesh/intern/bmesh_core.h
source/blender/bmesh/intern/bmesh_interp.c
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/intern/bmesh_mods.c
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/operators/bmo_bridge.c
source/blender/bmesh/operators/bmo_connect_pair.c
source/blender/bmesh/operators/bmo_normals.c
source/blender/bmesh/operators/bmo_subdivide_edgering.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/collada/AnimationImporter.cpp
source/blender/collada/ArmatureImporter.cpp
source/blender/collada/ArmatureImporter.h
source/blender/collada/DocumentImporter.cpp
source/blender/collada/TransformWriter.cpp
source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
source/blender/compositor/nodes/COM_TextureNode.cpp
source/blender/compositor/nodes/COM_ZCombineNode.cpp
source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
source/blender/compositor/operations/COM_KeyingScreenOperation.h
source/blender/compositor/operations/COM_TextureOperation.cpp
source/blender/compositor/operations/COM_TextureOperation.h
source/blender/compositor/operations/COM_TrackPositionOperation.h
source/blender/editors/animation/anim_markers.c
source/blender/editors/armature/armature_relations.c
source/blender/editors/armature/armature_select.c
source/blender/editors/armature/armature_utils.c
source/blender/editors/curve/editcurve.c
source/blender/editors/curve/editfont.c
source/blender/editors/include/ED_armature.h
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_render.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_transform.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/dynamicpaint_ops.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_preview.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sculpt_paint/sculpt_intern.h
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_view3d/drawmesh.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_ruler.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/util/undo.c
source/blender/editors/uvedit/uvedit_parametrizer.c
source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
source/blender/freestyle/intern/view_map/BoxGrid.cpp
source/blender/freestyle/intern/view_map/GridDensityProvider.h
source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp
source/blender/freestyle/intern/view_map/SphericalGrid.cpp
source/blender/freestyle/intern/view_map/ViewMap.cpp
source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
source/blender/imbuf/intern/cineon/logImageCore.c
source/blender/imbuf/intern/colormanagement.c
source/blender/imbuf/intern/tiff.c
source/blender/imbuf/intern/util.c
source/blender/makesdna/DNA_curve_types.h
source/blender/makesdna/DNA_particle_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_dynamicpaint.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_render.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_texture_api.c
source/blender/modifiers/intern/MOD_cast.c
source/blender/modifiers/intern/MOD_cloth.c
source/blender/modifiers/intern/MOD_displace.c
source/blender/modifiers/intern/MOD_hook.c
source/blender/modifiers/intern/MOD_laplaciansmooth.c
source/blender/modifiers/intern/MOD_meshdeform.c
source/blender/modifiers/intern/MOD_particlesystem.c
source/blender/modifiers/intern/MOD_screw.c
source/blender/modifiers/intern/MOD_shrinkwrap.c
source/blender/modifiers/intern/MOD_simpledeform.c
source/blender/modifiers/intern/MOD_skin.c
source/blender/modifiers/intern/MOD_smooth.c
source/blender/modifiers/intern/MOD_solidify.c
source/blender/modifiers/intern/MOD_surface.c
source/blender/modifiers/intern/MOD_util.c
source/blender/modifiers/intern/MOD_util.h
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_wave.c
source/blender/modifiers/intern/MOD_weightvg_util.c
source/blender/python/bmesh/bmesh_py_types.c
source/blender/render/extern/include/RE_engine.h
source/blender/render/extern/include/RE_shader_ext.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/external_engine.c
source/blender/render/intern/source/render_texture.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_playanim.c
source/gameengine/BlenderRoutines/CMakeLists.txt
source/gameengine/Converter/CMakeLists.txt
source/gameengine/Expressions/CMakeLists.txt
source/gameengine/GameLogic/CMakeLists.txt
source/gameengine/GamePlayer/common/CMakeLists.txt
source/gameengine/GamePlayer/ghost/CMakeLists.txt
source/gameengine/Ketsji/CMakeLists.txt
source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
source/gameengine/Network/CMakeLists.txt
source/gameengine/Physics/Bullet/CMakeLists.txt
source/gameengine/Physics/Dummy/CMakeLists.txt
source/gameengine/Rasterizer/CMakeLists.txt
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
source/gameengine/SceneGraph/CMakeLists.txt
source/gameengine/VideoTexture/CMakeLists.txt

index 0bd9cabfa7babff2f4dbde56f48be16682180b6a..d3c65baec345eb66e54213195f50552f69c9e877 100644 (file)
@@ -2040,6 +2040,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
        ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
        ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS    -Wno-unused-macros)
 
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
+
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
+
 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
 
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
index 1dffd54fed120421eb8c3640017e07724f1521b4..82f74373b8bc37886aa8444cc42f078f0c5122ec 100644 (file)
@@ -2,9 +2,11 @@
 # Find the native Python includes and library
 #
 # Note:, This is not _yet_ intended to be a general python module for other
-#  projects to use since its hard coded to python 3.2 as blender only supports
-#  a single python version.
-#  This is for blender/unix python only.
+#  projects to use since its hard coded to fixed Python version
+#  as Blender only supports a single Python version at the moment.
+#
+# Note:
+#  this is for Blender/Unix Python only.
 #
 # This module defines
 #  PYTHON_VERSION
index 109d9244b3a08d3512f1920e8b6d8aee94e09981..854609f1665a06345fa52c163a3d2127bfd87569 100644 (file)
@@ -530,7 +530,9 @@ macro(remove_strict_flags_file
 
        foreach(_SOURCE ${ARGV})
 
-               if(CMAKE_COMPILER_IS_GNUCC)
+               if(CMAKE_COMPILER_IS_GNUCC OR
+                 (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
+
                        set_source_files_properties(${_SOURCE}
                                PROPERTIES
                                        COMPILE_FLAGS "${CC_REMOVE_STRICT_FLAGS}"
index 4a2dcdd6f5bf8d372d2137651b06782d365b5d8e..70c875ca991f4415241aeb3bd9d7adc799fe4ce3 100644 (file)
@@ -1,3 +1,25 @@
+/* ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2008 Peter Schlaile
+ *
+ * This file is part of libredcode.
+ *
+ * Libredcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Libredcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libredcode; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****/
+
 #include "codec.h"
 #include "format.h"
 #include "debayer.h"
index dd239180c10c3fcb4f24d5b309aa29ca71db9caf..6f7092672eeff3c9632bab379a3e7b8b72559a28 100644 (file)
@@ -1,3 +1,25 @@
+/* ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2008 Peter Schlaile
+ *
+ * This file is part of libredcode.
+ *
+ * Libredcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Libredcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Libredcode; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****/
+
 #ifndef __CODEC_H__
 #define __CODEC_H__
 
index de7bec510cb9a61edd2bfdb3270b7b21e20718a2..a236fed174953026b093193fdde2c53a98225035 100644 (file)
@@ -1,3 +1,25 @@
+/* ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2008 Peter Schlaile
+ *
+ * This file is part of libredcode.
+ *
+ * Libredcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Libredcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Libredcode; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****/
+
 #include "debayer.h"
 
 /* pretty simple but astonishingly very effective "debayer" function 
index 43564240cc2a5c337e303a46612d03ceb9437bf3..31f3dd01fea5ddf1fc091c7d2c032a84e410e0bb 100644 (file)
@@ -1,3 +1,25 @@
+/* ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2008 Peter Schlaile
+ *
+ * This file is part of libredcode.
+ *
+ * Libredcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Libredcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Libredcode; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****/
+
 #ifndef __DEBAYER_H__
 #define __DEBAYER_H__
 
index cf8f9d5faa72c0bb8c1a6b2c496d7e6c0e0004f2..8c6cae5234e1422c5efa9c371109c9c92c0c19f1 100644 (file)
@@ -1,3 +1,25 @@
+/* ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2008 Peter Schlaile
+ *
+ * This file is part of libredcode.
+ *
+ * Libredcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Libredcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Libredcode; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 3cee804aa9d5fa2a635b2a982c68efa5c205a506..473a2b1a8d9f36e7391afa9811886984fb50f627 100644 (file)
@@ -1,3 +1,25 @@
+/* ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2008 Peter Schlaile
+ *
+ * This file is part of libredcode.
+ *
+ * Libredcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Libredcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Libredcode; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****/
+
 #ifndef __FORMAT_H__
 #define __FORMAT_H__
 
index e3907c5273dcf6881224ba7a0f3deb07e9d920c8..5a2e3538e0aee97c286a1d699d41aa4ddedd5afd 100644 (file)
@@ -28,10 +28,10 @@ set(INC
        ../container
        ../guardedalloc
        ../memutil
-       ../moto/include
 )
 
 set(INC_SYS
+       ../moto/include
        ../../extern/carve/include
 )
 
index b451b8ef3bf38ea687124020952a784d0a34174d..cefdf5042069db2fc098d33dce40ae419dc4dec7 100644 (file)
@@ -41,6 +41,7 @@ class CyclesRender(bpy.types.RenderEngine):
     bl_use_shading_nodes = True
     bl_use_preview = True
     bl_use_exclude_layers = True
+    bl_use_save_buffers = True
 
     def __init__(self):
         self.session = None
index 91e850d066f5357415d2042b357a7cc6cefd0e02..8d129aa821c3bed6057d05fface262a485dda3dc 100644 (file)
@@ -213,21 +213,23 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
         subsub.enabled = not rd.use_border
         subsub.prop(rd, "use_save_buffers")
 
-        col = split.column()
+        col = split.column(align=True)
 
-        sub = col.column(align=True)
-        sub.label(text="Acceleration structure:")
-        sub.prop(cscene, "debug_bvh_type", text="")
-        sub.prop(cscene, "debug_use_spatial_splits")
-        sub.prop(cscene, "use_cache")
+        col.label(text="Viewport:")
+        col.prop(cscene, "debug_bvh_type", text="")
+        col.separator()
+        col.prop(cscene, "preview_start_resolution")
 
-        sub = col.column(align=True)
-        sub.label(text="Viewport:")
-        sub.prop(cscene, "preview_start_resolution")
+        col.separator()
 
-        sub = col.column(align=True)
-        sub.label(text="Final Render:")
-        sub.prop(rd, "use_persistent_data", text="Persistent Images")
+        col.label(text="Final Render:")
+        col.prop(cscene, "use_cache")
+        col.prop(rd, "use_persistent_data", text="Persistent Images")
+
+        col.separator()
+
+        col.label(text="Acceleration structure:")   
+        col.prop(cscene, "debug_use_spatial_splits")
 
 
 class CyclesRender_PT_opengl(CyclesButtonsPanel, Panel):
index 90278f215c03cf524487100a07149de959b16a3d..9fa9e1267565a910be0462022003b8e0b1be1357 100644 (file)
@@ -212,13 +212,27 @@ static void mikk_compute_tangents(BL::Mesh b_mesh, BL::MeshTextureFaceLayer b_la
 
 static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<uint>& used_shaders)
 {
-       /* create vertices */
+       /* count vertices and faces */
+       int numverts = b_mesh.vertices.length();
+       int numfaces = b_mesh.tessfaces.length();
+       int numtris = 0;
+
        BL::Mesh::vertices_iterator v;
+       BL::Mesh::tessfaces_iterator f;
 
-       for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
-               mesh->verts.push_back(get_float3(v->co()));
+       for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f) {
+               int4 vi = get_int4(f->vertices_raw());
+               numtris += (vi[3] == 0)? 1: 2;
+       }
+
+       /* reserve memory */
+       mesh->reserve(numverts, numtris, 0, 0);
+
+       /* create vertex coordinates and normals */
+       int i = 0;
+       for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++i)
+               mesh->verts[i] = get_float3(v->co());
 
-       /* create vertex normals */
        Attribute *attr_N = mesh->attributes.add(ATTR_STD_VERTEX_NORMAL);
        float3 *N = attr_N->data_float3();
 
@@ -226,10 +240,10 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
                *N = get_float3(v->normal());
 
        /* create faces */
-       BL::Mesh::tessfaces_iterator f;
-       vector<int> nverts;
+       vector<int> nverts(numfaces);
+       int fi = 0, ti = 0;
 
-       for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f) {
+       for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f, ++fi) {
                int4 vi = get_int4(f->vertices_raw());
                int n = (vi[3] == 0)? 3: 4;
                int mi = clamp(f->material_index(), 0, used_shaders.size()-1);
@@ -239,18 +253,18 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
                if(n == 4) {
                        if(len_squared(cross(mesh->verts[vi[1]] - mesh->verts[vi[0]], mesh->verts[vi[2]] - mesh->verts[vi[0]])) == 0.0f ||
                                len_squared(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - mesh->verts[vi[0]])) == 0.0f) {
-                               mesh->add_triangle(vi[0], vi[1], vi[3], shader, smooth);
-                               mesh->add_triangle(vi[2], vi[3], vi[1], shader, smooth);
+                               mesh->set_triangle(ti++, vi[0], vi[1], vi[3], shader, smooth);
+                               mesh->set_triangle(ti++, vi[2], vi[3], vi[1], shader, smooth);
                        }
                        else {
-                               mesh->add_triangle(vi[0], vi[1], vi[2], shader, smooth);
-                               mesh->add_triangle(vi[0], vi[2], vi[3], shader, smooth);
+                               mesh->set_triangle(ti++, vi[0], vi[1], vi[2], shader, smooth);
+                               mesh->set_triangle(ti++, vi[0], vi[2], vi[3], shader, smooth);
                        }
                }
                else
-                       mesh->add_triangle(vi[0], vi[1], vi[2], shader, smooth);
+                       mesh->set_triangle(ti++, vi[0], vi[1], vi[2], shader, smooth);
 
-               nverts.push_back(n);
+               nverts[fi] = n;
        }
 
        /* create vertex color attributes */
index ed1f2b9d70f0d29fc7658788fd4f7b7fce0663c9..da86bafa9365621a4cc6cf8a7915c5b9f83cdf64 100644 (file)
@@ -127,6 +127,7 @@ private:
                  use_surfaces(true),
                  use_hair(true),
                  use_viewport_visibility(false),
+                 use_localview(false),
                  samples(0), bound_samples(false)
                {}
 
index 4b9ef8893f708698c699e4f569f1e717cd794238..c3cffc15ebe2e35c3372288c405e7eb1403da1d0 100644 (file)
@@ -166,6 +166,12 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra
 
        ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y);
 
+       /* indicates ray should not receive any light, outside of the lens */
+       if(is_zero(ray->D)) {   
+               ray->t = 0.0f;
+               return;
+       }
+
        /* modify ray for depth of field */
        float aperturesize = kernel_data.cam.aperturesize;
 
@@ -186,12 +192,6 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra
                ray->D = normalize(Pfocus - ray->P);
        }
 
-       /* indicates ray should not receive any light, outside of the lens */
-       if(is_zero(ray->D)) {   
-               ray->t = 0.0f;
-               return;
-       }
-
        /* transform ray from camera to world */
        Transform cameratoworld = kernel_data.cam.cameratoworld;
 
index 43aef755ba3105af0e510fafbead3d81db02be4c..2a16b7b6c217b9948f16f99a6cb8adef0f01871d 100644 (file)
@@ -359,12 +359,15 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
                        case PASS_BACKGROUND:
                                kfilm->pass_background = kfilm->pass_stride;
                                kfilm->use_light_pass = 1;
+                               break;
                        case PASS_AO:
                                kfilm->pass_ao = kfilm->pass_stride;
                                kfilm->use_light_pass = 1;
+                               break;
                        case PASS_SHADOW:
                                kfilm->pass_shadow = kfilm->pass_stride;
                                kfilm->use_light_pass = 1;
+                               break;
                        case PASS_NONE:
                                break;
                }
index 515bbe9233522e69f8a05a064c0d14a86f1dc9b8..2e8bc77b9c9ae663878679c272400b77569e8724 100644 (file)
@@ -347,8 +347,9 @@ void ShaderGraph::remove_unneeded_nodes()
 
                                        if(tonode->special_type == SHADER_SPECIAL_TYPE_AUTOCONVERT) {
                                                bool all_links_removed = true;
+                                               vector<ShaderInput*> links = tonode->outputs[0]->links;
 
-                                               foreach(ShaderInput *autoin, tonode->outputs[0]->links) {
+                                               foreach(ShaderInput *autoin, links) {
                                                        if(autoin->default_value == ShaderInput::NONE)
                                                                all_links_removed = false;
                                                        else
index 276647e6b2f1579ef3b86f4e42cabedad0a39618..8b831c25d28cbe51f7c3d1d186f57273bde901a2 100644 (file)
@@ -53,7 +53,7 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res
        }
 
        /* compute on device */
-       float4 *d_output_data = d_output.resize(width*height);
+       d_output.resize(width*height);
        memset((void*)d_output.data_pointer, 0, d_output.memory_size());
 
        device->const_copy_to("__data", &dscene->data, sizeof(dscene->data));
@@ -82,7 +82,7 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res
        device->mem_free(d_input);
        device->mem_free(d_output);
 
-       d_output_data = reinterpret_cast<float4*>(d_output.data_pointer);
+       float4 *d_output_data = reinterpret_cast<float4*>(d_output.data_pointer);
 
        pixels.resize(width*height);
 
index 4a2a64bb0f3f6f6b49e3cf92d58c03bbfffb1f6e..77d4a5fe7d20cb88e4a73fe6f30d44389c589fe9 100644 (file)
@@ -98,6 +98,18 @@ void Mesh::clear()
        transform_normal = transform_identity();
 }
 
+void Mesh::set_triangle(int i, int v0, int v1, int v2, int shader_, bool smooth_)
+{
+       Triangle tri;
+       tri.v[0] = v0;
+       tri.v[1] = v1;
+       tri.v[2] = v2;
+
+       triangles[i] = tri;
+       shader[i] = shader_;
+       smooth[i] = smooth_;
+}
+
 void Mesh::add_triangle(int v0, int v1, int v2, int shader_, bool smooth_)
 {
        Triangle tri;
index b74c41f64535974a681dcb04b05b1b02ac714eb1..a7703f7cabc380680f017adec91ad135d425aa92 100644 (file)
@@ -110,6 +110,7 @@ public:
 
        void reserve(int numverts, int numfaces, int numcurves, int numcurvekeys);
        void clear();
+       void set_triangle(int i, int v0, int v1, int v2, int shader, bool smooth);
        void add_triangle(int v0, int v1, int v2, int shader, bool smooth);
        void add_curve_key(float3 loc, float radius);
        void add_curve(int first_key, int num_keys, int shader);
index c7c86f6896089f0bf70457c0b69b25e1cf1f30c0..032fef7516e54105cc61ca3ee0ed3403579ca2b8 100644 (file)
@@ -99,7 +99,7 @@ void LookupTables::remove_table(size_t offset)
        for(table = lookup_tables.begin(); table != lookup_tables.end(); table++) {
                if(table->offset == offset) {
                        lookup_tables.erase(table);
-                       break;
+                       return;
                }
        }
 
index f746a50d4690afae235a8dab20e6ea41c1ea62a5..56bae1fd1b2945a572f3222ee479d5a44268003b 100644 (file)
@@ -152,6 +152,10 @@ private:
        GHOST_SystemWin32 *m_system;
        /* Data type of the dragged object */
        GHOST_TDragnDropTypes m_draggedObjectType;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DropTargetWin32")
+#endif
 };
 
 #endif  // __GHOST_DROPTARGETWIN32_H__
index e2e15277a99bdeb7f5fd848a4639b778b532c0c9..df50012244908407696c65f05ff41e77bcd8eb96 100644 (file)
@@ -84,6 +84,9 @@ void GHOST_DropTargetX11::Initialize(void)
 void GHOST_DropTargetX11::Uninitialize(void)
 {
        xdnd_shut(&m_dndClass);
+
+       delete[] m_dndActions;
+       delete[] m_dndTypes;
 }
 
 GHOST_DropTargetX11::GHOST_DropTargetX11(GHOST_WindowX11 *window, GHOST_SystemX11 *system)
index 3fed57986116d39753602c2bbbc63fbcc655ed95..0254139bcd820c615033c878702ae5033c22a30d 100644 (file)
@@ -130,6 +130,10 @@ private:
 
        /* counter of references to global XDND structures */
        static int m_refCounter;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DropTargetX11")
+#endif
 };
 
 #endif  // __GHOST_DROPTARGETX11_H__
index 711a70ff2600f09b8ca4d95687f35b6c14caf7e1..9476e0379e9d22cce0fccef1997bcdfac4ad57fc 100644 (file)
 set(INC
        intern
        ../memutil
-       ../moto/include
 )
 
 set(INC_SYS
-
+       ../moto/include
 )
 
 set(SRC
index b6338f90ebcb4efba02e33f8618fe8faaefaf9ae..2ca423dc73efecf0570ab744998a4b0d7edc2d06 100644 (file)
@@ -95,7 +95,7 @@ endif()
 
 if(WITH_FFTW3)
        add_definitions(-DWITH_FFTW3)
-       list(APPEND INC
+       list(APPEND INC_SYS
                ${FFTW3_INCLUDE_DIRS}
        )
 endif()
index 8c237840d9637aca49a8ac356843cab5e73416c2..1da45a9f415994fed477316ec0aa3c88bb2c12b7 100644 (file)
@@ -40,6 +40,7 @@ class SpellChecker():
         "derivate",
         "doesn",  # doesn't
         "fader",
+        "globbing",
         "hasn",  # hasn't
         "hoc",  # ad-hoc
         "indices",
@@ -59,6 +60,7 @@ class SpellChecker():
         "autoclip",
         "autocomplete",
         "autoexec",
+        "autoexecution",
         "autoname",
         "autosave",
         "autoscale",
index 56a77d643d61e2f11e23f74d9ea4153b0451fe23..15098d505318ca2a55a2a46cce12df64d2bb2cbe 100644 (file)
@@ -87,7 +87,7 @@ void blf_font_size(FontBLF *font, unsigned int size, unsigned int dpi)
        err = FT_Set_Char_Size(font->face, 0, (FT_F26Dot6)(size * 64), dpi, dpi);
        if (err) {
                /* FIXME: here we can go through the fixed size and choice a close one */
-               printf("The current font don't support the size, %d and dpi, %d\n", size, dpi);
+               printf("The current font don't support the size, %u and dpi, %u\n", size, dpi);
                return;
        }
 
index fdb43f5467e22fc59fc66fcc40df7352533898b7..ae936a1659a6d98f77313b78014c378f9684f2c3 100644 (file)
@@ -323,6 +323,7 @@ struct DerivedMesh {
 
        /** Get smooth vertex normal, undefined if index is not valid */
        void (*getVertNo)(DerivedMesh *dm, int index, float no_r[3]);
+       void (*getPolyNo)(DerivedMesh *dm, int index, float no_r[3]);
 
        /** Get a map of vertices to faces
         */
index ffce16f39fff3b83b489f3e448c8a948a12550dd..62715c205002caf137cc9285ee5bf0f5b271df4a 100644 (file)
@@ -29,6 +29,7 @@
 
 struct bContext;
 struct wmOperator;
+struct Scene;
 
 /* Actual surface point        */
 typedef struct PaintSurfaceData {
@@ -69,8 +70,8 @@ void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct Dyn
 
 int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, struct Scene *scene);
 struct DynamicPaintSurface *dynamicPaint_createNewSurface(struct DynamicPaintCanvasSettings *canvas, struct Scene *scene);
-void dynamicPaint_clearSurface(struct DynamicPaintSurface *surface);
-int  dynamicPaint_resetSurface(struct DynamicPaintSurface *surface);
+void dynamicPaint_clearSurface(struct Scene *scene, struct DynamicPaintSurface *surface);
+int  dynamicPaint_resetSurface(struct Scene *scene, struct DynamicPaintSurface *surface);
 void dynamicPaint_freeSurface(struct DynamicPaintSurface *surface);
 void dynamicPaint_freeCanvas(struct DynamicPaintModifierData *pmd);
 void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
@@ -85,7 +86,7 @@ void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
 struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
 
 /* image sequence baking */
-int dynamicPaint_createUVSurface(struct DynamicPaintSurface *surface);
+int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface);
 int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Scene *scene, struct Object *cObject, int frame);
 void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer);
 
index 11c9c00613f3141c51d00e499cbdcebc31258292..1c88a5c45dd06706ba2d18b97da2a719adb7acd5 100644 (file)
@@ -209,6 +209,7 @@ const char *BKE_mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh);
 
 struct BoundBox *BKE_mesh_boundbox_get(struct Object *ob);
 void BKE_mesh_texspace_get(struct Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]);
+void BKE_mesh_texspace_copy_from_object(struct Mesh *me, struct Object *ob);
 
 /* if old, it converts mface->edcode to edge drawflags */
 void BKE_mesh_make_edges(struct Mesh *me, const bool use_old);
index 463720fb8cfdd8ed25785d6b038502656ed963d3..992792dcb999b90ff256ef2e9fd8730b3ed8e833 100644 (file)
@@ -95,15 +95,16 @@ void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat)
 void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
 void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
 void BKE_object_apply_mat4(struct Object *ob, float mat[4][4], const bool use_compat, const bool use_parent);
+void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]);
 
 bool BKE_object_pose_context_check(struct Object *ob);
 struct Object *BKE_object_pose_armature_get(struct Object *ob);
 
 void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob);
-void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob);
+void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]);
 void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime);
 void BKE_object_where_is_calc_time_ex(struct Scene *scene, struct Object *ob, float ctime,
-                                      struct RigidBodyWorld *rbw);
+                                      struct RigidBodyWorld *rbw, float r_originmat[3][3]);
 void BKE_object_where_is_calc_simul(struct Scene *scene, struct Object *ob);
 void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]);
 
index 34f34bb99518baf8765542b2e18f0bb0a990fcb9..61f665be5860a919ff66448edda356d3111ae369 100644 (file)
@@ -75,7 +75,17 @@ struct Base *BKE_scene_base_add(struct Scene *sce, struct Object *ob);
 void         BKE_scene_base_unlink(struct Scene *sce, struct Base *base);
 void         BKE_scene_base_deselect_all(struct Scene *sce);
 void         BKE_scene_base_select(struct Scene *sce, struct Base *selbase);
-int          BKE_scene_base_iter_next(struct Scene **scene, int val, struct Base **base, struct Object **ob);
+
+/* Scene base iteration function.
+ * Define struct here, so no need to bother with alloc/free it.
+ */
+typedef struct SceneBaseIter {
+       struct ListBase *duplilist;
+       struct DupliObject *dupob;
+       int fase;
+} SceneBaseIter;
+
+int          BKE_scene_base_iter_next(struct SceneBaseIter *iter, struct Scene **scene, int val, struct Base **base, struct Object **ob);
 
 void BKE_scene_base_flag_to_objects(struct Scene *scene);
 void BKE_scene_base_flag_from_objects(struct Scene *scene);
index 9fc0812fff7ca27756f9b5f8eeb9194d7bd97bc2..4494d127082091e498b0966b19523194f0662510 100644 (file)
@@ -334,7 +334,7 @@ typedef struct SeqLoadInfo {
        int tot_success;
        int tot_error;
        int len;        /* only for image strips */
-       char path[512];
+       char path[1024]; /* 1024 = FILE_MAX */
        char name[64];
 } SeqLoadInfo;
 
index 6bde0a501f3902d07929cd06704e925df63ad690..8f91c1cb2d904735329041a9906dd227f1c8a797 100644 (file)
@@ -484,8 +484,6 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask)
        Mesh tmp = *me;
        int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
        int did_shapekeys = 0;
-       float *texloc, *texrot, *texsize;
-       short *texflag;
        
        CustomData_reset(&tmp.vdata);
        CustomData_reset(&tmp.edata);
@@ -533,12 +531,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask)
        }
 
        /* copy texture space */
-       if (BKE_object_obdata_texspace_get(ob, &texflag, &texloc, &texsize, &texrot)) {
-               tmp.texflag = *texflag;
-               copy_v3_v3(tmp.loc, texloc);
-               copy_v3_v3(tmp.size, texsize);
-               copy_v3_v3(tmp.rot, texrot);
-       }
+       BKE_mesh_texspace_copy_from_object(&tmp, ob);
        
        /* not all DerivedMeshes store their verts/edges/faces in CustomData, so
         * we set them here in case they are missing */
@@ -655,21 +648,25 @@ void DM_add_poly_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
 
 void *DM_get_vert_data(DerivedMesh *dm, int index, int type)
 {
+       BLI_assert(index >= 0 && index < dm->getNumVerts(dm));
        return CustomData_get(&dm->vertData, index, type);
 }
 
 void *DM_get_edge_data(DerivedMesh *dm, int index, int type)
 {
+       BLI_assert(index >= 0 && index < dm->getNumEdges(dm));
        return CustomData_get(&dm->edgeData, index, type);
 }
 
 void *DM_get_tessface_data(DerivedMesh *dm, int index, int type)
 {
+       BLI_assert(index >= 0 && index < dm->getNumTessFaces(dm));
        return CustomData_get(&dm->faceData, index, type);
 }
 
 void *DM_get_poly_data(DerivedMesh *dm, int index, int type)
 {
+       BLI_assert(index >= 0 && index < dm->getNumPolys(dm));
        return CustomData_get(&dm->polyData, index, type);
 }
 
index dfffb7c795e3e805fd45cdfa14ea42c7a624b918..cf761bf3dab9300df73093b50a6e387f7ccac694 100644 (file)
@@ -981,6 +981,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
                        rule = BLI_findlink(&state->rules, rand % BLI_countlist(&state->rules));
 
                        apply_boid_rule(bbd, rule, &val, pa, -1.0);
+                       break;
                }
                case eBoidRulesetType_Average:
                {
index 307dbc648473aff28e2a41b8c7a452bcd0892e41..70b5d90120de9ea86905f2283f92fec1b2ade36a 100644 (file)
@@ -539,7 +539,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
        else if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
                float rotation = -mtex->rot;
                float point_2d[2] = {point[0], point[1]};
-               float x = 0.0f, y = 0.0f; /* Quite warnings */
+               float x, y;
                float co[3];
 
                x = point_2d[0] - br->stencil_pos[0];
@@ -658,7 +658,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br,
        if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
                float rotation = -mtex->rot;
                float point_2d[2] = {point[0], point[1]};
-               float x = 0.0f, y = 0.0f; /* Quite warnings */
+               float x, y;
                float co[3];
 
                x = point_2d[0] - br->mask_stencil_pos[0];
@@ -993,7 +993,8 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side)
                                co[2] = 0.0f;
 
                                /* This is copied from displace modifier code */
-                               hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, NULL);
+                               /* TODO(sergey): brush are always cacheing with CM enabled for now. */
+                               hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, NULL, true);
 
                                /* if the texture gave an RGB value, we assume it didn't give a valid
                                 * intensity, so calculate one (formula from do_material_tex).
index 0cd13d528d559fba45a2364f33da23aadd1ede93..c78038c0f6673a7acfd92628a1fb562eea0b4510 100644 (file)
@@ -2519,7 +2519,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
        
        /* only evaluate if there is a target */
        if (VALID_CONS_TARGET(ct)) {
-               float dvec[3], dist = 0.0f, sfac = 1.0f;
+               float dvec[3], dist, sfac = 1.0f;
                short clamp_surf = 0;
                
                /* calculate our current distance from the target */
index b6c608661cd3e648d72f59cc9a2c2e0727bebe29..e08474e22c992b129547fc6ebcf918b0d0c4b464 100644 (file)
@@ -1729,16 +1729,19 @@ bool CustomData_free_layer(CustomData *data, int type, int totelem, int index)
        data->totlayer--;
 
        /* if layer was last of type in array, set new active layer */
-       if ((index >= data->totlayer) || (data->layers[index].type != type)) {
-               i = CustomData_get_layer_index__notypemap(data, type);
-               
-               if (i >= 0)
-                       for (; i < data->totlayer && data->layers[i].type == type; i++) {
-                               data->layers[i].active--;
-                               data->layers[i].active_rnd--;
-                               data->layers[i].active_clone--;
-                               data->layers[i].active_mask--;
-                       }
+       i = CustomData_get_layer_index__notypemap(data, type);
+
+       if (i != -1) {
+               /* don't decrement zero index */
+               const int index_nonzero = index ? index : 1;
+               CustomDataLayer *layer;
+
+               for (layer = &data->layers[i]; i < data->totlayer && layer->type == type; i++, layer++) {
+                       if (layer->active       >= index_nonzero) layer->active--;
+                       if (layer->active_rnd   >= index_nonzero) layer->active_rnd--;
+                       if (layer->active_clone >= index_nonzero) layer->active_clone--;
+                       if (layer->active_mask  >= index_nonzero) layer->active_mask--;
+               }
        }
 
        if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
@@ -2073,6 +2076,8 @@ void *CustomData_get(const CustomData *data, int index, int type)
        int offset;
        int layer_index;
        
+       BLI_assert(index >= 0);
+
        /* get the layer index of the active layer of type */
        layer_index = CustomData_get_active_layer_index(data, type);
        if (layer_index < 0) return NULL;
@@ -2088,6 +2093,8 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
        int layer_index;
        int offset;
 
+       BLI_assert(index >= 0 && n >= 0);
+
        /* get the layer index of the first layer of type */
        layer_index = data->typemap[type];
        if (layer_index < 0) return NULL;
index a668c6a6d7baeeb3d343b85b09d21415b9174557..1d5eaf3a1fccbe8bed28ba5bf20e6d8a407b055e 100644 (file)
@@ -1449,12 +1449,13 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
        MEM_freeN(temp_data);
 }
 
-static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
+static void dynamicPaint_setInitialColor(Scene *scene, DynamicPaintSurface *surface)
 {
        PaintSurfaceData *sData = surface->data;
        PaintPoint *pPoint = (PaintPoint *)sData->type_data;
        DerivedMesh *dm = surface->canvas->dm;
        int i;
+       bool scene_color_manage = BKE_scene_check_color_management_enabled(scene);
 
        if (surface->type != MOD_DPAINT_SURFACE_T_PAINT)
                return;
@@ -1503,7 +1504,7 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
                                        uv[0] = tface[i].uv[j][0] * 2.0f - 1.0f;
                                        uv[1] = tface[i].uv[j][1] * 2.0f - 1.0f;
 
-                                       multitex_ext_safe(tex, uv, &texres, pool);
+                                       multitex_ext_safe(tex, uv, &texres, pool, scene_color_manage);
 
                                        if (texres.tin > pPoint[*vert].alpha) {
                                                copy_v3_v3(pPoint[*vert].color, &texres.tr);
@@ -1536,8 +1537,8 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
                                /* remap to -1.0 to 1.0 */
                                uv_final[0] = uv_final[0] * 2.0f - 1.0f;
                                uv_final[1] = uv_final[1] * 2.0f - 1.0f;
-                                       
-                               multitex_ext_safe(tex, uv_final, &texres, NULL);
+
+                               multitex_ext_safe(tex, uv_final, &texres, NULL, scene_color_manage);
 
                                /* apply color */
                                copy_v3_v3(pPoint[i].color, &texres.tr);
@@ -1596,7 +1597,7 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
 }
 
 /* clears surface data back to zero */
-void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
+void dynamicPaint_clearSurface(Scene *scene, DynamicPaintSurface *surface)
 {
        PaintSurfaceData *sData = surface->data;
        if (sData && sData->type_data) {
@@ -1613,7 +1614,7 @@ void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
 
                /* set initial color */
                if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
-                       dynamicPaint_setInitialColor(surface);
+                       dynamicPaint_setInitialColor(scene, surface);
 
                if (sData->bData)
                        sData->bData->clear = 1;
@@ -1621,7 +1622,7 @@ void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
 }
 
 /* completely (re)initializes surface (only for point cache types)*/
-int dynamicPaint_resetSurface(DynamicPaintSurface *surface)
+int dynamicPaint_resetSurface(Scene *scene, DynamicPaintSurface *surface)
 {
        int numOfPoints = dynamicPaint_surfaceNumOfPoints(surface);
        /* free existing data */
@@ -1642,16 +1643,16 @@ int dynamicPaint_resetSurface(DynamicPaintSurface *surface)
 
        /* set initial color */
        if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
-               dynamicPaint_setInitialColor(surface);
+               dynamicPaint_setInitialColor(scene, surface);
 
        return 1;
 }
 
 /* make sure allocated surface size matches current requirements */
-static int dynamicPaint_checkSurfaceData(DynamicPaintSurface *surface)
+static int dynamicPaint_checkSurfaceData(Scene *scene, DynamicPaintSurface *surface)
 {
        if (!surface->data || ((dynamicPaint_surfaceNumOfPoints(surface) != surface->data->total_points))) {
-               return dynamicPaint_resetSurface(surface);
+               return dynamicPaint_resetSurface(scene, surface);
        }
        return 1;
 }
@@ -1942,6 +1943,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
                /* loop through surfaces */
                for (; surface; surface = surface->next) {
                        int current_frame = (int)scene->r.cfra;
+                       bool no_surface_data;
 
                        /* free bake data if not required anymore */
                        surface_freeUnusedData(surface);
@@ -1951,12 +1953,13 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
                        if (!(surface->flags & MOD_DPAINT_ACTIVE)) continue;
 
                        /* make sure surface is valid */
-                       if (!dynamicPaint_checkSurfaceData(surface)) continue;
+                       no_surface_data = surface->data == NULL;
+                       if (!dynamicPaint_checkSurfaceData(scene, surface)) continue;
 
                        /* limit frame range */
                        CLAMP(current_frame, surface->start_frame, surface->end_frame);
 
-                       if (current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
+                       if (no_surface_data || current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
                                PointCache *cache = surface->pointcache;
                                PTCacheID pid;
                                surface->current_frame = current_frame;
@@ -2223,7 +2226,7 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
 /*
  *     Create a surface for uv image sequence format
  */
-int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
+int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
 {
        /* Antialias jitter point relative coords       */
        float jitter5sample[10] =  {0.0f, 0.0f,
@@ -2674,7 +2677,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
                }
 
 #endif
-               dynamicPaint_setInitialColor(surface);
+               dynamicPaint_setInitialColor(scene, surface);
        }
 
        return (error == 0);
index 87f7da8a1fb2cd462b5e98616f8996e979e07bc4..46cee96a53716d0f61656ba2248a335432524c5b 100644 (file)
@@ -1109,6 +1109,66 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *r_vert)
                copy_v3_v3(r_vert->co, bmdm->vertexCos[index]);
 }
 
+static void emDM_getVertCo(DerivedMesh *dm, int index, float r_co[3])
+{
+       EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+       BMesh *bm = bmdm->em->bm;
+
+       if (UNLIKELY(index < 0 || index >= bm->totvert)) {
+               BLI_assert(!"error in emDM_getVertCo");
+               return;
+       }
+
+       if (bmdm->vertexCos) {
+               copy_v3_v3(r_co, bmdm->vertexCos[index]);
+       }
+       else {
+               BMVert *ev = bmdm->em->vert_index[index];  /* should be EDBM_vert_at_index() */
+               // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+               copy_v3_v3(r_co, ev->co);
+       }
+}
+
+static void emDM_getVertNo(DerivedMesh *dm, int index, float r_no[3])
+{
+       EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+       BMesh *bm = bmdm->em->bm;
+
+       if (UNLIKELY(index < 0 || index >= bm->totvert)) {
+               BLI_assert(!"error in emDM_getVertNo");
+               return;
+       }
+
+       if (bmdm->vertexNos) {
+               copy_v3_v3(r_no, bmdm->vertexNos[index]);
+       }
+       else {
+               BMVert *ev = bmdm->em->vert_index[index];  /* should be EDBM_vert_at_index() */
+               // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+               copy_v3_v3(r_no, ev->no);
+       }
+}
+
+static void emDM_getPolyNo(DerivedMesh *dm, int index, float r_no[3])
+{
+       EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+       BMesh *bm = bmdm->em->bm;
+
+       if (UNLIKELY(index < 0 || index >= bm->totface)) {
+               BLI_assert(!"error in emDM_getPolyNo");
+               return;
+       }
+
+       if (bmdm->polyNos) {
+               copy_v3_v3(r_no, bmdm->polyNos[index]);
+       }
+       else {
+               BMFace *efa = bmdm->em->face_index[index];  /* should be EDBM_vert_at_index() */
+               // efa = BM_face_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+               copy_v3_v3(r_no, efa->no);
+       }
+}
+
 static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *r_edge)
 {
        EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
@@ -1456,6 +1516,9 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
        bmdm->dm.getNumPolys = emDM_getNumPolys;
 
        bmdm->dm.getVert = emDM_getVert;
+       bmdm->dm.getVertCo = emDM_getVertCo;
+       bmdm->dm.getVertNo = emDM_getVertNo;
+       bmdm->dm.getPolyNo = emDM_getPolyNo;
        bmdm->dm.getEdge = emDM_getEdge;
        bmdm->dm.getTessFace = emDM_getTessFace;
        bmdm->dm.copyVertArray = emDM_copyVertArray;
@@ -1487,6 +1550,7 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
        bmdm->dm.release = emDM_release;
 
        bmdm->vertexCos = vertexCos;
+       bmdm->dm.deformedOnly = (vertexCos != NULL);
 
        if (cd_dvert_offset != -1) {
                BMIter iter;
index 02d1621e408b0fe547fe9de1e6c178e9fee99bb7..0df8684044a082efb64133faedfa810eb6a50b20 100644 (file)
@@ -744,6 +744,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
        float nabla = eff->pd->tex_nabla;
        int hasrgb;
        short mode = eff->pd->tex_mode;
+       bool scene_color_manage;
 
        if (!eff->pd->tex)
                return;
@@ -763,7 +764,9 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
                mul_m4_v3(eff->ob->imat, tex_co);
        }
 
-       hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result, NULL);
+       scene_color_manage = BKE_scene_check_color_management_enabled(eff->scene);
+
+       hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result, NULL, scene_color_manage);
 
        if (hasrgb && mode==PFIELD_TEX_RGB) {
                force[0] = (0.5f - result->tr) * strength;
@@ -774,15 +777,15 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
                strength/=nabla;
 
                tex_co[0] += nabla;
-               multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+1, NULL);
+               multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+1, NULL, scene_color_manage);
 
                tex_co[0] -= nabla;
                tex_co[1] += nabla;
-               multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+2, NULL);
+               multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+2, NULL, scene_color_manage);
 
                tex_co[1] -= nabla;
                tex_co[2] += nabla;
-               multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3, NULL);
+               multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3, NULL, scene_color_manage);
 
                if (mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we don't have rgb fall back to grad */
                        /* generate intensity if texture only has rgb value */
index f763670baefc32b80a9d3502700cc96de58664e6..8958680d611198c6f58bef5bd71853958763f071 100644 (file)
@@ -1697,7 +1697,7 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
                                
                                /* perform operations on the total if appropriate */
                                if (driver->type == DRIVER_TYPE_AVERAGE)
-                                       driver->curval = (value / (float)tot);
+                                       driver->curval = tot ? (value / (float)tot) : 0.0f;
                                else
                                        driver->curval = value;
                        }
index b3edeb67928355faa610ad118e8bb3c0598243d3..7c23438f93d1f7186d7123e2afb3ea4ad5298750 100644 (file)
@@ -516,7 +516,7 @@ struct CharTrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int
 
        /* Create unicode string */
        utf8len = BLI_strlen_utf8(cu->str);
-       mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
+       mem = MEM_mallocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
 
        BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1);
 
index e28b1bf3f69eddf2a8d00bfd446c855c6510c2e6..135d847cce7c8a48f9e8840da11b349a5ff776cc 100644 (file)
@@ -633,7 +633,7 @@ Image *BKE_image_load_exists(const char *filepath)
        for (ima = G.main->image.first; ima; ima = ima->id.next) {
                if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) {
                        BLI_strncpy(strtest, ima->name, sizeof(ima->name));
-                       BLI_path_abs(strtest, G.main->name);
+                       BLI_path_abs(strtest, ID_BLEND_PATH(G.main, &ima->id));
 
                        if (BLI_path_cmp(strtest, str) == 0) {
                                if (ima->anim == NULL || ima->id.us == 0) {
@@ -2718,8 +2718,8 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
        re = RE_GetRender(iuser->scene->id.name);
 
        channels = 4;
-       layer = (iuser) ? iuser->layer : 0;
-       pass = (iuser) ? iuser->pass : 0;
+       layer = iuser->layer;
+       pass = iuser->pass;
 
        if (from_render) {
                RE_AcquireResultImage(re, &rres);
index c9b904e76ac3bb47e7704bc64020e61826d71512..a4892253c63b2b86d16e8ebd811d7fbffb416b47 100644 (file)
@@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
         * we want either a Mesh with no derived data, or derived data with
         * deformverts
         */
-       if (target && target->type == OB_MESH) {
+       if (target->type == OB_MESH) {
                /* if there's derived data without deformverts, don't use vgroups */
                if (dm) {
                        use_vgroups = (dm->getVertData(dm, 0, CD_MDEFORMVERT) != NULL);
index f47f86744afb956fc93d51d0c8110f2b773e2563..3ab1a8093bee6333a6f9bbb9288a768cf4675fa5 100644 (file)
@@ -183,7 +183,7 @@ static LineStyleModifier *new_modifier(int type, size_t size)
 
        m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
        m->type = type;
-       strcpy(m->name, modifier_name[type]);
+       BLI_strncpy(m->name, modifier_name[type], sizeof(m->name));
        m->influence = 1.0f;
        m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED;
 
index 82410d56c52e1ebd87d6772870999656e2e69f9e..e68f87211eb90842117e6b175ec319c084ef5551 100644 (file)
@@ -530,7 +530,7 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
 
                if (1) {
                        /* now convert linknodes into arrays for faster per pixel access */
-                       unsigned int  **buckets_face = MEM_mallocN(bucket_tot * sizeof(unsigned int **), __func__);
+                       unsigned int  **buckets_face = MEM_mallocN(bucket_tot * sizeof(*buckets_face), __func__);
                        unsigned int bucket_index;
 
                        for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) {
index c8cd65e94773948018984168642b4faecab4da12..a445d43da00f5aef9fe83a21bc88cf4fd5f43baf 100644 (file)
@@ -2051,8 +2051,10 @@ int do_version_tface(Main *main, int fileload)
                                printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name + 2);
                                nowarning = 0;
                        }
-                       else
-                               convert_tfacematerial(main, ma); continue;
+                       else {
+                               convert_tfacematerial(main, ma);
+                       }
+                       continue;
                }
        
                /* no conflicts in this material - 90% of cases
index 31212c3a6b79b7fb71c0724444fdcd87db918da7..173b193b7527ff542c6e5f28fb8b11f5c2128f0c 100644 (file)
@@ -485,14 +485,15 @@ void BKE_mball_properties_copy(Scene *scene, Object *active_object)
        MetaBall *active_mball = (MetaBall *)active_object->data;
        int basisnr, obnr;
        char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
-       
+       SceneBaseIter iter;
+
        BLI_split_name_num(basisname, &basisnr, active_object->id.name + 2, '.');
 
        /* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
-       if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+       if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
                return;
        
-       while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+       while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
                if (ob->type == OB_MBALL) {
                        if (ob != active_object) {
                                BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@@ -529,14 +530,15 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
        Object *ob, *bob = basis;
        int basisnr, obnr;
        char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
+       SceneBaseIter iter;
 
        BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
 
        /* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
-       if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+       if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
                return NULL;
 
-       while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+       while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
                if (ob->type == OB_MBALL) {
                        if (ob != bob) {
                                BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@@ -1644,6 +1646,14 @@ BLI_INLINE void copy_v3_fl3(float v[3], float x, float y, float z)
        v[2] = z;
 }
 
+/* TODO(sergey): Perhaps it could be general utility function in mathutils. */
+static bool has_zero_axis_m4(float matrix[4][4])
+{
+       return len_squared_v3(matrix[0]) < FLT_EPSILON ||
+              len_squared_v3(matrix[1]) < FLT_EPSILON ||
+              len_squared_v3(matrix[2]) < FLT_EPSILON;
+}
+
 static float init_meta(PROCESS *process, Scene *scene, Object *ob)    /* return totsize */
 {
        Scene *sce_iter = scene;
@@ -1655,7 +1665,8 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob)    /* return
        //float max = 0.0f;
        int a, obnr, zero_size = 0;
        char obname[MAX_ID_NAME];
-       
+       SceneBaseIter iter;
+
        copy_m4_m4(obmat, ob->obmat);   /* to cope with duplicators from BKE_scene_base_iter_next */
        invert_m4_m4(obinv, ob->obmat);
        a = 0;
@@ -1663,8 +1674,8 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob)    /* return
        BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
        
        /* make main array */
-       BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL);
-       while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &bob)) {
+       BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL);
+       while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &bob)) {
 
                if (bob->type == OB_MBALL) {
                        zero_size = 0;
@@ -1691,13 +1702,13 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob)    /* return
 
                        /* when metaball object has zero scale, then MetaElem to this MetaBall
                         * will not be put to mainb array */
-                       if (bob->size[0] == 0.0f || bob->size[1] == 0.0f || bob->size[2] == 0.0f) {
+                       if (has_zero_axis_m4(bob->obmat)) {
                                zero_size = 1;
                        }
                        else if (bob->parent) {
                                struct Object *pob = bob->parent;
                                while (pob) {
-                                       if (pob->size[0] == 0.0f || pob->size[1] == 0.0f || pob->size[2] == 0.0f) {
+                                       if (has_zero_axis_m4(pob->obmat)) {
                                                zero_size = 1;
                                                break;
                                        }
@@ -2225,15 +2236,16 @@ static void mball_count(PROCESS *process, Scene *scene, Object *basis)
        MetaElem *ml = NULL;
        int basisnr, obnr;
        char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
+       SceneBaseIter iter;
 
        BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
        process->totelem = 0;
 
        /* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
-       if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+       if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
                return;
 
-       while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+       while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
                if (ob->type == OB_MBALL) {
                        if (ob == bob) {
                                MetaBall *mb = ob->data;
@@ -2434,6 +2446,7 @@ bool BKE_mball_center_median(MetaBall *mb, float r_cent[3])
 
        for (ml = mb->elems.first; ml; ml = ml->next) {
                add_v3_v3(r_cent, &ml->x);
+               total++;
        }
 
        if (total) {
index b40c3475df523e3f2488ac04b93e4072578586d4..f24a55dcc44dd30aeeaaa38ac0ed4607985f01ff 100644 (file)
@@ -702,6 +702,19 @@ void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_siz
        if (r_size) copy_v3_v3(r_size, me->size);
 }
 
+void BKE_mesh_texspace_copy_from_object(Mesh *me, Object *ob)
+{
+       float *texloc, *texrot, *texsize;
+       short *texflag;
+
+       if (BKE_object_obdata_texspace_get(ob, &texflag, &texloc, &texsize, &texrot)) {
+               me->texflag = *texflag;
+               copy_v3_v3(me->loc, texloc);
+               copy_v3_v3(me->size, texsize);
+               copy_v3_v3(me->rot, texrot);
+       }
+}
+
 float (*BKE_mesh_orco_verts_get(Object *ob))[3]
 {
        Mesh *me = ob->data;
@@ -2450,10 +2463,11 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
                                    int totvert, int totpoly, int totloop)
 {
        MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert poly map");
-       int *indices = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
-
+       int *indices, *index_iter;
        int i, j;
 
+       indices = index_iter = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
+
        /* Count number of polys for each vertex */
        for (i = 0; i < totpoly; i++) {
                const MPoly *p = &mpoly[i];
@@ -2464,8 +2478,8 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
 
        /* Assign indices mem */
        for (i = 0; i < totvert; i++) {
-               map[i].indices = indices;
-               indices += map[i].count;
+               map[i].indices = index_iter;
+               index_iter += map[i].count;
 
                /* Reset 'count' for use as index in last loop */
                map[i].count = 0;
@@ -2495,6 +2509,7 @@ void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
 {
        MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert-edge map");
        int *indices = MEM_mallocN(sizeof(int) * totedge * 2, "vert-edge map mem");
+       int *i_pt = indices;
 
        int i;
 
@@ -2506,8 +2521,8 @@ void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
 
        /* Assign indices mem */
        for (i = 0; i < totvert; i++) {
-               map[i].indices = indices;
-               indices += map[i].count;
+               map[i].indices = i_pt;
+               i_pt += map[i].count;
 
                /* Reset 'count' for use as index in last loop */
                map[i].count = 0;
index d062f302379f4fb1e17e88d8dfb66cd035f3b7cd..ef3b7ca0bdf7fbe6e23754df8ab1b72228c006e1 100644 (file)
@@ -440,7 +440,7 @@ static void *moviecache_getprioritydata(void *key_v)
        MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *) key_v;
        MovieClipCachePriorityData *priority_data;
 
-       priority_data = MEM_callocN(sizeof(priority_data), "movie cache clip priority data");
+       priority_data = MEM_callocN(sizeof(*priority_data), "movie cache clip priority data");
        priority_data->framenr = key->framenr;
 
        return priority_data;
index 8488fa63e2129211598f544f06d5db5edd2b3d10..386b50c7018e2023e6de48e746fbf04be4901519 100644 (file)
@@ -349,9 +349,6 @@ static void free_dynamic_typeinfo(bNodeType *ntype)
                if (ntype->outputs) {
                        MEM_freeN(ntype->outputs);
                }
-               if (ntype->ui_name) {
-                       MEM_freeN((void *)ntype->ui_name);
-               }
        }
 }
 
index f1183868e8b3b28e06594fda4dff0c6594d76e8d..e79a759407b2544f02792aee2126e9113448c7a0 100644 (file)
 
 #include "GPU_material.h"
 
-/* Local function protos */
-float originmat[3][3];  /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */
-
 void BKE_object_workob_clear(Object *workob)
 {
        memset(workob, 0, sizeof(Object));
@@ -1739,6 +1736,18 @@ void BKE_object_to_mat4(Object *ob, float mat[4][4])
        add_v3_v3v3(mat[3], ob->loc, ob->dloc);
 }
 
+void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
+{
+       if (ob->parent) {
+               float invmat[4][4]; /* for inverse of parent's matrix */
+               invert_m4_m4(invmat, ob->parent->obmat);
+               mul_m4_m4m4(mat, invmat, ob->obmat);
+       }
+       else {
+               copy_m4_m4(mat, ob->obmat);
+       }
+}
+
 /* extern */
 int enable_cu_speed = 1;
 
@@ -1991,7 +2000,11 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4])
        }
 }
 
-static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4], int simul)
+/**
+ * \param r_originmat  Optional matrix that stores the space the object is in (without its own matrix applied)
+ */
+static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4],
+                            float r_originmat[3][3], const bool simul)
 {
        float totmat[4][4];
        float tmat[4][4];
@@ -2056,8 +2069,10 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4
 
        }
        else {
-               /* external usable originmat */
-               copy_m3_m4(originmat, tmat);
+               if (r_originmat) {
+                       /* usable originmat */
+                       copy_m3_m4(r_originmat, tmat);
+               }
                
                /* origin, for help line */
                if ((ob->partype & PARTYPE) == PARSKEL) {
@@ -2091,7 +2106,7 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[
 
 /* note, scene is the active scene while actual_scene is the scene the object resides in */
 void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
-                                      RigidBodyWorld *rbw)
+                                      RigidBodyWorld *rbw, float r_originmat[3][3])
 {
        if (ob == NULL) return;
        
@@ -2103,7 +2118,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
                float slowmat[4][4] = MAT4_UNITY;
                
                /* calculate parent matrix */
-               solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
+               solve_parenting(scene, ob, par, ob->obmat, slowmat, r_originmat, false);
                
                /* "slow parent" is definitely not threadsafe, and may also give bad results jumping around 
                 * An old-fashioned hack which probably doesn't really cut it anymore
@@ -2138,7 +2153,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
 
 void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
 {
-       BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL);
+       BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL, NULL);
 }
 
 /* get object transformation matrix without recalculating dependencies and
@@ -2152,7 +2167,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
        if (ob->parent) {
                Object *par = ob->parent;
                
-               solve_parenting(scene, ob, par, obmat, slowmat, 1);
+               solve_parenting(scene, ob, par, obmat, slowmat, NULL, true);
                
                if (ob->partype & PARSLOW)
                        where_is_object_parslow(ob, obmat, slowmat);
@@ -2162,13 +2177,13 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
        }
 }
 
-void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob)
+void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
 {
-       BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw);
+       BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
 }
 void BKE_object_where_is_calc(Scene *scene, Object *ob)
 {
-       BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL);
+       BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
 }
 
 /* was written for the old game engine (until 2.04) */
@@ -2186,7 +2201,7 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
        if (ob->parent) {
                par = ob->parent;
                
-               solve_parenting(scene, ob, par, ob->obmat, slowmat, 1);
+               solve_parenting(scene, ob, par, ob->obmat, slowmat, NULL, true);
                
                if (ob->partype & PARSLOW) {
                        fac1 = (float)(1.0 / (1.0 + fabs(ob->sf)));
@@ -2658,7 +2673,7 @@ void BKE_object_handle_update_ex(Scene *scene, Object *ob,
                                        copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
                        }
                        else
-                               BKE_object_where_is_calc_ex(scene, rbw, ob);
+                               BKE_object_where_is_calc_ex(scene, rbw, ob, NULL);
                }
                
                if (ob->recalc & OB_RECALC_DATA) {
index f6901c7b81b3889da9577a874c0ecaad8e2744cc..6bea4bec3ce1fc5cea6b89165197ea8035463cbf 100644 (file)
@@ -3414,8 +3414,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m
        OrigSpaceFace *osface;
        float (*orcodata)[3];
 
-       int i = pa->num_dmcache == DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache;
-       
+       int i = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num : pa->num_dmcache;
        if (i == -1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; }
 
        mface = dm->getTessFaceData(dm, i, CD_MFACE);
@@ -4511,7 +4510,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
                        num = DMCACHE_NOTFOUND;
                }
 
-               if (mtface && num != DMCACHE_NOTFOUND) {
+               if (mtface && !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
                        mface = psmd->dm->getTessFaceData(psmd->dm, num, CD_MFACE);
                        mtface += num;
                        psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);
index c9be73c4bd45fe70b0d1c3f7f88b05f4903bbf0c..16ea71204ccbe53eb45ee92e99d6f6b68572a02d 100644 (file)
@@ -1660,17 +1660,22 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
 {
        Object *ob = sim->ob;
        ParticleSystem *psys = sim->psys;
-       ParticleSettings *part;
+       ParticleSettings *part = psys->part;
        ParticleTexture ptex;
        float fac, phasefac, nor[3] = {0,0,0},loc[3],vel[3] = {0.0,0.0,0.0},rot[4],q2[4];
        float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3] = {0.0,0.0,0.0};
        float x_vec[3] = {1.0,0.0,0.0}, utan[3] = {0.0,1.0,0.0}, vtan[3] = {0.0,0.0,1.0}, rot_vec[3] = {0.0,0.0,0.0};
        float q_phase[4];
+
+       const bool use_boids = ((part->phystype == PART_PHYS_BOIDS) &&
+                               (pa->boid != NULL));
+       const bool use_tangents = ((use_boids == false) &&
+                                  ((part->tanfac != 0.0f) || (part->rotmode == PART_ROT_NOR_TAN)));
+
        int p = pa - psys->particles;
-       part=psys->part;
 
        /* get birth location from object               */
-       if (part->tanfac != 0.f)
+       if (use_tangents)
                psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
        else
                psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
@@ -1688,7 +1693,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
        normalize_v3(nor);
 
        /* -tangent                                                             */
-       if (part->tanfac!=0.0f) {
+       if (use_tangents) {
                //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
                float phase=0.0f;
                mul_v3_fl(vtan,-cosf((float)M_PI*(part->tanphase+phase)));
@@ -1737,7 +1742,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
                mul_qt_qtqt(r_rot,r_rot,rot);
        }
 
-       if (part->phystype==PART_PHYS_BOIDS && pa->boid) {
+       if (use_boids) {
                float dvec[3], q[4], mat[3][3];
 
                copy_v3_v3(state->co,loc);
@@ -1823,35 +1828,112 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
                unit_qt(state->rot);
 
                if (part->rotmode) {
+                       bool use_global_space;
+
                        /* create vector into which rotation is aligned */
                        switch (part->rotmode) {
                                case PART_ROT_NOR:
+                               case PART_ROT_NOR_TAN:
                                        copy_v3_v3(rot_vec, nor);
+                                       use_global_space = false;
                                        break;
                                case PART_ROT_VEL:
                                        copy_v3_v3(rot_vec, vel);
+                                       use_global_space = true;
                                        break;
                                case PART_ROT_GLOB_X:
                                case PART_ROT_GLOB_Y:
                                case PART_ROT_GLOB_Z:
                                        rot_vec[part->rotmode - PART_ROT_GLOB_X] = 1.0f;
+                                       use_global_space = true;
                                        break;
                                case PART_ROT_OB_X:
                                case PART_ROT_OB_Y:
                                case PART_ROT_OB_Z:
                                        copy_v3_v3(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]);
+                                       use_global_space = false;
+                                       break;
+                               default:
+                                       use_global_space = true;
                                        break;
                        }
                        
                        /* create rotation quat */
-                       negate_v3(rot_vec);
-                       vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ);
 
-                       /* randomize rotation quat */
-                       if (part->randrotfac!=0.0f)
-                               interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
-                       else
-                               copy_qt_qt(rot,q2);
+
+                       if (use_global_space) {
+                               negate_v3(rot_vec);
+                               vec_to_quat(q2, rot_vec, OB_POSX, OB_POSZ);
+
+                               /* randomize rotation quat */
+                               if (part->randrotfac != 0.0f) {
+                                       interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
+                               }
+                               else {
+                                       copy_qt_qt(rot, q2);
+                               }
+                       }
+                       else {
+                               /* calculate rotation in local-space */
+                               float q_obmat[4];
+                               float q_imat[4];
+
+                               mat4_to_quat(q_obmat, ob->obmat);
+                               invert_qt_qt(q_imat, q_obmat);
+
+
+                               if (part->rotmode != PART_ROT_NOR_TAN) {
+                                       float rot_vec_local[3];
+
+                                       /* rot_vec */
+                                       negate_v3(rot_vec);
+                                       copy_v3_v3(rot_vec_local, rot_vec);
+                                       mul_qt_v3(q_imat, rot_vec_local);
+                                       normalize_v3(rot_vec_local);
+
+                                       vec_to_quat(q2, rot_vec_local, OB_POSX, OB_POSZ);
+                               }
+                               else {
+                                       /* (part->rotmode == PART_ROT_NOR_TAN) */
+                                       float tmat[3][3];
+
+                                       /* note: utan_local is not taken from 'utan', we calculate from rot_vec/vtan */
+                                       /* note: it looks like rotation phase may be applied twice (once with vtan, again below)
+                                        * however this isn't the case - campbell */
+                                       float *rot_vec_local = tmat[0];
+                                       float *vtan_local    = tmat[1];
+                                       float *utan_local    = tmat[2];
+
+                                       /* use tangents */
+                                       BLI_assert(use_tangents == true);
+
+                                       /* rot_vec */
+                                       copy_v3_v3(rot_vec_local, rot_vec);
+                                       mul_qt_v3(q_imat, rot_vec_local);
+
+                                       /* vtan_local */
+                                       copy_v3_v3(vtan_local, vtan);  /* flips, cant use */
+                                       mul_qt_v3(q_imat, vtan_local);
+
+                                       /* ensure orthogonal matrix (rot_vec aligned) */
+                                       cross_v3_v3v3(utan_local, vtan_local, rot_vec_local);
+                                       cross_v3_v3v3(vtan_local, utan_local, rot_vec_local);
+
+                                       /* note: no need to normalize */
+                                       mat3_to_quat(q2, tmat);
+                               }
+
+                               /* randomize rotation quat */
+                               if (part->randrotfac != 0.0f) {
+                                       mul_qt_qtqt(r_rot, r_rot, q_imat);
+                                       interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
+                               }
+                               else {
+                                       copy_qt_qt(rot, q2);
+                               }
+
+                               mul_qt_qtqt(rot, q_obmat, rot);
+                       }
 
                        /* rotation phase */
                        phasefac = part->phasefac;
index 6f77d63d90f3887f370f3469b137d85c57603a2a..06748dfc44d63e08e87c5e8f6fd827d0dfadfbb2 100644 (file)
@@ -2800,7 +2800,7 @@ int  BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
                        smokeModifier_reset_turbulence(pid->calldata);
 #endif
                else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
-                       dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata);
+                       dynamicPaint_clearSurface(scene, (DynamicPaintSurface*)pid->calldata);
        }
        if (clear)
                BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
index 26563afa65b4441019014076409f94fa6d99266c..1874523dac9908ffaf4089999885dbddd2771512 100644 (file)
@@ -684,12 +684,9 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
                }
        }
 
-       /* sort baselist */
-       DAG_scene_relations_rebuild(bmain, scene);
-       
-       /* ensure dags are built for sets */
+       /* sort baselist for scene and sets */
        for (sce = scene; sce; sce = sce->set)
-               DAG_scene_relations_update(bmain, sce);
+               DAG_scene_relations_rebuild(bmain, sce);
 
        /* copy layers and flags from bases to objects */
        for (base = scene->base.first; base; base = base->next) {
@@ -746,17 +743,16 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
 /* used by metaballs
  * doesn't return the original duplicated object, only dupli's
  */
-int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
+int BKE_scene_base_iter_next(SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
 {
-       static ListBase *duplilist = NULL;
-       static DupliObject *dupob;
-       static int fase = F_START, in_next_object = 0;
+       static int in_next_object = 0;
        int run_again = 1;
        
        /* init */
        if (val == 0) {
-               fase = F_START;
-               dupob = NULL;
+               iter->fase = F_START;
+               iter->dupob = NULL;
+               iter->duplilist = NULL;
                
                /* XXX particle systems with metas+dupligroups call this recursively */
                /* see bug #18725 */
@@ -774,11 +770,11 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
                        run_again = 0;
 
                        /* the first base */
-                       if (fase == F_START) {
+                       if (iter->fase == F_START) {
                                *base = (*scene)->base.first;
                                if (*base) {
                                        *ob = (*base)->object;
-                                       fase = F_SCENE;
+                                       iter->fase = F_SCENE;
                                }
                                else {
                                        /* exception: empty scene */
@@ -787,20 +783,20 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
                                                if ((*scene)->base.first) {
                                                        *base = (*scene)->base.first;
                                                        *ob = (*base)->object;
-                                                       fase = F_SCENE;
+                                                       iter->fase = F_SCENE;
                                                        break;
                                                }
                                        }
                                }
                        }
                        else {
-                               if (*base && fase != F_DUPLI) {
+                               if (*base && iter->fase != F_DUPLI) {
                                        *base = (*base)->next;
                                        if (*base) {
                                                *ob = (*base)->object;
                                        }
                                        else {
-                                               if (fase == F_SCENE) {
+                                               if (iter->fase == F_SCENE) {
                                                        /* (*scene) is finished, now do the set */
                                                        while ((*scene)->set) {
                                                                (*scene) = (*scene)->set;
@@ -816,45 +812,45 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
                        }
                        
                        if (*base == NULL) {
-                               fase = F_START;
+                               iter->fase = F_START;
                        }
                        else {
-                               if (fase != F_DUPLI) {
+                               if (iter->fase != F_DUPLI) {
                                        if ( (*base)->object->transflag & OB_DUPLI) {
                                                /* groups cannot be duplicated for mballs yet, 
                                                 * this enters eternal loop because of 
                                                 * makeDispListMBall getting called inside of group_duplilist */
                                                if ((*base)->object->dup_group == NULL) {
-                                                       duplilist = object_duplilist((*scene), (*base)->object, FALSE);
+                                                       iter->duplilist = object_duplilist((*scene), (*base)->object, FALSE);
                                                        
-                                                       dupob = duplilist->first;
+                                                       iter->dupob = iter->duplilist->first;
 
-                                                       if (!dupob)
-                                                               free_object_duplilist(duplilist);
+                                                       if (!iter->dupob)
+                                                               free_object_duplilist(iter->duplilist);
                                                }
                                        }
                                }
                                /* handle dupli's */
-                               if (dupob) {
+                               if (iter->dupob) {
                                        
-                                       copy_m4_m4(dupob->ob->obmat, dupob->mat);
+                                       copy_m4_m4(iter->dupob->ob->obmat, iter->dupob->mat);
                                        
                                        (*base)->flag |= OB_FROMDUPLI;
-                                       *ob = dupob->ob;
-                                       fase = F_DUPLI;
+                                       *ob = iter->dupob->ob;
+                                       iter->fase = F_DUPLI;
                                        
-                                       dupob = dupob->next;
+                                       iter->dupob = iter->dupob->next;
                                }
-                               else if (fase == F_DUPLI) {
-                                       fase = F_SCENE;
+                               else if (iter->fase == F_DUPLI) {
+                                       iter->fase = F_SCENE;
                                        (*base)->flag &= ~OB_FROMDUPLI;
                                        
-                                       for (dupob = duplilist->first; dupob; dupob = dupob->next) {
-                                               copy_m4_m4(dupob->ob->obmat, dupob->omat);
+                                       for (iter->dupob = iter->duplilist->first; iter->dupob; iter->dupob = iter->dupob->next) {
+                                               copy_m4_m4(iter->dupob->ob->obmat, iter->dupob->omat);
                                        }
                                        
-                                       free_object_duplilist(duplilist);
-                                       duplilist = NULL;
+                                       free_object_duplilist(iter->duplilist);
+                                       iter->duplilist = NULL;
                                        run_again = 1;
                                }
                        }
@@ -870,7 +866,7 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
        /* reset recursion test */
        in_next_object = 0;
        
-       return fase;
+       return iter->fase;
 }
 
 Object *BKE_scene_camera_find(Scene *sc)
@@ -1483,6 +1479,16 @@ void BKE_scene_disable_color_management(Scene *scene)
 
 int BKE_scene_check_color_management_enabled(const Scene *scene)
 {
+       /* TODO(sergey): shouldn't be needed. but we're currently far to close to the release,
+        *               so better be extra-safe than sorry.
+        *
+        *               Will remove the check after the release.
+        */
+       if (!scene) {
+               BLI_assert(!"Shouldn't happen!");
+               return TRUE;
+       }
+
        return strcmp(scene->display_settings.display_device, "None") != 0;
 }
 
index 68fac399c51cbedd4c05828e65bd6874e8614e62..e81afc7efb61d979f650d673a571eef455813310 100644 (file)
@@ -50,6 +50,7 @@
 #include "BLI_listbase.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
+#include "BLI_string_utf8.h"
 #include "BLI_threads.h"
 #include "BLI_utildefines.h"
 
@@ -3111,8 +3112,18 @@ static void sequence_invalidate_cache(Scene *scene, Sequence *seq, int invalidat
        Editing *ed = scene->ed;
 
        /* invalidate cache for current sequence */
-       if (invalidate_self)
+       if (invalidate_self) {
+               if (seq->anim) {
+                       /* Animation structure holds some buffers inside,
+                        * so for proper cache invalidation we need to
+                        * re-open the animation.
+                        */
+                       IMB_free_anim(seq->anim);
+                       seq->anim = NULL;
+               }
+
                BKE_sequencer_cache_cleanup_sequence(seq);
+       }
 
        /* if invalidation is invoked from sequence free routine, effectdata would be NULL here */
        if (seq->effectdata && seq->type == SEQ_TYPE_SPEED)
@@ -3938,7 +3949,8 @@ Mask *BKE_sequencer_mask_get(Scene *scene)
 static void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
 {
        if (seq) {
-               BLI_strncpy(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
+               BLI_strncpy_utf8(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
+               BLI_utf8_invalid_strip(seq->name + 2, sizeof(seq->name) - 2);
                BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
 
                if (seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
index 05c3550d81016b34aab21103449ab582766e4e40..b2c0a45cbc4e80c2d36919c2a0b7f02306022bb3 100644 (file)
@@ -1413,12 +1413,14 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke
        }
 }
 
+/* TODO(sergey): de-duplicate with get_texture_value from modifier utils */
+/* NOTE: Skips color management, because result is only used for value now, not for color. */
 static void get_texture_value(Tex *texture, float tex_co[3], TexResult *texres)
 {
        int result_type;
 
        /* no node textures for now */
-       result_type = multitex_ext_safe(texture, tex_co, texres, NULL);
+       result_type = multitex_ext_safe(texture, tex_co, texres, NULL, false);
 
        /* if the texture gave an RGB value, we assume it didn't give a valid
         * intensity, since this is in the context of modifiers don't use perceptual color conversion.
@@ -2100,7 +2102,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
                        /* sample subframes */
                        else {
                                int scene_frame = scene->r.cfra;
-                               float scene_subframe = scene->r.subframe;
+                               // float scene_subframe = scene->r.subframe;  // UNUSED
                                int subframe;
                                for (subframe = 0; subframe <= subframes; subframe++) {
                                        EmissionMap em_temp = {0};
index 296f25e303e163486a68f2100cd3e26779403a4e..aec924e15b3082667d3eb51cc22d0da814295f22 100644 (file)
@@ -847,19 +847,6 @@ int txt_utf8_column_to_offset(const char *str, int column)
        return offset;
 }
 
-/* returns the real number of characters in string */
-/* not the same as BLI_strlen_utf8, which returns length for wide characters */
-static int txt_utf8_len(const char *src)
-{
-       int len;
-
-       for (len = 0; *src; len++) {
-               src += BLI_str_utf8_size(src);
-       }
-
-       return len;
-}
-
 void txt_move_up(Text *text, short sel)
 {
        TextLine **linep;
@@ -2059,7 +2046,7 @@ void txt_do_undo(Text *text)
                                text->undo_pos--;
                        }
                        buf[i] = 0;
-                       linep = txt_utf8_len(buf);
+                       linep = BLI_strlen_utf8(buf);
                        MEM_freeN(buf);
                        
                        /* skip over the length that was stored again */
index 8141fc8aaa189e6bc35ee117be66b864538d3039..2c561dd447264ae9a9a7a4e581493b1b9cacc1ee 100644 (file)
@@ -3455,7 +3455,7 @@ static bool check_point_in_stroke(bGPDstroke *stroke, float x, float y)
                prev = i;
        }
 
-       return count % 2 ? true : false;
+       return (count % 2) ? true : false;
 }
 
 /* Check whether point is inside any stroke of grease pencil layer. */
index 097c9d076a4d0dbe9c50734df777e36938efd872..a69df62f505d3f1fbb76a47e2b34a145c8c2a40f 100644 (file)
@@ -95,6 +95,11 @@ typedef struct bUnitDef {
 #define B_UNIT_DEF_SUPPRESS 1 /* Use for units that are not used enough to be translated into for common use */
 #define B_UNIT_DEF_TENTH 2 /* Display a unit even if its value is 0.1, eg 0.1mm instead of 100um */
 
+/* workaround encoding issue with "µm", bug [#36090] */
+#define B_UNIT_CHAR_MICRO "\xb5"
+#define UM B_UNIT_CHAR_MICRO"m"
+#define US B_UNIT_CHAR_MICRO"s"
+
 /* define a single unit */
 typedef struct bUnitCollection {
        struct bUnitDef *units;
@@ -116,7 +121,7 @@ static struct bUnitDef buMetricLenDef[] = {
        {"decimeter", "decimeters",     "dm",  NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
        {"centimeter", "centimeters",   "cm",  NULL, "Centimeters", UN_SC_CM, 0.0,    B_UNIT_DEF_NONE},
        {"millimeter", "millimeters",   "mm",  NULL, "Millimeters", UN_SC_MM, 0.0,    B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
-       {"micrometer", "micrometers",   "µm",  "um", "Micrometers", UN_SC_UM, 0.0,    B_UNIT_DEF_NONE},     // micron too?
+       {"micrometer", "micrometers",   UM,    "um", "Micrometers", UN_SC_UM, 0.0,    B_UNIT_DEF_NONE},     // micron too?
 
        /* These get displayed because of float precision problems in the transform header,
         * could work around, but for now probably people wont use these */
@@ -149,7 +154,7 @@ static struct bUnitDef buMetricAreaDef[] = {
        {"square decimeter",  "square decimetees",  "dm²", "dm2",   "Square Decimeters", UN_SC_DM * UN_SC_DM, 0.0,    B_UNIT_DEF_SUPPRESS},
        {"square centimeter", "square centimeters", "cm²", "cm2",   "Square Centimeters", UN_SC_CM * UN_SC_CM, 0.0,   B_UNIT_DEF_NONE},
        {"square millimeter", "square millimeters", "mm²", "mm2",   "Square Millimeters", UN_SC_MM * UN_SC_MM, 0.0,   B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
-       {"square micrometer", "square micrometers", "µm²", "um2",   "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0,   B_UNIT_DEF_NONE},
+       {"square micrometer", "square micrometers", UM"²", "um2",   "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0,   B_UNIT_DEF_NONE},
        {NULL, NULL, NULL,  NULL, NULL, 0.0, 0.0}
 };
 static struct bUnitCollection buMetricAreaCollection = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)};
@@ -175,7 +180,7 @@ static struct bUnitDef buMetricVolDef[] = {
        {"cubic decimeter",  "cubic decimeters",  "dm³",  "dm3",  "Cubic Decimeters", UN_SC_DM * UN_SC_DM * UN_SC_DM, 0.0,    B_UNIT_DEF_SUPPRESS},
        {"cubic centimeter", "cubic centimeters", "cm³",  "cm3",  "Cubic Centimeters", UN_SC_CM * UN_SC_CM * UN_SC_CM, 0.0,   B_UNIT_DEF_NONE},
        {"cubic millimeter", "cubic millimeters", "mm³",  "mm3",  "Cubic Millimeters", UN_SC_MM * UN_SC_MM * UN_SC_MM, 0.0,   B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
-       {"cubic micrometer", "cubic micrometers", "µm³",  "um3",  "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0,   B_UNIT_DEF_NONE},
+       {"cubic micrometer", "cubic micrometers", UM"³",  "um3",  "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0,   B_UNIT_DEF_NONE},
        {NULL, NULL, NULL,  NULL, NULL, 0.0, 0.0}
 };
 static struct bUnitCollection buMetricVolCollection = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)};
@@ -253,7 +258,7 @@ static struct bUnitDef buNaturalTimeDef[] = {
        {"minute", "minutes",           "min", "m", "Minutes",      60.0, 0.0,      B_UNIT_DEF_NONE},
        {"second", "seconds",           "sec", "s", "Seconds",      1.0, 0.0,       B_UNIT_DEF_NONE}, /* base unit */
        {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0,     B_UNIT_DEF_NONE},
-       {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0,  B_UNIT_DEF_NONE},
+       {"microsecond", "microseconds", US,   "us", "Microseconds", 0.000001, 0.0,  B_UNIT_DEF_NONE},
        {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
 };
 static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)};
@@ -273,7 +278,7 @@ static struct bUnitDef buCameraLenDef[] = {
        {"decimeter", "decimeters",     "dm",  NULL, "10 Centimeters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS},
        {"centimeter", "centimeters",   "cm",  NULL, "Centimeters", UN_SC_DAM, 0.0,    B_UNIT_DEF_SUPPRESS},
        {"millimeter", "millimeters",   "mm",  NULL, "Millimeters", UN_SC_M, 0.0,    B_UNIT_DEF_NONE},
-       {"micrometer", "micrometers",   "µm",  "um", "Micrometers", UN_SC_MM, 0.0,    B_UNIT_DEF_SUPPRESS},     // micron too?
+       {"micrometer", "micrometers",   UM,    "um", "Micrometers", UN_SC_MM, 0.0,    B_UNIT_DEF_SUPPRESS},     // micron too?
        {NULL, NULL, NULL,      NULL, NULL, 0.0, 0.0}
 };
 static struct bUnitCollection buCameraLenCollection = {buCameraLenDef, 3, 0, sizeof(buCameraLenDef) / sizeof(bUnitDef)};
index 767f61b29dde152af1c40e6056b4e02241ccd3c8..4c7ddf7ba6643064354308e1f8603a5450d041f6 100644 (file)
@@ -72,7 +72,7 @@ void BLI_freelinkN(struct ListBase *listbase, void *vlink);
 void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src);
 void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src);
 void BLI_reverselist(struct ListBase *lb);
-void BLI_rotatelist(struct ListBase *lb, LinkData *vlink);
+void BLI_rotatelist(struct ListBase *lb, void *vlink);
 
 /* create a generic list node containing link to provided data */
 struct LinkData *BLI_genericNodeN(void *data);
index 96652c0e78d2f793f6cd365add29c068b46d50e6..f9671f57acd6616e1759cfb7927014e5a4c1d305 100644 (file)
@@ -75,7 +75,8 @@ void closest_to_line_segment_v2(float closest[2], const float p[2], const float
 
 float dist_to_plane_normalized_v3(const float p[3], const float plane_co[3], const float plane_no_unit[3]);
 float dist_to_plane_v3(const float p[3], const float plane_co[3], const float plane_no[3]);
-float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
+float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
+float         dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
 float dist_to_line_v3(const float p[3], const float l1[3], const float l2[3]);
 float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
 float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]);
index 0df4de1f8292d1d7a4103e8fc49713906f133107..304e2ea7fde62f2f572d6f2bb9188f81d347efae 100644 (file)
@@ -240,6 +240,7 @@ void rotate_normalized_v3_v3v3fl(float v[3], const float p[3], const float axis[
 void print_v2(const char *str, const float a[2]);
 void print_v3(const char *str, const float a[3]);
 void print_v4(const char *str, const float a[4]);
+void print_vn(const char *str, const float v[], const int n);
 
 MINLINE void normal_short_to_float_v3(float r[3], const short n[3]);
 MINLINE void normal_float_to_short_v3(short r[3], const float n[3]);
index c6f0bc49c9b1933e79e8eaada5303cb2c118a02f..02eb0734f8cf6a6bcc56d232de72b2037410c351 100644 (file)
@@ -93,14 +93,14 @@ __attribute__((nonnull))
 #endif
 ;
 
-size_t BLI_snprintf(char *__restrict buffer, size_t len, const char *__restrict format, ...)
+size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
 #ifdef __GNUC__
 __attribute__ ((format(printf, 3, 4)))
 __attribute__((nonnull))
 #endif
 ;
 
-size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restrict format, va_list arg)
+size_t BLI_vsnprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, va_list arg)
 #ifdef __GNUC__
 __attribute__ ((format(printf, 3, 0)))
 #endif
index d20cbd2a91cb03b2610cc0cd71121b3c7197a81e..adef843d2cc18ff439fa5252d9637a7dc06a5bd9 100644 (file)
@@ -51,8 +51,10 @@ char        *BLI_str_prev_char_utf8(const char *p);
 
 /* wchar_t functions, copied from blenders own font.c originally */
 size_t       BLI_wstrlen_utf8(const wchar_t *src);
+size_t       BLI_strlen_utf8_ex(const char *strc, int *r_len_bytes);
 size_t       BLI_strlen_utf8(const char *strc);
-size_t       BLI_strnlen_utf8(const char *start, const size_t maxlen);
+size_t       BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, int *r_len_bytes);
+size_t       BLI_strnlen_utf8(const char *strc, const size_t maxlen);
 size_t       BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxcpy);
 size_t       BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst, const char *__restrict src, const size_t maxcpy);
 
index 26fe0f21cd520d9ec4579d03e2b76ba5ad4bad14..26b9e08c7f66386924a5dc126323038c5c2c2e44 100644 (file)
@@ -199,7 +199,7 @@ bool BLI_file_touch(const char *file)
 {
        FILE *f = BLI_fopen(file, "r+b");
        if (f != NULL) {
-               char c = getc(f);
+               int c = getc(f);
                rewind(f);
                putc(c, f);
        }
index f060a2771fe57a2012bd5bc1571a03af92d65967..ded4f31ae05ac52c484b40d36b66c5c9c2e2bd60 100644 (file)
@@ -557,14 +557,14 @@ void BLI_reverselist(ListBase *lb)
 /**
  * \param vlink Link to make first.
  */
-void BLI_rotatelist(ListBase *lb, LinkData *vlink)
+void BLI_rotatelist(ListBase *lb, void *vlink)
 {
        /* make circular */
        ((LinkData *)lb->first)->prev = lb->last;
        ((LinkData *)lb->last)->next = lb->first;
 
        lb->first = vlink;
-       lb->last = vlink->prev;
+       lb->last = ((LinkData *)vlink)->prev;
 
        ((LinkData *)lb->first)->prev = NULL;
        ((LinkData *)lb->last)->next = NULL;
index 78b1f50c2e88732726a290db431b121cfc274122..28bb97689d825072119cefd958328ae74303b7ff 100644 (file)
@@ -324,21 +324,26 @@ float dist_to_plane_v3(const float p[3], const float plane_co[3], const float pl
        return line_point_factor_v3(p, plane_co, plane_co_other);
 }
 
-/* distance v1 to line-piece v2-v3 in 3D */
-float dist_to_line_segment_v3(const float v1[3], const float v2[3], const float v3[3])
+/* distance v1 to line-piece l1-l2 in 3D */
+float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
 {
        float closest[3];
 
-       closest_to_line_segment_v3(closest, v1, v2, v3);
+       closest_to_line_segment_v3(closest, p, l1, l2);
 
-       return len_v3v3(closest, v1);
+       return len_squared_v3v3(closest, p);
 }
 
-float dist_to_line_v3(const float v1[3], const float v2[3], const float v3[3])
+float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
+{
+       return sqrtf(dist_squared_to_line_segment_v3(p, l1, l2));
+}
+
+float dist_to_line_v3(const float v1[3], const float l1[3], const float l2[3])
 {
        float closest[3];
 
-       closest_to_line_v3(closest, v1, v2, v3);
+       closest_to_line_v3(closest, v1, l1, l2);
 
        return len_v3v3(closest, v1);
 }
@@ -2598,45 +2603,62 @@ static float mean_value_half_tan_v2(const float v1[2], const float v2[2], const
 
 void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[3])
 {
-       /* TODO: t1 and t2 overlap each iter, we could call this only once per iter and reuse previous value */
-       float totweight, t1, t2, len, *vmid, *vprev, *vnext;
-       int i, i_next, i_curr;
+       const float eps = 0.00001f;  /* take care, low values cause [#36105] */
+       const float eps_sq = eps * eps;
+       float *v_curr, *v_next;
+       float ht_prev, ht;  /* half tangents */
+       float totweight = 0.0f;
+       int i = 0;
+       bool vert_interp = false;
        bool edge_interp = false;
 
-       totweight = 0.0f;
+       v_curr = v[0];
+       v_next = v[1];
 
-       for (i = 0; i < n; i++) {
-               i_curr = i;
-               i_next = (i == n - 1) ? 0 : i + 1;
+       ht_prev = mean_value_half_tan_v3(co, v[n - 1], v_curr);
 
-               vmid = v[i];
-               vprev = (i == 0) ? v[n - 1] : v[i - 1];
-               vnext = v[i_next];
+       while (i < n) {
+               const float len_sq = len_squared_v3v3(co, v_curr);
 
                /* Mark Mayer et al algorithm that is used here does not operate well if vertex is close
                 * to borders of face. In that case, do simple linear interpolation between the two edge vertices */
-               if (dist_to_line_segment_v3(co, vmid, vnext) < 10 * FLT_EPSILON) {
+               if (len_sq < eps_sq) {
+                       vert_interp = true;
+                       break;
+               }
+               else if (dist_squared_to_line_segment_v3(co, v_curr, v_next) < eps_sq) {
                        edge_interp = true;
                        break;
                }
 
-               t1 = mean_value_half_tan_v3(co, vprev, vmid);
-               t2 = mean_value_half_tan_v3(co, vmid, vnext);
-
-               len = len_v3v3(co, vmid);
-               w[i] = (len != 0.0f) ? (t1 + t2) / len: 0.0f;
+               ht = mean_value_half_tan_v3(co, v_curr, v_next);
+               w[i] = (ht_prev + ht) / sqrtf(len_sq);
                totweight += w[i];
+
+               /* step */
+               i++;
+               v_curr = v_next;
+               v_next = v[(i + 1) % n];
+
+               ht_prev = ht;
        }
 
-       if (edge_interp) {
-               float len_curr = len_v3v3(co, vmid);
-               float len_next = len_v3v3(co, vnext);
+       if (vert_interp) {
+               const int i_curr = i;
+               for (i = 0; i < n; i++)
+                       w[i] = 0.0;
+               w[i_curr] = 1.0f;
+       }
+       else if (edge_interp) {
+               const int i_curr = i;
+               float len_curr = len_v3v3(co, v_curr);
+               float len_next = len_v3v3(co, v_next);
                float edge_len = len_curr + len_next;
                for (i = 0; i < n; i++)
                        w[i] = 0.0;
 
                w[i_curr] = len_next / edge_len;
-               w[i_next] = len_curr / edge_len;
+               w[(i_curr + 1) % n] = len_curr / edge_len;
        }
        else {
                if (totweight != 0.0f) {
@@ -2650,45 +2672,62 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
 
 void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[2])
 {
-       /* TODO: t1 and t2 overlap each iter, we could call this only once per iter and reuse previous value */
-       float totweight, t1, t2, len, *vmid, *vprev, *vnext;
-       int i, i_next, i_curr;
+       const float eps = 0.00001f;  /* take care, low values cause [#36105] */
+       const float eps_sq = eps * eps;
+       float *v_curr, *v_next;
+       float ht_prev, ht;  /* half tangents */
+       float totweight = 0.0f;
+       int i = 0;
+       bool vert_interp = false;
        bool edge_interp = false;
 
-       totweight = 0.0f;
+       v_curr = v[0];
+       v_next = v[1];
 
-       for (i = 0; i < n; i++) {
-               i_curr = i;
-               i_next = (i == n - 1) ? 0 : i + 1;
+       ht_prev = mean_value_half_tan_v2(co, v[n - 1], v_curr);
 
-               vmid = v[i];
-               vprev = (i == 0) ? v[n - 1] : v[i - 1];
-               vnext = v[i_next];
+       while (i < n) {
+               const float len_sq = len_squared_v2v2(co, v_curr);
 
                /* Mark Mayer et al algorithm that is used here does not operate well if vertex is close
                 * to borders of face. In that case, do simple linear interpolation between the two edge vertices */
-               if (dist_to_line_segment_v2(co, vmid, vnext) < 10 * FLT_EPSILON) {
+               if (len_sq < eps_sq) {
+                       vert_interp = true;
+                       break;
+               }
+               else if (dist_squared_to_line_segment_v2(co, v_curr, v_next) < eps_sq) {
                        edge_interp = true;
                        break;
                }
 
-               t1 = mean_value_half_tan_v2(co, vprev, vmid);
-               t2 = mean_value_half_tan_v2(co, vmid, vnext);
-
-               len = len_v2v2(co, vmid);
-               w[i] = (len != 0.0f) ? (t1 + t2) / len: 0.0f;
+               ht = mean_value_half_tan_v2(co, v_curr, v_next);
+               w[i] = (ht_prev + ht) / sqrtf(len_sq);
                totweight += w[i];
+
+               /* step */
+               i++;
+               v_curr = v_next;
+               v_next = v[(i + 1) % n];
+
+               ht_prev = ht;
        }
 
-       if (edge_interp) {
-               float len_curr = len_v2v2(co, vmid);
-               float len_next = len_v2v2(co, vnext);
+       if (vert_interp) {
+               const int i_curr = i;
+               for (i = 0; i < n; i++)
+                       w[i] = 0.0;
+               w[i_curr] = 1.0f;
+       }
+       else if (edge_interp) {
+               const int i_curr = i;
+               float len_curr = len_v2v2(co, v_curr);
+               float len_next = len_v2v2(co, v_next);
                float edge_len = len_curr + len_next;
                for (i = 0; i < n; i++)
                        w[i] = 0.0;
 
                w[i_curr] = len_next / edge_len;
-               w[i_next] = len_curr / edge_len;
+               w[(i_curr + 1) % n] = len_curr / edge_len;
        }
        else {
                if (totweight != 0.0f) {
index 298abfa8c5e2b159ee37bb5c0f0e2234baa0ec65..cd7dfdc6d2f7d8817c99b48038bf9e8a2565f556 100644 (file)
@@ -790,6 +790,7 @@ void orthogonalize_m3(float mat[3][3], int axis)
                                normalize_v3(mat[2]);
                                cross_v3_v3v3(mat[1], mat[2], mat[0]);
                        }
+                       break;
                case 1:
                        if (dot_v3v3(mat[1], mat[0]) < 1) {
                                cross_v3_v3v3(mat[2], mat[0], mat[1]);
@@ -812,6 +813,7 @@ void orthogonalize_m3(float mat[3][3], int axis)
                                normalize_v3(mat[0]);
                                cross_v3_v3v3(mat[2], mat[0], mat[1]);
                        }
+                       break;
                case 2:
                        if (dot_v3v3(mat[2], mat[0]) < 1) {
                                cross_v3_v3v3(mat[1], mat[2], mat[0]);
@@ -834,6 +836,9 @@ void orthogonalize_m3(float mat[3][3], int axis)
                                normalize_v3(mat[0]);
                                cross_v3_v3v3(mat[1], mat[2], mat[0]);
                        }
+                       break;
+               default:
+                       BLI_assert(0);
        }
        mul_v3_fl(mat[0], size[0]);
        mul_v3_fl(mat[1], size[1]);
@@ -868,8 +873,8 @@ void orthogonalize_m4(float mat[4][4], int axis)
                                normalize_v3(mat[2]);
                                cross_v3_v3v3(mat[1], mat[2], mat[0]);
                        }
+                       break;
                case 1:
-                       normalize_v3(mat[0]);
                        if (dot_v3v3(mat[1], mat[0]) < 1) {
                                cross_v3_v3v3(mat[2], mat[0], mat[1]);
                                normalize_v3(mat[2]);
@@ -891,6 +896,7 @@ void orthogonalize_m4(float mat[4][4], int axis)
                                normalize_v3(mat[0]);
                                cross_v3_v3v3(mat[2], mat[0], mat[1]);
                        }
+                       break;
                case 2:
                        if (dot_v3v3(mat[2], mat[0]) < 1) {
                                cross_v3_v3v3(mat[1], mat[2], mat[0]);
@@ -913,6 +919,9 @@ void orthogonalize_m4(float mat[4][4], int axis)
                                normalize_v3(mat[0]);
                                cross_v3_v3v3(mat[1], mat[2], mat[0]);
                        }
+                       break;
+               default:
+                       BLI_assert(0);
        }
        mul_v3_fl(mat[0], size[0]);
        mul_v3_fl(mat[1], size[1]);
@@ -1207,16 +1216,19 @@ void mat4_to_size(float size[3], float mat[4][4])
 float mat3_to_scale(float mat[3][3])
 {
        /* unit length vector */
-       float unit_vec[3] = {0.577350269189626f, 0.577350269189626f, 0.577350269189626f};
+       float unit_vec[3];
+       copy_v3_fl(unit_vec, 0.577350269189626f);
        mul_m3_v3(mat, unit_vec);
        return len_v3(unit_vec);
 }
 
 float mat4_to_scale(float mat[4][4])
 {
-       float tmat[3][3];
-       copy_m3_m4(tmat, mat);
-       return mat3_to_scale(tmat);
+       /* unit length vector */
+       float unit_vec[3];
+       copy_v3_fl(unit_vec, 0.577350269189626f);
+       mul_mat3_m4_v3(mat, unit_vec);
+       return len_v3(unit_vec);
 }
 
 void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3])
index 78266c47170886254d9ac0e03fc92d4d38dd7c6a..ba0394dbc66455ad7ee0506d824bfd4e3f0aa5e5 100644 (file)
@@ -542,6 +542,16 @@ void print_v4(const char *str, const float v[4])
        printf("%s: %.3f %.3f %.3f %.3f\n", str, v[0], v[1], v[2], v[3]);
 }
 
+void print_vn(const char *str, const float v[], const int n)
+{
+       int i = 0;
+       printf("%s[%d]:", str, n);
+       while (i < n) {
+               printf(" %.3f", v[i++]);
+       }
+       printf("\n");
+}
+
 void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
 {
        if (min[0] > vec[0]) min[0] = vec[0];
index 03bed428c0715b31b35f1013b1582f1d959b292c..24e14d04c682665567a95679df62181a608b4887 100644 (file)
@@ -47,6 +47,8 @@
 #  pragma GCC diagnostic error "-Wsign-conversion"
 #endif
 
+// #define DEBUG_STRSIZE
+
 /**
  * Duplicates the first \a len bytes of cstring \a str
  * into a newly mallocN'd string and returns it. \a str
@@ -111,6 +113,10 @@ char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t
        size_t srclen = BLI_strnlen(src, maxncpy - 1);
        BLI_assert(maxncpy != 0);
 
+#ifdef DEBUG_STRSIZE
+       memset(dst, 0xff, sizeof(*dst) * maxncpy);
+#endif
+
        memcpy(dst, src, srclen);
        dst[srclen] = '\0';
        return dst;
@@ -134,6 +140,10 @@ size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const
        size_t srclen = BLI_strnlen(src, maxncpy - 1);
        BLI_assert(maxncpy != 0);
 
+#ifdef DEBUG_STRSIZE
+       memset(dst, 0xff, sizeof(*dst) * maxncpy);
+#endif
+
        memcpy(dst, src, srclen);
        dst[srclen] = '\0';
        return srclen;
@@ -149,21 +159,21 @@ size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src)
 /**
  * Portable replacement for #vsnprintf
  */
-size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restrict format, va_list arg)
+size_t BLI_vsnprintf(char *__restrict buffer, size_t maxncpy, const char *__restrict format, va_list arg)
 {
        size_t n;
 
        BLI_assert(buffer != NULL);
-       BLI_assert(count > 0);
+       BLI_assert(maxncpy > 0);
        BLI_assert(format != NULL);
 
-       n = (size_t)vsnprintf(buffer, count, format, arg);
+       n = (size_t)vsnprintf(buffer, maxncpy, format, arg);
 
-       if (n != -1 && n < count) {
+       if (n != -1 && n < maxncpy) {
                buffer[n] = '\0';
        }
        else {
-               buffer[count - 1] = '\0';
+               buffer[maxncpy - 1] = '\0';
        }
 
        return n;
@@ -172,13 +182,17 @@ size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restri
 /**
  * Portable replacement for #snprintf
  */
-size_t BLI_snprintf(char *__restrict buffer, size_t count, const char *__restrict format, ...)
+size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
 {
        size_t n;
        va_list arg;
 
+#ifdef DEBUG_STRSIZE
+       memset(dst, 0xff, sizeof(*dst) * maxncpy);
+#endif
+
        va_start(arg, format);
-       n = BLI_vsnprintf(buffer, count, format, arg);
+       n = BLI_vsnprintf(dst, maxncpy, format, arg);
        va_end(arg);
 
        return n;
index b8dca95ae3319046568e6c149bde43619f23ffbc..d435ed8f6e7730c7ce1000d0eb86bd76ef65483f 100644 (file)
@@ -45,6 +45,8 @@
 #  pragma GCC diagnostic error "-Wsign-conversion"
 #endif
 
+// #define DEBUG_STRSIZE
+
 /* from libswish3, originally called u8_isvalid(),
  * modified to return the index of the bad character (byte index not utf).
  * http://svn.swish-e.org/libswish3/trunk/src/libswish3/utf8.c r3044 - campbell */
@@ -195,6 +197,10 @@ char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t
 
        BLI_assert(maxncpy != 0);
 
+#ifdef DEBUG_STRSIZE
+       memset(dst, 0xff, sizeof(*dst) * maxncpy);
+#endif
+
        /* note: currently we don't attempt to deal with invalid utf8 chars */
        BLI_STR_UTF8_CPY(dst, src, maxncpy);
 
@@ -208,6 +214,10 @@ char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t
                maxncpy--;
        }
 
+#ifdef DEBUG_STRSIZE
+       memset(dst, 0xff, sizeof(*dst) * maxncpy);
+#endif
+
        BLI_STR_UTF8_CPY(dst, src, maxncpy);
 
        return dst;
@@ -220,11 +230,16 @@ char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t
 
 size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxncpy)
 {
+       const size_t maxlen = maxncpy - 1;
        size_t len = 0;
 
        BLI_assert(maxncpy != 0);
 
-       while (*src && len < maxncpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */
+#ifdef DEBUG_STRSIZE
+       memset(dst, 0xff, sizeof(*dst) * maxncpy);
+#endif
+
+       while (*src && len < maxlen) { /* XXX can still run over the buffer because utf8 size isn't known :| */
                len += BLI_str_utf8_from_unicode((unsigned int)*src++, dst + len);
        }
 
@@ -245,24 +260,16 @@ size_t BLI_wstrlen_utf8(const wchar_t *src)
        return len;
 }
 
-/* this is very close to 'BLI_str_utf8_size' functionality, perhaps we should de-duplicate */
-/* size of UTF-8 character in bytes */
-static size_t strlen_utf8_char(const char *strc)
+size_t BLI_strlen_utf8_ex(const char *strc, int *r_len_bytes)
 {
-       if ((*strc & 0xe0) == 0xc0) {
-               if ((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
-                       return 2;
-       }
-       else if ((*strc & 0xf0) == 0xe0) {
-               if ((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
-                       return 3;
-       }
-       else if ((*strc & 0xf8) == 0xf0) {
-               if ((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
-                       return 4;
-       }
+       size_t len;
+       const char *strc_orig = strc;
 
-       return 1;
+       for (len = 0; *strc; len++)
+               strc += BLI_str_utf8_size_safe(strc);
+
+       *r_len_bytes = (strc - strc_orig);
+       return len;
 }
 
 size_t BLI_strlen_utf8(const char *strc)
@@ -270,8 +277,22 @@ size_t BLI_strlen_utf8(const char *strc)
        size_t len;
 
        for (len = 0; *strc; len++)
-               strc += strlen_utf8_char(strc);
+               strc += BLI_str_utf8_size_safe(strc);
+
+       return len;
+}
+
+size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, int *r_len_bytes)
+{
+       size_t len;
+       const char *strc_orig = strc;
+       const char *strc_end = strc + maxlen;
+
+       for (len = 0; *strc && strc < strc_end; len++) {
+               strc += BLI_str_utf8_size_safe(strc);
+       }
 
+       *r_len_bytes = (strc - strc_orig);
        return len;
 }
 
@@ -280,15 +301,13 @@ size_t BLI_strlen_utf8(const char *strc)
  * \param maxlen the string length (in bytes)
  * \return the unicode length (not in bytes!)
  */
-size_t BLI_strnlen_utf8(const char *start, const size_t maxlen)
+size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen)
 {
-       const char *strc = start;
-       const char *strc_end = start + maxlen;
-
        size_t len;
+       const char *strc_end = strc + maxlen;
 
        for (len = 0; *strc && strc < strc_end; len++) {
-               strc += strlen_utf8_char(strc);
+               strc += BLI_str_utf8_size_safe(strc);
        }
 
        return len;
@@ -296,13 +315,16 @@ size_t BLI_strnlen_utf8(const char *start, const size_t maxlen)
 
 size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy)
 {
+       const size_t maxlen = maxncpy - 1;
        size_t len = 0;
 
-       if (dst_w == NULL || src_c == NULL) {
-               return 0;
-       }
+       BLI_assert(maxncpy != 0);
 
-       while (*src_c && len < maxncpy) {
+#ifdef DEBUG_STRSIZE
+       memset(dst_w, 0xff, sizeof(*dst_w) * maxncpy);
+#endif
+
+       while (*src_c && len != maxlen) {
                size_t step = 0;
                unsigned int unicode = BLI_str_utf8_as_unicode_and_size(src_c, &step);
                if (unicode != BLI_UTF8_ERR) {
@@ -316,6 +338,9 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__rest
                dst_w++;
                len++;
        }
+
+       *dst_w = 0;
+
        return len;
 }
 
index c6856d8b71d337d398a2e905b8de967a54fbd7fb..82040020ce44e03fc19af6bbc582053d60360f85 100644 (file)
@@ -354,7 +354,7 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me)
                                ma = NULL;
 
                        for (b = 0; ma && b < MAX_MTEX; b++)
-                               if (ma->mtex && ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA)
+                               if (ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA)
                                        texalpha = 1;
                }
                else {
index 9b6699f3f215ccba1db7c0f82191d559f6763b7d..dd4361be1ff704ce64b64e5797fda502181d7756 100644 (file)
@@ -1642,13 +1642,6 @@ static void write_mballs(WriteData *wd, ListBase *idbase)
        }
 }
 
-static int amount_of_chars(char *str)
-{
-       // Since the data is saved as UTF-8 to the cu->str
-       // The cu->len is not same as the strlen(cu->str)
-       return strlen(str);
-}
-
 static void write_curves(WriteData *wd, ListBase *idbase)
 {
        Curve *cu;
@@ -1666,8 +1659,12 @@ static void write_curves(WriteData *wd, ListBase *idbase)
                        if (cu->adt) write_animdata(wd, cu->adt);
                        
                        if (cu->vfont) {
-                               writedata(wd, DATA, amount_of_chars(cu->str)+1, cu->str);
-                               writestruct(wd, DATA, "CharInfo", cu->len+1, cu->strinfo);
+                               /* TODO, sort out 'cu->len', in editmode its character, object mode its bytes */
+                               int len_bytes;
+                               int len_chars = BLI_strlen_utf8_ex(cu->str, &len_bytes);
+
+                               writedata(wd, DATA, len_bytes + 1, cu->str);
+                               writestruct(wd, DATA, "CharInfo", len_chars + 1, cu->strinfo);
                                writestruct(wd, DATA, "TextBox", cu->totbox, cu->tb);
                        }
                        else {
index 15030f90c65d29d863c9a0ced5583a6cb4f58829..4ec0a3699d067e5908edb102ef8dee6a22f6c185 100644 (file)
@@ -803,50 +803,65 @@ static void bm_face_attrs_copy(BMesh *source_mesh, BMesh *target_mesh,
 }
 
 /* BMESH_TODO: Special handling for hide flags? */
+/* BMESH_TODO: swap src/dst args, everywhere else in bmesh does other way round */
 
 /**
  * Copies attributes, e.g. customdata, header flags, etc, from one element
  * to another of the same type.
  */
-void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *source, void *target)
+void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v,
+                           const char hflag_mask)
 {
-       const BMHeader *sheader = source;
-       BMHeader *theader = target;
+       const BMHeader *ele_src = ele_src_v;
+       BMHeader *ele_dst = ele_dst_v;
 
-       BLI_assert(sheader->htype == theader->htype);
+       BLI_assert(ele_src->htype == ele_dst->htype);
 
-       if (sheader->htype != theader->htype) {
+       if (ele_src->htype != ele_dst->htype) {
                BLI_assert(!"type mismatch");
                return;
        }
 
-       /* First we copy select */
-       if (BM_elem_flag_test((BMElem *)sheader, BM_ELEM_SELECT)) {
-               BM_elem_select_set(target_mesh, (BMElem *)target, true);
+       if ((hflag_mask & BM_ELEM_SELECT) == 0) {
+               /* First we copy select */
+               if (BM_elem_flag_test((BMElem *)ele_src, BM_ELEM_SELECT)) {
+                       BM_elem_select_set(bm_dst, (BMElem *)ele_dst, true);
+               }
        }
-       
+
        /* Now we copy flags */
-       theader->hflag = sheader->hflag;
-       
+       if (hflag_mask == 0) {
+               ele_dst->hflag = ele_src->hflag;
+       }
+       else {
+               ele_dst->hflag = ((ele_dst->hflag & hflag_mask) | (ele_src->hflag & ~hflag_mask));
+       }
+
        /* Copy specific attributes */
-       switch (theader->htype) {
+       switch (ele_dst->htype) {
                case BM_VERT:
-                       bm_vert_attrs_copy(source_mesh, target_mesh, (const BMVert *)source, (BMVert *)target);
+                       bm_vert_attrs_copy(bm_src, bm_dst, (const BMVert *)ele_src, (BMVert *)ele_dst);
                        break;
                case BM_EDGE:
-                       bm_edge_attrs_copy(source_mesh, target_mesh, (const BMEdge *)source, (BMEdge *)target);
+                       bm_edge_attrs_copy(bm_src, bm_dst, (const BMEdge *)ele_src, (BMEdge *)ele_dst);
                        break;
                case BM_LOOP:
-                       bm_loop_attrs_copy(source_mesh, target_mesh, (const BMLoop *)source, (BMLoop *)target);
+                       bm_loop_attrs_copy(bm_src, bm_dst, (const BMLoop *)ele_src, (BMLoop *)ele_dst);
                        break;
                case BM_FACE:
-                       bm_face_attrs_copy(source_mesh, target_mesh, (const BMFace *)source, (BMFace *)target);
+                       bm_face_attrs_copy(bm_src, bm_dst, (const BMFace *)ele_src, (BMFace *)ele_dst);
                        break;
                default:
                        BLI_assert(0);
        }
 }
 
+void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src, void *ele_dst)
+{
+       /* BMESH_TODO, default 'use_flags' to false */
+       BM_elem_attrs_copy_ex(bm_src, bm_dst, ele_src, ele_dst, 0);
+}
+
 /* helper function for 'BM_mesh_copy' */
 static BMFace *bm_mesh_copy_new_face(BMesh *bm_new, BMesh *bm_old,
                                      BMVert **vtable, BMEdge **etable,
@@ -890,6 +905,24 @@ static BMFace *bm_mesh_copy_new_face(BMesh *bm_new, BMesh *bm_old,
        return f_new;
 }
 
+void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const BMAllocTemplate *allocsize)
+{
+       if (allocsize == NULL) {
+               allocsize = &bm_mesh_allocsize_default;
+       }
+
+       CustomData_copy(&bm_src->vdata, &bm_dst->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&bm_src->edata, &bm_dst->edata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&bm_src->ldata, &bm_dst->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&bm_src->pdata, &bm_dst->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+
+       CustomData_bmesh_init_pool(&bm_dst->vdata, allocsize->totvert, BM_VERT);
+       CustomData_bmesh_init_pool(&bm_dst->edata, allocsize->totedge, BM_EDGE);
+       CustomData_bmesh_init_pool(&bm_dst->ldata, allocsize->totloop, BM_LOOP);
+       CustomData_bmesh_init_pool(&bm_dst->pdata, allocsize->totface, BM_FACE);
+}
+
+
 BMesh *BM_mesh_copy(BMesh *bm_old)
 {
        BMesh *bm_new;
@@ -908,15 +941,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
        /* allocate a bmesh */
        bm_new = BM_mesh_create(&allocsize);
 
-       CustomData_copy(&bm_old->vdata, &bm_new->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
-       CustomData_copy(&bm_old->edata, &bm_new->edata, CD_MASK_BMESH, CD_CALLOC, 0);
-       CustomData_copy(&bm_old->ldata, &bm_new->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
-       CustomData_copy(&bm_old->pdata, &bm_new->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
-
-       CustomData_bmesh_init_pool(&bm_new->vdata, allocsize.totvert, BM_VERT);
-       CustomData_bmesh_init_pool(&bm_new->edata, allocsize.totedge, BM_EDGE);
-       CustomData_bmesh_init_pool(&bm_new->ldata, allocsize.totloop, BM_LOOP);
-       CustomData_bmesh_init_pool(&bm_new->pdata, allocsize.totface, BM_FACE);
+       BM_mesh_copy_init_customdata(bm_new, bm_old, &allocsize);
 
        vtable = MEM_mallocN(sizeof(BMVert *) * bm_old->totvert, "BM_mesh_copy vtable");
        etable = MEM_mallocN(sizeof(BMEdge *) * bm_old->totedge, "BM_mesh_copy etable");
index 949366309b9d2e9338c5404bc346becf74c6bae9..3dcb1eb1ccb68cf28e00b60a541a4b9804e3b788 100644 (file)
@@ -27,6 +27,8 @@
  *  \ingroup bmesh
  */
 
+struct BMAllocTemplate;
+
 BMFace *BM_face_create_quad_tri_v(BMesh *bm,
                                   BMVert **verts, int len,
                                   const BMFace *example, const bool no_double);
@@ -48,8 +50,11 @@ void BMO_remove_tagged_verts(BMesh *bm, const short oflag);
 
 void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type);
 
-void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *source, void *target);
+void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v,
+                           const char hflag_mask);
+void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v);
 
+void   BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const struct BMAllocTemplate *allocsize);
 BMesh *BM_mesh_copy(BMesh *bm_old);
 
 char  BM_face_flag_from_mflag(const char  mflag);
index b7eeceae4947879ceb229adb5d9478875621774d..ecb776e75892a7824dcc0a07e251c88124ec46ea 100644 (file)
@@ -210,7 +210,7 @@ static BMLoop *bm_face_boundary_add(BMesh *bm, BMFace *f, BMVert *startv, BMEdge
        return l;
 }
 
-BMFace *BM_face_copy(BMesh *bm, BMFace *f,
+BMFace *BM_face_copy(BMesh *bm_dst, BMesh *bm_src, BMFace *f,
                      const bool copy_verts, const bool copy_edges)
 {
        BMVert **verts = BLI_array_alloca(verts, f->len);
@@ -221,11 +221,13 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f,
        BMFace *f_copy;
        int i;
 
+       BLI_assert((bm_dst == bm_src) || (copy_verts && copy_edges));
+
        l_iter = l_first = BM_FACE_FIRST_LOOP(f);
        i = 0;
        do {
                if (copy_verts) {
-                       verts[i] = BM_vert_create(bm, l_iter->v->co, l_iter->v, 0);
+                       verts[i] = BM_vert_create(bm_dst, l_iter->v->co, l_iter->v, 0);
                }
                else {
                        verts[i] = l_iter->v;
@@ -248,7 +250,7 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f,
                                v1 = verts[(i + 1) % f->len];
                        }
                        
-                       edges[i] = BM_edge_create(bm,  v1, v2, l_iter->e, 0);
+                       edges[i] = BM_edge_create(bm_dst,  v1, v2, l_iter->e, 0);
                }
                else {
                        edges[i] = l_iter->e;
@@ -256,14 +258,14 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f,
                i++;
        } while ((l_iter = l_iter->next) != l_first);
        
-       f_copy = BM_face_create(bm, verts, edges, f->len, BM_CREATE_SKIP_CD);
+       f_copy = BM_face_create(bm_dst, verts, edges, f->len, BM_CREATE_SKIP_CD);
        
-       BM_elem_attrs_copy(bm, bm, f, f_copy);
+       BM_elem_attrs_copy(bm_src, bm_dst, f, f_copy);
        
        l_iter = l_first = BM_FACE_FIRST_LOOP(f);
        l_copy = BM_FACE_FIRST_LOOP(f_copy);
        do {
-               BM_elem_attrs_copy(bm, bm, l_iter, l_copy);
+               BM_elem_attrs_copy(bm_src, bm_dst, l_iter, l_copy);
                l_copy = l_copy->next;
        } while ((l_iter = l_iter->next) != l_first);
 
index a1f378aaa5d49dadf565760e3982f7d8e0b8f8c2..6e691a9a0b577ae5994717d9f350799593382e90 100644 (file)
@@ -27,7 +27,7 @@
  *  \ingroup bmesh
  */
 
-BMFace *BM_face_copy(BMesh *bm, BMFace *f,
+BMFace *BM_face_copy(BMesh *bm_dst, BMesh *bm_src, BMFace *f,
                      const bool copy_verts, const bool copy_edges);
 
 typedef enum eBMCreateFlag {
index 454eb201b78ba600e24a6fd68b13005927300260..446d32de5d2805cafff575ab50691651456dc8d4 100644 (file)
@@ -429,32 +429,32 @@ static void bm_loop_flip_disp(float source_axis_x[3], float source_axis_y[3],
        disp[1] = (mat[0][0] * b[1] - b[0] * mat[1][0]) / d;
 }
 
-static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
+static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *l_dst, BMFace *f_src)
 {
-       MDisps *mdisps;
+       const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
+       MDisps *md_dst;
        float d, v1[3], v2[3], v3[3], v4[3] = {0.0f, 0.0f, 0.0f}, e1[3], e2[3];
        int ix, res;
        float axis_x[3], axis_y[3];
-       
-       /* ignore 2-edged faces */
-       if (UNLIKELY(target->f->len < 3))
+
+       if (cd_loop_mdisp_offset == -1)
                return;
        
-       if (!CustomData_has_layer(&bm->ldata, CD_MDISPS))
+       /* ignore 2-edged faces */
+       if (UNLIKELY(l_dst->f->len < 3))
                return;
+
+       md_dst = BM_ELEM_CD_GET_VOID_P(l_dst, cd_loop_mdisp_offset);
+       compute_mdisp_quad(l_dst, v1, v2, v3, v4, e1, e2);
        
-       mdisps = CustomData_bmesh_get(&bm->ldata, target->head.data, CD_MDISPS);
-       compute_mdisp_quad(target, v1, v2, v3, v4, e1, e2);
-       
-       /* if no disps data allocate a new grid, the size of the first grid in source. */
-       if (!mdisps->totdisp) {
-               MDisps *md2 = CustomData_bmesh_get(&bm->ldata, BM_FACE_FIRST_LOOP(source)->head.data, CD_MDISPS);
+       /* if no disps data allocate a new grid, the size of the first grid in f_src. */
+       if (!md_dst->totdisp) {
+               MDisps *md_src = BM_ELEM_CD_GET_VOID_P(BM_FACE_FIRST_LOOP(f_src), cd_loop_mdisp_offset);
                
-               mdisps->totdisp = md2->totdisp;
-               mdisps->level = md2->level;
-               if (mdisps->totdisp) {
-                       mdisps->disps = MEM_callocN(sizeof(float) * 3 * mdisps->totdisp,
-                                                   "mdisp->disps in bmesh_loop_intern_mdisps");
+               md_dst->totdisp = md_src->totdisp;
+               md_dst->level = md_src->level;
+               if (md_dst->totdisp) {
+                       md_dst->disps = MEM_callocN(sizeof(float) * 3 * md_dst->totdisp, __func__);
                }
                else {
                        return;
@@ -463,7 +463,7 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
        
        mdisp_axis_from_quad(v1, v2, v3, v4, axis_x, axis_y);
 
-       res = (int)sqrt(mdisps->totdisp);
+       res = (int)sqrt(md_dst->totdisp);
        d = 1.0f / (float)(res - 1);
 #pragma omp parallel for if (res > 3)
        for (ix = 0; ix < res; ix++) {
@@ -487,18 +487,17 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
                        mul_v3_fl(co, x);
                        add_v3_v3(co, co1);
                        
-                       l_iter = l_first = BM_FACE_FIRST_LOOP(source);
+                       l_iter = l_first = BM_FACE_FIRST_LOOP(f_src);
                        do {
                                float x2, y2;
-                               MDisps *md1, *md2;
+                               MDisps *md_src;
                                float src_axis_x[3], src_axis_y[3];
 
-                               md1 = CustomData_bmesh_get(&bm->ldata, target->head.data, CD_MDISPS);
-                               md2 = CustomData_bmesh_get(&bm->ldata, l_iter->head.data, CD_MDISPS);
+                               md_src = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_mdisp_offset);
                                
-                               if (mdisp_in_mdispquad(target, l_iter, co, &x2, &y2, res, src_axis_x, src_axis_y)) {
-                                       old_mdisps_bilinear(md1->disps[iy * res + ix], md2->disps, res, (float)x2, (float)y2);
-                                       bm_loop_flip_disp(src_axis_x, src_axis_y, axis_x, axis_y, md1->disps[iy * res + ix]);
+                               if (mdisp_in_mdispquad(l_dst, l_iter, co, &x2, &y2, res, src_axis_x, src_axis_y)) {
+                                       old_mdisps_bilinear(md_dst->disps[iy * res + ix], md_src->disps, res, (float)x2, (float)y2);
+                                       bm_loop_flip_disp(src_axis_x, src_axis_y, axis_x, axis_y, md_dst->disps[iy * res + ix]);
 
                                        break;
                                }
@@ -513,16 +512,17 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
  */
 void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
 {
+       const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
        BMLoop *l;
        BMIter liter;
        
-       if (!CustomData_has_layer(&bm->ldata, CD_MDISPS))
+       if (cd_loop_mdisp_offset == -1)
                return;
        
        BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
-               MDisps *mdp = CustomData_bmesh_get(&bm->ldata, l->prev->head.data, CD_MDISPS);
-               MDisps *mdl = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
-               MDisps *mdn = CustomData_bmesh_get(&bm->ldata, l->next->head.data, CD_MDISPS);
+               MDisps *mdp = BM_ELEM_CD_GET_VOID_P(l->prev, cd_loop_mdisp_offset);
+               MDisps *mdl = BM_ELEM_CD_GET_VOID_P(l, cd_loop_mdisp_offset);
+               MDisps *mdn = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_mdisp_offset);
                float co1[3];
                int sides;
                int y;
@@ -551,7 +551,7 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
        }
        
        BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
-               MDisps *mdl1 = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
+               MDisps *mdl1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_mdisp_offset);
                MDisps *mdl2;
                float co1[3], co2[3], co[3];
                int sides;
@@ -575,9 +575,9 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
                        continue;
 
                if (l->radial_next->v == l->v)
-                       mdl2 = CustomData_bmesh_get(&bm->ldata, l->radial_next->head.data, CD_MDISPS);
+                       mdl2 = BM_ELEM_CD_GET_VOID_P(l->radial_next, cd_loop_mdisp_offset);
                else
-                       mdl2 = CustomData_bmesh_get(&bm->ldata, l->radial_next->next->head.data, CD_MDISPS);
+                       mdl2 = BM_ELEM_CD_GET_VOID_P(l->radial_next->next, cd_loop_mdisp_offset);
 
                sides = (int)sqrt(mdl1->totdisp);
                for (y = 0; y < sides; y++) {
@@ -640,8 +640,6 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
        /* convert the 3d coords into 2d for projection */
        axis_dominant_v3_to_m3(axis_mat, source->no);
 
-       BM_elem_attrs_copy(bm, bm, source, target->f);
-
        i = 0;
        l_iter = l_first = BM_FACE_FIRST_LOOP(source);
        do {
@@ -663,9 +661,7 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
        }
 
        if (do_multires) {
-               if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
-                       bm_loop_interp_mdisps(bm, target, source);
-               }
+               bm_loop_interp_mdisps(bm, target, source);
        }
 }
 
index 4027d4b2c19965e237708e0be2121a5eaa3d986b..64368390444ee624519286d51c1196bd22378f06 100644 (file)
@@ -240,7 +240,7 @@ void BM_mesh_clear(BMesh *bm)
        bm_mempool_init(bm, &bm_mesh_allocsize_default);
 
        bm->stackdepth = 1;
-       bm->totflags = 1;
+       bm->totflags = 0;
 
        CustomData_reset(&bm->vdata);
        CustomData_reset(&bm->edata);
index c75843f029abf90aa3c2d642493c97c16df3e291..cb8e9bd70040d9fa343781bd9f054000fb8f176b 100644 (file)
@@ -345,7 +345,7 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l
 
        /* do we have a multires layer? */
        if (has_mdisp) {
-               f_tmp = BM_face_copy(bm, f, false, false);
+               f_tmp = BM_face_copy(bm, bm, f, false, false);
        }
        
 #ifdef USE_BMESH_HOLES
@@ -414,7 +414,7 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[
 
        BLI_assert(v1 != v2);
 
-       f_tmp = BM_face_copy(bm, f, true, true);
+       f_tmp = BM_face_copy(bm, bm, f, true, true);
 
        if (!r_l)
                r_l = &l_dummy;
@@ -662,7 +662,7 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float perce
                /* flag existing faces so we can differentiate oldfaces from new faces */
                for (i = 0; i < BLI_array_count(oldfaces); i++) {
                        BM_ELEM_API_FLAG_ENABLE(oldfaces[i], _FLAG_OVERLAP);
-                       oldfaces[i] = BM_face_copy(bm, oldfaces[i], true, true);
+                       oldfaces[i] = BM_face_copy(bm, bm, oldfaces[i], true, true);
                        BM_ELEM_API_FLAG_DISABLE(oldfaces[i], _FLAG_OVERLAP);
                }
        }
index 3ffdbe167d726498edb78ddc6ea8833481e69a19..7f8b40d85dc507b7b5155785d129d9f6fbd629b0 100644 (file)
@@ -1248,7 +1248,7 @@ static void bmo_flag_layer_free(BMesh *bm)
                        /* now go through and memcpy all the flag */
                        BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {
                                void *oldflags = ele->oflags;
-                               ele->oflags = BLI_mempool_calloc(newpool);
+                               ele->oflags = BLI_mempool_alloc(newpool);
                                memcpy(ele->oflags, oldflags, new_totflags_size);
                                BM_elem_index_set(ele, i); /* set_inline */
                                BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
@@ -1264,7 +1264,7 @@ static void bmo_flag_layer_free(BMesh *bm)
 
                        BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
                                void *oldflags = ele->oflags;
-                               ele->oflags = BLI_mempool_calloc(newpool);
+                               ele->oflags = BLI_mempool_alloc(newpool);
                                memcpy(ele->oflags, oldflags, new_totflags_size);
                                BM_elem_index_set(ele, i); /* set_inline */
                                BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
@@ -1280,7 +1280,7 @@ static void bmo_flag_layer_free(BMesh *bm)
 
                        BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
                                void *oldflags = ele->oflags;
-                               ele->oflags = BLI_mempool_calloc(newpool);
+                               ele->oflags = BLI_mempool_alloc(newpool);
                                memcpy(ele->oflags, oldflags, new_totflags_size);
                                BM_elem_index_set(ele, i); /* set_inline */
                                BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
index 6b124a3030a037f8cd1391e030d1789d58e84cb9..5b046524e9537a45052c3547c76cae5f2727f3a9 100644 (file)
@@ -144,11 +144,13 @@ static void bridge_loop_pair(BMesh *bm,
                              struct BMEdgeLoopStore *el_store_b,
                              const bool use_merge, const float merge_factor)
 {
+       const float eps = 0.00001f;
        LinkData *el_a_first, *el_b_first;
        const bool is_closed = BM_edgeloop_is_closed(el_store_a) && BM_edgeloop_is_closed(el_store_b);
        int el_store_a_len, el_store_b_len;
        bool el_store_b_free = false;
        float el_dir[3];
+       float dot_a, dot_b;
        const bool use_edgeout = true;
 
        el_store_a_len = BM_edgeloop_length_get((struct BMEdgeLoopStore *)el_store_a);
@@ -160,7 +162,7 @@ static void bridge_loop_pair(BMesh *bm,
        }
 
        if (use_merge) {
-               BLI_assert((el_store_a_len == el_store_a_len));
+               BLI_assert((el_store_a_len == el_store_b_len));
        }
 
        if (el_store_a_len != el_store_b_len) {
@@ -202,9 +204,22 @@ static void bridge_loop_pair(BMesh *bm,
                BM_edgeloop_calc_normal_aligned(bm, el_store_b, no);
        }
 
-       if ((dot_v3v3(BM_edgeloop_normal_get(el_store_a), el_dir) < 0.0f) !=
-               (dot_v3v3(BM_edgeloop_normal_get(el_store_b), el_dir) < 0.0f))
+       dot_a = dot_v3v3(BM_edgeloop_normal_get(el_store_a), el_dir);
+       dot_b = dot_v3v3(BM_edgeloop_normal_get(el_store_b), el_dir);
+
+       if (UNLIKELY((len_squared_v3(el_dir) < eps) ||
+                    ((fabsf(dot_a) < eps) && (fabsf(dot_b) < eps))))
        {
+               /* in this case there is no depth between the two loops,
+                * eg: 2x 2d circles, one scaled smaller,
+                * in this case 'el_dir' cant be used, just ensure we have matching flipping. */
+               if (dot_v3v3(BM_edgeloop_normal_get(el_store_a),
+                            BM_edgeloop_normal_get(el_store_b)) < 0.0f)
+               {
+                       BM_edgeloop_flip(bm, el_store_b);
+               }
+       }
+       else if ((dot_a < 0.0f) != (dot_b < 0.0f)) {
                BM_edgeloop_flip(bm, el_store_b);
        }
 
index a56cdeec629821391dd8cf09d0a48d976c2baaaa..872f1cea2c7a4ece0ff5cd67b1c8e28eaf3ff23e 100644 (file)
@@ -381,7 +381,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
        pc.v_b = ((BMVert **)op_verts_slot->data.p)[1];
 
        /* fail! */
-       if (!(pc.v_a && pc.v_a)) {
+       if (!(pc.v_a && pc.v_b)) {
                return;
        }
 
index c4200a377480eb9afbb55b2fb2c97479083d4e65..4291fc22793e840d8c2820151fa9f741a20db294 100644 (file)
@@ -56,7 +56,7 @@ static bool bmo_recalc_normal_edge_filter_cb(BMEdge *e, void *UNUSED(user_data))
  */
 static void bmo_recalc_face_normals_array(BMesh *bm, BMFace **faces, const int faces_len, const short oflag)
 {
-       float cent[3];
+       float cent[3], tvec[3];
        float (*faces_center)[3] = MEM_mallocN(sizeof(*faces_center) * faces_len, __func__);
        const float cent_fac = 1.0f / (float)faces_len;
        int i, f_start_index;
@@ -91,7 +91,8 @@ static void bmo_recalc_face_normals_array(BMesh *bm, BMFace **faces, const int f
        }
 
        /* make sure the starting face has the correct winding */
-       if (dot_v3v3(faces_center[f_start_index], faces[f_start_index]->no) < 0.0f) {
+       sub_v3_v3v3(tvec, faces_center[f_start_index], cent);
+       if (dot_v3v3(tvec, faces[f_start_index]->no) < 0.0f) {
                BMO_elem_flag_enable(bm, faces[f_start_index], FACE_FLIP);
        }
 
index d9555c409f6e3cf9c3b575675aa19068beb6a198..44d4b63f5c40c51bbb1a8c37193d1a000a842418 100644 (file)
@@ -893,7 +893,7 @@ static void bm_edgering_pair_order(BMesh *bm,
        /* before going much further, get ourselves in order
         * - align loops (not strictly necessary but handy)
         * - ensure winding is set for both loops */
-       if (BM_edgeloop_is_closed(el_store_a) && BM_edgeloop_is_closed(el_store_a)) {
+       if (BM_edgeloop_is_closed(el_store_a) && BM_edgeloop_is_closed(el_store_b)) {
                BMIter eiter;
                BMEdge *e;
                BMVert *v_other;
index e0c11414e38dcca57091f59d9a4bd21f2b24a403..6431b6b7cf5f64b89bec70e21f1198791d8ae8d7 100644 (file)
@@ -1941,26 +1941,35 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
        int i, found_shared_face, ccw_test_sum;
        int nsel = 0;
        int ntot = 0;
+       int fcnt;
 
        /* Gather input selected edges.
         * Only bevel selected edges that have exactly two incident faces.
+        * Want edges to be ordered so that they share faces.
+        * There may be one or more chains of shared faces broken by
+        * gaps where there are no faces.
+        * TODO: make following work when more than one gap.
         */
 
-       if (bp->vertex_only)
-               first_bme = v->e;
-       else
-               first_bme = NULL;
+       first_bme = NULL;
        BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) {
+               fcnt = BM_edge_face_count(bme);
                if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) {
-                       BLI_assert(BM_edge_is_manifold(bme));
+                       BLI_assert(fcnt == 2);
                        nsel++;
                        if (!first_bme)
                                first_bme = bme;
                }
+               if (fcnt == 1) {
+                       /* good to start face chain from this edge */
+                       first_bme = bme;
+               }
                ntot++;
 
                BM_BEVEL_EDGE_TAG_DISABLE(bme);
        }
+       if (!first_bme)
+               first_bme = v->e;
 
        if ((nsel == 0 && !bp->vertex_only) || (ntot < 3 && bp->vertex_only)) {
                /* signal this vert isn't being beveled */
index 643b2cdc2b0148fb437396b33d9575031f07632e..445199dbdef46fc3d20089f2717fc2e04fc142d2 100644 (file)
@@ -1687,6 +1687,18 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
        }
 }
 
+static void report_class_type_unsupported(const char *path, 
+                                         const COLLADAFW::AnimationList::AnimationClass animclass,
+                                         const COLLADAFW::Transformation::TransformationType type) 
+{
+       if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
+               fprintf(stderr, "%s: UNKNOWN animation class\n", path);
+       }
+       else {
+               fprintf(stderr, "%s: animation class %d is not supported yet for transformation type %d\n", path, animclass, type);
+       }
+}
+
 // return true to indicate that mat contains a sane value
 bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float mat[4][4], float fra, const char *node_id)
 {
@@ -1741,11 +1753,6 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
                                        break;
                        }
 
-                       if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
-                               fprintf(stderr, "%s: UNKNOWN animation class\n", path);
-                               //continue;
-                       }
-
                        if (type == COLLADAFW::Transformation::ROTATE) {
                                if (curves.size() != 1) {
                                        fprintf(stderr, "expected 1 curve, got %d\n", (int)curves.size());
@@ -1754,7 +1761,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
 
                                // TODO support other animclasses
                                if (animclass != COLLADAFW::AnimationList::ANGLE) {
-                                       fprintf(stderr, "%s: animation class %d is not supported yet\n", path, animclass);
+                                       report_class_type_unsupported(path, animclass, type);
                                        return false;
                                }
 
@@ -1793,7 +1800,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
                                                vec[2] = evaluate_fcurve(curves[2], fra);
                                                break;
                                        default:
-                                               fprintf(stderr, "%s: animation class %d is not supported yet\n", path, animclass);
+                                               report_class_type_unsupported(path, animclass, type);
                                                break;
                                }
                        }
index 8791d94f44ae1df0f4eca7fe321af8ce4bd017ee..0cd48707566c3d699a6a8ede2b7a2e3799b679dc 100644 (file)
@@ -166,7 +166,7 @@ void ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBo
        }
 
        bone->length = len_v3v3(bone->head, bone->tail);
-
+       joint_by_uid[node->getUniqueId()] = node;
        finished_joints.push_back(node);
 }
 
@@ -517,16 +517,11 @@ void ArmatureImporter::set_pose(Object *ob_arm,  COLLADAFW::Node *root_node, con
 // root - if this joint is the top joint in hierarchy, if a joint
 // is a child of a node (not joint), root should be true since
 // this is where we build armature bones from
-void ArmatureImporter::add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce)
+void ArmatureImporter::add_root_joint(COLLADAFW::Node *node, Object *parent)
 {
-       joint_by_uid[node->getUniqueId()] = node;
-       if (root) {
-               root_joints.push_back(node);
-
-               if (parent) {
-                                       
-                       joint_parent_map[node->getUniqueId()] = parent;
-               }
+       root_joints.push_back(node);
+       if (parent) {
+               joint_parent_map[node->getUniqueId()] = parent;
        }
 }
 
index bfbf7433d97954aff74424fffaaf05497a2bc788..beeac85cc4d69fbbdfe9e46a8a8a38fce23dad27 100644 (file)
@@ -140,11 +140,7 @@ public:
        ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, Scene *sce);
        ~ArmatureImporter();
 
-       void add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce);
-
-#if 0
-       void add_root_joint(COLLADAFW::Node *node);
-#endif
+       void add_root_joint(COLLADAFW::Node *node, Object *parent);
 
        // here we add bones to armatures, having armatures previously created in write_controller
        void make_armatures(bContext *C);
index 0abf413788ffd2fb52adabc503c49293a1f1d345..80bde1842dd93780ba0b6f0cb9095b04831c3aa7 100644 (file)
@@ -311,11 +311,6 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
 #endif
        unsigned int i;
 
-
-       //for (i = 0; i < 4; i++)
-       //    ob =
-       anim_importer.translate_Animations(node, root_map, object_map, FW_object_map);
-
        if (node->getType() == COLLADAFW::Node::JOINT && par == NULL) {
                // For Skeletons without root node we have to simulate the
                // root node here and recursively enter the same function
@@ -323,6 +318,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
                translate_anim_recursive(node, node, parob);
        }
        else {
+               anim_importer.translate_Animations(node, root_map, object_map, FW_object_map);
                COLLADAFW::NodePointerArray &children = node->getChildNodes();
                for (i = 0; i < children.getCount(); i++) {
                        translate_anim_recursive(children[i], node, NULL);
@@ -480,7 +476,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                        object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), par));
                        node_map[node->getUniqueId()] = node;
                }
-               armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par, sce);
+               if (parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT) {
+                       armature_importer.add_root_joint(node, par);
+               }
 
                if (parent_node == NULL) {
                        // for skeletons without root node all has been done above.
@@ -601,11 +599,16 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                        anim_importer.read_node_transform(node, ob);  // overwrites location set earlier
 
                if (!is_joint) {
-                       // if par was given make this object child of the previous
-                       if (par && ob)
-                               bc_set_parent(ob, par, mContext);
+                       if (par && ob) {
+                               ob->parent = par;
+                               ob->partype = PAROBJECT;
+                               ob->parsubstr[0] = 0;
+
+                               //bc_set_parent(ob, par, mContext, false);
+                       }
                }
        }
+
        // if node has child nodes write them
        COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
 
@@ -624,7 +627,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
 }
 
 /** When this method is called, the writer must write the entire visual scene.
- * \return The writer should return true, if writing succeeded, false otherwise.*/
+ *  Return The writer should return true, if writing succeeded, false otherwise. */
 bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene)
 {
        if (mImportStage != General)
index d4db42da35b4c64aff834e7df1d51963ebd8a818..b088139262c4ac884e908aa9ccac05c554613642 100644 (file)
@@ -97,40 +97,28 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, B
 
        add_transform(node, loc, rot, scale);
 #endif
-       UnitConverter converter;
-       
-       /* Using parentinv should allow use of existing curves */
-       if (ob->parent) {
-               // If parentinv is identity don't add it.
-               bool add_parinv = false;
-
-               for (int i = 0; i < 16; ++i) {
-                       float f = (i % 4 == i / 4) ? 1.0f : 0.0f;
-                       add_parinv |= (ob->parentinv[i % 4][i / 4] != f);
-               }
 
-               if (add_parinv) {
-                       double dmat[4][4];
-                       converter.mat4_to_dae_double(dmat, ob->parentinv);
-                       node.addMatrix("parentinverse", dmat);
-               }
-       }
+       UnitConverter converter;
+       double d_obmat[4][4];
+       float  f_obmat[4][4];
 
-       double d_obmat[4][4];   
-       converter.mat4_to_dae_double(d_obmat, ob->obmat);
+       /* Export the local Matrix (relative to the object parent) */
+       BKE_object_matrix_local_get(ob, f_obmat);
+       converter.mat4_to_dae_double(d_obmat, f_obmat);
 
        switch (transformation_type) {
                case BC_TRANSFORMATION_TYPE_MATRIX     : {
                        node.addMatrix("transform",d_obmat);
                        break;
                }
-               case BC_TRANSFORMATION_TYPE_TRANSROTLOC: {
-                       add_transform(node, ob->loc, ob->rot, ob->size); 
-                       break;
-               }
                case BC_TRANSFORMATION_TYPE_BOTH       : {
                        node.addMatrix("transform",d_obmat);
-                       add_transform(node, ob->loc, ob->rot, ob->size);
+                       /* intentional fall-through */
+               }
+               case BC_TRANSFORMATION_TYPE_TRANSROTLOC: {
+                       float loc[3], rot[3], scale[3];
+                       TransformBase::decompose(f_obmat, loc, rot, NULL, scale);
+                       add_transform(node, loc, rot, scale); 
                        break;
                }
        }
index 4c4b77ba6cc5a12b028b677c1b5ebfe73c37d1da..d2598e661a96afe8da7565ba6fc7ab64c89a9527 100644 (file)
@@ -47,7 +47,7 @@ void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCont
        operation->setSettings((NodeChroma *)editorsnode->storage);
 
        inputSocketImage->relinkConnections(operationRGBToYCC_Image->getInputSocket(0), 0, graph);
-       inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 0, graph);
+       inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 1, graph);
 
        addLink(graph, operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0));
        addLink(graph, operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1));
index 5b386a504e473d62845116011ff74a680296f5a5..6f2baa63b0e5ec2087d1f0b288dafa351ae293f4 100644 (file)
@@ -34,11 +34,14 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext
        bNode *editorNode = this->getbNode();
        Tex *texture = (Tex *)editorNode->id;
        TextureOperation *operation = new TextureOperation();
+       const ColorManagedDisplaySettings *displaySettings = context->getDisplaySettings();
+       bool sceneColorManage = strcmp(displaySettings->display_device, "None") != 0;
        this->getOutputSocket(1)->relinkConnections(operation->getOutputSocket());
        this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
        this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system);
        operation->setTexture(texture);
        operation->setRenderData(context->getRenderData());
+       operation->setSceneColorManage(sceneColorManage);
        system->addOperation(operation);
        addPreviewOperation(system, context, operation->getOutputSocket());
 
@@ -49,6 +52,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext
                addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1));
                alphaOperation->setTexture(texture);
                alphaOperation->setRenderData(context->getRenderData());
+               alphaOperation->setSceneColorManage(sceneColorManage);
                system->addOperation(alphaOperation);
        }
 }
index 95f06e350b10b05c3e08c6b2f5a0ae9e4bd18dad..b48d974e8932238ff9399cdbb9d756a00c665691 100644 (file)
@@ -34,7 +34,7 @@
 
 void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
 {
-       if (context->getRenderData()->scemode & R_FULL_SAMPLE) {
+       if ((context->getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) {
                if (this->getOutputSocket(0)->isConnected()) {
                        ZCombineOperation *operation = NULL;
                        if (this->getbNode()->custom1) {
index e8268adff7a0f8c781e5b12a29e9570a44c2021a..0c67da2d55222fa14f4d02214923aa8c8e8f4aad 100644 (file)
@@ -53,33 +53,34 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
                                pixels++;
                
                                switch (this->m_setting) {
-                                       case 1:
+                                       case 1:  /* rgb combined */
                                        {
                                                float value = rgb_to_bw(&buffer[offset]);
                                                sum += (value - mean) * (value - mean);
                                                break;
                                        }
-                                       case 2:
+                                       case 2:  /* red */
                                        {
                                                float value = buffer[offset];
                                                sum += value;
                                                sum += (value - mean) * (value - mean);
                                                break;
                                        }
-                                       case 3:
+                                       case 3:  /* green */
                                        {
                                                float value = buffer[offset + 1];
                                                sum += value;
                                                sum += (value - mean) * (value - mean);
                                                break;
                                        }
-                                       case 4:
+                                       case 4:  /* blue */
                                        {
                                                float value = buffer[offset + 2];
                                                sum += value;
                                                sum += (value - mean) * (value - mean);
+                                               break;
                                        }
-                                       case 5:
+                                       case 5:  /* luminance */
                                        {
                                                float yuv[3];
                                                rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2]);
index 8b1128a4da30cdc1b381b96b39cccbfc5c51da65..fa22ba668b9c1cbc418567d38ac7b62cdc0b2111 100644 (file)
@@ -32,6 +32,7 @@
 #include "DNA_movieclip_types.h"
 
 #include "BLI_listbase.h"
+#include "BLI_string.h"
 
 extern "C" {
        #include "BLI_voronoi.h"
@@ -76,7 +77,7 @@ public:
        void deinitializeTileData(rcti *rect, void *data);
 
        void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
-       void setTrackingObject(const char *object) {strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));}
+       void setTrackingObject(const char *object) { BLI_strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject)); }
        void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
 
        void executePixel(float output[4], int x, int y, void *data);
index 08f6f8ada4af2661f33d09750ccaab486747f4c2..bbb7c8b52891489a3225d8ec0e65f42e97ceb876 100644 (file)
@@ -33,6 +33,8 @@ TextureBaseOperation::TextureBaseOperation() : SingleThreadedNodeOperation()
        this->m_inputSize = NULL;
        this->m_inputOffset = NULL;
        this->m_rd = NULL;
+       this->m_pool = NULL;
+       this->m_sceneColorManage = false;
 }
 TextureOperation::TextureOperation() : TextureBaseOperation()
 {
@@ -101,7 +103,7 @@ void TextureBaseOperation::executePixel(float output[4], float x, float y, Pixel
        vec[1] = textureSize[1] * (v + textureOffset[1]);
        vec[2] = textureSize[2] * textureOffset[2];
 
-       retval = multitex_ext(this->m_texture, vec, NULL, NULL, 0, &texres, m_pool);
+       retval = multitex_ext(this->m_texture, vec, NULL, NULL, 0, &texres, m_pool, m_sceneColorManage);
 
        if (texres.talpha)
                output[3] = texres.ta;
index fc9369099a6426280a2ec1771a6359b4cf8c5de3..b776f6f2493ee1d8d6824c98c227bcd9252d09ae 100644 (file)
@@ -46,6 +46,7 @@ private:
        SocketReader *m_inputSize;
        SocketReader *m_inputOffset;
        struct ImagePool *m_pool;
+       bool m_sceneColorManage;
 
 protected:
 
@@ -67,6 +68,7 @@ public:
        void initExecution();
        void deinitExecution();
        void setRenderData(const RenderData *rd) { this->m_rd = rd; }
+       void setSceneColorManage(bool sceneColorManage) { this->m_sceneColorManage = sceneColorManage; }
 };
 
 class TextureOperation : public TextureBaseOperation {
index 3f05b907ea036275f13da40606c8bee0749de103..b5499ab76b71d71084586e0e5ec83727404b40cc 100644 (file)
@@ -33,6 +33,7 @@
 #include "DNA_tracking_types.h"
 
 #include "BLI_listbase.h"
+#include "BLI_string.h"
 
 /**
  * Class with implementation of green screen gradient rasterization
@@ -60,8 +61,8 @@ public:
        TrackPositionOperation();
 
        void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
-       void setTrackingObject(char *object) {strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName));}
-       void setTrackName(char *track) {strncpy(this->m_trackName, track, sizeof(this->m_trackName));}
+       void setTrackingObject(char *object) { BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName)); }
+       void setTrackName(char *track) { BLI_strncpy(this->m_trackName, track, sizeof(this->m_trackName)); }
        void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
        void setAxis(int value) {this->m_axis = value;}
        void setPosition(int value) {this->m_position = value;}
index f3edb61f48791e3fde54096c5de55b9ae554adca..da76ad8a832e2b03f8c2c2bfd5d211441be26fe4 100644 (file)
@@ -401,7 +401,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
        glDisable(GL_BLEND);
        
        /* and the marker name too, shifted slightly to the top-right */
-       if (marker->name && marker->name[0]) {
+       if (marker->name[0]) {
                float x, y;
 
                /* minimal y coordinate which wouldn't be occluded by scroll */
index d5dbe80538ff6fae3767b8f1d825e4ab676e1734..289901076a17efb90227d526a34077822cd468e9 100644 (file)
@@ -170,7 +170,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
 }
 
 /* join armature exec is exported for use in object->join objects operator... */
-int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
+int join_armature_exec(bContext *C, wmOperator *op)
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
@@ -180,6 +180,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
        bPoseChannel *pchan, *pchann;
        EditBone *curbone;
        float mat[4][4], oimat[4][4];
+       bool ok = false;
        
        /*      Ensure we're not in editmode and that the active object is an armature*/
        if (!ob || ob->type != OB_ARMATURE)
@@ -187,6 +188,21 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
        if (!arm || arm->edbo)
                return OPERATOR_CANCELLED;
        
+       CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+       {
+               if (base->object == ob) {
+                       ok = true;
+                       break;
+               }
+       }
+       CTX_DATA_END;
+
+       /* that way the active object is always selected */
+       if (ok == false) {
+               BKE_report(op->reports, RPT_WARNING, "Active object is not a selected armature");
+               return OPERATOR_CANCELLED;
+       }
+
        /* Get editbones of active armature to add editbones to */
        ED_armature_to_edit(ob);
        
index bbdc0df41a77c4c78268c785fa09bcb54beac1d5..53d561c7736c642e9f5a1d6b1e2a99d2414a8510 100644 (file)
@@ -434,7 +434,7 @@ void ED_armature_deselect_all_visible(Object *obedit)
 
        for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
                /* first and foremost, bone must be visible and selected */
-               if (EBONE_SELECTABLE(arm, ebone)) {
+               if (EBONE_VISIBLE(arm, ebone)) {
                        ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
                }
        }
@@ -597,38 +597,48 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
        int action = RNA_enum_get(op->ptr, "action");
 
        if (action == SEL_TOGGLE) {
-               action = SEL_SELECT;
                /* Determine if there are any selected bones
                 * And therefore whether we are selecting or deselecting */
-               if (CTX_DATA_COUNT(C, selected_bones) > 0)
-                       action = SEL_DESELECT;
+               action = SEL_SELECT;
+               CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
+               {
+                       if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
+                               action = SEL_DESELECT;
+                               break;
+                       }
+               }
+               CTX_DATA_END;
        }
        
        /*      Set the flags */
        CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
        {
                /* ignore bone if selection can't change */
-               if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
-                       switch (action) {
-                               case SEL_SELECT:
+               switch (action) {
+                       case SEL_SELECT:
+                               if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
                                        ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-                                       if (ebone->parent)
+                                       if (ebone->parent) {
                                                ebone->parent->flag |= (BONE_TIPSEL);
-                                       break;
-                               case SEL_DESELECT:
-                                       ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-                                       break;
-                               case SEL_INVERT:
-                                       if (ebone->flag & BONE_SELECTED) {
-                                               ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
                                        }
-                                       else {
+                               }
+                               break;
+                       case SEL_DESELECT:
+                               ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+                               break;
+                       case SEL_INVERT:
+                               if (ebone->flag & BONE_SELECTED) {
+                                       ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+                               }
+                               else {
+                                       if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
                                                ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-                                               if (ebone->parent)
+                                               if (ebone->parent) {
                                                        ebone->parent->flag |= (BONE_TIPSEL);
+                                               }
                                        }
-                                       break;
-                       }
+                               }
+                               break;
                }
        }
        CTX_DATA_END;
@@ -672,16 +682,6 @@ static EnumPropertyItem prop_similar_types[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-/* could be used in more places */
-static void ED_armature_edit_bone_select(EditBone *ebone)
-{
-       BLI_assert((ebone->flag & BONE_UNSELECTABLE) == 0);
-       ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-
-       if ((ebone->flag & BONE_CONNECTED) && (ebone->parent != NULL)) {
-               ebone->parent->flag |= BONE_TIPSEL;
-       }
-}
 
 static void select_similar_length(bArmature *arm, EditBone *ebone_act, const float thresh)
 {
@@ -696,7 +696,7 @@ static void select_similar_length(bArmature *arm, EditBone *ebone_act, const flo
                        if ((ebone->length >= len_min) &&
                            (ebone->length <= len_max))
                        {
-                               ED_armature_edit_bone_select(ebone);
+                               ED_armature_ebone_select_set(ebone, true);
                        }
                }
        }
@@ -714,7 +714,7 @@ static void select_similar_direction(bArmature *arm, EditBone *ebone_act, const
                        sub_v3_v3v3(dir, ebone->head, ebone->tail);
 
                        if (angle_v3v3(dir_act, dir) / (float)M_PI < thresh) {
-                               ED_armature_edit_bone_select(ebone);
+                               ED_armature_ebone_select_set(ebone, true);
                        }
                }
        }
@@ -727,7 +727,7 @@ static void select_similar_layer(bArmature *arm, EditBone *ebone_act)
        for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
                if (EBONE_SELECTABLE(arm, ebone)) {
                        if (ebone->layer & ebone_act->layer) {
-                               ED_armature_edit_bone_select(ebone);
+                               ED_armature_ebone_select_set(ebone, true);
                        }
                }
        }
@@ -750,8 +750,8 @@ static void select_similar_prefix(bArmature *arm, EditBone *ebone_act)
                if (EBONE_SELECTABLE(arm, ebone)) {
                        char prefix_other[MAX_VGROUP_NAME];
                        BKE_deform_split_prefix(ebone->name, prefix_other, body_tmp);
-                       if (!strcmp(prefix_act, prefix_other)) {
-                               ED_armature_edit_bone_select(ebone);
+                       if (STREQ(prefix_act, prefix_other)) {
+                               ED_armature_ebone_select_set(ebone, true);
                        }
                }
        }
@@ -774,8 +774,8 @@ static void select_similar_suffix(bArmature *arm, EditBone *ebone_act)
                if (EBONE_SELECTABLE(arm, ebone)) {
                        char suffix_other[MAX_VGROUP_NAME];
                        BKE_deform_split_suffix(ebone->name, body_tmp, suffix_other);
-                       if (!strcmp(suffix_act, suffix_other)) {
-                               ED_armature_edit_bone_select(ebone);
+                       if (STREQ(suffix_act, suffix_other)) {
+                               ED_armature_ebone_select_set(ebone, true);
                        }
                }
        }
index 4120be08b46a2b7821f768883cbc4d8d12ea3948..0e93a00b01db52c71a7581ec1d17c62e778f2284 100644 (file)
@@ -337,18 +337,9 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
                }
                else {
                        /* if the bone is not selected, but connected to its parent
-                        *  copy the parents tip selection state */
+                        * always use the parents tip selection state */
                        if (eBone->parent && (eBone->flag & BONE_CONNECTED)) {
-                               /* selecting with the mouse gives this behavior */
-                               if (eBone->parent->flag & BONE_TIPSEL) {
-                                       eBone->flag |= BONE_ROOTSEL;
-                               }
-                               else {
-                                       eBone->flag &= ~BONE_ROOTSEL;
-                               }
-                               
-                               /* probably not selected but just in case */
-                               eBone->flag &= ~BONE_TIPSEL;
+                               eBone->flag &= ~BONE_ROOTSEL;
                        }
                }
                
@@ -588,6 +579,60 @@ void ED_armature_to_edit(Object *ob)
 /* *************************************************************** */
 /* Undo for Armature EditMode*/
 
+/* free's bones and their properties */
+
+static void ED_armature_ebone_listbase_free(ListBase *lb)
+{
+       EditBone *ebone, *ebone_next;
+
+       for (ebone = lb->first; ebone; ebone = ebone_next) {
+               ebone_next = ebone->next;
+
+               if (ebone->prop) {
+                       IDP_FreeProperty(ebone->prop);
+                       MEM_freeN(ebone->prop);
+               }
+
+               MEM_freeN(ebone);
+       }
+
+       lb->first = NULL;
+       lb->last = NULL;
+}
+
+static void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src)
+{
+       EditBone *ebone_src;
+       EditBone *ebone_dst;
+
+       BLI_assert(lb_dst->first == NULL);
+
+       for (ebone_src = lb_src->first; ebone_src; ebone_src = ebone_src->next) {
+               ebone_dst = MEM_dupallocN(ebone_src);
+               if (ebone_dst->prop) {
+                       ebone_dst->prop = IDP_CopyProperty(ebone_dst->prop);
+               }
+               ebone_src->temp = ebone_dst;
+               BLI_addtail(lb_dst, ebone_dst);
+       }
+
+       /* set pointers */
+       for (ebone_dst = lb_dst->first; ebone_dst; ebone_dst = ebone_dst->next) {
+               if (ebone_dst->parent) {
+                       ebone_dst->parent = ebone_dst->parent->temp;
+               }
+       }
+}
+
+static void ED_armature_ebone_listbase_temp_clear(ListBase *lb)
+{
+       EditBone *ebone;
+       /* be sure they don't hang ever */
+       for (ebone = lb->first; ebone; ebone = ebone->next) {
+               ebone->temp = NULL;
+       }
+}
+
 typedef struct UndoArmature {
        EditBone *act_edbone;
        ListBase lb;
@@ -597,60 +642,40 @@ static void undoBones_to_editBones(void *uarmv, void *armv, void *UNUSED(data))
 {
        UndoArmature *uarm = uarmv;
        bArmature *arm = armv;
-       EditBone *ebo, *newebo;
-       
-       BLI_freelistN(arm->edbo);
+       EditBone *ebone;
        
-       /* copy  */
-       for (ebo = uarm->lb.first; ebo; ebo = ebo->next) {
-               newebo = MEM_dupallocN(ebo);
-               ebo->temp = newebo;
-               BLI_addtail(arm->edbo, newebo);
-       }
+       ED_armature_ebone_listbase_free(arm->edbo);
+       ED_armature_ebone_listbase_copy(arm->edbo, &uarm->lb);
        
        /* active bone */
        if (uarm->act_edbone) {
-               ebo = uarm->act_edbone;
-               arm->act_edbone = ebo->temp;
+               ebone = uarm->act_edbone;
+               arm->act_edbone = ebone->temp;
        }
-       else
+       else {
                arm->act_edbone = NULL;
-
-       /* set pointers */
-       for (newebo = arm->edbo->first; newebo; newebo = newebo->next) {
-               if (newebo->parent) newebo->parent = newebo->parent->temp;
-       }
-       /* be sure they don't hang ever */
-       for (newebo = arm->edbo->first; newebo; newebo = newebo->next) {
-               newebo->temp = NULL;
        }
+
+       ED_armature_ebone_listbase_temp_clear(arm->edbo);
 }
 
 static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata))
 {
        bArmature *arm = armv;
        UndoArmature *uarm;
-       EditBone *ebo, *newebo;
+       EditBone *ebone;
        
        uarm = MEM_callocN(sizeof(UndoArmature), "listbase undo");
        
-       /* copy */
-       for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
-               newebo = MEM_dupallocN(ebo);
-               ebo->temp = newebo;
-               BLI_addtail(&uarm->lb, newebo);
-       }
+       ED_armature_ebone_listbase_copy(&uarm->lb, arm->edbo);
        
        /* active bone */
        if (arm->act_edbone) {
-               ebo = arm->act_edbone;
-               uarm->act_edbone = ebo->temp;
+               ebone = arm->act_edbone;
+               uarm->act_edbone = ebone->temp;
        }
 
-       /* set pointers */
-       for (newebo = uarm->lb.first; newebo; newebo = newebo->next) {
-               if (newebo->parent) newebo->parent = newebo->parent->temp;
-       }
+       ED_armature_ebone_listbase_temp_clear(&uarm->lb);
        
        return uarm;
 }
@@ -659,7 +684,8 @@ static void free_undoBones(void *uarmv)
 {
        UndoArmature *uarm = uarmv;
        
-       BLI_freelistN(&uarm->lb);
+       ED_armature_ebone_listbase_free(&uarm->lb);
+
        MEM_freeN(uarm);
 }
 
@@ -678,3 +704,62 @@ void undo_push_armature(bContext *C, const char *name)
        // XXX solve getdata()
        undo_editmode_push(C, name, get_armature_edit, free_undoBones, undoBones_to_editBones, editBones_to_undoBones, NULL);
 }
+
+/* *************************************************************** */
+/* Low level selection functions which hide connected-parent
+ * flag behavior which gets tricky to handle in selection operators.
+ * (no flushing in ED_armature_ebone_select.*, that should be explicit) */
+
+int ED_armature_ebone_selectflag_get(const EditBone *ebone)
+{
+       if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+               return ((ebone->flag & (BONE_SELECTED | BONE_TIPSEL)) |
+                       ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0));
+       }
+       else {
+               return (ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL));
+       }
+}
+
+void ED_armature_ebone_selectflag_set(EditBone *ebone, int flag)
+{
+       flag = flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
+
+       if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+               ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
+               ebone->parent->flag &= ~BONE_TIPSEL;
+
+               ebone->flag |= flag;
+               ebone->parent->flag |= (flag & BONE_ROOTSEL) ? BONE_TIPSEL : 0;
+       }
+       else {
+               ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
+               ebone->flag |= flag;
+       }
+}
+
+void ED_armature_ebone_selectflag_enable(EditBone *ebone, int flag)
+{
+       BLI_assert((flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) != 0);
+       ED_armature_ebone_selectflag_set(ebone, ebone->flag | flag);
+}
+
+void ED_armature_ebone_selectflag_disable(EditBone *ebone, int flag)
+{
+       BLI_assert((flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) != 0);
+       ED_armature_ebone_selectflag_set(ebone, ebone->flag & ~flag);
+}
+
+/* could be used in more places */
+void ED_armature_ebone_select_set(EditBone *ebone, bool select)
+{
+       int flag;
+       if (select) {
+               BLI_assert((ebone->flag & BONE_UNSELECTABLE) == 0);
+               flag = (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+       }
+       else {
+               flag = 0;
+       }
+       ED_armature_ebone_selectflag_set(ebone, flag);
+}
index 0f96e886ef3b069c85bc6cab7c667f761cee5796..75de4e137071ffa307b1057be3a64e9c17449492 100644 (file)
@@ -6100,7 +6100,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot)
 
 /************** join operator, to be used externally? ****************/
 /* TODO: shape keys - as with meshes */
-int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
+int join_curve_exec(bContext *C, wmOperator *op)
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
@@ -6112,6 +6112,22 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
        ListBase tempbase;
        float imat[4][4], cmat[4][4];
        int a;
+       bool ok = false;
+
+       CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+       {
+               if (base->object == ob) {
+                       ok = true;
+                       break;
+               }
+       }
+       CTX_DATA_END;
+
+       /* that way the active object is always selected */
+       if (ok == false) {
+               BKE_report(op->reports, RPT_WARNING, "Active object is not a selected curve");
+               return OPERATOR_CANCELLED;
+       }
 
        tempbase.first = tempbase.last = NULL;
        
index 5b2cc49d1068614338c4f57ac611bec9da7152fe..db4e4dc85009c6ffc3f00005145d32dd065420e4 100644 (file)
@@ -380,7 +380,7 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename)
 
        if (cu->len + filelen < MAXTEXT) {
                int tmplen;
-               wchar_t *mem = MEM_callocN((sizeof(wchar_t) * filelen) + (4 * sizeof(wchar_t)), "temporary");
+               wchar_t *mem = MEM_mallocN((sizeof(wchar_t) * filelen) + (4 * sizeof(wchar_t)), "temporary");
                tmplen = BLI_strncpy_wchar_from_utf8(mem, strp, filelen + 1);
                wcscat(ef->textbuf, mem);
                MEM_freeN(mem);
@@ -1273,7 +1273,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
                                accentcode = 0;
                        }
                        else if (event->utf8_buf[0]) {
-                               BLI_strncpy_wchar_from_utf8(inserted_text, event->utf8_buf, 1);
+                               BLI_strncpy_wchar_from_utf8(inserted_text, event->utf8_buf, 2);
                                ascii = inserted_text[0];
                                insert_into_textbuf(obedit, ascii);
                                accentcode = 0;
index 801fa12d444d8331b94b3a54290e646e9cae35b1..9b9a4c154db39058d8d5ba0084277b64f3d43b69 100644 (file)
@@ -153,6 +153,13 @@ void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const
 
 void undo_push_armature(struct bContext *C, const char *name);
 
+/* low level selection functions which handle */
+int  ED_armature_ebone_selectflag_get(const EditBone *ebone);
+void ED_armature_ebone_selectflag_set(EditBone *ebone, int flag);
+void ED_armature_ebone_select_set(EditBone *ebone, bool select);
+void ED_armature_ebone_selectflag_enable(EditBone *ebone, int flag);
+void ED_armature_ebone_selectflag_disable(EditBone *ebone, int flag);
+
 /* poseobject.c */
 void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
 void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
index 51d5d42394cd48b8411395fc8abd51923fc61208..fd08039c24b2f71ed45faa7acf8570ab40d1254e 100644 (file)
@@ -95,6 +95,7 @@ void EDBM_selectmode_to_scene(struct bContext *C);
 void EDBM_mesh_make(struct ToolSettings *ts, struct Scene *scene, struct Object *ob);
 void EDBM_mesh_free(struct BMEditMesh *em);
 void EDBM_mesh_load(struct Object *ob);
+struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em);
 
 void           EDBM_index_arrays_ensure(struct BMEditMesh *em, const char htype);
 void           EDBM_index_arrays_init(struct BMEditMesh *em, const char htype);
index e8e7643164f82215a35bc973d43e7b8cbd77c131..bdfbbbb9c7434351a535947b5ec640c1e4c8eabf 100644 (file)
@@ -52,7 +52,7 @@ void ED_render_engine_changed(struct Main *bmain);
 void ED_render_engine_area_exit(struct ScrArea *sa);
 void ED_render_scene_update(struct Main *bmain, struct Scene *scene, int updated);
 
-void ED_viewport_render_kill_jobs(const struct bContext *C);
+void ED_viewport_render_kill_jobs(const struct bContext *C, bool free_database);
 
 /* render_preview.c */
 
index b566fd360b6081e0628b54730d9232d8f6208aa0..e5cc0dd8ea726d31ddc28fd04aed3edbb4e0ba9c 100644 (file)
@@ -236,6 +236,8 @@ typedef enum {
        BUT_NORMAL    = (31 << 9),
        BUT_CURVE     = (32 << 9),
        ICONTOGN      = (34 << 9),
+       LISTBOX       = (35 << 9),
+       LISTROW       = (36 << 9),
        TOGBUT        = (37 << 9),
        OPTION        = (38 << 9),
        OPTIONN       = (39 << 9),
@@ -244,8 +246,6 @@ typedef enum {
        SEARCH_MENU   = (41 << 9),
        BUT_EXTRA     = (42 << 9),
        HSVCIRCLE     = (43 << 9),
-       LISTBOX       = (44 << 9),
-       LISTROW       = (45 << 9),
        HOTKEYEVT     = (46 << 9),
        BUT_IMAGE     = (47 << 9),
        HISTOGRAM     = (48 << 9),
index 9ac499fc94b790ad255ecf2d67cd18f201bc77f6..097f042d6c9a2dff2cb33f11711e64943c25bac1 100644 (file)
@@ -2167,6 +2167,15 @@ static void ui_set_but_soft_range(uiBut *but)
                but->softmin = softmin;
                but->softmax = softmax;
        }
+       else if (but->poin && (but->pointype & UI_BUT_POIN_TYPES)) {
+               float value = ui_get_but_val(but);
+               CLAMP(value, but->hardmin, but->hardmax);
+               but->softmin = min_ff(but->softmin, value);
+               but->softmax = max_ff(but->softmax, value);
+       }
+       else {
+               BLI_assert(0);
+       }
 }
 
 /* ******************* Free ********************/
@@ -2368,8 +2377,12 @@ void ui_check_but(uiBut *but)
        ui_check_but_select(but, &value);
        
        /* only update soft range while not editing */
-       if (but->rnaprop && !(but->editval || but->editstr || but->editvec)) {
-               ui_set_but_soft_range(but);
+       if (!(but->editval || but->editstr || but->editvec)) {
+               if ((but->rnaprop != NULL) ||
+                   (but->poin && (but->pointype & UI_BUT_POIN_TYPES)))
+               {
+                       ui_set_but_soft_range(but);
+               }
        }
 
        /* test for min and max, icon sliders, etc */
@@ -2757,13 +2770,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
        uiBut *but;
        int slen;
 
-       BLI_assert(width >= 0);
-       BLI_assert(height >= 0);
+       BLI_assert(width >= 0 && height >= 0);
        
        /* we could do some more error checks here */
        if ((type & BUTTYPE) == LABEL) {
-               if ((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)))
-                       printf("blah\n");
                BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE);
        }
 
@@ -2851,7 +2861,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
        }
 
        /* keep track of UI_interface.h */
-       if      (ELEM9(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM, SCROLL, SEPR /* , FTPREVIEW */)) {}
+       if      (ELEM8(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, BUTM, SCROLL, SEPR)) {}
        else if (but->type >= SEARCH_MENU) {}
        else but->flag |= UI_BUT_UNDO;
 
@@ -4132,6 +4142,7 @@ void uiButGetStrInfo(bContext *C, uiBut *but, ...)
 
                si->strinfo = tmp;
        }
+       va_end(args);
 
        if (free_items && items)
                MEM_freeN(items);
index 342c0569f411080939c13a1f3f9c72b2be195b8e..68cf07f695fb6a8d165cc11269461ab8d7174b87 100644 (file)
@@ -875,6 +875,10 @@ static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
                        uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__);
                        ARegion *ar_prev;
 
+                       /* call here because regular mouse-up event wont run,
+                        * typically 'button_activate_exit()' handles this */
+                       ui_apply_autokey(C, but);
+
                        drag_info->is_set = ui_is_but_push(but);
                        drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect);
                        drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect);
@@ -1297,9 +1301,14 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
                        if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
                                ID *id = (ID *)wmd->poin;
                                
-                               if (but->poin == NULL && but->rnapoin.data == NULL) {}
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                                BLI_strncpy(data->str, id->name + 2, data->maxlen);
+
+                               if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
+                                       but->changed = true;
+                                       ui_searchbox_update(C, data->searchbox, but, true);
+                               }
+