Merging r57729 through r57815 from trunk into soc-2013-depsgraph_mt
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 27 Jun 2013 09:07:19 +0000 (09:07 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 27 Jun 2013 09:07:19 +0000 (09:07 +0000)
138 files changed:
build_files/build_environment/install_deps.sh
doc/python_api/examples/bpy.app.translations.py
doc/python_api/examples/bpy.types.WindowManager.popup_menu.py
intern/cycles/blender/addon/ui.py
intern/cycles/device/device_cuda.cpp
intern/cycles/device/device_opencl.cpp
intern/cycles/kernel/kernel_compat_opencl.h
intern/cycles/kernel/kernel_sse2.cpp
intern/cycles/kernel/kernel_sse3.cpp
intern/cycles/kernel/shaders/CMakeLists.txt
intern/cycles/kernel/shaders/SConscript
intern/cycles/kernel/shaders/node_brick_texture.osl
intern/cycles/kernel/svm/svm_brick.h
intern/cycles/util/util_types.h
intern/cycles/util/util_vector.h
release/scripts/modules/bl_i18n_utils/utils_languages_menu.py
release/scripts/modules/bpy/utils.py
release/scripts/modules/console/complete_namespace.py
release/scripts/modules/nodeitems_utils.py
release/scripts/startup/bl_operators/anim.py
release/scripts/startup/bl_operators/node.py
release/scripts/startup/bl_operators/presets.py
release/scripts/startup/bl_operators/vertexpaint_dirt.py
release/scripts/startup/bl_operators/view3d.py
release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/properties_freestyle.py
release/scripts/startup/bl_ui/properties_game.py
release/scripts/startup/bl_ui/properties_physics_fluid.py
release/scripts/startup/bl_ui/properties_render.py
release/scripts/startup/bl_ui/space_clip.py
release/scripts/startup/bl_ui/space_image.py
release/scripts/startup/bl_ui/space_node.py
release/scripts/startup/bl_ui/space_userpref.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
release/scripts/startup/nodeitems_builtins.py
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/autoexec.c
source/blender/blenkernel/intern/bpath.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/BLI_scanfill.h
source/blender/blenlib/intern/fileops.c
source/blender/blenlib/intern/graph.c
source/blender/blenlib/intern/math_color_inline.c
source/blender/blenlib/intern/math_geom.c
source/blender/blenlib/intern/path_util.c
source/blender/blenlib/intern/scanfill.c
source/blender/blenloader/intern/readfile.c
source/blender/bmesh/intern/bmesh_edgeloop.c
source/blender/bmesh/intern/bmesh_iterators.h
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mesh_conv.h
source/blender/bmesh/intern/bmesh_polygon.c
source/blender/bmesh/intern/bmesh_polygon.h
source/blender/bmesh/intern/bmesh_walkers.c
source/blender/bmesh/operators/bmo_beautify.c
source/blender/bmesh/operators/bmo_bridge.c
source/blender/bmesh/operators/bmo_connect.c
source/blender/bmesh/operators/bmo_dupe.c
source/blender/bmesh/operators/bmo_mirror.c
source/blender/bmesh/operators/bmo_poke.c
source/blender/bmesh/operators/bmo_subdivide.c
source/blender/bmesh/operators/bmo_wireframe.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/bmesh/tools/bmesh_decimate_collapse.c
source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
source/blender/collada/AnimationExporter.cpp
source/blender/editors/curve/editcurve.c
source/blender/editors/curve/editfont.c
source/blender/editors/curve/lorem.c
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_opengl.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screendump.c
source/blender/editors/sculpt_paint/CMakeLists.txt
source/blender/editors/sculpt_paint/paint_hide.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/paint_vertex_proj.c [new file with mode: 0644]
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/transform/transform_manipulator.c
source/blender/freestyle/intern/view_map/SteerableViewMap.h
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_draw.c
source/blender/imbuf/intern/thumbs.c
source/blender/imbuf/intern/util.c
source/blender/makesdna/DNA_key_types.h
source/blender/makesrna/intern/rna_key.c
source/blender/makesrna/intern/rna_lamp.c
source/blender/modifiers/intern/MOD_multires.c
source/blender/python/bmesh/bmesh_py_api.c
source/blender/python/bmesh/bmesh_py_types.c
source/blender/python/intern/bpy_rna_array.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_operators.c
source/creator/creator.c
source/gameengine/Ketsji/BL_Shader.cpp
source/gameengine/Ketsji/KX_Dome.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h

index 2ac3a75688e3198a098a0ebe220c6b57d5d3c9ce..7b41f156ea8b604cf8e7425f2ebb17165179c154 100755 (executable)
@@ -229,7 +229,7 @@ LLVM_FORCE_REBUILD=false
 LLVM_SKIP=false
 
 # OSL needs to be compiled for now!
-OSL_VERSION="1.3.0"
+OSL_VERSION="1.3.2"
 OSL_SOURCE="https://github.com/imageworks/OpenShadingLanguage/archive/Release-$OSL_VERSION.tar.gz"
 OSL_FORCE_REBUILD=false
 OSL_SKIP=false
@@ -1527,7 +1527,7 @@ clean_OSL() {
 
 compile_OSL() {
   # To be changed each time we make edits that would modify the compiled result!
-  osl_magic=9
+  osl_magic=10
   _init_osl
 
   # Clean install if needed!
index 2c21bb54ba9bae950e0faa2962ecf5ad16e969d1..01d5a987215edcfe4492acba21ea0828865158e4 100644 (file)
@@ -4,7 +4,7 @@ Intro
 
 .. warning::
    Most of this object should only be useful if you actually manipulate i18n stuff from Python.
-   If you are a regular addon, you should only bother about :const:`contexts` member, 
+   If you are a regular addon, you should only bother about :const:`contexts` member,
    and the :func:`register`/:func:`unregister` functions! The :func:`pgettext` family of functions
    should only be used in rare, specific cases (like e.g. complex "composited" UI strings...).
 
index c1887d8b41d40a4a77eb57fafe8bffc249b2dcd5..df591521440a838be4f3b90ee23d7ed433a18225 100644 (file)
@@ -8,6 +8,7 @@ Note that they will not block the scripts execution, so the caller can't wait fo
 
 import bpy
 
+
 def draw(self, context):
     self.layout.label("Hello World")
 
index dc632b9bb2c386a5919525ba75dd8d7e12c43730..91e850d066f5357415d2042b357a7cc6cefd0e02 100644 (file)
@@ -20,7 +20,7 @@
 
 import bpy
 
-from bpy.types import Panel, Menu
+from bpy.types import Panel, Menu, Operator
 
 
 class CYCLES_MT_integrator_presets(Menu):
@@ -547,6 +547,26 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
             flow.prop(visibility, "shadow")
 
 
+class CYCLES_OT_use_shading_nodes(Operator):
+    """Enable nodes on a material, world or lamp"""
+    bl_idname = "cycles.use_shading_nodes"
+    bl_label = "Use Nodes"
+
+    @classmethod
+    def poll(cls, context):
+        return context.material or context.world or context.lamp
+
+    def execute(self, context):
+        if context.material:
+            context.material.use_nodes = True
+        elif context.world:
+            context.world.use_nodes = True
+        elif context.lamp:
+            context.lamp.use_nodes = True
+
+        return {'FINISHED'}
+
+
 def find_node(material, nodetype):
     if material and material.node_tree:
         ntree = material.node_tree
@@ -568,7 +588,7 @@ def find_node_input(node, name):
 
 def panel_node_draw(layout, id_data, output_type, input_name):
     if not id_data.use_nodes:
-        layout.prop(id_data, "use_nodes", icon='NODETREE')
+        layout.operator("cycles.use_shading_nodes", icon='NODETREE')
         return False
 
     ntree = id_data.node_tree
@@ -753,6 +773,7 @@ class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
         row.prop(light, "ao_factor", text="Factor")
         row.prop(light, "distance", text="Distance")
 
+
 class CyclesWorld_PT_mist(CyclesButtonsPanel, Panel):
     bl_label = "Mist Pass"
     bl_context = "world"
@@ -920,7 +941,7 @@ class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
         col = split.column(align=True)
         col.label()
         col.prop(mat, "pass_index")
-        
+
         col = layout.column()
         col.prop(cmat, "sample_as_light")
         col.prop(cmat, "use_transparent_shadow")
@@ -1146,7 +1167,7 @@ class CyclesRender_PT_CurveRendering(CyclesButtonsPanel, Panel):
 
             row = layout.row()
             row.prop(ccscene, "use_parents", text="Include parents")
-        
+
         row = layout.row()
         row.prop(ccscene, "minimum_width", text="Min Pixels")
         row.prop(ccscene, "maximum_width", text="Max Ext.")
@@ -1178,7 +1199,7 @@ class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
         row = layout.row()
         row.prop(cpsys, "root_width", text="Root")
         row.prop(cpsys, "tip_width", text="Tip")
-        
+
         row = layout.row()
         row.prop(cpsys, "radius_scale", text="Scaling")
         row.prop(cpsys, "use_closetip", text="Close tip")
index 6b0c9120bd9af0c081d41f5941582ab9cf89c079..4441ff1c69fe708b0adbb257cc0223f34685bdfa 100644 (file)
@@ -607,13 +607,8 @@ public:
                cuda_assert(cuParamSetSize(cuPathTrace, offset))
 
                /* launch kernel: todo find optimal size, cache config for fermi */
-#ifndef __APPLE__
                int xthreads = 16;
                int ythreads = 16;
-#else
-               int xthreads = 8;
-               int ythreads = 8;
-#endif
                int xblocks = (rtile.w + xthreads - 1)/xthreads;
                int yblocks = (rtile.h + ythreads - 1)/ythreads;
 
@@ -676,13 +671,8 @@ public:
                cuda_assert(cuParamSetSize(cuFilmConvert, offset))
 
                /* launch kernel: todo find optimal size, cache config for fermi */
-#ifndef __APPLE__
                int xthreads = 16;
                int ythreads = 16;
-#else
-               int xthreads = 8;
-               int ythreads = 8;
-#endif
                int xblocks = (task.w + xthreads - 1)/xthreads;
                int yblocks = (task.h + ythreads - 1)/ythreads;
 
@@ -730,11 +720,7 @@ public:
                cuda_assert(cuParamSetSize(cuDisplace, offset))
 
                /* launch kernel: todo find optimal size, cache config for fermi */
-#ifndef __APPLE__
                int xthreads = 16;
-#else
-               int xthreads = 8;
-#endif
                int xblocks = (task.shader_w + xthreads - 1)/xthreads;
 
                cuda_assert(cuFuncSetCacheConfig(cuDisplace, CU_FUNC_CACHE_PREFER_L1))
index 4f61f771df10a05d5f229af6a373874a252c9b3b..a127bd9e5d1f6953567976e38cbc48d0587ad872 100644 (file)
@@ -241,6 +241,9 @@ public:
        {
                cl_context context = get_something<cl_context>(platform, device, &Slot::context, slot_locker);
 
+               if(!context)
+                       return NULL;
+
                /* caller is going to release it when done with it, so retain it */
                cl_int ciErr = clRetainContext(context);
                assert(ciErr == CL_SUCCESS);
@@ -255,6 +258,9 @@ public:
        {
                cl_program program = get_something<cl_program>(platform, device, &Slot::program, slot_locker);
 
+               if(!program)
+                       return NULL;
+
                /* caller is going to release it when done with it, so retain it */
                cl_int ciErr = clRetainProgram(program);
                assert(ciErr == CL_SUCCESS);
index 2bf3b58ce9917729d602b9c1ce55564d44200f40..c4cb7a516c21f7a492e125303cc93133ec89931c 100644 (file)
 
 /* data lookup defines */
 #define kernel_data (*kg->data)
-#define kernel_tex_lookup(t, x, offset, size) kernel_tex_lookup_(kg->t, offset, size, x)
 #define kernel_tex_fetch(t, index) kg->t[index]
 
 /* define NULL */
index b58e41f954f00df26f0dcb59cca6b46c583ae649..cfadb02b93b393d07012a0bb2ce49e2a960b6c63 100644 (file)
@@ -22,6 +22,8 @@
 
 #ifdef WITH_OPTIMIZED_KERNEL
 
+#define __KERNEL_SSE2__
+
 #include "kernel.h"
 #include "kernel_compat_cpu.h"
 #include "kernel_math.h"
index ff6bb412d5bd84eb1ba33731cfd479d94bfb12c0..de4c979b82ecdd3b894792ce76d7a9b91f959988 100644 (file)
@@ -22,6 +22,7 @@
 
 #ifdef WITH_OPTIMIZED_KERNEL
 
+#define __KERNEL_SSE2__
 #define __KERNEL_SSE3__
 #define __KERNEL_SSSE3__
 
index f2beb3da9c03922beddceb2a4d750729d72f69d8..23112f565369366ca9c02ad59224fed37e88fd58 100644 (file)
@@ -91,7 +91,7 @@ foreach(_file ${SRC_OSL})
        string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _OSO_FILE ${_OSO_FILE})
        add_custom_command(
                OUTPUT ${_OSO_FILE} 
-               COMMAND ${OSL_COMPILER} -O2  -I"${CMAKE_CURRENT_SOURCE_DIR}" ${_OSL_FILE}
+               COMMAND ${OSL_COMPILER} -q -O2  -I"${CMAKE_CURRENT_SOURCE_DIR}" ${_OSL_FILE}
                DEPENDS ${_OSL_FILE} ${SRC_OSL_HEADERS})
        list(APPEND SRC_OSO
                ${_OSO_FILE}
index daf2b67ad2b36381485a964421d80c783fb07f3a..aad6e23e4d46ed008878ae35a664dbb006526d78 100644 (file)
@@ -57,7 +57,7 @@ if env['WITH_BF_CYCLES_OSL']:
             osl_file = os.path.join(source_dir, f)
             oso_file = os.path.join(build_dir, f.replace('.osl', '.oso'))
 
-            command = "%s -O2 -I%s -o %s %s" % (osl_compiler, source_dir, oso_file, osl_file)
+            command = "%s -q -O2 -I%s -o %s %s" % (osl_compiler, source_dir, oso_file, osl_file)
 
             shaders.Command(oso_file, f, command)
             shaders.Depends(oso_file, [f] + dependencies)
index 509b4f2883b9639cef736feb1374900e42cb1ec6..aa9742fb277039344ee180d771706a3628fa8664 100644 (file)
@@ -41,8 +41,8 @@ float brick(point p, float mortar_size, float bias,
        rownum = (int)floor(p[1] / row_height);
        
        if (offset_frequency && squash_frequency) {
-               brick_width *= ((int)(rownum) % squash_frequency) ? 1.0 : squash_amount;                /* squash */
-               offset       = ((int)(rownum) % offset_frequency) ? 0 : (brick_width * offset_amount);  /* offset */
+               brick_width *= (rownum % squash_frequency) ? 1.0 : squash_amount;                /* squash */
+               offset       = (rownum % offset_frequency) ? 0.0 : (brick_width * offset_amount);  /* offset */
        }
 
        bricknum = (int)floor((p[0] + offset) / brick_width);
index 43dc1a2f2955669b94aae605aeaffc260c46091c..c44a4740cca44eebb54610fd210421fd341599c8 100644 (file)
@@ -41,8 +41,8 @@ __device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, flo
        rownum = floor_to_int(p.y / row_height);
        
        if(offset_frequency && squash_frequency) {
-               brick_width *= ((int)(rownum) % squash_frequency ) ? 1.0f : squash_amount; /* squash */
-               offset = ((int)(rownum) % offset_frequency ) ? 0 : (brick_width*offset_amount); /* offset */
+               brick_width *= (rownum % squash_frequency) ? 1.0f : squash_amount; /* squash */
+               offset = (rownum % offset_frequency) ? 0.0f : (brick_width*offset_amount); /* offset */
        }
 
        bricknum = floor_to_int((p.x+offset) / brick_width);
index 891fb82d06b8e5d1f158d1f09a59c449bd56870a..b2d842edccd012d60723d95d3df340961bf5cc76 100644 (file)
 
 #ifndef __KERNEL_GPU__
 
-/* not enabled, globally applying it just gives slowdown,
- * but useful for testing. */
-//#define __KERNEL_SSE__
-#ifdef __KERNEL_SSE__
-
-#include <xmmintrin.h> /* SSE 1 */
-#include <emmintrin.h> /* SSE 2 */
-#include <pmmintrin.h> /* SSE 3 */
-#include <tmmintrin.h> /* SSSE 3 */
-#include <smmintrin.h> /* SSE 4 */
-
+/* not enabled, globally applying it gives slowdown, only for testing. */
+#if 0
+#define __KERNEL_SSE__
 #ifndef __KERNEL_SSE2__
 #define __KERNEL_SSE2__
 #endif
-
 #ifndef __KERNEL_SSE3__
 #define __KERNEL_SSE3__
 #endif
-
 #ifndef __KERNEL_SSSE3__
 #define __KERNEL_SSSE3__
 #endif
-
 #ifndef __KERNEL_SSE4__
 #define __KERNEL_SSE4__
 #endif
+#endif
 
-#else
+/* SSE2 is always available on x86_64 CPUs, so auto enable */
+#if defined(__x86_64__) && !defined(__KERNEL_SSE2__)
+#define __KERNEL_SSE2__
+#endif
 
-#if defined(__x86_64__) || defined(__KERNEL_SSSE3__)
+/* SSE intrinsics headers */
+#ifndef FREE_WINDOWS64
 
-/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
- * Since we can't avoid including <windows.h>, better only include that */
-#ifdef FREE_WINDOWS64
-#include <windows.h>
-#else
+#ifdef __KERNEL_SSE2__
 #include <xmmintrin.h> /* SSE 1 */
 #include <emmintrin.h> /* SSE 2 */
+#endif
 
 #ifdef __KERNEL_SSE3__
 #include <pmmintrin.h> /* SSE 3 */
 #endif
+
 #ifdef __KERNEL_SSSE3__
 #include <tmmintrin.h> /* SSSE 3 */
 #endif
-#endif
 
-#ifndef __KERNEL_SSE2__
-#define __KERNEL_SSE2__
-#endif
+#else
 
-#endif
+/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
+ * Since we can't avoid including <windows.h>, better only include that */
+#include <windows.h>
 
 #endif
 
@@ -552,30 +543,6 @@ template<size_t i0, size_t i1, size_t i2, size_t i3> __device_inline const __m12
 }
 #endif
 
-#ifndef __KERNEL_GPU__
-
-static inline void *malloc_aligned(size_t size, size_t alignment)
-{
-       void *data = (void*)malloc(size + sizeof(void*) + alignment - 1);
-
-       union { void *ptr; size_t offset; } u;
-       u.ptr = (char*)data + sizeof(void*);
-       u.offset = (u.offset + alignment - 1) & ~(alignment - 1);
-       *(((void**)u.ptr) - 1) = data;
-
-       return u.ptr;
-}
-
-static inline void free_aligned(void *ptr)
-{
-       if(ptr) {
-               void *data = *(((void**)ptr) - 1);
-               free(data);
-       }
-}
-
-#endif
-
 CCL_NAMESPACE_END
 
 #endif /* __UTIL_TYPES_H__ */
index 0fd4488d91da05fd1a82ef2f6f7e237393af050b..65aad37c88c6e27e8d006e538a25bbad41a593c6 100644 (file)
@@ -30,6 +30,26 @@ CCL_NAMESPACE_BEGIN
 
 using std::vector;
 
+static inline void *malloc_aligned(size_t size, size_t alignment)
+{
+       void *data = (void*)malloc(size + sizeof(void*) + alignment - 1);
+
+       union { void *ptr; size_t offset; } u;
+       u.ptr = (char*)data + sizeof(void*);
+       u.offset = (u.offset + alignment - 1) & ~(alignment - 1);
+       *(((void**)u.ptr) - 1) = data;
+
+       return u.ptr;
+}
+
+static inline void free_aligned(void *ptr)
+{
+       if(ptr) {
+               void *data = *(((void**)ptr) - 1);
+               free(data);
+       }
+}
+
 /* Array
  *
  * Simplified version of vector, serving multiple purposes:
index 789b1315659b2a69a642abb38e5e9335dce17421..24255d9be61085fa42a9e7e8a8d6ff6a27da3b5a 100755 (executable)
@@ -35,6 +35,7 @@ FLAG_MESSAGES = {
     FORBIDDEN: "Explicitly forbidden!",
 }
 
+
 def gen_menu_file(stats, settings):
     # Generate languages file used by Blender's i18n system.
     # First, match all entries in LANGUAGES to a lang in stats, if possible!
index ec3891e8d761df4bd8077f80518b573e27a0a495..ab35d7747194449caecbb367afabd4f894c3d98f 100644 (file)
@@ -507,7 +507,8 @@ def keyconfig_set(filepath, report=None):
             report({'ERROR'}, error_msg)
         print(error_msg)
 
-    kc_new = next(chain(iter(kc for kc in keyconfigs if kc not in keyconfigs_old), (None,)))
+    kc_new = next(chain(iter(kc for kc in keyconfigs
+                             if kc not in keyconfigs_old), (None,)))
     if kc_new is None:
         if report is not None:
             report({'ERROR'}, "Failed to load keymap %r" % filepath)
index 31e4f3cf22584801c560136958ee2f969ae6a031..74406d5e002d2aac33d7bb5a327b8bca489b7d8e 100644 (file)
@@ -110,7 +110,7 @@ def complete_indices(word, namespace, obj=None, base=None):
         # dictionary type
         matches = ['%s[%r]' % (base, key) for key in sorted(obj.keys())]
     else:
-        # list type
+        # list type
         matches = ['%s[%d]' % (base, idx) for idx in range(obj_len)]
     if word != base:
         matches = [match for match in matches if match.startswith(word)]
index 2114a64e416ccc400d88acc899c62c83514a60bc..7418452b039336684e05642997b9d2fd3ab11e26 100644 (file)
@@ -42,6 +42,7 @@ class NodeCategory():
                         yield item
             self.items = items_gen
 
+
 class NodeItem():
     def __init__(self, nodetype, label=None, settings={}, poll=None):
         self.nodetype = nodetype
@@ -81,6 +82,7 @@ class NodeItemCustom():
 
 _node_categories = {}
 
+
 def register_node_categories(identifier, cat_list):
     if identifier in _node_categories:
         raise KeyError("Node categories list '%s' already registered" % identifier)
@@ -97,21 +99,21 @@ def register_node_categories(identifier, cat_list):
     menu_types = []
     panel_types = []
     for cat in cat_list:
-        menu_type = type("NODE_MT_category_"+cat.identifier, (bpy.types.Menu,), {
-            "bl_space_type" : 'NODE_EDITOR',
-            "bl_label" : cat.name,
-            "category" : cat,
-            "poll" : cat.poll,
-            "draw" : draw_node_item,
+        menu_type = type("NODE_MT_category_" + cat.identifier, (bpy.types.Menu,), {
+            "bl_space_type": 'NODE_EDITOR',
+            "bl_label": cat.name,
+            "category": cat,
+            "poll": cat.poll,
+            "draw": draw_node_item,
             })
-        panel_type = type("NODE_PT_category_"+cat.identifier, (bpy.types.Panel,), {
-            "bl_space_type" : 'NODE_EDITOR',
-            "bl_region_type" : 'TOOLS',
-            "bl_label" : cat.name,
-            "bl_options" : {'DEFAULT_CLOSED'},
-            "category" : cat,
-            "poll" : cat.poll,
-            "draw" : draw_node_item,
+        panel_type = type("NODE_PT_category_" + cat.identifier, (bpy.types.Panel,), {
+            "bl_space_type": 'NODE_EDITOR',
+            "bl_region_type": 'TOOLS',
+            "bl_label": cat.name,
+            "bl_options": {'DEFAULT_CLOSED'},
+            "category": cat,
+            "poll": cat.poll,
+            "draw": draw_node_item,
             })
 
         menu_types.append(menu_type)
@@ -166,4 +168,3 @@ def unregister_node_categories(identifier=None):
         for cat_types in _node_categories.values():
             unregister_node_cat_types(cat_types)
         _node_categories.clear()
-
index 943eed74b1da36dcba38403b6b360d3d54b35f1f..ed20cb22297dacfb830018aad74a23f7df94192e 100644 (file)
@@ -261,8 +261,8 @@ class ClearUselessActions(Operator):
 
         for action in bpy.data.actions:
             # if only user is "fake" user...
-            if     ((self.only_unused is False) or
-                    (action.use_fake_user and action.users == 1)):
+            if ((self.only_unused is False) or
+                (action.use_fake_user and action.users == 1)):
 
                 # if it has F-Curves, then it's a "action library"
                 # (i.e. walk, wave, jump, etc.)
index c9ce38e1c6f568a29734db30d740ce121b70fed8..1e92619c519b6a3f67a197d3044d420c6fa94258 100644 (file)
 
 # <pep8-80 compliant>
 
-import bpy, nodeitems_utils
-from bpy.types import Operator, PropertyGroup
-from bpy.props import BoolProperty, CollectionProperty, EnumProperty, IntProperty, StringProperty
+import bpy
+import nodeitems_utils
+from bpy.types import (Operator,
+                       PropertyGroup,
+                       )
+from bpy.props import (BoolProperty,
+                       CollectionProperty,
+                       EnumProperty,
+                       IntProperty,
+                       StringProperty,
+                       )
 
 
 class NodeSetting(PropertyGroup):
@@ -30,6 +38,7 @@ class NodeSetting(PropertyGroup):
             default="",
             )
 
+
 # Base class for node 'Add' operators
 class NodeAddOperator():
 
@@ -57,8 +66,12 @@ class NodeAddOperator():
 
         # convert mouse position to the View2D for later node placement
         if context.region.type == 'WINDOW':
+            # XXX, why use DPI for coords?
+            dpi_fac = context.user_preferences.system.dpi / 72.0
             space.cursor_location = v2d.region_to_view(event.mouse_region_x,
-                                                   event.mouse_region_y)
+                                                       event.mouse_region_y)
+            space.cursor_location /= dpi_fac
+
         else:
             space.cursor_location = tree.view_center
 
@@ -80,12 +93,12 @@ class NodeAddOperator():
         for setting in self.settings:
             # XXX catch exceptions here?
             value = eval(setting.value)
-                
+
             try:
                 setattr(node, setting.name, value)
             except AttributeError as e:
-                self.report({'ERROR_INVALID_INPUT'}, "Node has no attribute "+setting.name)
-                print (str(e))
+                self.report({'ERROR_INVALID_INPUT'}, "Node has no attribute " + setting.name)
+                print(str(e))
                 # Continue despite invalid attribute
 
         if space.use_hidden_preview:
@@ -198,7 +211,7 @@ class NODE_OT_add_search(NodeAddOperator, Operator):
 
         # no need to keep
         self._enum_item_hack.clear()
-        
+
         if item:
             # apply settings from the node item
             for setting in item.settings.items():
index ed0943ac2e00caa51f2a54eef5813b79733405c3..05dfd882180dea42bb5644efbf1e67a25c2b7f2f 100644 (file)
@@ -30,7 +30,9 @@ class AddPresetBase():
      - preset_subdir """
     # bl_idname = "script.preset_base_add"
     # bl_label = "Add a Python Preset"
-    bl_options = {'REGISTER', 'INTERNAL'} # only because invoke_props_popup requires. Also do not add to search menu.
+
+    # only because invoke_props_popup requires. Also do not add to search menu.
+    bl_options = {'REGISTER', 'INTERNAL'}
 
     name = StringProperty(
             name="Name",
index fbca4e1ac733fbf199ff97a7e6f6395b8d79eb82..345d8d4d3a191c040253a6145bb93539ae827355 100644 (file)
@@ -23,6 +23,7 @@
 
 # Contributor(s): Keith "Wahooney" Boshoff, Campbell Barton
 
+
 def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only):
     from mathutils import Vector
     from math import acos
index cfdb5dbe6774a98dd5a83759adcc5a3adc42d3be..e0b5526e2200b2ffec85c24008cb1810bfb740eb 100644 (file)
@@ -138,7 +138,7 @@ class VIEW3D_OT_select_or_deselect_all(Operator):
         x = event.mouse_region_x
         y = event.mouse_region_y
 
-        if self.extend == False and self.toggle == False and self.deselect == False:
+        if self.extend is False and self.toggle is False and self.deselect is False:
             active_object = context.active_object
 
             if active_object:
index fba7672e8466ed602c86bad4a11053c1fb6668e3..5cb7a44267a023ea777621dc5a5b9149be63d8d1 100644 (file)
@@ -1180,6 +1180,7 @@ class WM_OT_keyconfig_activate(Operator):
         else:
             return {'CANCELLED'}
 
+
 class WM_OT_appconfig_default(Operator):
     bl_idname = "wm.appconfig_default"
     bl_label = "Default Application Configuration"
@@ -1574,8 +1575,9 @@ class WM_OT_addon_enable(Operator):
 
     def execute(self, context):
         import addon_utils
-        
+
         err_str = ""
+
         def err_cb():
             import traceback
             nonlocal err_str
@@ -1618,6 +1620,7 @@ class WM_OT_addon_disable(Operator):
         import addon_utils
 
         err_str = ""
+
         def err_cb():
             import traceback
             nonlocal err_str
index 6f4ffbf361617c95c27b599bbd443af3c15d9152..89e90618383564efbcc94fba4886a77c8fdc1c7d 100644 (file)
@@ -120,7 +120,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
     def BEVEL(self, layout, ob, md):
         split = layout.split()
-        
+
         col = split.column()
         col.prop(md, "width")
         col.prop(md, "segments")
@@ -982,26 +982,26 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
     def VERTEX_WEIGHT_EDIT(self, layout, ob, md):
         split = layout.split()
-        
+
         col = split.column()
         col.label(text="Vertex Group:")
         col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
 
         col.label(text="Default Weight:")
         col.prop(md, "default_weight", text="")
-        
+
         col = split.column()
         col.prop(md, "use_add")
         sub = col.column()
         sub.active = md.use_add
         sub.prop(md, "add_threshold")
-        
+
         col = col.column()
         col.prop(md, "use_remove")
         sub = col.column()
         sub.active = md.use_remove
         sub.prop(md, "remove_threshold")
-        
+
         layout.separator()
 
         layout.prop(md, "falloff_type")
@@ -1047,20 +1047,20 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col = split.column()
         col.label(text="Target Object:")
         col.prop(md, "target", text="")
-        
+
         split = layout.split()
-        
+
         col = split.column()
         col.label(text="Distance:")
         col.prop(md, "proximity_mode", text="")
         if md.proximity_mode == 'GEOMETRY':
             col.row().prop(md, "proximity_geometry")
-            
+
         col = split.column()
         col.label()
         col.prop(md, "min_dist")
         col.prop(md, "max_dist")
-        
+
         layout.separator()
         layout.prop(md, "falloff_type")
 
@@ -1070,25 +1070,25 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
     def SKIN(self, layout, ob, md):
         layout.operator("object.skin_armature_create", text="Create Armature")
-        
+
         layout.separator()
-        
+
         col = layout.column(align=True)
         col.prop(md, "branch_smoothing")
         col.prop(md, "use_smooth_shade")
-        
+
         split = layout.split()
-        
+
         col = split.column()
         col.label(text="Selected Vertices:")
         sub = col.column(align=True)
         sub.operator("object.skin_loose_mark_clear", text="Mark Loose").action = 'MARK'
         sub.operator("object.skin_loose_mark_clear", text="Clear Loose").action = 'CLEAR'
-        
+
         sub = col.column()
         sub.operator("object.skin_root_mark", text="Mark Root")
         sub.operator("object.skin_radii_equalize", text="Equalize Radii")
-        
+
         col = split.column()
         col.label(text="Symmetry Axes:")
         col.prop(md, "use_x_symmetry")
index 96321eded50c24dc0534d7396d914e204559a8ae..eec753e1d041661cb7375a3b387c0f2aa0ffc3b8 100644 (file)
@@ -47,7 +47,7 @@ class RENDER_PT_freestyle(RenderFreestyleButtonsPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
-        
+
         rd = context.scene.render
 
         layout.active = rd.use_freestyle
@@ -55,7 +55,7 @@ class RENDER_PT_freestyle(RenderFreestyleButtonsPanel, Panel):
         row = layout.row()
         row.label(text="Line Thickness:")
         row.prop(rd, "line_thickness_mode", expand=True)
-        
+
         if (rd.line_thickness_mode == 'ABSOLUTE'):
             layout.prop(rd, "line_thickness")
 
@@ -65,7 +65,7 @@ class RENDER_PT_freestyle(RenderFreestyleButtonsPanel, Panel):
 
 
 # Render layer properties
-        
+
 class RenderLayerFreestyleButtonsPanel():
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -77,7 +77,7 @@ class RenderLayerFreestyleButtonsPanel():
         scene = context.scene
         rd = context.scene.render
         with_freestyle = bpy.app.build_options.freestyle
-        
+
         return (scene and with_freestyle and rd.use_freestyle
             and rd.layers.active and(scene.render.engine in cls.COMPAT_ENGINES))
 
@@ -119,28 +119,28 @@ class RENDERLAYER_PT_freestyle(RenderLayerFreestyleButtonsPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
-        
+
         rd = context.scene.render
         rl = rd.layers.active
         freestyle = rl.freestyle_settings
 
         layout.active = rl.use_freestyle
-        
+
         layout.prop(freestyle, "mode", text="Control mode")
         layout.label(text="Edge Detection Options:")
-        
+
         split = layout.split()
-        
+
         col = split.column()
         col.prop(freestyle, "crease_angle")
         col.prop(freestyle, "use_culling")
         col.prop(freestyle, "use_advanced_options")
-        
+
         col = split.column()
         col.prop(freestyle, "use_smoothness")
         if freestyle.mode == 'SCRIPT':
             col.prop(freestyle, "use_material_boundaries")
-        
+
         # Advanced options are hidden by default to warn new users
         if freestyle.use_advanced_options:
             if freestyle.mode == 'SCRIPT':
@@ -184,7 +184,7 @@ class RENDERLAYER_PT_freestyle_lineset(RenderLayerFreestyleEditorButtonsPanel, P
 
     def draw(self, context):
         layout = self.layout
-        
+
         rd = context.scene.render
         rl = rd.layers.active
         freestyle = rl.freestyle_settings
@@ -233,14 +233,14 @@ class RENDERLAYER_PT_freestyle_lineset(RenderLayerFreestyleEditorButtonsPanel, P
                 row.prop(lineset, "edge_type_combination", expand=True)
 
                 split = col.split()
-                
+
                 sub = split.column()
                 self.draw_edge_type_buttons(sub, lineset, "silhouette")
                 self.draw_edge_type_buttons(sub, lineset, "border")
                 self.draw_edge_type_buttons(sub, lineset, "contour")
                 self.draw_edge_type_buttons(sub, lineset, "suggestive_contour")
                 self.draw_edge_type_buttons(sub, lineset, "ridge_valley")
-                
+
                 sub = split.column()
                 self.draw_edge_type_buttons(sub, lineset, "crease")
                 self.draw_edge_type_buttons(sub, lineset, "edge_mark")
@@ -518,7 +518,7 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
 
     def draw(self, context):
         layout = self.layout
-        
+
         rd = context.scene.render
         rl = rd.layers.active
         lineset = rl.freestyle_settings.linesets.active
index 48cfb6f816a3cf17d46487b9f136ab07f08107a3..38e49853454abcd7cec178fc3e2e0727b59ef857 100644 (file)
@@ -643,7 +643,7 @@ class WORLD_PT_game_physics(WorldButtonsPanel, Panel):
             sub.prop(gs, "deactivation_angular_threshold", text="Angular Threshold")
             sub = col.row()
             sub.prop(gs, "deactivation_time", text="Time")
-            
+
             col = layout.column()
             col.prop(gs, "use_occlusion_culling", text="Occlusion Culling")
             sub = col.column()
index 1392d21cf15a0b33110d782d6176a628863f0241..1fc61b7714e509e5f88ed47e2a9d6817ad054c5d 100644 (file)
@@ -67,10 +67,10 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
             # odd formatting here so translation script can extract string
             layout.operator("fluid.bake", text=iface_("Bake (Req. Memory: %s)") % fluid.memory_estimate,
                             translate=False, icon='MOD_FLUIDSIM')
-            
+
             if bpy.app.build_options.openmp:
                 layout.prop(fluid, "threads", text="Simulation Threads")
-            
+
             split = layout.split()
 
             col = split.column()
index 23cec2642e78593204d32faff1a59635acb27626..bf4975f2e43ab4f3b2f54e6cc41cc3a507a76e21 100644 (file)
@@ -79,6 +79,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
 
     _frame_rate_args_prev = None
     _preset_class = None
+
     @staticmethod
     def _draw_framerate_label(*args):
         # avoids re-creating text string each draw
@@ -86,7 +87,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
             return RENDER_PT_dimensions._frame_rate_ret
 
         fps, fps_base, preset_label = args
-        
+
         if fps_base == 1.0:
             fps_rate = round(fps)
         else:
index 46ffe6bb68a67f960bc34ee72c3ba496550f4424..5048a93d56534f41dc8e43e4ded8d654a28702ad 100644 (file)
@@ -336,7 +336,8 @@ class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
         col.prop(settings, "use_keyframe_selection")
 
         col = layout.column(align=True)
-        col.active = not settings.use_tripod_solver and not settings.use_keyframe_selection
+        col.active = (not settings.use_tripod_solver and
+                      not settings.use_keyframe_selection)
         col.prop(tracking_object, "keyframe_a")
         col.prop(tracking_object, "keyframe_b")
 
@@ -408,7 +409,7 @@ class CLIP_PT_tools_orientation(CLIP_PT_reconstruction_panel, Panel):
         layout.separator()
 
         col = layout.column()
-        row = col.row(align=True);
+        row = col.row(align=True)
         row.operator("clip.set_scale")
         row.operator("clip.apply_solution_scale", text="Apply Scale")
         col.prop(settings, "distance")
index fd0f6dbc6fdaaec031b738f4e088dc70d730acff..eb0d9c5082dfb34d075f091b01402032de09613a 100644 (file)
@@ -756,7 +756,6 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
         sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
 
 
-
 class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
     bl_label = "Texture Mask"
     bl_options = {'DEFAULT_CLOSED'}
@@ -783,7 +782,7 @@ class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
                 row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
             else:
                 row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
-        
+
         sub = row.row()
         sub.prop(brush, "mask_overlay_alpha", text="Alpha")
         sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
@@ -901,7 +900,7 @@ class IMAGE_PT_tools_brush_appearance(BrushButtonsPanel, Panel):
             return
 
         col = layout.column()
-        col.prop(toolsettings, "show_brush");
+        col.prop(toolsettings, "show_brush")
 
         col = col.column()
         col.prop(brush, "cursor_color_add", text="")
index 91eeb3d07b4285cb7868eef9daf47ca9cc6201cc..da41f9c6bef026c6aa2816e959ef709b67cbf868 100644 (file)
@@ -131,7 +131,7 @@ class NODE_MT_view(Menu):
 
         layout.operator("node.properties", icon='MENU_PANEL')
         layout.operator("node.toolbar", icon='MENU_PANEL')
-        
+
         layout.separator()
 
         layout.operator("view2d.zoom_in")
index 7cd8cb8fb7cb1713cc33f6ee9b6f583e79052261..54387f10a8d217451bbfa4ca33804596d893fb27 100644 (file)
@@ -1171,12 +1171,12 @@ class USERPREF_PT_addons(Panel):
                 continue
 
             # check if addon should be visible with current filters
-            if     ((filter == "All") or
-                    (filter == info["category"]) or
-                    (filter == "Enabled" and is_enabled) or
-                    (filter == "Disabled" and not is_enabled) or
-                    (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
-                    ):
+            if ((filter == "All") or
+                (filter == info["category"]) or
+                (filter == "Enabled" and is_enabled) or
+                (filter == "Disabled" and not is_enabled) or
+                (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
+                ):
 
                 if search and search not in info["name"].lower():
                     if info["author"]:
index 74f9d36db0a257bf3c4825c20eb87fef9aa3082b..51995ba501222b3ff0dcf48e6a62a43c7c01052c 100644 (file)
@@ -238,8 +238,10 @@ class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
         layout.separator()
 
         obj = context.object
-        if     (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and
-                obj.data.draw_type in {'BBONE', 'ENVELOPE'}):
+        if (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and
+            obj.data.draw_type in {'BBONE', 'ENVELOPE'}
+            ):
+
             layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
 
         if context.edit_object and context.edit_object.type == 'ARMATURE':
@@ -989,7 +991,7 @@ class VIEW3D_MT_object_specials(Menu):
                         props.data_path_item = "data.size_y"
                         props.header_text = "Lamp Size Y: %.3f"
 
-                elif lamp.type in  {'SPOT', 'POINT', 'SUN'}:
+                elif lamp.type in {'SPOT', 'POINT', 'SUN'}:
                     props = layout.operator("wm.context_modal_mouse", text="Size")
                     props.data_path_iter = "selected_editable_objects"
                     props.data_path_item = "data.shadow_soft_size"
@@ -1317,8 +1319,8 @@ class VIEW3D_MT_vertex_group(Menu):
             if ob.vertex_groups.active:
                 layout.separator()
                 layout.operator("object.vertex_group_assign", text="Assign to Active Group").new = False
-                layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False
-                layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
+                layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").use_all_groups = False
+                layout.operator("object.vertex_group_remove_from", text="Remove from All").use_all_groups = True
                 layout.separator()
 
         if ob.vertex_groups.active:
@@ -2218,6 +2220,10 @@ class VIEW3D_MT_edit_font(Menu):
         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
 
+        layout.separator()
+
+        layout.operator("font.insert_lorem")
+
 
 class VIEW3D_MT_edit_text_chars(Menu):
     bl_label = "Special Characters"
index a892a91d50554152013cb720740117a223a816d0..7bc6d476a4be184b62956101611c7fa4bfbcddc0 100644 (file)
@@ -563,7 +563,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
             row = col.row(align=True)
 
             ups = toolsettings.unified_paint_settings
-            if     ((ups.use_unified_size and ups.use_locked_size) or
+            if ((ups.use_unified_size and ups.use_locked_size) or
                     ((not ups.use_unified_size) and brush.use_locked_size)):
                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
                 self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
@@ -681,7 +681,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
                 row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
             else:
                 row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
-        
+
             sub = row.row()
             sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
             sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
@@ -714,17 +714,16 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
             col = layout.column(align=True)
             col.label(text="Overlay:")
 
-            row = col.row()            
+            row = col.row()
             if brush.use_cursor_overlay:
                 row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
             else:
                 row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
-        
+
             sub = row.row()
             sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
             sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
 
-
         # Weight Paint Mode #
         elif context.weight_paint_object and brush:
             layout.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
@@ -776,7 +775,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
                 row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
             else:
                 row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
-        
+
             sub = row.row()
             sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
             sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
@@ -816,7 +815,7 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
                 row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
             else:
                 row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
-        
+
         sub = row.row()
         sub.prop(brush, "texture_overlay_alpha", text="Alpha")
         sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
@@ -843,7 +842,7 @@ class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
 
         brush_mask_texture_settings(col, brush)
+
         col = layout.column(align=True)
         col.active = brush.brush_capabilities.has_overlay
         col.label(text="Overlay:")
@@ -854,7 +853,7 @@ class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
                 row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
             else:
                 row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
-        
+
         sub = row.row()
         sub.prop(brush, "mask_overlay_alpha", text="Alpha")
         sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
@@ -1083,7 +1082,7 @@ class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
             return
 
         col = layout.column()
-        col.prop(settings, "show_brush");
+        col.prop(settings, "show_brush")
 
         col = col.column()
         col.active = settings.show_brush
index fe9e06301f3fa5ffe0c628c9f51825f7cefd7074..af966fa106e87890034650e34a676587cc4f1fec 100644 (file)
@@ -27,19 +27,22 @@ from nodeitems_utils import NodeCategory, NodeItem, NodeItemCustom
 class CompositorNodeCategory(NodeCategory):
     @classmethod
     def poll(cls, context):
-        return context.space_data.tree_type == 'CompositorNodeTree'
+        return (context.space_data.tree_type == 'CompositorNodeTree')
+
 
 class ShaderNewNodeCategory(NodeCategory):
     @classmethod
     def poll(cls, context):
-        return context.space_data.tree_type == 'ShaderNodeTree' and \
-               context.scene.render.use_shading_nodes
+        return (context.space_data.tree_type == 'ShaderNodeTree' and
+                context.scene.render.use_shading_nodes)
+
 
 class ShaderOldNodeCategory(NodeCategory):
     @classmethod
     def poll(cls, context):
-        return context.space_data.tree_type == 'ShaderNodeTree' and \
-               not context.scene.render.use_shading_nodes
+        return (context.space_data.tree_type == 'ShaderNodeTree' and
+                not context.scene.render.use_shading_nodes)
+
 
 class TextureNodeCategory(NodeCategory):
     @classmethod
@@ -54,10 +57,12 @@ def group_make_draw(self, layout, context):
 
 # maps node tree type to group node type
 node_tree_group_type = {
-    'CompositorNodeTree'    : 'CompositorNodeGroup',
-    'ShaderNodeTree'        : 'ShaderNodeGroup',
-    'TextureNodeTree'       : 'TextureNodeGroup',
+    'CompositorNodeTree': 'CompositorNodeGroup',
+    'ShaderNodeTree': 'ShaderNodeGroup',
+    'TextureNodeTree': 'TextureNodeGroup',
     }
+
+
 # generic node group items generator for shader, compositor and texture node groups
 def node_group_items(context):
     space = context.space_data
@@ -86,7 +91,10 @@ def node_group_items(context):
         if contains_group(group, ntree):
             continue
 
-        yield NodeItem(node_tree_group_type[group.bl_idname], group.name, { "node_tree" : "bpy.data.node_groups[%r]" % group.name })
+        yield NodeItem(node_tree_group_type[group.bl_idname],
+                       group.name,
+                       {"node_tree": "bpy.data.node_groups[%r]" % group.name})
+
 
 # only show input/output nodes inside node groups
 def group_input_output_item_poll(context):
@@ -231,8 +239,8 @@ shader_node_categories = [
     ]
 
 compositor_node_categories = [
-     # Compositor Nodes
-     CompositorNodeCategory("CMP_INPUT", "Input", items = [
+    # Compositor Nodes
+    CompositorNodeCategory("CMP_INPUT", "Input", items=[
         NodeItem("CompositorNodeRLayers"),
         NodeItem("CompositorNodeImage"),
         NodeItem("CompositorNodeMovieClip"),
@@ -245,7 +253,7 @@ compositor_node_categories = [
         NodeItem("CompositorNodeTrackPos"),
         NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
         ]),
-    CompositorNodeCategory("CMP_OUTPUT", "Output", items = [
+    CompositorNodeCategory("CMP_OUTPUT", "Output", items=[
         NodeItem("CompositorNodeComposite"),
         NodeItem("CompositorNodeViewer"),
         NodeItem("CompositorNodeSplitViewer"),
@@ -253,7 +261,7 @@ compositor_node_categories = [
         NodeItem("CompositorNodeLevels"),
         NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
         ]),
-    CompositorNodeCategory("CMP_OP_COLOR", "Color", items = [
+    CompositorNodeCategory("CMP_OP_COLOR", "Color", items=[
         NodeItem("CompositorNodeMixRGB"),
         NodeItem("CompositorNodeAlphaOver"),
         NodeItem("CompositorNodeInvert"),
@@ -267,7 +275,7 @@ compositor_node_categories = [
         NodeItem("CompositorNodeTonemap"),
         NodeItem("CompositorNodeZcombine"),
         ]),
-    CompositorNodeCategory("CMP_CONVERTOR", "Converter", items = [
+    CompositorNodeCategory("CMP_CONVERTOR", "Converter", items=[
         NodeItem("CompositorNodeMath"),
         NodeItem("CompositorNodeValToRGB"),
         NodeItem("CompositorNodeSetAlpha"),
@@ -283,7 +291,7 @@ compositor_node_categories = [
         NodeItem("CompositorNodeSepYCCA"),
         NodeItem("CompositorNodeCombYCCA"),
         ]),
-    CompositorNodeCategory("CMP_OP_FILTER", "Filter", items = [
+    CompositorNodeCategory("CMP_OP_FILTER", "Filter", items=[
         NodeItem("CompositorNodeBlur"),
         NodeItem("CompositorNodeBilateralblur"),
         NodeItem("CompositorNodeDilateErode"),
@@ -297,14 +305,14 @@ compositor_node_categories = [
         NodeItem("CompositorNodeDBlur"),
         NodeItem("CompositorNodePixelate"),
         ]),
-    CompositorNodeCategory("CMP_OP_VECTOR", "Vector", items = [
+    CompositorNodeCategory("CMP_OP_VECTOR", "Vector", items=[
         NodeItem("CompositorNodeNormal"),
         NodeItem("CompositorNodeMapValue"),
         NodeItem("CompositorNodeMapRange"),
         NodeItem("CompositorNodeNormalize"),
         NodeItem("CompositorNodeCurveVec"),
         ]),
-    CompositorNodeCategory("CMP_MATTE", "Matte", items = [
+    CompositorNodeCategory("CMP_MATTE", "Matte", items=[
         NodeItem("CompositorNodeKeying"),
         NodeItem("CompositorNodeKeyingScreen"),
         NodeItem("CompositorNodeChannelMatte"),
@@ -318,7 +326,7 @@ compositor_node_categories = [
         NodeItem("CompositorNodeColorMatte"),
         NodeItem("CompositorNodeDoubleEdgeMask"),
         ]),
-    CompositorNodeCategory("CMP_DISTORT", "Distort", items = [
+    CompositorNodeCategory("CMP_DISTORT", "Distort", items=[
         NodeItem("CompositorNodeScale"),
         NodeItem("CompositorNodeLensdist"),
         NodeItem("CompositorNodeMovieDistortion"),
@@ -332,7 +340,7 @@ compositor_node_categories = [
         NodeItem("CompositorNodeStabilize"),
         ]),
     CompositorNodeCategory("CMP_GROUP", "Group", items=node_group_items),
-    CompositorNodeCategory("CMP_LAYOUT", "Layout", items = [
+    CompositorNodeCategory("CMP_LAYOUT", "Layout", items=[
         NodeItem("NodeFrame"),
         NodeItem("NodeReroute"),
         NodeItem("CompositorNodeSwitch"),
@@ -341,19 +349,19 @@ compositor_node_categories = [
 
 texture_node_categories = [
     # Texture Nodes
-    TextureNodeCategory("TEX_INPUT", "Input", items = [
+    TextureNodeCategory("TEX_INPUT", "Input", items=[
         NodeItem("TextureNodeCurveTime"),
         NodeItem("TextureNodeCoordinates"),
         NodeItem("TextureNodeTexture"),
         NodeItem("TextureNodeImage"),
         NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
         ]),
-    TextureNodeCategory("TEX_OUTPUT", "Output", items = [
+    TextureNodeCategory("TEX_OUTPUT", "Output", items=[
         NodeItem("TextureNodeOutput"),
         NodeItem("TextureNodeViewer"),
         NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
         ]),
-    TextureNodeCategory("TEX_OP_COLOR", "Color", items = [
+    TextureNodeCategory("TEX_OP_COLOR", "Color", items=[
         NodeItem("TextureNodeMixRGB"),
         NodeItem("TextureNodeCurveRGB"),
         NodeItem("TextureNodeInvert"),
@@ -361,11 +369,11 @@ texture_node_categories = [
         NodeItem("TextureNodeCompose"),
         NodeItem("TextureNodeDecompose"),
         ]),
-    TextureNodeCategory("TEX_PATTERN", "Pattern", items = [
+    TextureNodeCategory("TEX_PATTERN", "Pattern", items=[
         NodeItem("TextureNodeChecker"),
         NodeItem("TextureNodeBricks"),
         ]),
-    TextureNodeCategory("TEX_TEXTURE", "Textures", items = [
+    TextureNodeCategory("TEX_TEXTURE", "Textures", items=[
         NodeItem("TextureNodeTexNoise"),
         NodeItem("TextureNodeTexDistNoise"),
         NodeItem("TextureNodeTexClouds"),
@@ -377,20 +385,20 @@ texture_node_categories = [
         NodeItem("TextureNodeTexMusgrave"),
         NodeItem("TextureNodeTexStucci"),
         ]),
-    TextureNodeCategory("TEX_CONVERTOR", "Converter", items = [
+    TextureNodeCategory("TEX_CONVERTOR", "Converter", items=[
         NodeItem("TextureNodeMath"),
         NodeItem("TextureNodeValToRGB"),
         NodeItem("TextureNodeRGBToBW"),
         NodeItem("TextureNodeValToNor"),
         NodeItem("TextureNodeDistance"),
         ]),
-    TextureNodeCategory("TEX_DISTORT", "Distort", items = [
+    TextureNodeCategory("TEX_DISTORT", "Distort", items=[
         NodeItem("TextureNodeScale"),
         NodeItem("TextureNodeTranslate"),
         NodeItem("TextureNodeRotate"),
         ]),
     TextureNodeCategory("TEX_GROUP", "Group", items=node_group_items),
-    TextureNodeCategory("TEX_LAYOUT", "Layout", items = [
+    TextureNodeCategory("TEX_LAYOUT", "Layout", items=[
         NodeItem("NodeFrame"),
         NodeItem("NodeReroute"),
         ]),
@@ -398,15 +406,15 @@ texture_node_categories = [
 
 
 def register():
-    nodeitems_utils.register_node_categories("SHADER", shader_node_categories)
-    nodeitems_utils.register_node_categories("COMPOSITING", compositor_node_categories)
-    nodeitems_utils.register_node_categories("TEXTURE", texture_node_categories)
+    nodeitems_utils.register_node_categories('SHADER', shader_node_categories)
+    nodeitems_utils.register_node_categories('COMPOSITING', compositor_node_categories)
+    nodeitems_utils.register_node_categories('TEXTURE', texture_node_categories)
 
 
 def unregister():
-    nodeitems_utils.unregister_node_categories("SHADER")
-    nodeitems_utils.unregister_node_categories("COMPOSITING")
-    nodeitems_utils.unregister_node_categories("TEXTURE")
+    nodeitems_utils.unregister_node_categories('SHADER')
+    nodeitems_utils.unregister_node_categories('COMPOSITING')
+    nodeitems_utils.unregister_node_categories('TEXTURE')
 
 
 if __name__ == "__main__":
index bd2a9423649231deef1a6e155d4dacdbbf8354f9..fdb43f5467e22fc59fc66fcc40df7352533898b7 100644 (file)
@@ -615,10 +615,13 @@ void DM_interp_poly_data(struct DerivedMesh *source, struct DerivedMesh *dest,
 /* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
 void vDM_ColorBand_store(const struct ColorBand *coba, const char alert_color[4]);
 
+/* UNUSED */
+#if 0
 /** Simple function to get me->totvert amount of vertices/normals,
  * correctly deformed and subsurfered. Needed especially when vertexgroups are involved.
  * In use now by vertex/weight paint and particles */
 DMCoNo *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
+#endif
 
 /* */
 DerivedMesh *mesh_get_derived_final(struct Scene *scene, struct Object *ob,
index 339d13b06b2df6a073424806d6eb6f451999e3ce..7481a403dc882c1589a5dd8b742dd6a855dc2384 100644 (file)
@@ -138,18 +138,26 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v);
 
 /* update the hide flag for edges and polys from the corresponding
  * flag in verts */
-void BKE_mesh_flush_hidden_from_verts(const struct MVert *mvert,
-                                      const struct MLoop *mloop,
-                                      struct MEdge *medge, int totedge,
-                                      struct MPoly *mpoly, int totpoly);
+void BKE_mesh_flush_hidden_from_verts_ex(const struct MVert *mvert,
+                                         const struct MLoop *mloop,
+                                         struct MEdge *medge, const int totedge,
+                                         struct MPoly *mpoly, const int totpoly);
+void BKE_mesh_flush_hidden_from_verts(struct Mesh *me);
+
+void BKE_mesh_flush_hidden_from_polys_ex(struct MVert *mvert,
+                                         const struct MLoop *mloop,
+                                         struct MEdge *medge, int totedge,
+                                         const struct MPoly *mpoly, const int totpoly);
+void BKE_mesh_flush_hidden_from_polys(struct Mesh *me);
+
 
 void BKE_mesh_flush_select_from_polys_ex(struct MVert *mvert,       const int totvert,
-                                         struct MLoop *mloop,
+                                         const struct MLoop *mloop,
                                          struct MEdge *medge,       const int totedge,
                                          const struct MPoly *mpoly, const int totpoly);
 void BKE_mesh_flush_select_from_polys(struct Mesh *me);
 void BKE_mesh_flush_select_from_verts_ex(const struct MVert *mvert, const int totvert,
-                                         struct MLoop *mloop,
+                                         const struct MLoop *mloop,
                                          struct MEdge *medge,       const int totedge,
                                          struct MPoly *mpoly,       const int totpoly);
 void BKE_mesh_flush_select_from_verts(struct Mesh *me);
index 96ccc5be8e0c46e40f76e72d5a2b3e67444d38f4..aeb664b3c2f5f60b955836b9f68305b29d87e74f 100644 (file)
@@ -2432,6 +2432,8 @@ DerivedMesh *editbmesh_get_derived_base(Object *obedit, BMEditMesh *em)
        return getEditDerivedBMesh(em, obedit, NULL);
 }
 
+/* UNUSED */
+#if 0
 
 /* ********* For those who don't grasp derived stuff! (ton) :) *************** */
 
@@ -2488,6 +2490,8 @@ DMCoNo *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
        return vertexcosnos;
 }
 
+#endif
+
 /* ******************* GLSL ******************** */
 
 typedef struct {
index 35510fe64d5f2f385a04ff032f3f9f6c1f3250d7..9fea3d2e13f507d7dbfa8053844c80b3a4c05db8 100644 (file)
@@ -1724,8 +1724,11 @@ ListBase *object_duplilist_ex(Scene *sce, Object *ob, bool update, bool for_rend
        int persistent_id[MAX_DUPLI_RECUR] = {0};
        int flag = 0;
 
-       if (update)     flag |= DUPLILIST_DO_UPDATE;
-       if (for_render) flag |= DUPLILIST_FOR_RENDER;
+       /* don't allow BKE_object_handle_update for viewport during render, can crash */
+       if (update && !(G.is_rendering && !for_render))
+               flag |= DUPLILIST_DO_UPDATE;
+       if (for_render)
+               flag |= DUPLILIST_FOR_RENDER;
 
        duplilist->first = duplilist->last = NULL;
        object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, persistent_id, 0, 0, flag);
index c27343bf80a03926eb9d1addd878da4ddee9ff6b..872780bd50a724765c073111323e32d06f928a1a 100644 (file)
@@ -20,7 +20,7 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/blenkernel/intern/armature.c
+/** \file blender/blenkernel/intern/autoexec.c
  *  \ingroup bke
  *
  * Currently just checks if a blend file can be trusted to autoexec,
index 6a51dadd28e205f00d72b7483500638bd1a40f60..6699cbcff2d806ef01fc072bf3f936a28fcf125c 100644 (file)
@@ -235,7 +235,7 @@ static int findFileRecursive(char *filename_new,
 
                BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
 
-               if (stat(path, &status) != 0)
+               if (BLI_stat(path, &status) != 0)
                        continue;  /* cant stat, don't bother with this file, could print debug info here */
 
                if (S_ISREG(status.st_mode)) { /* is file */
index 73c722a4849cc92b60dc1ac36547a56fbb6c5fc2..7f6dc680a7468172e4150a2f3781c5e3e029fe7e 100644 (file)
@@ -2232,7 +2232,10 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals
        CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
        float (*face_nors)[3] = NULL;
 
-       if (dm->numVertData == 0) return;
+       if (dm->numVertData == 0) {
+               cddm->dm.dirty &= ~DM_DIRTY_NORMALS;
+               return;
+       }
 
        /* now we skip calculating vertex normals for referenced layer,
         * no need to duplicate verts.
index edeef26ed58c9b6a7cc938f610e704137034a249..b82e89d1af65f2fb24b2a34d0ed759acba64199a 100644 (file)
@@ -88,7 +88,7 @@ void defvert_copy_subset(MDeformVert *dvert_dst, const MDeformVert *dvert_src,
                          const bool *vgroup_subset, const int vgroup_tot)
 {
        int defgroup;
-       for (defgroup=0; defgroup < vgroup_tot; defgroup++) {
+       for (defgroup = 0; defgroup < vgroup_tot; defgroup++) {
                if (vgroup_subset[defgroup]) {
                        defvert_copy_index(dvert_dst, dvert_src, defgroup);
                }
index db1012456ef4f29ad47ea1f20aa4bca7acb13d96..02d1621e408b0fe547fe9de1e6c178e9fee99bb7 100644 (file)
@@ -148,12 +148,6 @@ PartDeflect *object_add_collision_fields(int type)
        return pd;
 }
 
-/* temporal struct, used for reading return of mesh_get_mapped_verts_nors() */
-
-typedef struct VeNoCo {
-       float co[3], no[3];
-} VeNoCo;
-
 /* ***************** PARTICLES ***************** */
 
 /* -------------------------- Effectors ------------------ */
index dfa5fcff94cdac48972390392e52c8cf58676f69..e141b9dbabe83cded1dbad094f179f9358a1e6c6 100644 (file)
@@ -289,6 +289,16 @@ void key_curve_position_weights(float t, float data[4], int type)
                data[2] = -0.5f        * t3  + 0.5f * t2   + 0.5f * t    + 0.16666666f;
                data[3] =  0.16666666f * t3;
        }
+       else if (type == KEY_CATMULL_ROM) {
+               t2 = t * t;
+               t3 = t2 * t;
+               fc = 0.5f;
+
+               data[0] = -fc          * t3  + 2.0f * fc          * t2 - fc * t;
+               data[1] =  (2.0f - fc) * t3  + (fc - 3.0f)        * t2 + 1.0f;
+               data[2] =  (fc - 2.0f) * t3  + (3.0f - 2.0f * fc) * t2 + fc * t;
+               data[3] =  fc          * t3  - fc * t2;
+       }
 }
 
 /* first derivative */
@@ -319,6 +329,15 @@ void key_curve_tangent_weights(float t, float data[4], int type)
                data[2] = -1.5f * t2  + t         + 0.5f;
                data[3] =  0.5f * t2;
        }
+       else if (type == KEY_CATMULL_ROM) {
+               t2 = t * t;
+               fc = 0.5f;
+
+               data[0] = -3.0f * fc          * t2  + 4.0f * fc * t                  - fc;
+               data[1] =  3.0f * (2.0f - fc) * t2  + 2.0f * (fc - 3.0f) * t;
+               data[2] =  3.0f * (fc - 2.0f) * t2  + 2.0f * (3.0f - 2.0f * fc) * t  + fc;
+               data[3] =  3.0f * fc          * t2  - 2.0f * fc * t;
+       }
 }
 
 /* second derivative */
@@ -346,6 +365,14 @@ void key_curve_normal_weights(float t, float data[4], int type)
                data[2] = -3.0f * t  + 1.0f;
                data[3] =  1.0f * t;
        }
+       else if (type == KEY_CATMULL_ROM) {
+               fc = 0.5f;
+
+               data[0] = -6.0f * fc          * t  + 4.0f * fc;
+               data[1] =  6.0f * (2.0f - fc) * t  + 2.0f * (fc - 3.0f);
+               data[2] =  6.0f * (fc - 2.0f) * t  + 2.0f * (3.0f - 2.0f * fc);
+               data[3] =  6.0f * fc          * t  - 2.0f * fc;
+       }
 }
 
 static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl)
index 140c4f55b055362cb050050b6f2a7b1ece3dfd67..afe1c0f24df952828e5d9fcff41a61dc44fc6842 100644 (file)
@@ -151,7 +151,7 @@ typedef struct process {        /* parameters, function, storage */
 
        /* what happens here? floats, I think. */
        /*  float (*function)(void);     */     /* implicit surface function */
-       float (*function)(struct process*, float, float, float);
+       float (*function)(struct process *, float, float, float);
        float size, delta;          /* cube size, normal delta */
        int bounds;                 /* cube range within lattice */
        CUBES *cubes;               /* active cubes */
@@ -2283,7 +2283,7 @@ void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase, bool for
 
        if (process.totelem == 0) return;
        if ((for_render == FALSE) && (mb->flag == MB_UPDATE_NEVER)) return;
-       if ((G.moving & (G_TRANSFORM_OBJ|G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_FAST) return;
+       if ((G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_FAST) return;
 
        process.thresh = mb->thresh;
 
@@ -2325,7 +2325,9 @@ void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase, bool for
        }
        else {
                width = mb->wiresize;
-               if ((G.moving & (G_TRANSFORM_OBJ|G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_HALFRES) width *= 2;
+               if ((G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_HALFRES) {
+                       width *= 2;
+               }
        }
        /* nr_cubes is just for safety, minimum is totsize */
        nr_cubes = (int)(0.5f + totsize / width);
index 2b59aa4a8bb41bb8c1a895751427915f37bdd7ac..92ba82a9ce2c0c81a664e9659636261be3eef3da 100644 (file)
@@ -2765,7 +2765,9 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
                        BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert_first);
 #ifdef USE_TESSFACE_CALCNORMAL
                        add_newell_cross_v3_v3v3(normal, sf_vert_last->co, sf_vert_first->co);
-                       normalize_v3(normal);
+                       if (UNLIKELY(normalize_v3(normal) == 0.0f)) {
+                               normal[2] = 1.0f;
+                       }
                        totfilltri = BLI_scanfill_calc_ex(&sf_ctx, 0, normal);
 #else
                        totfilltri = BLI_scanfill_calc(&sf_ctx, 0);
@@ -3437,10 +3439,10 @@ int BKE_mesh_edge_other_vert(const MEdge *e, int v)
 
 /* update the hide flag for edges and faces from the corresponding
  * flag in verts */
-void BKE_mesh_flush_hidden_from_verts(const MVert *mvert,
-                                      const MLoop *mloop,
-                                      MEdge *medge, int totedge,
-                                      MPoly *mpoly, int totpoly)
+void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert,
+                                         const MLoop *mloop,
+                                         MEdge *medge, const int totedge,
+                                         MPoly *mpoly, const int totpoly)
 {
        int i, j;
        
@@ -3464,12 +3466,59 @@ void BKE_mesh_flush_hidden_from_verts(const MVert *mvert,
                }
        }
 }
+void BKE_mesh_flush_hidden_from_verts(Mesh *me)
+{
+       BKE_mesh_flush_hidden_from_verts_ex(me->mvert, me->mloop,
+                                           me->medge, me->totedge,
+                                           me->mpoly, me->totpoly);
+}
+
+void BKE_mesh_flush_hidden_from_polys_ex(MVert *mvert,
+                                         const MLoop *mloop,
+                                         MEdge *medge, const int UNUSED(totedge),
+                                         const MPoly *mpoly, const int totpoly)
+{
+       const MPoly *mp;
+       int i;
+
+       i = totpoly;
+       for (mp = mpoly; i--; mp++) {
+               if (mp->flag & ME_HIDE) {
+                       const MLoop *ml;
+                       int j;
+                       j = mp->totloop;
+                       for (ml = &mloop[mp->loopstart]; j--; ml++) {
+                               mvert[ml->v].flag |= ME_HIDE;
+                               medge[ml->e].flag |= ME_HIDE;
+                       }
+               }
+       }
+
+       i = totpoly;
+       for (mp = mpoly; i--; mp++) {
+               if ((mp->flag & ME_HIDE) == 0) {
+                       const MLoop *ml;
+                       int j;
+                       j = mp->totloop;
+                       for (ml = &mloop[mp->loopstart]; j--; ml++) {
+                               mvert[ml->v].flag &= ~ME_HIDE;
+                               medge[ml->e].flag &= ~ME_HIDE;
+                       }
+               }
+       }
+}
+void BKE_mesh_flush_hidden_from_polys(Mesh *me)
+{
+       BKE_mesh_flush_hidden_from_polys_ex(me->mvert, me->mloop,
+                                           me->medge, me->totedge,
+                                           me->mpoly, me->totpoly);
+}
 
 /**
  * simple poly -> vert/edge selection.
  */
 void BKE_mesh_flush_select_from_polys_ex(MVert *mvert,       const int totvert,
-                                         MLoop *mloop,
+                                         const MLoop *mloop,
                                          MEdge *medge,       const int totedge,
                                          const MPoly *mpoly, const int totpoly)
 {
@@ -3493,7 +3542,7 @@ void BKE_mesh_flush_select_from_polys_ex(MVert *mvert,       const int totvert,
                /* assume if its selected its not hidden and none of its verts/edges are hidden
                 * (a common assumption)*/
                if (mp->flag & ME_FACE_SEL) {
-                       MLoop *ml;
+                       const MLoop *ml;
                        int j;
                        j = mp->totloop;
                        for (ml = &mloop[mp->loopstart]; j--; ml++) {
@@ -3512,7 +3561,7 @@ void BKE_mesh_flush_select_from_polys(Mesh *me)
 }
 
 void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(totvert),
-                                         MLoop *mloop,
+                                         const MLoop *mloop,
                                          MEdge *medge,       const int totedge,
                                          MPoly *mpoly,       const int totpoly)
 {
@@ -3538,7 +3587,7 @@ void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(to
        for (mp = mpoly; i--; mp++) {
                if ((mp->flag & ME_HIDE) == 0) {
                        int ok = TRUE;
-                       MLoop *ml;
+                       const MLoop *ml;
                        int j;
                        j = mp->totloop;
                        for (ml = &mloop[mp->loopstart]; j--; ml++) {
index af67ada776555b895716466880f64c0d9ea655a1..f97429d7e650be6bbe27beb93a6a8d076819cafc 100644 (file)
@@ -378,7 +378,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
        BLI_strncpy(name, filename, sizeof(name));
        BLI_path_abs(name, G.main->name);
        
-       if (stat(name, &st)) {
+       if (BLI_stat(name, &st)) {
                ret_val = PF_NOFILE;
        }
        else if (st.st_size != pf->size) {
index 9ae3c5cdfe153149b4ca00640857974752438f96..c073c716ec699f87c49e5817774840b2f6ccd3e9 100644 (file)
@@ -3889,7 +3889,7 @@ ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf
         * But need to keep an eye on this if the function will be
         * used in other cases.
         */
-       #pragma omp parallel for if(tmpibuf->y > 128)
+       #pragma omp parallel for if (tmpibuf->y > 128)
        for (j = 0; j < tmpibuf->y; j++) {
                int i;
                for (i = 0; i < tmpibuf->x; i++) {
index 0cbd4ee70b1f8789c6fe8b318d5e5ec0b6e56166..21197670640064f1d06fd60f9e18f4f23bb512d8 100644 (file)
@@ -115,7 +115,6 @@ void BLI_scanfill_end(ScanFillContext *sf_ctx);
 
 /* These callbacks are needed to make the lib finction properly */
 void BLI_setErrorCallBack(void (*f)(const char *));
-void BLI_setInterruptCallBack(int (*f)(void));
 
 #ifdef __cplusplus
 }
index d4a8b800f1710f776fca27d91437757274f5f29f..26fe0f21cd520d9ec4579d03e2b76ba5ad4bad14 100644 (file)
@@ -251,7 +251,7 @@ void *BLI_gzopen(const char *filename, const char *mode)
                        fclose(ufopen(filename, "a"));
 
                /* temporary #if until we update all libraries to 1.2.7
-                * for  correct wide char path handling */
+                * for correct wide char path handling */
 #if ZLIB_VERNUM >= 0x1270 && !defined(FREE_WINDOWS)
                UTF16_ENCODE(filename);
 
index cedec7d07b68fd3ce9a66c34d178e05605d51c2e..24497f8fb0603bda8f1864defd04bad507064085 100644 (file)
@@ -598,7 +598,7 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
 
        /* sort ring by arc length
         * using a rather bogus insertion sort
-        * butrings will never get too big to matter
+        * but rings will never get too big to matter
         * */
        for (i = 0; i < total; i++) {
                int j;
index bef4e5adaaaa6d82754b5e9f334dcd7a86702647..4af1307c521c5f14d78446ef3da569af20ca6dc6 100644 (file)
@@ -78,7 +78,7 @@ MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[
        F4TOCHAR4(srgb_f, srgb);
 }
 
-/* predivide versions to work on associated/pre-multipled alpha. if this should
+/* predivide versions to work on associated/pre-multiplied alpha. if this should
  * be done or not depends on the background the image will be composited over,
  * ideally you would never do color space conversion on an image with alpha
  * because it is ill defined */
index a4e7424e5ddaafa8b8d8fc8ef590a3e3c2efd364..ddf1c598a1c5d483b53be372ff407965bb9248e7 100644 (file)
@@ -3621,7 +3621,7 @@ static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float
 static __m128 sse_approx_acos(__m128 x)
 {
        /* needs a better approximation than taylor expansion of acos, since that
-        * gives big erros for near 1.0 values, sqrt(2 * x) * acos(1 - x) should work
+        * gives big errors for near 1.0 values, sqrt(2 * x) * acos(1 - x) should work
         * better, see http://www.tom.womack.net/projects/sse-fast-arctrig.html */
 
        return _mm_set_ps1(1.0f);
index 1f96c10e7121cb3aef0918c70ab2a74603c2f462..fe50c2abcc19577df502cb23123a518b8af19b81 100644 (file)
@@ -1222,6 +1222,9 @@ const char *BLI_get_folder(int folder_id, const char *subfolder)
                        if (get_path_local(path, "python", subfolder, ver)) break;
                        if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break;
                        return NULL;
+
+               default:
+                       BLI_assert(0);
        }
        
        return path;
@@ -1248,6 +1251,8 @@ const char *BLI_get_user_folder_notest(int folder_id, const char *subfolder)
                case BLENDER_USER_SCRIPTS:
                        get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver);
                        break;
+               default:
+                       BLI_assert(0);
        }
        if ('\0' == path[0]) {
                return NULL;
index b6a86b8618818dca8ecc85d948396a24f41edd6b..873ce302b9cf0167489fbd337cf8850c807b2c71 100644 (file)
@@ -45,7 +45,6 @@
 
 /* callbacks for errors and interrupts and some goo */
 static void (*BLI_localErrorCallBack)(const char *) = NULL;
-static int (*BLI_localInterruptCallBack)(void) = NULL;
 
 /**
  * Set a function taking a (char *) as argument to flag errors. If the
@@ -58,19 +57,6 @@ void BLI_setErrorCallBack(void (*f)(const char *))
        BLI_localErrorCallBack = f;
 }
 
-/**
- * Set a function to be able to interrupt the execution of processing
- * in this module. If the function returns true, the execution will
- * terminate gracefully. If the callback is not set, interruption is
- * not possible.
- * \param f The function to use as callback
- * \attention used in creator.c
- */
-void BLI_setInterruptCallBack(int (*f)(void))
-{
-       BLI_localInterruptCallBack = f;
-}
-
 /* just flush the error to /dev/null if the error handler is missing */
 void callLocalErrorCallBack(const char *msg)
 {
index d6bc6b91841dba2e9d872b7f01d66b038fd294fd..917b1e5d054eff0749418c863421ad1f99978f5f 100644 (file)
@@ -9332,7 +9332,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        }
 
        if (main->versionfile < 267) {
-               //if(!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
+               //if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
                Brush *brush;
 
                for (brush = main->brush.first; brush; brush = brush->id.next) {
index dc3a223ae5d1a48b728a4fbf151e3d6de412d7cb..8b5b95c5caec7c296b35f61aec2c8aa418ad762d 100644 (file)
@@ -520,7 +520,7 @@ const float *BM_edgeloop_center_get(struct BMEdgeLoopStore *el_store)
 #define NODE_AS_CO(n) ((BMVert *)((LinkData *)n)->data)->co
 
 /**
- * edges are assined to one vert -> the next.
+ * edges are assigned to one vert -> the next.
  */
 void BM_edgeloop_edges_get(struct BMEdgeLoopStore *el_store, BMEdge **e_arr)
 {
@@ -612,7 +612,7 @@ bool BM_edgeloop_calc_normal(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store)
 }
 
 /**
- * For open loops that are stright lines,
+ * For open loops that are straight lines,
  * calculating the normal as if it were a polygon is meaningless.
  *
  * Instead use an alignment vector and calculate the normal based on that.
index e4d7a88dc83c0c0e7a6ad16db3ec75347a353554..b5535b59321aaac512f251e5126feefe57556b6c 100644 (file)
@@ -154,7 +154,7 @@ typedef void *(*BMIter__step_cb) (void *);
 
 /* Iterator Structure */
 /* note: some of these vars are not used,
- * so they have beem commented to save stack space since this struct is used all over */
+ * so they have been commented to save stack space since this struct is used all over */
 typedef struct BMIter {
        /* keep union first */
        union {
index 9d330075a3ae7d79c6cc7fe9bbba7e03e3d97c0f..7c4af8eaa3b745ed00782c5f96dac451904b53ce 100644 (file)
 #include "bmesh.h"
 #include "intern/bmesh_private.h" /* for element checking */
 
+/**
+ * Currently this is only used for Python scripts
+ * which may fail to keep matching UV/TexFace layers.
+ *
+ * \note This should only perform any changes in exceptional cases,
+ * if we need this to be faster we could inline #BM_data_layer_add and only
+ * call #update_data_blocks once at the end.
+ */
+void BM_mesh_cd_validate(BMesh *bm)
+{
+       int totlayer_mtex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       int totlayer_uv = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
+
+       if (LIKELY(totlayer_mtex == totlayer_uv)) {
+               /* pass */
+       }
+       else if (totlayer_mtex < totlayer_uv) {
+               const int uv_index_first = CustomData_get_layer_index(&bm->ldata, CD_MLOOPUV);
+               do {
+                       const char *from_name =  bm->ldata.layers[uv_index_first + totlayer_mtex].name;
+                       BM_data_layer_add_named(bm, &bm->pdata, CD_MTEXPOLY, from_name);
+                       CustomData_set_layer_unique_name(&bm->pdata, totlayer_mtex);
+               } while (totlayer_uv != ++totlayer_mtex);
+       }
+       else if (totlayer_uv < totlayer_mtex) {
+               const int mtex_index_first = CustomData_get_layer_index(&bm->pdata, CD_MTEXPOLY);
+               do {
+                       const char *from_name = bm->pdata.layers[mtex_index_first + totlayer_uv].name;
+                       BM_data_layer_add_named(bm, &bm->ldata, CD_MLOOPUV, from_name);
+                       CustomData_set_layer_unique_name(&bm->ldata, totlayer_uv);
+               } while (totlayer_mtex != ++totlayer_uv);
+       }
+
+       BLI_assert(totlayer_mtex == totlayer_uv);
+}
+
 void BM_mesh_cd_flag_ensure(BMesh *bm, Mesh *mesh, const char cd_flag)
 {
        const char cd_flag_all = BM_mesh_cd_flag_from_bmesh(bm) | cd_flag;
index 754ae8bcad40689643b00c9cd76252bcc0624af7..ab9d7a0ccf3ceff3a6ad0996dfa6c85b4c634840 100644 (file)
@@ -34,6 +34,7 @@
 
 struct Mesh;
 
+void BM_mesh_cd_validate(BMesh *bm);
 void BM_mesh_cd_flag_ensure(BMesh *bm, struct Mesh *mesh, const char cd_flag);
 void BM_mesh_cd_flag_apply(BMesh *bm, const char cd_flag);
 char BM_mesh_cd_flag_from_bmesh(BMesh *bm);
index 3d0ea4e9aed0c1ad45e4f9c5d35099b60a874e1d..88186df89fb7c2a298678951d708b5033fa5f936 100644 (file)
@@ -95,13 +95,14 @@ static void calc_poly_normal(float normal[3], float verts[][3], int nverts)
  *
  * Same as #calc_poly_normal but operates directly on a bmesh face.
  */
-static void bm_face_calc_poly_normal(BMFace *f)
+static void bm_face_calc_poly_normal(BMFace *f, float n[3])
 {
        BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
        BMLoop *l_iter  = l_first;
        float const *v_prev = l_first->prev->v->co;
        float const *v_curr = l_first->v->co;
-       float n[3] = {0.0f};
+
+       zero_v3(n);
 
        /* Newell's Method */
        do {
@@ -113,8 +114,8 @@ static void bm_face_calc_poly_normal(BMFace *f)
 
        } while (l_iter != l_first);
 
-       if (UNLIKELY(normalize_v3_v3(f->no, n) == 0.0f)) {
-               f->no[2] = 1.0f; /* other axis set to 0.0 */
+       if (UNLIKELY(normalize_v3(n) == 0.0f)) {
+               n[2] = 1.0f;
        }
 }
 
@@ -458,20 +459,20 @@ void calc_poly_plane(float (*verts)[3], const int nverts)
  * the list that bridges a concave region of the face or intersects
  * any of the faces's edges.
  */
-static void scale_edge_v3f(float v1[3], float v2[3], const float fac)
+static void scale_edge_v2f(float v1[2], float v2[2], const float fac)
 {
-       float mid[3];
+       float mid[2];
 
-       mid_v3_v3v3(mid, v1, v2);
+       mid_v2_v2v2(mid, v1, v2);
 
-       sub_v3_v3v3(v1, v1, mid);
-       sub_v3_v3v3(v2, v2, mid);
+       sub_v2_v2v2(v1, v1, mid);
+       sub_v2_v2v2(v2, v2, mid);
 
-       mul_v3_fl(v1, fac);
-       mul_v3_fl(v2, fac);
+       mul_v2_fl(v1, fac);
+       mul_v2_fl(v2, fac);
 
-       add_v3_v3v3(v1, v1, mid);
-       add_v3_v3v3(v2, v2, mid);
+       add_v2_v2v2(v1, v1, mid);
+       add_v2_v2v2(v2, v2, mid);
 }
 
 /**
@@ -563,7 +564,7 @@ void BM_vert_normal_update_all(BMVert *v)
  * is passed in as well.
  */
 
-void BM_face_normal_update(BMFace *f)
+void BM_face_calc_normal(BMFace *f, float r_no[3])
 {
        BMLoop *l;
 
@@ -576,7 +577,7 @@ void BM_face_normal_update(BMFace *f)
                        const float *co3 = (l = l->next)->v->co;
                        const float *co4 = (l->next)->v->co;
 
-                       normal_quad_v3(f->no, co1, co2, co3, co4);
+                       normal_quad_v3(r_no, co1, co2, co3, co4);
                        break;
                }
                case 3:
@@ -585,16 +586,21 @@ void BM_face_normal_update(BMFace *f)
                        const float *co2 = (l = l->next)->v->co;
                        const float *co3 = (l->next)->v->co;
 
-                       normal_tri_v3(f->no, co1, co2, co3);
+                       normal_tri_v3(r_no, co1, co2, co3);
                        break;
                }
                default:
                {
-                       bm_face_calc_poly_normal(f);
+                       bm_face_calc_poly_normal(f, r_no);
                        break;
                }
        }
 }
+void BM_face_normal_update(BMFace *f)
+{
+       BM_face_calc_normal(f, f->no);
+}
+
 /* exact same as 'bmesh_face_normal_update' but accepts vertex coords */
 void BM_face_normal_update_vcos(BMesh *bm, BMFace *f, float no[3],
                                 float const (*vertexCos)[3])
@@ -1025,64 +1031,47 @@ void BM_face_triangulate(BMesh *bm, BMFace *f,
  * intersecting splits, only the first of the set of intersecting
  * splits survives
  */
-void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len)
+void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len)
 {
-       BMIter iter;
+       const int len2 = len * 2;
        BMLoop *l;
-       float v1[3], v2[3], v3[3] /*, v4[3 */, no[3], mid[3], *p1, *p2, *p3, *p4;
-       float out[3] = {-FLT_MAX, -FLT_MAX, 0.0f};
-       float (*projverts)[3] = BLI_array_alloca(projverts, f->len);
-       float (*edgeverts)[3] = BLI_array_alloca(edgeverts, len * 2);
+       float v1[2], v2[2], v3[2] /*, v4[3 */, no[3], mid[2], *p1, *p2, *p3, *p4;
+       float out[2] = {-FLT_MAX, -FLT_MAX};
+       float axis_mat[3][3];
+       float (*projverts)[2] = BLI_array_alloca(projverts, f->len);
+       float (*edgeverts)[2] = BLI_array_alloca(edgeverts, len2);
        float fac1 = 1.0000001f, fac2 = 0.9f; //9999f; //0.999f;
        int i, j, a = 0, clen;
-       
-       i = 0;
-       l = BM_iter_new(&iter, bm, BM_LOOPS_OF_FACE, f);
-       for ( ; l; l = BM_iter_step(&iter)) {
-               BM_elem_index_set(l, i); /* set_loop */
-               copy_v3_v3(projverts[i], l->v->co);
-               i++;
-       }
-       
-       for (i = 0; i < len; i++) {
-               copy_v3_v3(v1, loops[i][0]->v->co);
-               copy_v3_v3(v2, loops[i][1]->v->co);
 
-               scale_edge_v3f(v1, v2, fac2);
-               
-               copy_v3_v3(edgeverts[a], v1);
-               a++;
-               copy_v3_v3(edgeverts[a], v2);
-               a++;
-       }
-       
-       calc_poly_normal(no, projverts, f->len);
-       poly_rotate_plane(no, projverts, f->len);
-       poly_rotate_plane(no, edgeverts, len * 2);
+       /* TODO, the face normal may already be correct */
+       BM_face_calc_normal(f, no);
+
+       axis_dominant_v3_to_m3(axis_mat, no);
 
        for (i = 0, l = BM_FACE_FIRST_LOOP(f); i < f->len; i++, l = l->next) {
-               p1 = projverts[i];
-               out[0] = max_ff(out[0], p1[0]);
-               out[1] = max_ff(out[1], p1[1]);
-               /* out[2] = 0.0f; */ /* keep at zero */
+               BM_elem_index_set(l, i); /* set_loop */
+               mul_v2_m3v3(projverts[i], axis_mat, l->v->co);
 
-               p1[2] = 0.0f;
+               out[0] = max_ff(out[0], projverts[i][0]);
+               out[1] = max_ff(out[1], projverts[i][1]);
        }
        
        /* ensure we are well outside the face bounds (value is arbitrary) */
        add_v2_fl(out, 1.0f);
 
        for (i = 0; i < len; i++) {
-               edgeverts[i * 2][2] = 0.0f;
-               edgeverts[i * 2 + 1][2] = 0.0f;
+               copy_v2_v2(edgeverts[a + 0], projverts[BM_elem_index_get(loops[i][0])]);
+               copy_v2_v2(edgeverts[a + 1], projverts[BM_elem_index_get(loops[i][1])]);
+               scale_edge_v2f(edgeverts[a + 0], edgeverts[a + 1], fac2);
+               a += 2;
        }
 
        /* do convexity test */
        for (i = 0; i < len; i++) {
-               copy_v3_v3(v2, edgeverts[i * 2]);
-               copy_v3_v3(v3, edgeverts[i * 2 + 1]);
+               copy_v2_v2(v2, edgeverts[i * 2 + 0]);
+               copy_v2_v2(v3, edgeverts[i * 2 + 1]);
 
-               mid_v3_v3v3(mid, v2, v3);
+               mid_v2_v2v2(mid, v2, v3);
                
                clen = 0;
                for (j = 0; j < f->len; j++) {
@@ -1090,10 +1079,10 @@ void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len)
                        p2 = projverts[(j + 1) % f->len];
                        
 #if 0
-                       copy_v3_v3(v1, p1);
-                       copy_v3_v3(v2, p2);
+                       copy_v2_v2(v1, p1);
+                       copy_v2_v2(v2, p2);
 
-                       scale_edge_v3f(v1, v2, fac1);
+                       scale_edge_v2f(v1, v2, fac1);
                        if (line_crosses_v2f(v1, v2, mid, out)) {
                                clen++;
                        }
@@ -1114,10 +1103,10 @@ void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len)
                p1 = projverts[i];
                p2 = projverts[(i + 1) % f->len];
                
-               copy_v3_v3(v1, p1);
-               copy_v3_v3(v2, p2);
+               copy_v2_v2(v1, p1);
+               copy_v2_v2(v2, p2);
 
-               scale_edge_v3f(v1, v2, fac1);
+               scale_edge_v2f(v1, v2, fac1);
 
                for (j = 0; j < len; j++) {
                        if (!loops[j][0]) {
@@ -1141,10 +1130,10 @@ void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len)
                                p3 = edgeverts[j * 2];
                                p4 = edgeverts[j * 2 + 1];
 
-                               copy_v3_v3(v1, p1);
-                               copy_v3_v3(v2, p2);
+                               copy_v2_v2(v1, p1);
+                               copy_v2_v2(v2, p2);
 
-                               scale_edge_v3f(v1, v2, fac1);
+                               scale_edge_v2f(v1, v2, fac1);
 
                                if (line_crosses_v2f(v1, v2, p3, p4)) {
                                        loops[i][0] = NULL;
index 428a98e776c578377d81bd54778af11a09212028..2f6b54b91d307425f6b19b3d916645489b32e3cf 100644 (file)
@@ -33,6 +33,7 @@ int   BM_face_calc_tessellation(BMFace *f, BMLoop **r_loops, int (*r_index)[3])
        __attribute__((nonnull))
 #endif
 ;
+void  BM_face_calc_normal(BMFace *f, float r_no[3]);
 float BM_face_calc_area(BMFace *f);
 float BM_face_calc_perimeter(BMFace *f);
 void  BM_face_calc_plane(BMFace *f, float r_plane[3]);
@@ -55,7 +56,7 @@ bool  BM_face_point_inside_test(BMFace *f, const float co[3]);
 void  BM_face_triangulate(BMesh *bm, BMFace *f, BMFace **newfaces,
                           const bool use_beauty, const bool use_tag);
 
-void  BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len);
+void  BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len);
 
 void BM_face_as_array_vert_tri(BMFace *f, BMVert *r_verts[3]);
 void BM_face_as_array_vert_quad(BMFace *f, BMVert *r_verts[4]);
index 79e097a7a7c583993c6be98132835d6113bc59de..04edec01a5c3c05092fb91b13ff75a3fa190ef05 100644 (file)
@@ -40,7 +40,7 @@
  * - joeedh -
  * design notes:
  *
- * original desing: walkers directly emulation recursive functions.
+ * original design: walkers directly emulation recursive functions.
  * functions save their state onto a worklist, and also add new states
  * to implement recursive or looping behavior.  generally only one
  * state push per call with a specific state is desired.
index f1c400574f51b9c8fdbd7e999ade6b92a4a1b1ad..2c0bc7f95d9bd2f44a44edbcd0dbac3bf111d3b3 100644 (file)
 /** \file blender/bmesh/operators/bmo_beautify.c
  *  \ingroup bmesh
  *
- * Beautify the mesh by rotating edes between triangles
+ * Beautify the mesh by rotating edges between triangles
  * to more attractive positions until no more rotations can be made.
  *
- * In princible this is very simple however there is the possability of
+ * In principle this is very simple however there is the possibility of
  * going into an eternal loop where edges keep rotating.
  * To avoid this - each edge stores a hash of it previous
  * states so as not to rotate back.
index 116fe46ee53b262d8015c420c0d55bf8f52eeb98..a517b7af5021844810c63f4b1d5a97d5c96e88cd 100644 (file)
@@ -363,7 +363,7 @@ static void bridge_loop_pair(BMesh *bm,
                int i;
 
                BMOperator op_sub;
-               /* when we have to bridge betweeen different sized edge-loops,
+               /* when we have to bridge between different sized edge-loops,
                 * be clever and post-process for best results */
 
 
index a6b0d9c522b0a26334460ddf862a8788584557ce..50588ad70a921659ee7a3a38fd7f4d1444cb9e4a 100644 (file)
@@ -83,7 +83,7 @@ static int bm_face_connect_verts(BMesh *bm, BMFace *f)
                l_pair[1] = loops_split[0][0];
        }
 
-       BM_face_legal_splits(bm, f, loops_split, STACK_SIZE(loops_split));
+       BM_face_legal_splits(f, loops_split, STACK_SIZE(loops_split));
 
        for (i = 0; i < STACK_SIZE(loops_split); i++) {
                BMVert **v_pair;
index 2d78a02f7097dcfaa4ad38450aa42201014daa83..e41fbd69616eeed86153544632d2bc5d0d411696 100644 (file)
@@ -23,7 +23,7 @@
 /** \file blender/bmesh/operators/bmo_dupe.c
  *  \ingroup bmesh
  *
- * Duplicate, Split, Spint operators.
+ * Duplicate, Split, Split operators.
  */
 
 #include "MEM_guardedalloc.h"
index cd35ea679149afc4ecba4c636a108e3d8ae187e4..f1bf3179cd6aca0a4a2d82dd806cd31e278a9fb7 100644 (file)
@@ -92,12 +92,11 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
                BMFace *f;
                BMLoop *l;
                MLoopUV *luv;
-               int totlayer;
+               const int totlayer = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
                BMIter liter;
 
                BMO_ITER (f, &siter, dupeop.slots_out, "geom.out", BM_FACE) {
                        BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
-                               totlayer = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
                                for (i = 0; i < totlayer; i++) {
                                        luv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i);
                                        if (mirror_u)
index 7105210da046bbd26a5d248daa3e1146eb9c60c2..03084ebb1b66c34cc7cceded3381b1fb57062803 100644 (file)
@@ -73,7 +73,7 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
                float f_center[3];
                BMVert *v_center = NULL;
                BMLoop *l_iter, *l_first;
-               /* only interpolate the centeral loop from the face once,
+               /* only interpolate the central loop from the face once,
                 * then copy to all others in the fan */
                BMLoop *l_center_example;
 
index 96771e002912d7de10145b7b9977aa968339b3d6..6b55d5ea87702f29805125378f0fd703ed3b07cd 100644 (file)
@@ -1112,7 +1112,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
                         * - concave corner of an ngon.
                         * - 2 edges being used in 2+ ngons.
                         */
-//                     BM_face_legal_splits(bm, face, loops_split, BLI_array_count(loops_split));
+//                     BM_face_legal_splits(face, loops_split, BLI_array_count(loops_split));
 
                        for (j = 0; j < BLI_array_count(loops_split); j++) {
                                if (loops_split[j][0]) {
index ba8c5432a6883af9370030c4a0c9bcfc15f2482b..fc2e1bbaf3edd93477fd9e3d3bd2139c1d409b80 100644 (file)
@@ -80,6 +80,7 @@ static void bm_vert_boundary_tangent(BMVert *v, float r_no[3], float r_no_face[3
        }
 
        if (e_a && e_b) {
+               /* note, with an incorrectly flushed selection this can crash */
                l_a = bm_edge_tag_faceloop(e_a);
                l_b = bm_edge_tag_faceloop(e_b);
 
index 6b5e18ceb61529aedbc27b3b369116805e064026..a2cbb0fe44c294594c157cb1df9d59c8d5cd387f 100644 (file)
@@ -223,7 +223,7 @@ static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv)
        return BLI_ghash_lookup(bp->vert_hash, bmv);
 }
 
-/* Return a good respresentative face (for materials, etc.) for faces
+/* Return a good representative face (for materials, etc.) for faces
  * created around/near BoundVert v */
 static BMFace *boundvert_rep_face(BoundVert *v)
 {
@@ -531,7 +531,7 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f)
  * Also find vd, which is in direction normal to parallelogram and 1 unit away
  * from the origin.
  * The quarter circle in first quadrant of unit square will be mapped to the
- * quadrant of a sheared ellipse in the parallelgram, using a matrix.
+ * quadrant of a sheared ellipse in the parallelogram, using a matrix.
  * The matrix mat is calculated to map:
  *    (0,1,0) -> va
  *    (1,1,0) -> vmid
index f47abc8891cd02de37a90e438dbb00a643e108bc..d3ffc3485392244970d7c75dda2339a076f5cac1 100644 (file)
@@ -116,7 +116,7 @@ static void bm_decim_build_quadrics(BMesh *bm, Quadric *vquadrics)
 static void bm_decim_calc_target_co(BMEdge *e, float optimize_co[3],
                                     const Quadric *vquadrics)
 {
-       /* compute an edge contration target for edge 'e'
+       /* compute an edge contraction target for edge 'e'
         * this is computed by summing it's vertices quadrics and
         * optimizing the result. */
        Quadric q;
@@ -682,7 +682,7 @@ static bool bm_edge_collapse_is_degenerate_topology(BMEdge *e_first)
 
 /**
  * special, highly limited edge collapse function
- * intended for speed over flexibiliy.
+ * intended for speed over flexibility.
  * can only collapse edges connected to (1, 2) tris.
  *
  * Important - dont add vert/edge/face data on collapsing!
index c48e83686b5090d9a4d1b290e8b361e52904bbf7..0667d560615e63ee08a0fb5f9835abe861c55e18 100644 (file)
@@ -79,7 +79,7 @@ static bool bm_vert_dissolve_fan(BMesh *bm, BMVert *v)
 {
        /* collapse under 2 conditions.
         * - vert connects to 4 manifold edges (and 4 faces).
-        * - vert connecrs to 1 manifold edge, 2 boundary edges (and 2 faces).
+        * - vert connects to 1 manifold edge, 2 boundary edges (and 2 faces).
         *
         * This covers boundary verts of a quad grid and center verts.
         * note that surrounding faces dont have to be quads.
index 19a49c4344d65d90da255d99314b8876645a5a6c..bcbcdd42752b2819960f4cdb29bedfc222e3df0a 100644 (file)
@@ -924,7 +924,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
        bPoseChannel *parchan = NULL;
        bPoseChannel *pchan = NULL;
 
-       if (ob->type == OB_ARMATURE ) {
+       if (ob->type == OB_ARMATURE && bone) {
                bPose *pose = ob->pose;
                pchan = BKE_pose_channel_find_name(pose, bone->name);
                if (!pchan)
index ae65cc9dbbe66de28c0b5ef30646a762202ecc8b..3327d4a07e94d058ab0b6c39ac658a336254fe44 100644 (file)
@@ -47,6 +47,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_bitmap.h"
 #include "BLI_math.h"
 #include "BLI_dynstr.h"
 #include "BLI_rand.h"
@@ -5143,7 +5144,6 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
        BPoint *bp, *tempbp;
        int a;
        short sel = 0;
-       short *selbpoints;
        
        /* note that NURBS surface is a special case because we mimic */
        /* the behavior of "select more" of mesh tools.       */
@@ -5151,11 +5151,12 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
        /* may not be optimal always (example: end of NURBS sphere)   */
        if (obedit->type == OB_SURF) {
                for (nu = editnurb->first; nu; nu = nu->next) {
+                       BLI_bitmap selbpoints;
                        a = nu->pntsu * nu->pntsv;
                        bp = nu->bp;
-                       selbpoints = MEM_callocN(sizeof(short) * a - nu->pntsu, "selectlist");
+                       selbpoints = BLI_BITMAP_NEW(a, "selectlist");
                        while (a > 0) {
-                               if ((selbpoints[a] != 1) && (bp->hide == 0) && (bp->f1 & SELECT)) {
+                               if ((!BLI_BITMAP_GET(selbpoints, a)) && (bp->hide == 0) && (bp->f1 & SELECT)) {
                                        /* upper control point */
                                        if (a % nu->pntsu != 0) {
                                                tempbp = bp - 1;
@@ -5168,7 +5169,7 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
                                                tempbp = bp + nu->pntsu;
                                                if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE);
                                                /* make sure selected bpoint is discarded */
-                                               if (sel == 1) selbpoints[a - nu->pntsu] = 1;
+                                               if (sel == 1) BLI_BITMAP_SET(selbpoints, a - nu->pntsu);
                                        }
                                        
                                        /* right control point */
@@ -5233,13 +5234,13 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
        BezTriple *bezt;
        int a;
        short sel = 0, lastsel = false;
-       short *selbpoints;
        
        if (obedit->type == OB_SURF) {
                for (nu = editnurb->first; nu; nu = nu->next) {
+                       BLI_bitmap selbpoints;
                        a = nu->pntsu * nu->pntsv;
                        bp = nu->bp;
-                       selbpoints = MEM_callocN(sizeof(short) * a, "selectlist");
+                       selbpoints = BLI_BITMAP_NEW(a, "selectlist");
                        while (a--) {
                                if ((bp->hide == 0) && (bp->f1 & SELECT)) {
                                        sel = 0;
@@ -5251,7 +5252,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
                                        }
                                        else {
                                                bp--;
-                                               if ((selbpoints[a + 1] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
+                                               if (BLI_BITMAP_GET(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
                                                bp++;
                                        }
                                        
@@ -5269,7 +5270,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
                                        }
                                        else {
                                                bp -= nu->pntsu;
-                                               if ((selbpoints[a + nu->pntsu] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
+                                               if (BLI_BITMAP_GET(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
                                                bp += nu->pntsu;
                                        }
 
@@ -5284,7 +5285,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
 
                                        if (sel != 4) {
                                                select_bpoint(bp, DESELECT, 1, VISIBLE); 
-                                               selbpoints[a] = 1;
+                                               BLI_BITMAP_SET(selbpoints, a);
                                        }
                                }
                                else {
index f990afcc044d31ffe41f1dc5515ed771d6e590a2..5b2cc49d1068614338c4f57ac611bec9da7152fe 100644 (file)
@@ -299,7 +299,7 @@ static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op))
        Object *obedit = CTX_data_edit_object(C);
        const char *p, *p2;
        int i;
-       static const char *lastlorem;
+       static const char *lastlorem = NULL;
        
        if (lastlorem)
                p = lastlorem;
index 7823be3df6d43acec2ed947f8326d85e5006e2df..52f5101f58a5d808fad53a077338b31b8125981e 100644 (file)
@@ -653,5 +653,5 @@ const char ED_lorem[] = {
 32, 115, 101, 100,  32, 116, 117, 114, 112, 105, 115,  32, 117, 116,  32, 100, 111, 108, 111, 114,  32, 112, 108,  97,  99, 101, 114,  97, 116,  32, 100, 105,
 103, 110, 105, 115, 115, 105, 109,  46,  32,  81, 117, 105, 115, 113, 117, 101,  32, 113, 117, 105, 115,  32, 108, 101, 111,  46,  32,  67, 114,  97, 115,  32,
 117, 108, 116, 114, 105,  99, 101, 115,  46,  32,  77,  97, 101,  99, 101, 110,  97, 115,  32, 104, 101, 110, 100, 114, 101, 114, 105, 116,  32,  97, 117,  99,
-116, 111, 114,  32, 116, 111, 114, 116, 111, 114,  46,  32,  69, 116, 105,  97, 109,  32, 115, 105, 116,  32,  97, 109, 101, 116,  32,  97, 114,  99, 117,  46
-};
+116, 111, 114,  32, 116, 111, 114, 116, 111, 114,  46,  32,  69, 116, 105,  97, 109,  32, 115, 105, 116,  32,  97, 109, 101, 116,  32,  97, 114,  99, 117,  46,
+0};
index 86e51b201d9dd79390655b93c7af0a348889c843..b997d0ef6a0e4e9a6ac9e2500b2f6f0b9bdb9f2c 100644 (file)
@@ -95,84 +95,88 @@ typedef struct uiLayout uiLayout;
 #define UI_EMBOSST      3   /* Table */
 
 /* uiBlock->direction */
-#define UI_DIRECTION    (UI_TOP | UI_DOWN | UI_LEFT | UI_RIGHT)
-#define UI_TOP      1
-#define UI_DOWN     2
-#define UI_LEFT     4
-#define UI_RIGHT    8
-
-#define UI_CENTER       16
-#define UI_SHIFT_FLIPPED    32
-
+#define UI_DIRECTION       (UI_TOP | UI_DOWN | UI_LEFT | UI_RIGHT)
+#define UI_TOP             (1 << 0)
+#define UI_DOWN            (1 << 1)
+#define UI_LEFT            (1 << 2)
+#define UI_RIGHT           (1 << 3)
+#define UI_CENTER          (1 << 4)
+#define UI_SHIFT_FLIPPED   (1 << 5)
+
+#if 0
 /* uiBlock->autofill (not yet used) */
-// #define UI_BLOCK_COLLUMNS   1
-// #define UI_BLOCK_ROWS               2
+#define UI_BLOCK_COLLUMNS  1
+#define UI_BLOCK_ROWS      2
+#endif
 
 /* uiBlock->flag (controls) */
-#define UI_BLOCK_LOOP           1
-#define UI_BLOCK_REDRAW         2
-#define UI_BLOCK_SEARCH_MENU    4
-#define UI_BLOCK_NUMSELECT      8
-#define UI_BLOCK_NO_WIN_CLIP    16      /* don't apply window clipping */ /* was UI_BLOCK_ENTER_OK */
-#define UI_BLOCK_CLIPBOTTOM     32
-#define UI_BLOCK_CLIPTOP        64
-#define UI_BLOCK_MOVEMOUSE_QUIT 128
-#define UI_BLOCK_KEEP_OPEN      256
-#define UI_BLOCK_POPUP          512
-#define UI_BLOCK_OUT_1          1024
-#define UI_BLOCK_NO_FLIP        2048
-#define UI_BLOCK_POPUP_MEMORY   4096
-#define UI_BLOCK_CLIP_EVENTS    8192    /* stop handling mouse events */
+#define UI_BLOCK_LOOP           (1 << 0)
+#define UI_BLOCK_REDRAW         (1 << 1)
+#define UI_BLOCK_SEARCH_MENU    (1 << 2)
+#define UI_BLOCK_NUMSELECT      (1 << 3)
+#define UI_BLOCK_NO_WIN_CLIP    (1 << 4)   /* don't apply window clipping */ /* was UI_BLOCK_ENTER_OK */
+#define UI_BLOCK_CLIPBOTTOM     (1 << 5)
+#define UI_BLOCK_CLIPTOP        (1 << 6)
+#define UI_BLOCK_MOVEMOUSE_QUIT (1 << 7)
+#define UI_BLOCK_KEEP_OPEN      (1 << 8)
+#define UI_BLOCK_POPUP          (1 << 9)
+#define UI_BLOCK_OUT_1          (1 << 10)
+#define UI_BLOCK_NO_FLIP        (1 << 11)
+#define UI_BLOCK_POPUP_MEMORY   (1 << 12)
+#define UI_BLOCK_CLIP_EVENTS    (1 << 13)  /* stop handling mouse events */
+
+/* XXX This comment is no more valid! Maybe it is now bits 14-17? */
+/* block->flag bits 12-15 are identical to but->flag bits */
 
-/* uiPopupBlockHandle->menuretval */
-#define UI_RETURN_CANCEL     1       /* cancel all menus cascading */
-#define UI_RETURN_OK         2       /* choice made */
-#define UI_RETURN_OUT        4       /* left the menu */
-#define UI_RETURN_OUT_PARENT 8       /* let the parent handle this event */
-#define UI_RETURN_UPDATE     16      /* update the button that opened */
-#define UI_RETURN_POPUP_OK   32      /* popup is ok to be handled */
+#define UI_BLOCK_LIST_ITEM   (1 << 19)
 
-/* block->flag bits 12-15 are identical to but->flag bits */
+/* uiPopupBlockHandle->menuretval */
+#define UI_RETURN_CANCEL     (1 << 0)   /* cancel all menus cascading */
+#define UI_RETURN_OK         (1 << 1)   /* choice made */
+#define UI_RETURN_OUT        (1 << 2)   /* left the menu */
+#define UI_RETURN_OUT_PARENT (1 << 3)   /* let the parent handle this event */
+#define UI_RETURN_UPDATE     (1 << 4)   /* update the button that opened */
+#define UI_RETURN_POPUP_OK   (1 << 5)   /* popup is ok to be handled */
 
 /* panel controls */
-#define UI_PNL_SOLID    2
-#define UI_PNL_CLOSE    32
-#define UI_PNL_SCALE    512
+#define UI_PNL_SOLID    (1 << 1)
+#define UI_PNL_CLOSE    (1 << 5)
+#define UI_PNL_SCALE    (1 << 9)
 
 /* warning the first 6 flags are internal */
 /* but->flag */
-#define UI_TEXT_LEFT    64
-#define UI_ICON_LEFT    128
-#define UI_ICON_SUBMENU 256
-#define UI_ICON_PREVIEW 512
+#define UI_TEXT_LEFT         (1 << 6)
+#define UI_ICON_LEFT         (1 << 7)
+#define UI_ICON_SUBMENU      (1 << 8)
+#define UI_ICON_PREVIEW      (1 << 9)
 
-#define UI_TEXT_RIGHT       1024
-#define UI_BUT_NODE_LINK    2048
-#define UI_BUT_NODE_ACTIVE  4096
-#define UI_BUT_DRAG_LOCK    8192
+#define UI_TEXT_RIGHT        (1 << 10)
+#define UI_BUT_NODE_LINK     (1 << 11)
+#define UI_BUT_NODE_ACTIVE   (1 << 12)
+#define UI_BUT_DRAG_LOCK     (1 << 13)
 
 /* button align flag, for drawing groups together */
-#define UI_BUT_ALIGN        (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN)
-#define UI_BUT_ALIGN_TOP    (1 << 14)
-#define UI_BUT_ALIGN_LEFT   (1 << 15)
-#define UI_BUT_ALIGN_RIGHT  (1 << 16)
-#define UI_BUT_ALIGN_DOWN   (1 << 17)
-
-#define UI_BUT_DISABLED     (1 << 18)
-#define UI_BUT_COLOR_LOCK   (1 << 19)
-#define UI_BUT_ANIMATED     (1 << 20)
-#define UI_BUT_ANIMATED_KEY (1 << 21)
-#define UI_BUT_DRIVEN       (1 << 22)
-#define UI_BUT_REDALERT     (1 << 23)
-#define UI_BUT_INACTIVE     (1 << 24)
-#define UI_BUT_LAST_ACTIVE  (1 << 25)
-#define UI_BUT_UNDO         (1 << 26)
-#define UI_BUT_IMMEDIATE    (1 << 27)
-#define UI_BUT_NO_TOOLTIP   (1 << 28)
-#define UI_BUT_NO_UTF8      (1 << 29)
+#define UI_BUT_ALIGN         (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN)
+#define UI_BUT_ALIGN_TOP     (1 << 14)
+#define UI_BUT_ALIGN_LEFT    (1 << 15)
+#define UI_BUT_ALIGN_RIGHT   (1 << 16)
+#define UI_BUT_ALIGN_DOWN    (1 << 17)
+
+#define UI_BUT_DISABLED      (1 << 18)
+#define UI_BUT_COLOR_LOCK    (1 << 19)
+#define UI_BUT_ANIMATED      (1 << 20)
+#define UI_BUT_ANIMATED_KEY  (1 << 21)
+#define UI_BUT_DRIVEN        (1 << 22)
+#define UI_BUT_REDALERT      (1 << 23)
+#define UI_BUT_INACTIVE      (1 << 24)
+#define UI_BUT_LAST_ACTIVE   (1 << 25)
+#define UI_BUT_UNDO          (1 << 26)
+#define UI_BUT_IMMEDIATE     (1 << 27)
+#define UI_BUT_NO_TOOLTIP    (1 << 28)
+#define UI_BUT_NO_UTF8       (1 << 29)
 
 #define UI_BUT_VEC_SIZE_LOCK (1 << 30) /* used to flag if color hsv-circle should keep luminance */
-#define UI_BUT_COLOR_CUBIC  (1 << 31) /* cubic saturation for the color wheel */
+#define UI_BUT_COLOR_CUBIC   (1 << 31) /* cubic saturation for the color wheel */
 
 #define UI_PANEL_WIDTH          340
 #define UI_COMPACT_PANEL_WIDTH  160
@@ -249,7 +253,8 @@ typedef enum {
        VECTORSCOPE   = (50 << 9),
        PROGRESSBAR   = (51 << 9),
        SEARCH_MENU_UNLINK   = (52 << 9),
-       NODESOCKET    = (53 << 9)
+       NODESOCKET    = (53 << 9),
+       LISTLABEL     = (54 << 9),
 } eButType;
 
 #define BUTTYPE     (63 << 9)
@@ -279,9 +284,9 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
 void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
 
 /* state for scrolldrawing */
-#define UI_SCROLL_PRESSED       1
-#define UI_SCROLL_ARROWS        2
-#define UI_SCROLL_NO_OUTLINE    4
+#define UI_SCROLL_PRESSED       (1 << 0)
+#define UI_SCROLL_ARROWS        (1 << 1)
+#define UI_SCROLL_NO_OUTLINE    (1 << 2)
 void uiWidgetScrollDraw(struct uiWidgetColors *wcol, const struct rcti *rect, const struct rcti *slider, int state);
 
 /* Callbacks
@@ -556,18 +561,18 @@ void uiButGetStrInfo(struct bContext *C, uiBut *but, ...);
  * - PickerButtons: buttons like the color picker (for code sharing).
  * - AutoButR: RNA property button with type automatically defined. */
 
-#define UI_ID_RENAME        1
-#define UI_ID_BROWSE        2
-#define UI_ID_ADD_NEW       4
-#define UI_ID_OPEN          8
-#define UI_ID_ALONE         16
-#define UI_ID_DELETE        32
-#define UI_ID_LOCAL         64
-#define UI_ID_AUTO_NAME     128
-#define UI_ID_FAKE_USER     256
-#define UI_ID_PIN           512
-#define UI_ID_BROWSE_RENDER 1024
-#define UI_ID_PREVIEWS      2048
+#define UI_ID_RENAME        (1 << 0)
+#define UI_ID_BROWSE        (1 << 1)
+#define UI_ID_ADD_NEW       (1 << 2)
+#define UI_ID_OPEN          (1 << 3)
+#define UI_ID_ALONE         (1 << 4)
+#define UI_ID_DELETE        (1 << 5)
+#define UI_ID_LOCAL         (1 << 6)
+#define UI_ID_AUTO_NAME     (1 << 7)
+#define UI_ID_FAKE_USER     (1 << 8)
+#define UI_ID_PIN           (1 << 9)
+#define UI_ID_BROWSE_RENDER (1 << 10)
+#define UI_ID_PREVIEWS      (1 << 11)
 #define UI_ID_FULL          (UI_ID_RENAME | UI_ID_BROWSE | UI_ID_ADD_NEW | UI_ID_OPEN | UI_ID_ALONE | UI_ID_DELETE | UI_ID_LOCAL)
 
 int uiIconFromID(struct ID *id);
@@ -708,15 +713,15 @@ void UI_exit(void);
 #define UI_LAYOUT_ALIGN_CENTER  2
 #define UI_LAYOUT_ALIGN_RIGHT   3
 
-#define UI_ITEM_O_RETURN_PROPS  1
-#define UI_ITEM_R_EXPAND        2
-#define UI_ITEM_R_SLIDER        4
-#define UI_ITEM_R_TOGGLE        8
-#define UI_ITEM_R_ICON_ONLY     16
-#define UI_ITEM_R_EVENT         32
-#define UI_ITEM_R_FULL_EVENT    64
-#define UI_ITEM_R_NO_BG         128
-#define UI_ITEM_R_IMMEDIATE     256
+#define UI_ITEM_O_RETURN_PROPS  (1 << 0)
+#define UI_ITEM_R_EXPAND        (1 << 1)
+#define UI_ITEM_R_SLIDER        (1 << 2)
+#define UI_ITEM_R_TOGGLE        (1 << 3)
+#define UI_ITEM_R_ICON_ONLY     (1 << 4)
+#define UI_ITEM_R_EVENT         (1 << 5)
+#define UI_ITEM_R_FULL_EVENT    (1 << 6)
+#define UI_ITEM_R_NO_BG         (1 << 7)
+#define UI_ITEM_R_IMMEDIATE     (1 << 8)
 
 /* uiLayoutOperatorButs flags */
 #define UI_LAYOUT_OP_SHOW_TITLE 1
@@ -729,13 +734,13 @@ void UI_exit(void);
  * 8------4 */
 
 enum {
-       UI_CNR_TOP_LEFT = 1,
-       UI_CNR_TOP_RIGHT = 2,
-       UI_CNR_BOTTOM_RIGHT = 4,
-       UI_CNR_BOTTOM_LEFT = 8,
+       UI_CNR_TOP_LEFT     = (1 << 0),
+       UI_CNR_TOP_RIGHT    = (1 << 1),
+       UI_CNR_BOTTOM_RIGHT = (1 << 2),
+       UI_CNR_BOTTOM_LEFT  = (1 << 3),
        /* just for convenience */
-       UI_CNR_NONE = 0,
-       UI_CNR_ALL = (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)
+       UI_CNR_NONE         = 0,
+       UI_CNR_ALL          = (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)
 };
 
 /* not apart of the corner flags but mixed in some functions  */
index 7aee228ddaabdfd229227f6edc21a64f9d4d3df5..d86f22df4a798fb2cf097420c9dfba8d599b1b6a 100644 (file)
@@ -276,7 +276,7 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
 
 static bool ui_but_editable(uiBut *but)
 {
-       return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
+       return ELEM6(but->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
 }
 
 static uiBut *ui_but_prev(uiBut *but)
@@ -2010,7 +2010,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
        uiBut *but;
 
        /* label and roundbox can overlap real buttons (backdrops...) */
-       if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
+       if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
                return;
 
        for (but = actbut->next; but; but = but->next) {
@@ -2038,7 +2038,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
        uiBut *but;
 
        /* label and roundbox can overlap real buttons (backdrops...) */
-       if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
+       if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
                return;
 
        for (but = actbut->prev; but; but = but->prev) {
@@ -5361,6 +5361,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
                case ROUNDBOX:
                case LISTBOX:
                case LABEL:
+               case LISTLABEL:
                case ROW:
                case LISTROW:
                case BUT_IMAGE:
@@ -5558,7 +5559,7 @@ static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
 bool ui_is_but_interactive(uiBut *but)
 {
        /* note, LABEL is included for highlights, this allows drags */
-       if (but->type == LABEL && but->dragpoin == NULL)
+       if (ELEM(but->type, LABEL, LISTLABEL) && but->dragpoin == NULL)
                return false;
        if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
                return false;
@@ -6995,7 +6996,7 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH
                                                for (but = block->buttons.first; but; but = but->next) {
                                                        int doit = FALSE;
                                                        
-                                                       if (but->type != LABEL && but->type != SEPR)
+                                                       if (but->type != LABEL && but->type != LISTLABEL && but->type != SEPR)
                                                                count++;
                                                        
                                                        /* exception for rna layer buts */
index a6076b8df78bcc0a84efb6ecbe8740e13e390e94..82352cee05e9efec7ebc0b80dea78d7379b13d11 100644 (file)
@@ -94,7 +94,8 @@ typedef enum {
        UI_WTYPE_BOX,
        UI_WTYPE_SCROLL,
        UI_WTYPE_LISTITEM,
-       UI_WTYPE_PROGRESSBAR
+       UI_WTYPE_PROGRESSBAR,
+       UI_WTYPE_LISTLABEL,
 } uiWidgetTypeEnum;
 
 /* menu scrolling */
@@ -563,6 +564,7 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but);
 int ui_but_can_align(uiBut *but);
 void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop);
 void ui_but_add_shortcut(uiBut *but, const char *key_str, const bool do_strip);
+void ui_layout_list_set_labels_active(uiLayout *layout);
 
 /* interface_anim.c */
 void ui_but_anim_flag(uiBut *but, float cfra);
index ef839f1d14359f1ac70b2dec3fa1a892d10f988c..2a6a9600582f201b943b857cdd9109ccccbca604 100644 (file)
@@ -1632,7 +1632,7 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
                but = uiDefIconBut(block, LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
        else
                but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
-       
+
        /* to compensate for string size padding in ui_text_icon_width,
         * make text aligned right if the layout is aligned right.
         */
@@ -1640,7 +1640,12 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
                but->flag &= ~UI_TEXT_LEFT;     /* default, needs to be unset */
                but->flag |= UI_TEXT_RIGHT;
        }
-       
+
+       /* Mark as a label inside a listbox. */
+       if (block->flag & UI_BLOCK_LIST_ITEM) {
+               but->type = LISTLABEL;
+       }
+
        return but;
 }
 
@@ -1749,7 +1754,7 @@ void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const ch
 
        /* add hotkey here, lower UI code can't detect it */
        if (layout->root->block->flag & UI_BLOCK_LOOP) {
-               if (ot->prop &&
+               if (ot->prop && ot->invoke &&
                    WM_key_event_operator_string(C, ot->idname, layout->root->opcontext, NULL, false, keybuf, sizeof(keybuf)))
                {
                        namestr += BLI_snprintf(namestr, sizeof(namestr_buf) - (namestr - namestr_buf), "|%s", keybuf);
@@ -2399,6 +2404,18 @@ uiLayout *uiLayoutBox(uiLayout *layout)
        return (uiLayout *)ui_layout_box(layout, ROUNDBOX);
 }
 
+/* Check all buttons defined in this layout, and set labels as active/selected.
+ * Needed to handle correctly text colors of list items. */
+void ui_layout_list_set_labels_active(uiLayout *layout)
+{
+       uiButtonItem *bitem;
+       for (bitem = layout->items.first; bitem; bitem = bitem->item.next) {
+               if (bitem->item.type == ITEM_BUTTON && bitem->but->type == LISTLABEL) {
+                       uiButSetFlag(bitem->but, UI_SELECT);
+               }
+       }
+}
+
 uiLayout *uiLayoutListBox(uiLayout *layout, uiList *ui_list, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *actptr,
                           PropertyRNA *actprop)
 {
index 1ff46004bdfd3d9786a360b6b0324cf218da6e73..0f2cedf8b0a5ad747f260cc87e426997d4a73fde 100644 (file)
@@ -632,6 +632,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
        memset(&type, 0, sizeof(ARegionType));
        type.draw = ui_tooltip_region_draw_cb;
        type.free = ui_tooltip_region_free_cb;
+       type.regionid = RGN_TYPE_TEMPORARY;
        ar->type = &type;
        
        /* set font, get bb */
@@ -1159,6 +1160,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
        memset(&type, 0, sizeof(ARegionType));
        type.draw = ui_searchbox_region_draw_cb;
        type.free = ui_searchbox_region_free_cb;
+       type.regionid = RGN_TYPE_TEMPORARY;
        ar->type = &type;
        
        /* create searchbox data */
@@ -1669,6 +1671,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
 
        memset(&type, 0, sizeof(ARegionType));
        type.draw = ui_block_region_draw;
+       type.regionid = RGN_TYPE_TEMPORARY;
        ar->type = &type;
 
        UI_add_region_handlers(&ar->handlers);
index 34d1c24aade1d5ed32f70dcc3a0e2a61ec1ea9ff..57392c60f809f2e20f9474532bf387e0ec61f9e3 100644 (file)
@@ -2478,14 +2478,14 @@ static void uilist_draw_item_default(struct uiList *ui_list, struct bContext *UN
 
        /* Simplest one! */
        switch (ui_list->layout_type) {
-       case UILST_LAYOUT_GRID:
-               uiItemL(layout, "", icon);
-               break;
-       case UILST_LAYOUT_DEFAULT:
-       case UILST_LAYOUT_COMPACT:
-       default:
-               uiItemL(layout, name, icon);
-               break;
+               case UILST_LAYOUT_GRID:
+                       uiItemL(layout, "", icon);
+                       break;
+               case UILST_LAYOUT_DEFAULT:
+               case UILST_LAYOUT_COMPACT:
+               default:
+                       uiItemL(layout, name, icon);
+                       break;
        }
 
        /* free name */
@@ -2599,145 +2599,159 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
        ui_list->layout_type = layout_type;
 
        switch (layout_type) {
-       case UILST_LAYOUT_DEFAULT:
-               /* default rows */
-               if (rows == 0)
-                       rows = 5;
-               if (maxrows == 0)
-                       maxrows = 5;
-               if (ui_list->list_grip_size != 0)
-                       rows = ui_list->list_grip_size;
-
-               /* layout */
-               box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
-               row = uiLayoutRow(box, FALSE);
-               col = uiLayoutColumn(row, TRUE);
+               case UILST_LAYOUT_DEFAULT:
+                       /* default rows */
+                       if (rows == 0)
+                               rows = 5;
+                       if (maxrows == 0)
+                               maxrows = 5;
+                       if (ui_list->list_grip_size != 0)
+                               rows = ui_list->list_grip_size;
+
+                       /* layout */
+                       box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
+                       row = uiLayoutRow(box, FALSE);
+                       col = uiLayoutColumn(row, TRUE);
 
-               /* init numbers */
-               RNA_property_int_range(active_dataptr, activeprop, &min, &max);
+                       /* init numbers */
+                       RNA_property_int_range(active_dataptr, activeprop, &min, &max);
 
-               if (prop)
-                       len = RNA_property_collection_length(dataptr, prop);
-               items = CLAMPIS(len, rows, MAX2(rows, maxrows));
+                       if (prop)
+                               len = RNA_property_collection_length(dataptr, prop);
+                       items = CLAMPIS(len, rows, MAX2(rows, maxrows));
 
-               /* if list length changes and active is out of view, scroll to it */
-               if ((ui_list->list_last_len != len) &&
-                   (activei < ui_list->list_scroll || activei >= ui_list->list_scroll + items))
-               {
-                       ui_list->list_scroll = activei;
-               }
+                       /* if list length changes and active is out of view, scroll to it */
+                       if ((ui_list->list_last_len != len) &&
+                           (activei < ui_list->list_scroll || activei >= ui_list->list_scroll + items))
+                       {
+                               ui_list->list_scroll = activei;
+                       }
 
-               ui_list->list_scroll = min_ii(ui_list->list_scroll, len - items);
-               ui_list->list_scroll = max_ii(ui_list->list_scroll, 0);
-               ui_list->list_size = items;
-               ui_list->list_last_len = len;
+                       ui_list->list_scroll = min_ii(ui_list->list_scroll, len - items);
+                       ui_list->list_scroll = max_ii(ui_list->list_scroll, 0);
+                       ui_list->list_size = items;
+                       ui_list->list_last_len = len;
 
-               if (dataptr->data && prop) {
-                       /* create list items */
-                       RNA_PROP_BEGIN (dataptr, itemptr, prop)
-                       {
-                               if (i >= ui_list->list_scroll && i < ui_list->list_scroll + items) {
-                                       subblock = uiLayoutGetBlock(col);
-                                       overlap = uiLayoutOverlap(col);
+                       if (dataptr->data && prop) {
+                               /* create list items */
+                               RNA_PROP_BEGIN (dataptr, itemptr, prop)
+                               {
+                                       if (i >= ui_list->list_scroll && i < ui_list->list_scroll + items) {
+                                               subblock = uiLayoutGetBlock(col);
+                                               overlap = uiLayoutOverlap(col);
 
-                                       /* list item behind label & other buttons */
-                                       sub = uiLayoutRow(overlap, FALSE);
+                                               uiBlockSetFlag(subblock, UI_BLOCK_LIST_ITEM);
 
-                                       but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
-                                                            active_dataptr, activeprop, 0, 0, i, 0, 0, "");
-                                       uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
+                                               /* list item behind label & other buttons */
+                                               sub = uiLayoutRow(overlap, FALSE);
 
-                                       sub = uiLayoutRow(overlap, FALSE);
+                                               but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
+                                                                    active_dataptr, activeprop, 0, 0, i, 0, 0, "");
+                                               uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
 
-                                       icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
-                                       if (icon == ICON_DOT)
-                                               icon = ICON_NONE;
-                                       draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
+                                               sub = uiLayoutRow(overlap, FALSE);
+
+                                               icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
+                                               if (icon == ICON_DOT)
+                                                       icon = ICON_NONE;
+                                               draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
+
+                                               /* If we are "drawing" active item, set all labels as active. */
+                                               if (i == activei) {
+                                                       ui_layout_list_set_labels_active(sub);
+                                               }
+                                       }
+                                       i++;
                                }
+                               RNA_PROP_END;
+                       }
+
+                       /* add dummy buttons to fill space */
+                       while (i < ui_list->list_scroll + items) {
+                               if (i >= ui_list->list_scroll)
+                                       uiItemL(col, "", ICON_NONE);
                                i++;
                        }
-                       RNA_PROP_END;
-               }
 
-               /* add dummy buttons to fill space */
-               while (i < ui_list->list_scroll + items) {
-                       if (i >= ui_list->list_scroll)
-                               uiItemL(col, "", ICON_NONE);
-                       i++;
-               }
+                       /* add scrollbar */
+                       if (len > items) {
+                               col = uiLayoutColumn(row, FALSE);
+                               uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &ui_list->list_scroll,
+                                         0, len - items, items, 0, "");
+                       }
+                       break;
+               case UILST_LAYOUT_COMPACT:
+                       row = uiLayoutRow(layout, TRUE);
+
+                       if (dataptr->data && prop) {
+                               /* create list items */
+                               RNA_PROP_BEGIN (dataptr, itemptr, prop)
+                               {
+                                       found = (activei == i);
+
+                                       if (found) {
+                                               icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
+                                               if (icon == ICON_DOT)
+                                                       icon = ICON_NONE;
+                                               draw_item(ui_list, C, row, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
+                                       }
 
-               /* add scrollbar */
-               if (len > items) {
-                       col = uiLayoutColumn(row, FALSE);
-                       uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &ui_list->list_scroll,
-                                 0, len - items, items, 0, "");
-               }
-               break;
-       case UILST_LAYOUT_COMPACT:
-               row = uiLayoutRow(layout, TRUE);
+                                       i++;
+                               }
+                               RNA_PROP_END;
+                       }
 
-               if (dataptr->data && prop) {
-                       /* create list items */
-                       RNA_PROP_BEGIN (dataptr, itemptr, prop)
-                       {
-                               found = (activei == i);
+                       /* if list is empty, add in dummy button */
+                       if (i == 0)
+                               uiItemL(row, "", ICON_NONE);
 
-                               if (found) {
-                                       icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
-                                       if (icon == ICON_DOT)
-                                               icon = ICON_NONE;
-                                       draw_item(ui_list, C, row, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
-                               }
+                       /* next/prev button */
+                       BLI_snprintf(numstr, sizeof(numstr), "%d :", i);
+                       but = uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y,
+                                                    active_dataptr, activeprop, 0, 0, 0, 0, 0, "");
+                       if (i == 0)
+                               uiButSetFlag(but, UI_BUT_DISABLED);
+                       break;
+               case UILST_LAYOUT_GRID:
+                       box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
+                       col = uiLayoutColumn(box, TRUE);
+                       row = uiLayoutRow(col, FALSE);
 
-                               i++;
-                       }
-                       RNA_PROP_END;
-               }
+                       if (dataptr->data && prop) {
+                               /* create list items */
+                               RNA_PROP_BEGIN (dataptr, itemptr, prop)
+                               {
+                                       /* create button */
+                                       if (!(i % 9))
+                                               row = uiLayoutRow(col, FALSE);
 
-               /* if list is empty, add in dummy button */
-               if (i == 0)
-                       uiItemL(row, "", ICON_NONE);
+                                       subblock = uiLayoutGetBlock(row);
+                                       overlap = uiLayoutOverlap(row);
 
-               /* next/prev button */
-               BLI_snprintf(numstr, sizeof(numstr), "%d :", i);
-               but = uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y,
-                                            active_dataptr, activeprop, 0, 0, 0, 0, 0, "");
-               if (i == 0)
-                       uiButSetFlag(but, UI_BUT_DISABLED);
-               break;
-       case UILST_LAYOUT_GRID:
-               box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
-               col = uiLayoutColumn(box, TRUE);
-               row = uiLayoutRow(col, FALSE);
-
-               if (dataptr->data && prop) {
-                       /* create list items */
-                       RNA_PROP_BEGIN (dataptr, itemptr, prop)
-                       {
-                               /* create button */
-                               if (!(i % 9))
-                                       row = uiLayoutRow(col, FALSE);
+                                       uiBlockSetFlag(subblock, UI_BLOCK_LIST_ITEM);
 
-                               subblock = uiLayoutGetBlock(row);
-                               overlap = uiLayoutOverlap(row);
+                                       /* list item behind label & other buttons */
+                                       sub = uiLayoutRow(overlap, FALSE);
 
-                               /* list item behind label & other buttons */
-                               sub = uiLayoutRow(overlap, FALSE);
+                                       but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
+                                                            active_dataptr, activeprop, 0, 0, i, 0, 0, "");
+                                       uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
 
-                               but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
-                                                    active_dataptr, activeprop, 0, 0, i, 0, 0, "");
-                               uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
+                                       sub = uiLayoutRow(overlap, FALSE);
 
-                               sub = uiLayoutRow(overlap, FALSE);
+                                       icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
+                                       draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
 
-                               icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
-                               draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
+                                       /* If we are "drawing" active item, set all labels as active. */
+                                       if (i == activei) {
+                                               ui_layout_list_set_labels_active(sub);
+                                       }
 
-                               i++;
+                                       i++;
+                               }
+                               RNA_PROP_END;
                        }
-                       RNA_PROP_END;
-               }
-               break;
+                       break;
        }
 }
 
index d8efb972ce9a15161876d73dc6c103dc73b598e7..9b736eb1bf429067f654d0344405ddd752133632 100644 (file)
@@ -883,7 +883,8 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti
        }
        
        /* extra feature allows more alpha blending */
-       if (but->type == LABEL && but->a1 == 1.0f) alpha *= but->a2;
+       if (ELEM(but->type, LABEL, LISTLABEL) && but->a1 == 1.0f)
+               alpha *= but->a2;
        
        glEnable(GL_BLEND);
        
@@ -1731,34 +1732,19 @@ static void widget_state_numslider(uiWidgetType *wt, int state)
        }
 }
 
-/* labels use theme colors for text */
-static void widget_state_label(uiWidgetType *wt, int state)
-{
-       /* call this for option button */
-       widget_state(wt, state);
-
-       if (state & UI_SELECT)
-               UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
-       else
-               UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
-       
-}
-
 /* labels use theme colors for text */
 static void widget_state_option_menu(uiWidgetType *wt, int state)
 {
+       bTheme *btheme = UI_GetTheme(); /* XXX */
        
        /* call this for option button */
        widget_state(wt, state);
        
        /* if not selected we get theme from menu back */
        if (state & UI_SELECT)
-               UI_GetThemeColor4ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
-       else {
-               bTheme *btheme = UI_GetTheme(); /* XXX */
-
+               copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel);
+       else
                copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text);
-       }
 }
 
 
@@ -2980,9 +2966,11 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
                case UI_WTYPE_REGULAR:
                        break;
 
+               case UI_WTYPE_LISTLABEL:
+                       wt.wcol_theme = &btheme->tui.wcol_list_item;
+                       /* No break, we use usual label code too. */
                case UI_WTYPE_LABEL:
                        wt.draw = NULL;
-                       wt.state = widget_state_label;
                        break;
                        
                case UI_WTYPE_TOGGLE:
@@ -3230,6 +3218,11 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
                                }
                                break;
                                
+                       case LISTLABEL:
+                               wt = widget_type(UI_WTYPE_LISTLABEL);
+                               fstyle = &style->widgetlabel;
+                               break;
+
                        case SEPR:
                                break;
                                
index 89f0da102c93f03cc775c1886fa15b14d775765c..3216e79deb01877a6ad49af85d0be2ffce274de9 100644 (file)
@@ -1014,17 +1014,24 @@ void ui_style_init_default(void)
 
 void UI_SetTheme(int spacetype, int regionid)
 {
-       if (spacetype == 0) {  /* called for safety, when delete themes */
-               theme_active = U.themes.first;
-               theme_spacetype = SPACE_VIEW3D;
-               theme_regionid = RGN_TYPE_WINDOW;
-       }
-       else {
+       if (spacetype) {
                /* later on, a local theme can be found too */
                theme_active = U.themes.first;
                theme_spacetype = spacetype;
                theme_regionid = regionid;
        }
+       else if (regionid) {
+               /* popups */
+               theme_active = U.themes.first;
+               theme_spacetype = SPACE_BUTS;
+               theme_regionid = regionid;
+       }
+       else {
+               /* for safety, when theme was deleted */
+               theme_active = U.themes.first;
+               theme_spacetype = SPACE_VIEW3D;
+               theme_regionid = RGN_TYPE_WINDOW;
+       }
 }
 
 bTheme *UI_GetTheme(void)
index e194f9907398efdb035ef57b11990e7e3516d720..82d958a5c7b5130d0afebd912b22bf1611db58eb 100644 (file)
@@ -74,6 +74,8 @@ void paintface_flush_flags(Object *ob)
        if (me == NULL)
                return;
 
+       /* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */
+
        /* we could call this directly in all areas that change selection,
         * since this could become slow for realtime updates (circle-select for eg) */
        BKE_mesh_flush_select_from_polys(me);
@@ -139,18 +141,20 @@ void paintface_hide(Object *ob, const bool unselected)
        a = me->totpoly;
        while (a--) {
                if ((mpoly->flag & ME_HIDE) == 0) {
-                       if (unselected) {
-                               if ((mpoly->flag & ME_FACE_SEL) == 0) mpoly->flag |= ME_HIDE;
-                       }
-                       else {
-                               if ((mpoly->flag & ME_FACE_SEL)) mpoly->flag |= ME_HIDE;
+                       if (((mpoly->flag & ME_FACE_SEL) == 0) == unselected) {
+                               mpoly->flag |= ME_HIDE;
                        }
                }
-               if (mpoly->flag & ME_HIDE) mpoly->flag &= ~ME_FACE_SEL;
+
+               if (mpoly->flag & ME_HIDE) {
+                       mpoly->flag &= ~ME_FACE_SEL;
+               }
                
                mpoly++;
        }
        
+       BKE_mesh_flush_hidden_from_polys(me);
+
        paintface_flush_flags(ob);
 }
 
@@ -174,6 +178,8 @@ void paintface_reveal(Object *ob)
                mpoly++;
        }
 
+       BKE_mesh_flush_hidden_from_polys(me);
+
        paintface_flush_flags(ob);
 }
 
index df5d764d69b139bd5a62eaee6c70fca0ab9b4435..468bbb8a5c5112f5904d1c37a4ae7a1015c92512 100644 (file)
@@ -2392,16 +2392,18 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **r_eve, BMEdge **r_eed,
        EDBM_selectmode_flush(em);
        ele = BM_mesh_active_elem_get(em->bm);
 
-       switch (ele->head.htype) {
-               case BM_VERT:
-                       *r_eve = (BMVert *)ele;
-                       return;
-               case BM_EDGE:
-                       *r_eed = (BMEdge *)ele;
-                       return;
-               case BM_FACE:
-                       *r_efa = (BMFace *)ele;
-                       return;
+       if (ele) {
+               switch (ele->head.htype) {
+                       case BM_VERT:
+                               *r_eve = (BMVert *)ele;
+                               return;
+                       case BM_EDGE:
+                               *r_eed = (BMEdge *)ele;
+                               return;
+                       case BM_FACE:
+                               *r_efa = (BMFace *)ele;
+                               return;
+               }
        }
 
        if (em->selectmode & SCE_SELECT_VERTEX) {
@@ -3186,6 +3188,8 @@ static int edbm_loop_to_region_exec(bContext *C, wmOperator *op)
                }
        }
        
+       EDBM_selectmode_flush(em);
+
        WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
        return OPERATOR_FINISHED;
 }
index 51d02e8cc2b83c317fe2aa8b42ad4148f5ae0933..0d0134af4e52b1edcd6872dda79b53a0e86a7770 100644 (file)
@@ -407,34 +407,6 @@ void MESH_OT_edge_collapse(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-static int edbm_collapse_edge_loop_exec(bContext *C, wmOperator *op)
-{
-       Object *obedit = CTX_data_edit_object(C);
-       BMEditMesh *em = BKE_editmesh_from_object(obedit);
-
-       if (!EDBM_op_callf(em, op, "dissolve_edge_loop edges=%he", BM_ELEM_SELECT))
-               return OPERATOR_CANCELLED;
-
-       EDBM_update_generic(em, true, true);
-
-       return OPERATOR_FINISHED;
-}
-
-void MESH_OT_edge_collapse_loop(wmOperatorType *ot)
-{
-       /* identifiers */
-       ot->name = "Edge Collapse Loop";
-       ot->description = "Collapse selected edge loops";
-       ot->idname = "MESH_OT_edge_collapse_loop";
-
-       /* api callbacks */
-       ot->exec = edbm_collapse_edge_loop_exec;
-       ot->poll = ED_operator_editmesh;
-
-       /* flags */
-       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
 static int edbm_add_edge_face__smooth_get(BMesh *bm)
 {
        BMEdge *e;
index e086e11e3bfeae4517e300752b36134bce257397..69f471670edf8c52905663f524446800f4410f42 100644 (file)
@@ -180,7 +180,6 @@ void MESH_OT_colors_rotate(struct wmOperatorType *ot);
 void MESH_OT_colors_reverse(struct wmOperatorType *ot);
 void MESH_OT_delete(struct wmOperatorType *ot);
 void MESH_OT_edge_collapse(struct wmOperatorType *ot);
-void MESH_OT_edge_collapse_loop(struct wmOperatorType *ot);
 void MESH_OT_faces_shade_smooth(struct wmOperatorType *ot);
 void MESH_OT_faces_shade_flat(struct wmOperatorType *ot);
 void MESH_OT_split(struct wmOperatorType *ot);
index c97b674dd2d81e4ac905447ac6c57dadb6ac2547..4f2924293eafe32945f23a132b173db397ca0a4b 100644 (file)
@@ -119,7 +119,6 @@ void ED_operatortypes_mesh(void)
 
        WM_operatortype_append(MESH_OT_delete);
        WM_operatortype_append(MESH_OT_edge_collapse);
-       WM_operatortype_append(MESH_OT_edge_collapse_loop);
 
        WM_operatortype_append(MESH_OT_separate);
        WM_operatortype_append(MESH_OT_dupli_extrude_cursor);
index 5ad6bd4993af7fbe81be35c7045367312870960a..c7aec9f93d49b6c9856e92adc8399a23f420340c 100644 (file)
@@ -1762,7 +1762,7 @@ void OBJECT_OT_convert(wmOperatorType *ot)
 
 /* 
  * dupflag: a flag made from constants declared in DNA_userdef_types.h
- * The flag tells adduplicate() weather to copy data linked to the object, or to reference the existing data.
+ * The flag tells adduplicate() whether to copy data linked to the object, or to reference the existing data.
  * U.dupflag for default operations or you can construct a flag as python does
  * if the dupflag is 0 then no data will be copied (linked duplicate) */
 
index 485987fd8fe122f1df571dadb3f49ba3aa6bb7f4..b3ce932085237128e0a4c4e77b0570f9e608809d 100644 (file)
@@ -226,7 +226,7 @@ void OBJECT_OT_vertex_group_move(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_weight_paste(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_weight_delete(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_weight_set_active(struct wmOperatorType *ot);
-void OBJECT_OT_vertex_weight_normalize_active(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_weight_normalize_active_vertex(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_weight_copy(struct wmOperatorType *ot);
 
 /* object_shapekey.c */
index 3afb04c34f6402acba96794ea7340f6eef239546..356bda109a4a8278a77b32f0cf23995043f7b7f9 100644 (file)
@@ -198,7 +198,7 @@ void ED_operatortypes_object(void)
        WM_operatortype_append(OBJECT_OT_vertex_weight_paste);
        WM_operatortype_append(OBJECT_OT_vertex_weight_delete);
        WM_operatortype_append(OBJECT_OT_vertex_weight_set_active);
-       WM_operatortype_append(OBJECT_OT_vertex_weight_normalize_active);
+       WM_operatortype_append(OBJECT_OT_vertex_weight_normalize_active_vertex);
        WM_operatortype_append(OBJECT_OT_vertex_weight_copy);
 
        WM_operatortype_append(OBJECT_OT_game_property_new);
index c5efa91d105544635776980d542617d91e6df0e4..b85c7126fdb7f5780badb7bba6c12c7539cb9d8a 100644 (file)
@@ -2941,6 +2941,13 @@ static int vertex_group_poll(bContext *C)
        return (ob && !ob->id.lib && OB_TYPE_SUPPORT_VGROUP(ob->type) && data && !data->lib);
 }
 
+static int vertex_group_mesh_poll(bContext *C)
+{
+       Object *ob = ED_object_context(C);
+       ID *data = (ob) ? ob->data : NULL;
+       return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib);
+}
+
 static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C)
 {
        Object *ob = ED_object_context(C);
@@ -2953,7 +2960,42 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C)
 }
 
 /* editmode _or_ weight paint vertex sel */
-static int vertex_group_poll_edit_or_wpaint_vert_select(bContext *C)
+static int vertex_group_vert_select_poll(bContext *C)
+{
+       Object *ob = ED_object_context(C);
+       ID *data = (ob) ? ob->data : NULL;
+
+       if (!(ob && !ob->id.lib && data && !data->lib))
+               return 0;
+
+       return (vgroup_object_in_edit_mode(ob) ||
+               vgroup_object_in_wpaint_vert_select(ob));
+}
+
+/* editmode _or_ weight paint vertex sel and active group unlocked */
+static int vertex_group_vert_select_unlocked_poll(bContext *C)
+{
+       Object *ob = ED_object_context(C);
+       ID *data = (ob) ? ob->data : NULL;
+
+       if (!(ob && !ob->id.lib && data && !data->lib))
+               return 0;
+
+       if (!(vgroup_object_in_edit_mode(ob) ||
+               vgroup_object_in_wpaint_vert_select(ob))) {
+               return 0;
+       }
+
+       if (ob->actdef != -1) {
+               bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef - 1);
+               if (dg) {
+                       return !(dg->flag & DG_LOCK_WEIGHT);
+               }
+       }
+       return 0;
+}
+
+static int vertex_group_vert_select_mesh_poll(bContext *C)
 {
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
@@ -2961,6 +3003,10 @@ static int vertex_group_poll_edit_or_wpaint_vert_select(bContext *C)
        if (!(ob && !ob->id.lib && data && !data->lib))
                return 0;
 
+       /* only difference to #vertex_group_vert_select_poll */
+       if (ob->type != OB_MESH)
+               return 0;
+
        return (vgroup_object_in_edit_mode(ob) ||
                vgroup_object_in_wpaint_vert_select(ob));
 }
@@ -3049,10 +3095,10 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot)
        /* identifiers */
        ot->name = "Assign Vertex Group";
        ot->idname = "OBJECT_OT_vertex_group_assign";
-       ot->description = "Assign the selected vertices to the current (or a new) vertex group";
+       ot->description = "Assign the selected vertices to the active (or a new) vertex group";
        
        /* api callbacks */
-       ot->poll = vertex_group_poll_edit_or_wpaint_vert_select;
+       ot->poll = vertex_group_vert_select_unlocked_poll;
        ot->exec = vertex_group_assign_exec;
 
        /* flags */
@@ -3100,7 +3146,7 @@ void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot)
        ot->description = "Remove the selected vertices from active or all vertex group(s)";
 
        /* api callbacks */
-       ot->poll = vertex_group_poll_edit_or_wpaint_vert_select;
+       ot->poll = vertex_group_vert_select_unlocked_poll;
        ot->exec = vertex_group_remove_from_exec;
 
        /* flags */
@@ -3137,7 +3183,7 @@ void OBJECT_OT_vertex_group_select(wmOperatorType *ot)
        ot->description = "Select all the vertices assigned to the active vertex group";
 
        /* api callbacks */
-       ot->poll = vertex_group_poll_edit_or_wpaint_vert_select;
+       ot->poll = vertex_group_vert_select_poll;
        ot->exec = vertex_group_select_exec;
 
        /* flags */
@@ -3162,7 +3208,7 @@ void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot)
        ot->description = "Deselect all selected vertices assigned to the active vertex group";
 
        /* api callbacks */
-       ot->poll = vertex_group_poll_edit_or_wpaint_vert_select;
+       ot->poll = vertex_group_vert_select_poll;
        ot->exec = vertex_group_deselect_exec;
 
        /* flags */
@@ -3336,7 +3382,7 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot)
                          "groups' weights (this tool may be slow for many vertices)";
        
        /* api callbacks */
-       ot->poll = vertex_group_poll;
+       ot->poll = vertex_group_mesh_poll;
        ot->exec = vertex_group_fix_exec;
        
        /* flags */
@@ -4101,11 +4147,33 @@ static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr)
        }
 }
 
-static int vertex_weight_paste(bContext *C, wmOperator *op)
+static bool check_vertex_group_accessible(wmOperator *op, Object *ob, int def_nr)
+{
+       bDeformGroup *dg = BLI_findlink(&ob->defbase, def_nr);
+
+       if (!dg) {
+               BKE_report(op->reports, RPT_ERROR, "Invalid Weight Group Index");
+               return true;
+       }
+
+       if (dg->flag & DG_LOCK_WEIGHT) {
+               BKE_report(op->reports, RPT_ERROR, "Weight Group is locked");
+               return true;
+       }
+
+       return false;
+}
+
+static int vertex_weight_paste_exec(bContext *C, wmOperator *op)
 {
        Object *ob = ED_object_context(C);
-       const int wg_index = RNA_int_get(op->ptr, "weight_group");
-       vgroup_copy_active_to_sel_single(ob, wg_index);
+       const int def_nr = RNA_int_get(op->ptr, "weight_group");
+
+       if (!check_vertex_group_accessible(op, ob, def_nr)) {
+               return OPERATOR_CANCELLED;
+       }
+
+       vgroup_copy_active_to_sel_single(ob, def_nr);
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -4119,25 +4187,30 @@ void OBJECT_OT_vertex_weight_paste(wmOperatorType *ot)
 
        ot->name = "Paste weight to Selected";
        ot->idname = "OBJECT_OT_vertex_weight_paste";
-       ot->description = "Copy this group's weight to other selected verts";
-
-       prop = RNA_def_int(ot->srna, "weight_group",
-                       -1, 0, 0, "Weight Index", "Index of source weight in active Weight Group", 0, 0);
-       RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
+       ot->description = "Copy this group's weight to other selected verts (disabled if vertex Group is locked)";
 
        /* api callbacks */
-       ot->poll = vertex_group_poll;
-       ot->exec = vertex_weight_paste;
+       ot->poll = vertex_group_vert_select_mesh_poll;
+       ot->exec = vertex_weight_paste_exec;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+       prop = RNA_def_int(ot->srna, "weight_group", -1, -1, INT_MAX, "Weight Index",
+                          "Index of source weight in active Weight Group", -1, INT_MAX);
+       RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
 }
 
-static int vertex_weight_delete(bContext *C, wmOperator *op)
+static int vertex_weight_delete_exec(bContext *C, wmOperator *op)
 {
        Object *ob = ED_object_context(C);
-       const int wg_index = RNA_int_get(op->ptr, "weight_group");
-       vgroup_remove_weight(ob, wg_index);
+       const int def_nr = RNA_int_get(op->ptr, "weight_group");
+
+       if (check_vertex_group_accessible(op, ob, def_nr)) {
+               return OPERATOR_CANCELLED;
+       }
+
+       vgroup_remove_weight(ob, def_nr);
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -4151,21 +4224,21 @@ void OBJECT_OT_vertex_weight_delete(wmOperatorType *ot)
 
        ot->name = "Delete Weight";
        ot->idname = "OBJECT_OT_vertex_weight_delete";
-       ot->description = "Delete this weight from the vertex";
-
-       prop = RNA_def_int(ot->srna, "weight_group",
-                       -1, 0, 0, "Weight Index", "Index of source weight in active Weight Group", 0, 0);
-       RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
+       ot->description = "Delete this weight from the vertex (disabled if vertex Group is locked)";
 
        /* api callbacks */
-       ot->poll = vertex_group_poll;
-       ot->exec = vertex_weight_delete;
+       ot->poll = vertex_group_vert_select_mesh_poll;
+       ot->exec = vertex_weight_delete_exec;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+       prop = RNA_def_int(ot->srna, "weight_group", -1, -1, INT_MAX, "Weight Index",
+                          "Index of source weight in active Weight Group", -1, INT_MAX);
+       RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
 }
 
-static int vertex_weight_set_active(bContext *C, wmOperator *op)
+static int vertex_weight_set_active_exec(bContext *C, wmOperator *op)
 {
        Object *ob = ED_object_context(C);
        const int wg_index = RNA_int_get(op->ptr, "weight_group");
@@ -4187,19 +4260,19 @@ void OBJECT_OT_vertex_weight_set_active(wmOperatorType *ot)
        ot->idname = "OBJECT_OT_vertex_weight_set_active";
        ot->description = "Set as active Vertex Group";
 
-       prop = RNA_def_int(ot->srna, "weight_group",
-                       -1, 0, 0, "Weight Index", "Index of source weight in active Weight Group", 0, 0);
-       RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
-
        /* api callbacks */
-       ot->poll = vertex_group_poll;
-       ot->exec = vertex_weight_set_active;
+       ot->poll = vertex_group_vert_select_mesh_poll;
+       ot->exec = vertex_weight_set_active_exec;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+       prop = RNA_def_int(ot->srna, "weight_group", -1, -1, INT_MAX, "Weight Index",
+                          "Index of source weight in active Weight Group", -1, INT_MAX);
+       RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
 }
 
-static int vertex_weight_normalize_active(bContext *C, wmOperator *UNUSED(op))
+static int vertex_weight_normalize_active_vertex_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob = ED_object_context(C);
        ToolSettings *ts = CTX_data_tool_settings(C);
@@ -4213,22 +4286,22 @@ static int vertex_weight_normalize_active(bContext *C, wmOperator *UNUSED(op))
        return OPERATOR_FINISHED;
 }
 
-void OBJECT_OT_vertex_weight_normalize_active(wmOperatorType *ot)
+void OBJECT_OT_vertex_weight_normalize_active_vertex(wmOperatorType *ot)
 {
 
        ot->name = "Normalize Active";
-       ot->idname = "OBJECT_OT_vertex_weight_normalize_active";
+       ot->idname = "OBJECT_OT_vertex_weight_normalize_active_vertex";
        ot->description = "Normalize Active Vert Weights";
 
        /* api callbacks */
-       ot->poll = vertex_group_poll;
-       ot->exec = vertex_weight_normalize_active;
+       ot->poll = vertex_group_vert_select_mesh_poll;
+       ot->exec = vertex_weight_normalize_active_vertex_exec;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-static int vertex_weight_copy(bContext *C, wmOperator *UNUSED(op))
+static int vertex_weight_copy_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob = ED_object_context(C);
        ToolSettings *ts = CTX_data_tool_settings(C);
@@ -4250,8 +4323,8 @@ void OBJECT_OT_vertex_weight_copy(wmOperatorType *ot)
        ot->description = "Copy weights from Active to selected";
 
        /* api callbacks */
-       ot->poll = vertex_group_poll;
-       ot->exec = vertex_weight_copy;
+       ot->poll = vertex_group_vert_select_mesh_poll;
+       ot->exec = vertex_weight_copy_exec;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
index ec68d2e193db8b716cef0954275dc7bb394817a5..563f416ead0bc84799d2e4988caa7cc5dda529c5 100644 (file)
@@ -300,7 +300,7 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
        megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
 
        /* local view */
-       if(rs->localview)
+       if (rs->localview)
                spos += sprintf(spos, "%s | ", IFACE_("Local View"));
 
        /* frame number */
@@ -324,8 +324,9 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
 
        /* statistics */
        if (rs->statstr) {
-               if(rs->statstr[0])
+               if (rs->statstr[0]) {
                        spos += sprintf(spos, "| %s ", rs->statstr);
+               }
        }
        else {
                if (rs->totvert || rs->totface || rs->tothalo || rs->totstrand || rs->totlamp)
@@ -469,7 +470,7 @@ static void render_endjob(void *rjv)
 
        /* XXX render stability hack */
        G.is_rendering = FALSE;
-       WM_main_add_notifier(NC_SCENE|ND_RENDER_RESULT, NULL);
+       WM_main_add_notifier(NC_SCENE | ND_RENDER_RESULT, NULL);
 
        /* Partial render result will always update display buffer
         * for first render layer only. This is nice because you'll
index a22f776d9a020cdfbd0b96544c8db6fe90ce31c9..13379425258dd06126957ec5c27cd90a4e4ed27f 100644 (file)
@@ -271,7 +271,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
        if (rect) {
                int profile_to;
                
-               if(BKE_scene_check_color_management_enabled(scene))
+               if (BKE_scene_check_color_management_enabled(scene))
                        profile_to = IB_PROFILE_LINEAR_RGB;
                else
                        profile_to = IB_PROFILE_SRGB;
index f424424519481935e7e69eb6ce8150465f7a6d28..c274135786f585db257be6a60caf55724905edbb 100644 (file)
@@ -1635,23 +1635,17 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa)
        if (sl->next) {
                /* specific checks for space types */
 
-               int sima_restore = 0;
-
                /* Special check added for non-render image window (back from fullscreen through "Back to Previous" button) */
                if (sl->spacetype == SPACE_IMAGE) {
                        SpaceImage *sima = sa->spacedata.first;
-                       if (!(sima->flag & SI_PREVSPACE) && !(sima->flag & SI_FULLWINDOW))
-                               sima_restore = 1;
-               }
 
-               if (sl->spacetype == SPACE_IMAGE && !sima_restore) {
-                       SpaceImage *sima = sa->spacedata.first;
-                       if (sima->flag & SI_PREVSPACE)
+                       if(sima->flag & (SI_PREVSPACE|SI_FULLWINDOW)) {
                                sima->flag &= ~SI_PREVSPACE;
-                       if (sima->flag & SI_FULLWINDOW) {
                                sima->flag &= ~SI_FULLWINDOW;
                                ED_screen_full_prevspace(C, sa);
                        }
+                       else
+                               ED_screen_full_toggle(C, win, sa);
                }
                else if (sl->spacetype == SPACE_FILE) {
                        ED_screen_full_prevspace(C, sa);
index 527715cdbd3b412560ef150df20a0b5413d9056b..b16721640da5835c8bce284da725c93eda5c3d5b 100644 (file)
@@ -254,6 +254,13 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
        uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, '\0');
 }
 
+static int screenshot_poll(bContext *C)
+{
+       if (G.background)
+               return false;
+
+       return WM_operator_winactive(C);
+}
 
 void SCREEN_OT_screenshot(wmOperatorType *ot)
 {
@@ -266,7 +273,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
        ot->exec = screenshot_exec;
        ot->cancel = screenshot_cancel;
        ot->ui = screenshot_draw;
-       ot->poll = WM_operator_winactive;
+       ot->poll = screenshot_poll;
        
        ot->flag = 0;
        
index 9b46a07b60e5545d9f4ddd5916fe16a3e9afd5e7..79ce4f879b7676b24bdde128066f8e399ba581eb 100644 (file)
@@ -50,6 +50,7 @@ set(SRC
        paint_undo.c
        paint_utils.c
        paint_vertex.c
+       paint_vertex_proj.c
        sculpt.c
        sculpt_undo.c
        sculpt_uv.c
index e0d578ec21073f7a505bb3c3e975cdd4a85c3b59..3db0bd61f03dd829a565a4180533cd00ad68308a 100644 (file)
@@ -416,9 +416,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
        /* ensure that edges and faces get hidden as well (not used by
         * sculpt but it looks wrong when entering editmode otherwise) */
        if (pbvh_type == PBVH_FACES) {
-               BKE_mesh_flush_hidden_from_verts(me->mvert, me->mloop,
-                                                me->medge, me->totedge,
-                                                me->mpoly, me->totpoly);
+               BKE_mesh_flush_hidden_from_verts(me);
        }
 
        ED_region_tag_redraw(ar);
index a24ee13e3bf6430dbce592b7c4673194a010000d..553a5cbe9aca8693e08b83205d95fbe991cf40b3 100644 (file)
@@ -1121,6 +1121,44 @@ static void screen_px_from_persp(
        interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w);
 }
 
+
+/* same as screen_px_from_persp except we return ortho weights back to the caller.
+ * These weights will be used to determine correct interpolation of uvs in cloned uv layer */
+static void screen_px_from_persp_ortho_weights(
+        float uv[2],
+        float v1co[4], float v2co[4], float v3co[4],  /* screenspace coords */
+        float uv1co[2], float uv2co[2], float uv3co[2],
+        float pixelScreenCo[4],
+        float w[3])
+{
+       float w_int[3];
+       float wtot_inv, wtot;
+       barycentric_weights_v2(uv1co, uv2co, uv3co, uv, w);
+
+       /* re-weight from the 4th coord of each screen vert */
+       w_int[0] = w[0] * v1co[3];
+       w_int[1] = w[1] * v2co[3];
+       w_int[2] = w[2] * v3co[3];
+
+       wtot = w_int[0] + w_int[1] + w_int[2];
+
+       if (wtot > 0.0f) {
+               wtot_inv = 1.0f / wtot;
+               w_int[0] *= wtot_inv;
+               w_int[1] *= wtot_inv;
+               w_int[2] *= wtot_inv;
+       }
+       else {
+               w[0] = w[1] = w[2] =
+               w_int[0] = w_int[1] = w_int[2] = 1.0f / 3.0f;  /* dummy values for zero area face */
+       }
+       /* done re-weighting */
+
+       /* do interpolation based on projected weight */
+       interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w_int);
+}
+
+
 static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const float w[3],
                                int side, unsigned char rgba_ub[4], float rgba_f[4])
 {
@@ -2168,6 +2206,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
        float uv_clip[8][2];
        int uv_clip_tot;
        const short is_ortho = ps->is_ortho;
+       const short is_clone_other = ((ps->brush->imagepaint_tool == PAINT_TOOL_CLONE) && ps->dm_mtface_clone);
        const short do_backfacecull = ps->do_backfacecull;
        const short do_clip = ps->rv3d ? ps->rv3d->rflag & RV3D_CLIPPING : 0;
 
@@ -2191,8 +2230,6 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
         * but since the first thing most people try is painting onto a quad- better make it work.
         */
 
-
-
        tf_uv_pxoffset[0][0] = tf->uv[0][0] - xhalfpx;
        tf_uv_pxoffset[0][1] = tf->uv[0][1] - yhalfpx;
 
@@ -2277,7 +2314,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
                                                has_x_isect = has_isect = 1;
 
                                                if (is_ortho) screen_px_from_ortho(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
-                                               else          screen_px_from_persp(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
+                                               else if (is_clone_other) screen_px_from_persp_ortho_weights(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
+                                               else screen_px_from_persp(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
 
                                                /* a pity we need to get the worldspace pixel location here */
                                                if (do_clip || do_3d_mapping) {
index df0fb8ec4f8e754db3b58908f56a2c1ecd17a300..6c13f6efb748add2de4fa6f868d4579e38fd6d77 100644 (file)
@@ -54,6 +54,7 @@ struct wmOperator;
 struct wmOperatorType;
 struct ImagePaintState;
 struct wmWindowManager;
+struct DMCoNo;
 enum PaintMode;
 
 /* paint_stroke.c */
@@ -115,6 +116,20 @@ void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
 
 unsigned int vpaint_get_current_col(struct VPaint *vp);
 
+
+/* paint_vertex_proj.c */
+struct VertProjHandle;
+struct VertProjHandle *ED_vpaint_proj_handle_create(
+        struct Scene *scene, struct Object *ob,
+        struct DMCoNo **r_vcosnos);
+void  ED_vpaint_proj_handle_update(
+        struct VertProjHandle *vp_handle,
+        /* runtime vars */
+        struct ARegion *ar, const float mval_fl[2]);
+void  ED_vpaint_proj_handle_free(
+        struct VertProjHandle *vp_handle);
+
+
 /* paint_image.c */
 typedef struct ImagePaintPartialRedraw {
        int x1, y1, x2, y2;  /* XXX, could use 'rcti' */
index df1978c49f65f776ef728e8cebd5fda17bc52c84..2c7824d4a0dcbf90e310568d3627820e1a6cb073 100644 (file)
@@ -1242,7 +1242,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        /*Weight paint's Vertex Selection Mode */
        keymap = WM_keymap_find(keyconf, "Weight Paint Vertex Selection", 0, 0);
        keymap->poll = vert_paint_poll;
-       WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
        kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
        RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
        WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
@@ -1283,7 +1284,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        keymap = WM_keymap_find(keyconf, "Face Mask", 0, 0);
        keymap->poll = facemask_paint_poll;
 
-       WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
        kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
        RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
        kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, 0, 0);
index 181b32d58fc2e19ca3f808db04ee7b281ce4de35..158a6a925365bfbf73099bcfe2c7650213e8d08b 100644 (file)
  *  \ingroup edsculpt
  */
 
-
-#include <math.h>
-#include <string.h>
-
-#ifdef WIN32
-#include <io.h>
-#else
-#include <unistd.h>
-#endif   
-
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
-#include "BLI_math_color.h"
 #include "BLI_memarena.h"
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
 
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_brush_types.h"
 #include "DNA_object_types.h"
-#include "DNA_meshdata_types.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
 #include "BKE_DerivedMesh.h"
-#include "BKE_armature.h"
 #include "BKE_action.h"
 #include "BKE_brush.h"
 #include "BKE_context.h"
@@ -87,7 +72,7 @@
 #include "ED_screen.h"
 #include "ED_view3d.h"
 
-#include "paint_intern.h"
+#include "paint_intern.h"  /* own include */
 
 /* check if we can do partial updates and have them draw realtime
  * (without rebuilding the 'derivedFinal') */
@@ -2135,7 +2120,10 @@ struct WPaintData {
        int *indexar;
        int vgroup_active;
        int vgroup_mirror;
+
+       void *vp_handle;
        DMCoNo *vertexcosnos;
+
        float wpimat[3][3];
 
        /* variables for auto normalize */
@@ -2244,7 +2232,8 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNU
        }
 
        /* painting on subsurfs should give correct points too, this returns me->totvert amount */
-       wpd->vertexcosnos = mesh_get_mapped_verts_nors(scene, ob);
+       wpd->vp_handle = ED_vpaint_proj_handle_create(scene, ob, &wpd->vertexcosnos);
+
        wpd->indexar = get_indexarray(me);
        copy_wpaint_prev(wp, me->dvert, me->totvert);
 
@@ -2378,6 +2367,9 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                indexar = NULL;
        }
 
+       /* incase we have modifiers */
+       ED_vpaint_proj_handle_update(wpd->vp_handle, vc->ar, mval);
+
        /* make sure each vertex gets treated only once */
        /* and calculate filter weight */
        totw = 0.0f;
@@ -2516,8 +2508,7 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
        struct WPaintData *wpd = paint_stroke_mode_data(stroke);
        
        if (wpd) {
-               if (wpd->vertexcosnos)
-                       MEM_freeN(wpd->vertexcosnos);
+               ED_vpaint_proj_handle_free(wpd->vp_handle);
                MEM_freeN(wpd->indexar);
                
                if (wpd->vgroup_validmap)
@@ -2750,7 +2741,10 @@ typedef struct VPaintData {
        ViewContext vc;
        unsigned int paintcol;
        int *indexar;
+
+       struct VertProjHandle *vp_handle;
        DMCoNo *vertexcosnos;
+
        float vpimat[3][3];
 
        /* modify 'me->mcol' directly, since the derived mesh is drawing from this
@@ -2829,7 +2823,8 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl
        paint_stroke_set_mode_data(stroke, vpd);
        view3d_set_viewcontext(C, &vpd->vc);
        
-       vpd->vertexcosnos = mesh_get_mapped_verts_nors(vpd->vc.scene, ob);
+       vpd->vp_handle = ED_vpaint_proj_handle_create(vpd->vc.scene, ob, &vpd->vertexcosnos);
+
        vpd->indexar = get_indexarray(me);
        vpd->paintcol = vpaint_get_current_col(vp);
 
@@ -3027,6 +3022,9 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        
        swap_m4m4(vc->rv3d->persmat, mat);
 
+       /* incase we have modifiers */
+       ED_vpaint_proj_handle_update(vpd->vp_handle, vc->ar, mval);
+
        /* clear modified tag for blur tool */
        if (vpd->mlooptag)
                memset(vpd->mlooptag, 0, sizeof(bool) * me->totloop);
@@ -3072,8 +3070,7 @@ static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
        ViewContext *vc = &vpd->vc;
        Object *ob = vc->obact;
        
-       if (vpd->vertexcosnos)
-               MEM_freeN(vpd->vertexcosnos);
+       ED_vpaint_proj_handle_free(vpd->vp_handle);
        MEM_freeN(vpd->indexar);
        
        /* frees prev buffer */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
new file mode 100644 (file)
index 0000000..2d5de80
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2013 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/sculpt_paint/paint_vertex_proj.c
+ *  \ingroup edsculpt
+ *
+ * Utility functions for getting vertex locations while painting
+ * (since they may be instanced multiple times in a DerivedMesh)
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_DerivedMesh.h"
+#include "BKE_context.h"
+
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "paint_intern.h"  /* own include */
+
+
+/* Opaque Structs for internal use */
+
+/* stored while painting */
+struct VertProjHandle {
+       DMCoNo *vcosnos;
+
+       bool use_update;
+
+       /* use for update */
+       float *dists;
+
+       Object *ob;
+       Scene *scene;
+};
+
+/* only for passing to the callbacks */
+struct VertProjUpdate {
+       struct VertProjHandle *vp_handle;
+
+       /* runtime */
+       ARegion *ar;
+       const float *mval_fl;
+};
+
+
+/* -------------------------------------------------------------------- */
+/* Internal Init */
+
+static void vpaint_proj_dm_map_cosnos_init__map_cb(void *userData, int index, const float co[3],
+                                                   const float no_f[3], const short no_s[3])
+{
+       struct VertProjHandle *vp_handle = userData;
+       DMCoNo *co_no = &vp_handle->vcosnos[index];
+
+       /* check if we've been here before (normal should not be 0) */
+       if (!is_zero_v3(co_no->no)) {
+               /* remember that multiple dm verts share the same source vert */
+               vp_handle->use_update = true;
+               return;
+       }
+
+       copy_v3_v3(co_no->co, co);
+       if (no_f) {
+               copy_v3_v3(co_no->no, no_f);
+       }
+       else {
+               normal_short_to_float_v3(co_no->no, no_s);
+       }
+}
+
+static void vpaint_proj_dm_map_cosnos_init(Scene *scene, Object *ob,
+                                           struct VertProjHandle *vp_handle)
+{
+       Mesh *me = ob->data;
+       DerivedMesh *dm;
+
+       dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+
+       if (dm->foreachMappedVert) {
+               memset(vp_handle->vcosnos, 0, sizeof(DMCoNo) * me->totvert);
+               dm->foreachMappedVert(dm, vpaint_proj_dm_map_cosnos_init__map_cb, vp_handle);
+       }
+       else {
+               DMCoNo *v_co_no = vp_handle->vcosnos;
+               int a;
+               for (a = 0; a < me->totvert; a++, v_co_no++) {
+                       dm->getVertCo(dm, a, v_co_no->co);
+                       dm->getVertNo(dm, a, v_co_no->no);
+               }
+       }
+
+       dm->release(dm);
+}
+
+
+/* -------------------------------------------------------------------- */
+/* Internal Update */
+
+/* Same as init but take mouse location into account */
+
+static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData, int index, const float co[3],
+                                                     const float no_f[3], const short no_s[3])
+{
+       struct VertProjUpdate *vp_update = userData;
+       struct VertProjHandle *vp_handle = vp_update->vp_handle;
+
+       DMCoNo *co_no = &vp_handle->vcosnos[index];
+
+       /* find closest vertex */
+       {
+               /* first find distance to this vertex */
+               float co_ss[2];  /* screenspace */
+
+               if (ED_view3d_project_float_object(vp_update->ar,
+                                                  co, co_ss,
+                                                  V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
+               {
+                       const float dist = len_squared_v2v2(vp_update->mval_fl, co_ss);
+                       if (dist > vp_handle->dists[index]) {
+                               /* bail out! */
+                               return;
+                       }
+
+                       vp_handle->dists[index] = dist;
+               }
+       }
+       /* continue with regular functionality */
+
+       copy_v3_v3(co_no->co, co);
+       if (no_f) {
+               copy_v3_v3(co_no->no, no_f);
+       }
+       else {
+               normal_short_to_float_v3(co_no->no, no_s);
+       }
+}
+
+static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle,
+                                             ARegion *ar, const float mval_fl[2])
+{
+       struct VertProjUpdate vp_update = {vp_handle, ar, mval_fl};
+
+       Scene *scene = vp_handle->scene;
+       Object *ob = vp_handle->ob;
+       Mesh *me = ob->data;
+       DerivedMesh *dm;
+
+       /* quick sanity check - we shouldn't have to run this if there are no modifiers */
+       BLI_assert(ob->modifiers.first != NULL);
+
+       dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+
+       /* highly unlikely this will become unavailable once painting starts (perhaps with animated modifiers) */
+       if (LIKELY(dm->foreachMappedVert)) {
+               fill_vn_fl(vp_handle->dists, me->totvert, FLT_MAX);
+
+               dm->foreachMappedVert(dm, vpaint_proj_dm_map_cosnos_update__map_cb, &vp_update);
+       }
+
+       dm->release(dm);
+}
+
+
+/* -------------------------------------------------------------------- */
+/* Public Functions */
+
+struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob,
+                                                    DMCoNo **r_vcosnos)
+{
+       struct VertProjHandle *vp_handle = MEM_mallocN(sizeof(struct VertProjHandle), __func__);
+       Mesh *me = ob->data;
+
+       /* setup the handle */
+       vp_handle->vcosnos = MEM_mallocN(sizeof(DMCoNo) * me->totvert, "vertexcosnos map");
+       vp_handle->use_update = false;
+
+       /* sets 'use_update' if needed */
+       vpaint_proj_dm_map_cosnos_init(scene, ob, vp_handle);
+
+       if (vp_handle->use_update) {
+               vp_handle->dists = MEM_mallocN(sizeof(float) * me->totvert, __func__);
+
+               vp_handle->ob = ob;
+               vp_handle->scene = scene;
+       }
+       else {
+               vp_handle->dists = NULL;
+
+               vp_handle->ob = NULL;
+               vp_handle->scene = NULL;
+       }
+
+       *r_vcosnos = vp_handle->vcosnos;
+       return vp_handle;
+}
+
+void  ED_vpaint_proj_handle_update(struct VertProjHandle *vp_handle,
+                                   ARegion *ar, const float mval_fl[2])
+{
+       if (vp_handle->use_update) {
+               vpaint_proj_dm_map_cosnos_update(vp_handle, ar, mval_fl);
+       }
+}
+
+void  ED_vpaint_proj_handle_free(struct VertProjHandle *vp_handle)
+{
+       if (vp_handle->use_update) {
+               MEM_freeN(vp_handle->dists);
+       }
+
+       MEM_freeN(vp_handle->vcosnos);
+       MEM_freeN(vp_handle);
+}
index 8533dd3bc488d92797fa8f1a3a0d3889add2db4f..8e2a29964ee4f6e7b4459680db7693ace8ac23a4 100644 (file)
@@ -1528,6 +1528,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
        float *tmpgrid_mask, *tmprow_mask;
        int v1, v2, v3, v4;
        int thread_num;
+       BLI_bitmap *grid_hidden;
        int *grid_indices, totgrid, gridsize, i, x, y;
 
        sculpt_brush_test_init(ss, &test);
@@ -1538,6 +1539,8 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
                                NULL, &gridsize, &griddata, &gridadj);
        BKE_pbvh_get_grid_key(ss->pbvh, &key);
 
+       grid_hidden = BKE_pbvh_grid_hidden(ss->pbvh);
+
        thread_num = 0;
 #ifdef _OPENMP
        if (sd->flags & SCULPT_USE_OPENMP)
@@ -1549,8 +1552,10 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
        tmprow_mask = ss->cache->tmprow_mask[thread_num];
 
        for (i = 0; i < totgrid; ++i) {
-               data = griddata[grid_indices[i]];
-               adj = &gridadj[grid_indices[i]];
+               int gi = grid_indices[i];
+               BLI_bitmap gh = grid_hidden[gi];
+               data = griddata[gi];
+               adj = &gridadj[gi];
 
                if (smooth_mask)
                        memset(tmpgrid_mask, 0, sizeof(float) * gridsize * gridsize);
@@ -1611,6 +1616,11 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
                                float *mask;
                                int index;
 
+                               if (gh) {
+                                       if (BLI_BITMAP_GET(gh, y * gridsize + x))
+                                               continue;
+                               }
+
                                if (x == 0 && adj->index[0] == -1)
                                        continue;
 
index a31af851575dad27e16285be78b39b2c2f77a65c..85e4d255603693e874e8c444bcdcd6cb9e197b37 100644 (file)
@@ -667,7 +667,7 @@ bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
                                        
                                        BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
 
-                                       if (stat(path, &status) == 0) {
+                                       if (BLI_stat(path, &status) == 0) {
                                                if (S_ISDIR(status.st_mode)) { /* is subdir */
                                                        autocomplete_do_name(autocpl, path);
                                                }
index ca6bab1d1daf894a3bc074600ae92a69b46b69d2..dec61a0e1ca76b9324caf451484d1cddc55955d5 100644 (file)
@@ -486,7 +486,7 @@ static void txt_write_file(Text *text, ReportList *reports)
        
        fclose(fp);
 
-       if (stat(filepath, &st) == 0) {
+       if (BLI_stat(filepath, &st) == 0) {
                text->mtime = st.st_mtime;
        }
        else {
@@ -3107,7 +3107,7 @@ int text_file_modified(Text *text)
        if (!BLI_exists(file))
                return 2;
 
-       result = stat(file, &st);
+       result = BLI_stat(file, &st);
        
        if (result == -1)
                return -1;
@@ -3134,7 +3134,7 @@ static void text_ignore_modified(Text *text)
 
        if (!BLI_exists(file)) return;
 
-       result = stat(file, &st);
+       result = BLI_stat(file, &st);
        
        if (result == -1 || (st.st_mode & S_IFMT) != S_IFREG)
                return;
index d0a34f20c773231e33683b90465b4c69f3be7208..6a836c4af13190d8dfcaf0760c0d8fc12f5b81c6 100644 (file)
@@ -89,6 +89,7 @@ typedef struct drawEMTFMapped_userData {
 } drawEMTFMapped_userData;
 
 typedef struct drawTFace_userData {
+       Mesh *me;
        MFace *mf;
        MTFace *tf;
 } drawTFace_userData;
@@ -538,7 +539,7 @@ static void update_tface_color_layer(DerivedMesh *dm)
 
 static DMDrawOption draw_tface_mapped__set_draw(void *userData, int index)
 {
-       Mesh *me = (Mesh *)userData;
+       Mesh *me = ((drawTFace_userData *)userData)->me;
 
        /* array checked for NULL before calling */
        MPoly *mpoly = &me->mpoly[index];
@@ -735,6 +736,7 @@ static int compareDrawOptions(void *userData, int cur_index, int next_index)
        return 1;
 }
 
+
 static int compareDrawOptionsEm(void *userData, int cur_index, int next_index)
 {
        drawEMTFMapped_userData *data = userData;
@@ -777,8 +779,14 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
                if (ob->mode & OB_MODE_WEIGHT_PAINT)
                        dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me,
                                            DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH);
-               else
-                       dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me);
+               else {
+                       drawTFace_userData userData;
+
+                       userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
+                       userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
+                       userData.me = me;
+                       dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, compareDrawOptions, &userData);
+               }
        }
        else {
                if (GPU_buffer_legacy(dm)) {
@@ -794,6 +802,7 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
 
                        userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
                        userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
+                       userData.me = NULL;
 
                        dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData);
                }
index b3d58bfa1b1b9f2a2694b88bc48fe63430f55f2b..92bf8214336c25af552c801525b9a7c925632519 100644 (file)
@@ -805,7 +805,9 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN
                                case ND_NODES:
                                        if ((v3d->drawtype == OB_MATERIAL) ||
                                            (v3d->drawtype == OB_TEXTURE && scene->gm.matmode == GAME_MAT_GLSL))
+                                       {
                                                ED_region_tag_redraw(ar);
+                                       }
                                        break;
                                case ND_SHADING_DRAW:
                                case ND_SHADING_LINKS:
@@ -829,10 +831,15 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN
                        break;
                case NC_LAMP:
                        switch (wmn->data) {
-                               case ND_LIGHTING_DRAW:
+                               case ND_LIGHTING:
                                        if ((v3d->drawtype == OB_MATERIAL) ||
                                            (v3d->drawtype == OB_TEXTURE && (scene->gm.matmode == GAME_MAT_GLSL)))
+                                       {
                                                ED_region_tag_redraw(ar);
+                                       }
+                                       break;
+                               case ND_LIGHTING_DRAW:
+                                       ED_region_tag_redraw(ar);
                                        break;
                        }
                        break;
index 369051a0ab9410ed4e1e9ee799f0877c341437e1..daed039ee28ff769567f3b3f6817d9062383af7f 100644 (file)
@@ -839,12 +839,13 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
                const bool *vgroup_validmap;
                eVGroupSelect subset_type = ts->vgroupsubset;
                int yco = 0;
+               int lock_count = 0;
 
                uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL);
 
                bcol = uiLayoutColumn(pa->layout, true);
                row = uiLayoutRow(bcol, true); /* The filter button row */
-
+               
                RNA_pointer_create(NULL, &RNA_ToolSettings, ts, &tools_ptr);
                uiItemR(row, &tools_ptr, "vertex_group_subset", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
 
@@ -852,11 +853,14 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
 
                vgroup_validmap = ED_vgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count);
                for (i = 0, dg = ob->defbase.first; dg; i++, dg = dg->next) {
+                       bool locked = dg->flag & DG_LOCK_WEIGHT;
                        if (vgroup_validmap[i]) {
                                MDeformWeight *dw = defvert_find_index(dv, i);
                                if (dw) {
                                        int x, xco = 0;
-                                       row = uiLayoutRow(col, true);
+                                       int icon;
+                                       uiLayout *split = uiLayoutSplit(col, 0.45, true);
+                                       row = uiLayoutRow(split, true);
 
                                        /* The Weight Group Name */
 
@@ -871,12 +875,18 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
                                        }
                                        xco += x;
                                        
+                                       row = uiLayoutRow(split, true);
+                                       uiLayoutSetEnabled(row, !locked);
+
                                        /* The weight group value */
                                        /* To be reworked still */
                                        but = uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + i, "",
                                                        xco, yco, (x = UI_UNIT_X * 4), UI_UNIT_Y,
                                                        &dw->weight, 0.0, 1.0, 1, 3, "");
                                        uiButSetFlag(but, UI_TEXT_LEFT);
+                                       if (locked) {
+                                               lock_count++;
+                                       }
                                        xco += x;
 
                                        /* The weight group paste function */
@@ -884,14 +894,16 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
                                        ot = ot_weight_paste;
                                        WM_operator_properties_create_ptr(&op_ptr, ot);
                                        RNA_int_set(&op_ptr, "weight_group", i);
-                                       uiItemFullO_ptr(row, ot, "", ICON_PASTEDOWN, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+                                       icon = (locked) ? ICON_BLANK1:ICON_PASTEDOWN;
+                                       uiItemFullO_ptr(row, ot, "", icon, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
 
                                        /* The weight entry delete function */
 
                                        ot = ot_weight_delete;
                                        WM_operator_properties_create_ptr(&op_ptr, ot);
                                        RNA_int_set(&op_ptr, "weight_group", i);
-                                       uiItemFullO_ptr(row, ot, "", ICON_X, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+                                       icon = (locked) ? ICON_LOCKED:ICON_X;
+                                       uiItemFullO_ptr(row, ot, "", icon, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
 
                                        yco -= UI_UNIT_Y;
                                        
@@ -905,15 +917,21 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
                col = uiLayoutColumn(pa->layout, true);
                row = uiLayoutRow(col, true);
 
-               ot = WM_operatortype_find("OBJECT_OT_vertex_weight_normalize_active", 1);
+               ot = WM_operatortype_find("OBJECT_OT_vertex_weight_normalize_active_vertex", 1);
                but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, "Normalize",
-                                   0, yco,UI_UNIT_X * 5, UI_UNIT_Y,
-                                   TIP_("Normalize active vertex weights"));
+                                   0, yco, UI_UNIT_X * 5, UI_UNIT_Y,
+                                   TIP_("Normalize weights of active vertex (if affected groups are unlocked"));
+               if (lock_count) {
+                       uiButSetFlag(but, UI_BUT_DISABLED);
+               }
 
                ot = WM_operatortype_find("OBJECT_OT_vertex_weight_copy", 1);
                but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, "Copy",
-                                   UI_UNIT_X * 5, yco,UI_UNIT_X * 5, UI_UNIT_Y,
-                                   TIP_("Copy active vertex to other selected verts"));
+                                   UI_UNIT_X * 5, yco, UI_UNIT_X * 5, UI_UNIT_Y,
+                                   TIP_("Copy active vertex to other selected verts (if affected groups are unlocked)"));
+               if (lock_count) {
+                       uiButSetFlag(but, UI_BUT_DISABLED);
+               }
 
        }
 }
index 6bab677fb61db227a0db1b2ce336ddc02f4b566a..659c9a6c2e679002cbec4dc2377702e57571791c 100644 (file)
@@ -345,7 +345,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
 
        fly->rv3d->rflag |= RV3D_NAVIGATING; /* so we draw the corner margins */
 
-       /* detect weather to start with Z locking */
+       /* detect whether to start with Z locking */
        upvec[0] = 1.0f;
        upvec[1] = 0.0f;
        upvec[2] = 0.0f;
index 8972229d6184063625f5ba1ba30db67946087d65..5059e3bcc401d874d4128f1bce9cef0ad566a4f1 100644 (file)
@@ -1651,7 +1651,7 @@ void BIF_draw_manipulator(const bContext *C)
                if (v3d->twtype & V3D_MANIP_ROTATE) {
 
                        if (G.debug_value == 3) {
-                               if (G.moving & (G_TRANSFORM_OBJ|G_TRANSFORM_EDIT))
+                               if (G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT))
                                        draw_manipulator_rotate_cyl(v3d, rv3d, 1, drawflags, v3d->twtype, MAN_MOVECOL);
                                else
                                        draw_manipulator_rotate_cyl(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB);
index 79321cafefebd1aa7292a8006ab6c8d825de3abb..9af65765fcde8901202230e52594ef84d7115d9c 100644 (file)
@@ -99,7 +99,7 @@ public:
         *  \param copy
         *    If false, the data is not duplicated, and Canvas deals with the memory management of these
         *    _nbOrientations+1 images. If true, data is copied, and it's up to the caller to delete the images.
-        *  \params iNbLevels
+        *  \param iNbLevels
         *    The number of levels desired for each pyramid.
         *    If iNbLevels == 0, the complete pyramid is built.
         *  \param iSigma
index f9e1babcb56c92ec1e27eea1630614f2e15c724a..e244c7cf57fc0d00dcec66d8e14b4cc52d19efb7 100644 (file)
@@ -567,7 +567,7 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
                                        "tmp", input->link->output->id);
                        }
                        else if (input->source == GPU_SOURCE_BUILTIN) {
-                               if(input->builtin == GPU_VIEW_NORMAL)
+                               if (input->builtin == GPU_VIEW_NORMAL)
                                        BLI_dynstr_append(ds, "facingnormal");
                                else
                                        BLI_dynstr_append(ds, GPU_builtin_name(input->builtin));
@@ -615,7 +615,7 @@ static char *code_generate_fragment(ListBase *nodes, GPUOutput *output, const ch
        BLI_dynstr_append(ds, "void main(void)\n");
        BLI_dynstr_append(ds, "{\n");
 
-       if(builtins & GPU_VIEW_NORMAL)
+       if (builtins & GPU_VIEW_NORMAL)
                BLI_dynstr_append(ds, "\tvec3 facingnormal = (gl_FrontFacing)? varnormal: -varnormal;\n");
                
 
index e98f8988aa6755cd1ebfca1c52affb0cc165c23f..cfdbf87785e6ef5e34d9f426594afe08492a5c6d 100644 (file)
@@ -932,6 +932,77 @@ void GPU_paint_set_mipmap(int mipmap)
        }
 }
 
+
+/* check if image has been downscaled and do scaled partial update */
+static bool GPU_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x, int y, int w, int h)
+{
+       if ((!GPU_non_power_of_two_support() && !is_power_of_2_resolution(ibuf->x, ibuf->y)) ||
+           is_over_resolution_limit(ibuf->x, ibuf->y))
+       {
+               int x_limit = smaller_power_of_2_limit(ibuf->x);
+               int y_limit = smaller_power_of_2_limit(ibuf->y);
+
+               float xratio = x_limit / (float)ibuf->x;
+               float yratio = y_limit / (float)ibuf->y;
+
+               /* find new width, height and x,y gpu texture coordinates */
+
+               /* take ceiling because we will be losing 1 pixel due to rounding errors in x,y... */
+               int rectw = (int)ceil(xratio * w);
+               int recth = (int)ceil(yratio * h);
+
+               x *= xratio;
+               y *= yratio;
+
+               /* ...but take back if we are over the limit! */
+               if (rectw + x > x_limit) rectw--;
+               if (recth + y > y_limit) recth--;
+
+               /* float rectangles are already continuous in memory so we can use gluScaleImage */
+               if (frect) {
+                       float *fscalerect = MEM_mallocN(rectw*recth*sizeof(*fscalerect)*4, "fscalerect");
+                       gluScaleImage(GL_RGBA, w, h, GL_FLOAT, frect, rectw, recth, GL_FLOAT, fscalerect);
+
+                       glBindTexture(GL_TEXTURE_2D, ima->bindcode);
+                       glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA,
+                                       GL_FLOAT, fscalerect);
+
+                       MEM_freeN(fscalerect);
+               }
+               /* byte images are not continuous in memory so do manual interpolation */
+               else {
+                       unsigned char *scalerect = MEM_mallocN(rectw * recth * sizeof(*scalerect) * 4, "scalerect");
+                       unsigned int *p = (unsigned int *)scalerect;
+                       int i, j;
+                       float inv_xratio = 1.0f / xratio;
+                       float inv_yratio = 1.0f / yratio;
+                       for (i = 0; i < rectw; i++) {
+                               float u = (x + i) * inv_xratio;
+                               for (j = 0; j < recth; j++) {
+                                       float v = (y + j) * inv_yratio;
+                                       bilinear_interpolation_color_wrap(ibuf, (unsigned char *)(p + i + j * (rectw)), NULL, u, v);
+                               }
+                       }
+                       glBindTexture(GL_TEXTURE_2D, ima->bindcode);
+                       glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA,
+                                       GL_UNSIGNED_BYTE, scalerect);
+
+                       MEM_freeN(scalerect);
+               }
+
+               if (GPU_get_mipmap()) {
+                       gpu_generate_mipmap(GL_TEXTURE_2D);
+               }
+               else {
+                       ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+               }
+
+               return true;
+       }
+
+       return false;
+}
+
 void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
 {
        ImBuf *ibuf;
@@ -959,6 +1030,15 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
                        int is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA);
                        IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data);
 
+                       if (GPU_check_scaled_image(ibuf, ima, buffer, x, y, w, h)) {
+                               MEM_freeN(buffer);
+                               glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
+                               glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
+                               glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
+                               BKE_image_release_ibuf(ima, ibuf, NULL);
+                               return;
+                       }
+
                        glBindTexture(GL_TEXTURE_2D, ima->bindcode);
                        glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
                                        GL_FLOAT, buffer);
@@ -977,7 +1057,15 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
                        BKE_image_release_ibuf(ima, ibuf, NULL);
                        return;
                }
-               
+
+               if (GPU_check_scaled_image(ibuf, ima, NULL, x, y, w, h)) {
+                       glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
+                       glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
+                       glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
+                       BKE_image_release_ibuf(ima, ibuf, NULL);
+                       return;
+               }
+
                glBindTexture(GL_TEXTURE_2D, ima->bindcode);
 
                glPixelStorei(GL_UNPACK_ROW_LENGTH, ibuf->x);
index 44358d8147eb30fbd64cee174e8f706b6af50c32..59b78109aaf8039ed6f8e9c3f29fce8ff9d088f3 100644 (file)
@@ -319,7 +319,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
                                }
 
                                if (img != NULL) {
-                                       stat(path, &info);
+                                       BLI_stat(path, &info);
                                        BLI_snprintf(mtime, sizeof(mtime), "%ld", (long int)info.st_mtime);
                                        BLI_snprintf(cwidth, sizeof(cwidth), "%d", img->x);
                                        BLI_snprintf(cheight, sizeof(cheight), "%d", img->y);
@@ -339,7 +339,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
                                        }
                                        IMB_free_anim(anim);
                                }
-                               stat(path, &info);
+                               BLI_stat(path, &info);
                                BLI_snprintf(mtime, sizeof(mtime), "%ld", (long int)info.st_mtime);
                        }
                        if (!img) return NULL;
index fa1316f631fe2b0b0702f4e37df3e91567fbe9a7..234d80bf7822d4c4b7d8913ce2249e642e4e14f0 100644 (file)
@@ -164,7 +164,7 @@ static int IMB_ispic_name(const char *name)
 
        if (UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name);
        
-       if (stat(name, &st) == -1)
+       if (BLI_stat(name, &st) == -1)
                return FALSE;
        if (((st.st_mode) & S_IFMT) != S_IFREG)
                return FALSE;
index 4783247420cfea4d047fb182e5f62ca529c23087..0a09a82b2bb7ceefaa8eb84aaba2f92e1e7ea7d6 100644 (file)
@@ -125,7 +125,8 @@ enum {
 enum {
        KEY_LINEAR      = 0,
        KEY_CARDINAL    = 1,
-       KEY_BSPLINE     = 2
+       KEY_BSPLINE     = 2,
+       KEY_CATMULL_ROM = 3,
 };
 
 /* KeyBlock->flag */
index 3a2677c83983799e7352214b28a07a9951bc93ff..49d760adb326eb67761fd4cd8e365d50e3ce7f63 100644 (file)
@@ -458,6 +458,7 @@ static char *rna_ShapeKeyPoint_path(PointerRNA *ptr)
 EnumPropertyItem keyblock_type_items[] = {
        {KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""},
        {KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""},
+       {KEY_CATMULL_ROM, "KEY_CATMULL_ROM", 0, "Catmull-Rom", ""},
        {KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""},
        {0, NULL, 0, NULL, NULL}
 };
index d733d9b4cb6647d0c07553b534e979c617e77114..ffc9ac0e52ec8d0825cd87f99afbaea115a018d9 100644 (file)
@@ -136,10 +136,7 @@ static void rna_Lamp_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
        Lamp *la = ptr->id.data;
 
        DAG_id_tag_update(&la->id, 0);
-       if (scene->gm.matmode == GAME_MAT_GLSL)
-               WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, la);
-       else
-               WM_main_add_notifier(NC_LAMP | ND_LIGHTING, la);
+       WM_main_add_notifier(NC_LAMP | ND_LIGHTING, la);
 }
 
 static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
index 4292246d8ccbf825a93570e5e8689387791a950a..848f7ee0fc1d56eaed9c5ce1d59a01e515cae372 100644 (file)
@@ -118,12 +118,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
                                                         cddm->getVertArray(cddm),
                                                         mdisps);
 
-                               BKE_mesh_flush_hidden_from_verts(cddm->getVertArray(cddm),
-                                                                cddm->getLoopArray(cddm),
-                                                                cddm->getEdgeArray(cddm),
-                                                                cddm->getNumEdges(cddm),
-                                                                cddm->getPolyArray(cddm),
-                                                                cddm->getNumPolys(cddm));
+                               BKE_mesh_flush_hidden_from_verts_ex(cddm->getVertArray(cddm),
+                                                                   cddm->getLoopArray(cddm),
+                                                                   cddm->getEdgeArray(cddm),
+                                                                   cddm->getNumEdges(cddm),
+                                                                   cddm->getPolyArray(cddm),
+                                                                   cddm->getNumPolys(cddm));
                        }
                        if (grid_paint_mask) {
                                float *paint_mask = CustomData_add_layer(&cddm->vertData,
index 99fd3429973525bd5a3b69de463b950608f96da7..c7b10d0aa4bcada1556038ae7b7e528538a6ac1a 100644 (file)
@@ -138,6 +138,12 @@ static PyObject *bpy_bm_update_edit_mesh(PyObject *UNUSED(self), PyObject *args,
 
        {
                extern void EDBM_update_generic(BMEditMesh *em, const bool do_tessface, const bool is_destructive);
+               BMEditMesh *em = me->edit_btmesh;
+               BMesh *bm = em->bm;
+
+               /* python won't ensure matching uv/mtex */
+               BM_mesh_cd_validate(bm);
+
                EDBM_update_generic(me->edit_btmesh, do_tessface, is_destructive);
        }
 
index 6ea8d6c68ce62213a695c1291eb6fe23edf5a071..0db8b07d5f50b44259238417d9995c55fa5287dd 100644 (file)
@@ -907,6 +907,9 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args)
 
        bm = self->bm;
 
+       /* python won't ensure matching uv/mtex */
+       BM_mesh_cd_validate(bm);
+
        BM_mesh_bm_to_me(bm, me, false);
 
        /* we could have the user do this but if they forget blender can easy crash
index 62c0ced9eab92d6b1e311678b9d0a7506e26ae1d..ee5f6109ab89e56ebdf056a873d2f68c125ca4c9 100644 (file)
@@ -74,13 +74,14 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
        /* not the last dimension */
        if (dim + 1 < totdim) {
                /* check that a sequence contains dimsize[dim] items */
-               const Py_ssize_t seq_size = PySequence_Size(seq);
+               const int seq_size = PySequence_Size(seq);
                if (seq_size == -1) {
                        PyErr_Format(PyExc_ValueError, "%s sequence expected at dimension %d, not '%s'",
-                                    error_prefix, (int)dim + 1, Py_TYPE(seq)->tp_name);
+                                    error_prefix, dim + 1, Py_TYPE(seq)->tp_name);
                        return -1;
                }
                for (i = 0; i < seq_size; i++) {
+                       Py_ssize_t item_seq_size;
                        PyObject *item;
                        int ok = 1;
                        item = PySequence_GetItem(seq, i);
@@ -90,7 +91,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
                                             error_prefix, Py_TYPE(seq)->tp_name, i);
                                ok = 0;
                        }
-                       else if (!PySequence_Check(item)) {
+                       else if ((item_seq_size = PySequence_Size(item)) == -1) {
                                /* BLI_snprintf(error_str, error_str_size, "expected a sequence of %s", item_type_str); */
                                PyErr_Format(PyExc_TypeError, "%s expected a sequence of %s, not %s",
                                             error_prefix, item_type_str, Py_TYPE(item)->tp_name);
@@ -101,12 +102,12 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
                         * dimsize[2] = 5
                         *
                         * dim = 0 */
-                       else if (PySequence_Size(item) != dimsize[dim + 1]) {
+                       else if (item_seq_size != dimsize[dim + 1]) {
                                /* BLI_snprintf(error_str, error_str_size,
                                 *              "sequences of dimension %d should contain %d items",
-                                *              (int)dim + 1, (int)dimsize[dim + 1]); */
-                               PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items",
-                                            error_prefix, (int)dim + 1, (int)dimsize[dim + 1]);
+                                *              dim + 1, dimsize[dim + 1]); */
+                               PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items, not %d",
+                                            error_prefix, dim + 1, dimsize[dim + 1], item_seq_size);
                                ok = 0;
                        }
                        else if (validate_array_type(item, dim + 1, totdim, dimsize, check_item_type, item_type_str, error_prefix) == -1) {
@@ -125,9 +126,15 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
                const int seq_size = PySequence_Size(seq);
                if (seq_size == -1) {
                        PyErr_Format(PyExc_ValueError, "%s sequence expected at dimension %d, not '%s'",
-                                    error_prefix, (int)dim + 1, Py_TYPE(seq)->tp_name);
+                                    error_prefix, dim + 1, Py_TYPE(seq)->tp_name);
                        return -1;
                }
+               else if (seq_size != dimsize[dim]) {
+                       PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items, not %d",
+                                    error_prefix, dim, dimsize[dim], seq_size);
+                       return -1;
+               }
+
                for (i = 0; i < seq