Merged revision(s) 58859-58993 from trunk/blender into soc-2013-dingto.
authorThomas Dinges <blender@dingto.org>
Wed, 7 Aug 2013 16:57:18 +0000 (16:57 +0000)
committerThomas Dinges <blender@dingto.org>
Wed, 7 Aug 2013 16:57:18 +0000 (16:57 +0000)
250 files changed:
doc/python_api/rst/bge_types/bge.types.KX_Camera.rst
intern/cycles/CMakeLists.txt
intern/cycles/kernel/kernel_accumulate.h
intern/cycles/kernel/kernel_light.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/osl/osl_globals.h
intern/cycles/kernel/osl/osl_services.cpp
intern/cycles/kernel/osl/osl_shader.cpp
intern/cycles/kernel/svm/svm_blackbody.h
intern/cycles/kernel/svm/svm_fresnel.h
intern/cycles/render/blackbody.cpp
intern/cycles/render/light.cpp
intern/cycles/render/nodes.cpp
intern/dualcon/dualcon.h
intern/dualcon/intern/GeoCommon.h
intern/dualcon/intern/MemoryAllocator.h
intern/dualcon/intern/ModelReader.h
intern/dualcon/intern/Projections.cpp
intern/dualcon/intern/Projections.h
intern/dualcon/intern/Queue.h
intern/dualcon/intern/cubes.h
intern/dualcon/intern/dualcon_c_api.cpp
intern/dualcon/intern/manifold_table.h
intern/dualcon/intern/marching_cubes_table.h
intern/dualcon/intern/octree.cpp
intern/dualcon/intern/octree.h
intern/guardedalloc/MEM_guardedalloc.h
intern/guardedalloc/intern/mallocn.c
intern/mikktspace/mikktspace.c
intern/rigidbody/rb_bullet_api.cpp
release/scripts/modules/bl_i18n_utils/utils_spell_check.py
release/scripts/presets/keyconfig/3dsmax.py
release/scripts/presets/keyconfig/maya.py
source/blender/avi/intern/avi_mjpeg.c
source/blender/blenfont/BLF_api.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/fmodifier.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/image_gen.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/movieclip.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/navmesh_conversion.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/pbvh.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenkernel/intern/sketch.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/BLI_buffer.h
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/BLI_memarena.h
source/blender/blenlib/BLI_mempool.h
source/blender/blenlib/BLI_string.h
source/blender/blenlib/intern/BLI_heap.c
source/blender/blenlib/intern/BLI_mempool.c
source/blender/blenlib/intern/buffer.c
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/scanfill.c
source/blender/blenlib/intern/voronoi.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/runtime.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_core.c
source/blender/bmesh/intern/bmesh_edgeloop.c
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/intern/bmesh_polygon.c
source/blender/bmesh/intern/bmesh_polygon.h
source/blender/bmesh/intern/bmesh_private.h
source/blender/bmesh/intern/bmesh_queries.c
source/blender/bmesh/intern/bmesh_queries.h
source/blender/bmesh/intern/bmesh_structure.c
source/blender/bmesh/intern/bmesh_structure.h
source/blender/bmesh/intern/bmesh_walkers.c
source/blender/bmesh/operators/bmo_create.c
source/blender/bmesh/operators/bmo_edgenet.c
source/blender/bmesh/operators/bmo_smooth_laplacian.c
source/blender/bmesh/operators/bmo_wireframe.c
source/blender/bmesh/tools/bmesh_decimate_collapse.c
source/blender/bmesh/tools/bmesh_decimate_dissolve.c
source/blender/compositor/CMakeLists.txt
source/blender/compositor/COM_compositor.h
source/blender/compositor/intern/COM_ExecutionGroup.cpp
source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
source/blender/compositor/nodes/COM_RenderLayersNode.cpp
source/blender/compositor/nodes/COM_SplitViewerNode.cpp
source/blender/compositor/operations/COM_SplitOperation.cpp [moved from source/blender/compositor/operations/COM_SplitViewerOperation.cpp with 62% similarity]
source/blender/compositor/operations/COM_SplitOperation.h [moved from source/blender/compositor/operations/COM_SplitViewerOperation.h with 78% similarity]
source/blender/compositor/operations/COM_ViewerBaseOperation.cpp [deleted file]
source/blender/compositor/operations/COM_ViewerBaseOperation.h [deleted file]
source/blender/compositor/operations/COM_ViewerOperation.cpp
source/blender/compositor/operations/COM_ViewerOperation.h
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/armature/armature_select.c
source/blender/editors/armature/pose_transform.c
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_ops.c
source/blender/editors/interface/resources.c
source/blender/editors/mask/mask_select.c
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_navmesh.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_modifier.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/area.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_node/node_add.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/drawvolume.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/freestyle/intern/application/AppView.h
source/blender/freestyle/intern/application/Controller.h
source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
source/blender/freestyle/intern/blender_interface/BlenderTextureManager.h
source/blender/freestyle/intern/geometry/BBox.h
source/blender/freestyle/intern/geometry/FastGrid.h
source/blender/freestyle/intern/geometry/Grid.h
source/blender/freestyle/intern/geometry/Noise.h
source/blender/freestyle/intern/geometry/Polygon.h
source/blender/freestyle/intern/geometry/SweepLine.h
source/blender/freestyle/intern/geometry/VecMat.h
source/blender/freestyle/intern/geometry/normal_cycle.h
source/blender/freestyle/intern/image/GaussianFilter.h
source/blender/freestyle/intern/image/Image.h
source/blender/freestyle/intern/scene_graph/DrawingStyle.h
source/blender/freestyle/intern/scene_graph/FrsMaterial.h
source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
source/blender/freestyle/intern/scene_graph/LineRep.h
source/blender/freestyle/intern/scene_graph/Node.h
source/blender/freestyle/intern/scene_graph/NodeCamera.h
source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
source/blender/freestyle/intern/stroke/Module.h
source/blender/freestyle/intern/stroke/Operators.h
source/blender/freestyle/intern/stroke/Predicates0D.h
source/blender/freestyle/intern/stroke/Stroke.h
source/blender/freestyle/intern/stroke/StrokeRenderer.h
source/blender/freestyle/intern/stroke/StrokeRep.h
source/blender/freestyle/intern/stroke/StrokeTesselator.h
source/blender/freestyle/intern/stroke/StyleModule.h
source/blender/freestyle/intern/system/BaseIterator.h
source/blender/freestyle/intern/system/BaseObject.h
source/blender/freestyle/intern/system/Exception.h
source/blender/freestyle/intern/system/Id.h
source/blender/freestyle/intern/system/Interpreter.h
source/blender/freestyle/intern/system/ProgressBar.h
source/blender/freestyle/intern/system/PseudoNoise.h
source/blender/freestyle/intern/system/RandGen.h
source/blender/freestyle/intern/system/RenderMonitor.h
source/blender/freestyle/intern/system/TimeStamp.h
source/blender/freestyle/intern/system/TimeUtils.h
source/blender/freestyle/intern/view_map/BoxGrid.h
source/blender/freestyle/intern/view_map/FEdgeXDetector.h
source/blender/freestyle/intern/view_map/Functions1D.h
source/blender/freestyle/intern/view_map/GridDensityProvider.h
source/blender/freestyle/intern/view_map/Interface1D.h
source/blender/freestyle/intern/view_map/OccluderSource.h
source/blender/freestyle/intern/view_map/SphericalGrid.h
source/blender/freestyle/intern/view_map/SteerableViewMap.h
source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
source/blender/freestyle/intern/view_map/ViewMap.h
source/blender/freestyle/intern/view_map/ViewMapBuilder.h
source/blender/freestyle/intern/view_map/ViewMapIterators.h
source/blender/freestyle/intern/view_map/ViewMapTesselator.h
source/blender/freestyle/intern/winged_edge/WEdge.h
source/blender/freestyle/intern/winged_edge/WFillGrid.h
source/blender/freestyle/intern/winged_edge/WSFillGrid.h
source/blender/freestyle/intern/winged_edge/WXEdge.h
source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
source/blender/imbuf/intern/colormanagement.c
source/blender/makesrna/SConscript
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/SConscript
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_dynamicpaint.c
source/blender/makesrna/intern/rna_gpencil.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_scene.c
source/blender/modifiers/intern/MOD_boolean_util.c
source/blender/modifiers/intern/MOD_decimate.c
source/blender/modifiers/intern/MOD_laplaciansmooth.c
source/blender/modifiers/intern/MOD_skin.c
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_weightvgedit.c
source/blender/modifiers/intern/MOD_weightvgproximity.c
source/blender/python/bmesh/bmesh_py_ops.c
source/blender/python/bmesh/bmesh_py_types_meshdata.c
source/blender/python/intern/bpy_rna.c
source/blender/render/intern/source/bake.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/initrender.c
source/blender/render/intern/source/multires_bake.c
source/blender/render/intern/source/occlusion.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pointdensity.c
source/blender/render/intern/source/rayshade.c
source/blender/render/intern/source/render_result.c
source/blender/render/intern/source/render_texture.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/strand.c
source/blender/render/intern/source/zbuf.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_subwindow.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/Converter/BL_ArmatureConstraint.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.cpp
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Converter/KX_ConvertSensors.cpp
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/Ketsji/KX_Camera.cpp
source/gameengine/Ketsji/KX_Camera.h
source/gameengine/Ketsji/KX_MeshProxy.cpp
source/gameengine/Ketsji/KX_NavMeshObject.cpp
source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
source/gameengine/Ketsji/KX_PolyProxy.h
source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
source/gameengine/Rasterizer/RAS_2DFilterManager.h

index baf60ec0c970580d0c9543f47bd5e5340266fcb6..0baba5c33591475a05358ce3add5bf112049776f 100644 (file)
@@ -27,6 +27,12 @@ base class --- :class:`KX_GameObject`
 
       :type: float
 
+   .. attribute:: fov
+
+      The camera's field of view value.
+
+      :type: float
+
    .. attribute:: ortho_scale
 
       The camera's view scale when in orthographic mode.
index 82029e3a7af8194db8a2b4b880e1662d0ab3027a..d83ff20f5386004ff3be14924e2768cb7e830aab 100644 (file)
@@ -19,8 +19,8 @@ if(WIN32 AND MSVC)
 
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox")
-       set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} /Ox")
-       set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} /Ox")
+       set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Ox")
+       set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Ox")
 elseif(CMAKE_COMPILER_IS_GNUCC)
        set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2 -mfpmath=sse")
        set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse")
index ca420909bc78a426d88bd0b2d3c908bf1eee0267..fb11cbd395f6bbf169075ab4fa0e5c53add6dc86 100644 (file)
@@ -286,7 +286,7 @@ __device_inline void path_radiance_sum_indirect(PathRadiance *L)
 #ifdef __PASSES__
        /* this division is a bit ugly, but means we only have to keep track of
         * only a single throughput further along the path, here we recover just
-        * the indirect parth that is not influenced by any particular BSDF type */
+        * the indirect path that is not influenced by any particular BSDF type */
        if(L->use_light_pass) {
                L->direct_emission = safe_divide_color(L->direct_emission, L->direct_throughput);
                L->direct_diffuse += L->path_diffuse*L->direct_emission;
index 5091eac41db6f4a34ee93de0fa11129161a2f767..e25d4c208858eb4fc604d17b3572d14fc7c1f84c 100644 (file)
@@ -375,7 +375,7 @@ __device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, f
                ls->pdf = invarea;
 
                if(type == LIGHT_SPOT) {
-                       /* spot light attentuation */
+                       /* spot light attenuation */
                        float4 data2 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 2);
                        ls->eval_fac *= spot_light_attenuation(data1, data2, ls);
 
index 03ca04ec132203cdca6afff83a8f956c18776695..0608dad5c05a02326410e7cb37867aefbe9d6d05 100644 (file)
@@ -44,11 +44,11 @@ CCL_NAMESPACE_BEGIN
 #define BSSRDF_MIN_RADIUS                      1e-8f
 #define BSSRDF_MAX_ATTEMPTS                    8
 
-#define BB_DRAPPER                             800.0
-#define BB_MAX_TABLE_RANGE             12000.0
-#define BB_TABLE_XPOWER                        1.5
-#define BB_TABLE_YPOWER                        5.0
-#define BB_TABLE_SPACING               2.0
+#define BB_DRAPPER                             800.0f
+#define BB_MAX_TABLE_RANGE             12000.0f
+#define BB_TABLE_XPOWER                        1.5f
+#define BB_TABLE_YPOWER                        5.0f
+#define BB_TABLE_SPACING               2.0f
 
 #define TEX_NUM_FLOAT_IMAGES   5
 
@@ -833,7 +833,7 @@ typedef struct KernelBSSRDF {
 typedef struct KernelBlackbody {
        int table_offset;
        int pad1, pad2, pad3;
-} KernelBLACKBODY;
+} KernelBlackbody;
 
 
 typedef struct KernelData {
index fb5691176988209aed0c13aae4916ab5a0ec2d11..c52b39026795a9c9267b2d7ddb2bdae4f7c620ab 100644 (file)
@@ -87,9 +87,10 @@ struct OSLTraceData {
 /* thread key for thread specific data lookup */
 struct OSLThreadData {
        OSL::ShaderGlobals globals;
-       OSL::PerThreadInfo *thread_info;
+       OSL::PerThreadInfo *osl_thread_info;
        OSLTraceData tracedata;
        OSL::ShadingContext *context[SHADER_CONTEXT_NUM];
+       OIIO::TextureSystem::Perthread *oiio_thread_info;
 };
 
 CCL_NAMESPACE_END
index f3b79da88944709407c2da458d769476fffc06d9..95cd73c6019e948f21d22d384094d749cc26e2ba 100644 (file)
@@ -775,7 +775,15 @@ bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
                                 float dsdy, float dtdy, float *result)
 {
        OSL::TextureSystem *ts = osl_ts;
-       bool status = ts->texture(filename, options, s, t, dsdx, dtdx, dsdy, dtdy, result);
+       ShaderData *sd = (ShaderData *)(sg->renderstate);
+       KernelGlobals *kg = sd->osl_globals;
+       OSLThreadData *tdata = kg->osl_tdata;
+       OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
+
+       OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
+
+       bool status = ts->texture(th, thread_info,
+                                 options, s, t, dsdx, dtdx, dsdy, dtdy, result);
 
        if(!status) {
                if(options.nchannels == 3 || options.nchannels == 4) {
@@ -797,7 +805,15 @@ bool OSLRenderServices::texture3d(ustring filename, TextureOpt &options,
                                   const OSL::Vec3 &dPdz, float *result)
 {
        OSL::TextureSystem *ts = osl_ts;
-       bool status = ts->texture3d(filename, options, P, dPdx, dPdy, dPdz, result);
+       ShaderData *sd = (ShaderData *)(sg->renderstate);
+       KernelGlobals *kg = sd->osl_globals;
+       OSLThreadData *tdata = kg->osl_tdata;
+       OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
+
+       OIIO::TextureSystem::TextureHandle *th =  ts->get_texture_handle(filename, thread_info);
+
+       bool status = ts->texture3d(th, thread_info,
+                                   options, P, dPdx, dPdy, dPdz, result);
 
        if(!status) {
                if(options.nchannels == 3 || options.nchannels == 4) {
@@ -819,7 +835,14 @@ bool OSLRenderServices::environment(ustring filename, TextureOpt &options,
                                     const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, float *result)
 {
        OSL::TextureSystem *ts = osl_ts;
-       bool status = ts->environment(filename, options, R, dRdx, dRdy, result);
+       ShaderData *sd = (ShaderData *)(sg->renderstate);
+       KernelGlobals *kg = sd->osl_globals;
+       OSLThreadData *tdata = kg->osl_tdata;
+       OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
+
+       OIIO::TextureSystem::TextureHandle *th =  ts->get_texture_handle(filename, thread_info);
+       bool status = ts->environment(th, thread_info,
+                                     options, R, dRdx, dRdy, result);
 
        if(!status) {
                if(options.nchannels == 3 || options.nchannels == 4) {
index 0b0c8ab2e3c351755da18558b4d8e7f78e8a2f23..dedda1dc10ea6bc9c0bf9e941cdecdc5a30799f8 100644 (file)
@@ -55,10 +55,12 @@ void OSLShader::thread_init(KernelGlobals *kg, KernelGlobals *kernel_globals, OS
        memset(&tdata->globals, 0, sizeof(OSL::ShaderGlobals));
        tdata->globals.tracedata = &tdata->tracedata;
        tdata->globals.flipHandedness = false;
-       tdata->thread_info = ss->create_thread_info();
+       tdata->osl_thread_info = ss->create_thread_info();
 
        for(int i = 0; i < SHADER_CONTEXT_NUM; i++)
-               tdata->context[i] = ss->get_context(tdata->thread_info);
+               tdata->context[i] = ss->get_context(tdata->osl_thread_info);
+
+       tdata->oiio_thread_info = osl_globals->ts->get_perthread_info();
 
        kg->osl_ss = (OSLShadingSystem*)ss;
        kg->osl_tdata = tdata;
@@ -75,7 +77,7 @@ void OSLShader::thread_free(KernelGlobals *kg)
        for(int i = 0; i < SHADER_CONTEXT_NUM; i++)
                ss->release_context(tdata->context[i]);
 
-       ss->destroy_thread_info(tdata->thread_info);
+       ss->destroy_thread_info(tdata->osl_thread_info);
 
        delete tdata;
 
index 3c6e11ca683237362af09c2d808dfb00471c96d6..2fc2c770a8328e2ef2baf4591531908b6deed1e3 100644 (file)
@@ -53,7 +53,7 @@ __device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack
 
                /* reconstruct a proper index for the table lookup, compared to OSL we don't look up two colors
                just one (the OSL-lerp is also automatically done for us by "lookup_table_read") */
-               float t = powf((temperature - BB_DRAPPER) * (1.0f / BB_TABLE_SPACING), 1.0f/BB_TABLE_XPOWER);
+               float t = powf((temperature - BB_DRAPPER) * (1.0f / BB_TABLE_SPACING), (1.0f / BB_TABLE_XPOWER));
 
                int blackbody_table_offset = kernel_data.blackbody.table_offset;
 
index 492e6070dfd1cc3b2674367c3824091df93a0b7f..48cbc54d915344fe166aa0b825b44ce895fffc8c 100644 (file)
@@ -31,7 +31,7 @@ __device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, ui
        stack_store_float(stack, out_offset, f);
 }
 
-/* Blend Weight Node */
+/* Layer Weight Node */
 
 __device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
 {
index 467368935d7c8053e810e19f2cc842d0604955f3..ab61886e262f232a5c323515af513c2184e71651 100644 (file)
@@ -91,7 +91,7 @@ vector<float> blackbody_table()
        const double c1 = 3.74183e-16; // 2*pi*h*c^2, W*m^2
        const double c2 = 1.4388e-2;   // h*c/k, m*K
                                                                   // h is Planck's const, k is Boltzmann's
-       const float dlambda = 5.0f * 1e-9;  // in meters
+       const float dlambda = 5.0f * 1e-9f;  // in meters
 
        /* Blackbody table from 800 to 12k Kelvin (319 entries (317+2 offset) * 3) */
        vector<float> blackbody_table(956);
@@ -100,7 +100,7 @@ vector<float> blackbody_table()
 
        /* ToDo: bring this back to what OSL does with the lastTemperature limit ? */
        for (int i = 0;  i <= 317;  ++i) {
-               float Temperature = powf (float(i), BB_TABLE_XPOWER) * BB_TABLE_SPACING + BB_DRAPPER;
+               double Temperature = pow((double)i, (double)BB_TABLE_XPOWER) * (double)BB_TABLE_SPACING + (double)BB_DRAPPER;
                X = 0;
                Y = 0;
                Z = 0;
@@ -108,10 +108,10 @@ vector<float> blackbody_table()
                /* from OSL "spectrum_to_XYZ" */
                for (int n = 0; n < 81; ++n) {
                        float lambda = 380.0f + 5.0f * n;
-                       double wlm = lambda * 1e-9;   // Wavelength in meters
+                       double wlm = lambda * 1e-9f;   // Wavelength in meters
                        // N.B. spec_intens returns result in W/m^2 but it's a differential,
                        // needs to be scaled by dlambda!
-                       float spec_intens = float((c1 * powf(wlm,-5.0)) / (expf(c2 / (wlm * Temperature)) -1.0f));
+                       float spec_intens = float((c1 * pow(wlm, -5.0)) / (exp(c2 / (wlm * Temperature)) -1.0));
                        float Me = spec_intens * dlambda;
 
                        X += Me * cie_colour_match[n][0];
index 8b831c25d28cbe51f7c3d1d186f57273bde901a2..96eabe75ff78e630215f53a57af88c5327d418a2 100644 (file)
@@ -517,7 +517,6 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
        for(size_t i = 0; i < scene->lights.size(); i++) {
                Light *light = scene->lights[i];
                float3 co = light->co;
-               float3 dir = normalize(light->dir);
                int shader_id = scene->shader_manager->get_shader_id(scene->lights[i]->shader);
                float samples = __int_as_float(light->samples);
 
@@ -559,6 +558,10 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
                        float cosangle = cosf(angle);
                        float area = M_PI_F*radius*radius;
                        float invarea = (area > 0.0f)? 1.0f/area: 1.0f;
+                       float3 dir = light->dir;
+                       
+                       if(len(dir) > 0.0f)
+                               dir = normalize(dir);
 
                        if(light->use_mis && area > 0.0f)
                                shader_id |= SHADER_USE_MIS;
@@ -597,6 +600,10 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
                        float3 axisv = light->axisv*(light->sizev*light->size);
                        float area = len(axisu)*len(axisv);
                        float invarea = (area > 0.0f)? 1.0f/area: 1.0f;
+                       float3 dir = light->dir;
+                       
+                       if(len(dir) > 0.0f)
+                               dir = normalize(dir);
 
                        if(light->use_mis && area > 0.0f)
                                shader_id |= SHADER_USE_MIS;
@@ -613,6 +620,10 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
                        float invarea = (radius > 0.0f)? 1.0f/(M_PI_F*radius*radius): 1.0f;
                        float spot_angle = cosf(light->spot_angle*0.5f);
                        float spot_smooth = (1.0f - spot_angle)*light->spot_smooth;
+                       float3 dir = light->dir;
+                       
+                       if(len(dir) > 0.0f)
+                               dir = normalize(dir);
 
                        if(light->use_mis && radius > 0.0f)
                                shader_id |= SHADER_USE_MIS;
index b5107315d4c0232e3cab3421676455c5d8b45d41..db402c5fc9f1d11240cce1d331b36b289bb10565 100644 (file)
@@ -2136,7 +2136,7 @@ void LightPathNode::compile(OSLCompiler& compiler)
 /* Light Falloff */
 
 LightFalloffNode::LightFalloffNode()
-: ShaderNode("light_path")
+: ShaderNode("light_fallof")
 {
        add_input("Strength", SHADER_SOCKET_FLOAT, 100.0f);
        add_input("Smooth", SHADER_SOCKET_FLOAT, 0.0f);
@@ -2777,7 +2777,7 @@ void SeparateRGBNode::compile(OSLCompiler& compiler)
 
 /* Separate HSV */
 SeparateHSVNode::SeparateHSVNode()
-: ShaderNode("separate_rgb")
+: ShaderNode("separate_hsv")
 {
        add_input("Color", SHADER_SOCKET_COLOR);
        add_output("H", SHADER_SOCKET_FLOAT);
@@ -2944,7 +2944,7 @@ void CameraNode::compile(OSLCompiler& compiler)
 /* Fresnel */
 
 FresnelNode::FresnelNode()
-: ShaderNode("Fresnel")
+: ShaderNode("fresnel")
 {
        add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL);
        add_input("IOR", SHADER_SOCKET_FLOAT, 1.45f);
@@ -2966,10 +2966,10 @@ void FresnelNode::compile(OSLCompiler& compiler)
        compiler.add(this, "node_fresnel");
 }
 
-/* Blend Weight */
+/* Layer Weight */
 
 LayerWeightNode::LayerWeightNode()
-: ShaderNode("LayerWeight")
+: ShaderNode("layer_weight")
 {
        add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL);
        add_input("Blend", SHADER_SOCKET_FLOAT, 0.5f);
@@ -3008,7 +3008,7 @@ void LayerWeightNode::compile(OSLCompiler& compiler)
 /* Wireframe */
 
 WireframeNode::WireframeNode()
-: ShaderNode("Wireframe")
+: ShaderNode("wireframe")
 {
        add_input("Size", SHADER_SOCKET_FLOAT, 0.01f);
        add_output("Fac", SHADER_SOCKET_FLOAT);
@@ -3035,7 +3035,7 @@ void WireframeNode::compile(OSLCompiler& compiler)
 /* Wavelength */
 
 WavelengthNode::WavelengthNode()
-: ShaderNode("Wavelength")
+: ShaderNode("wavelength")
 {
        add_input("Wavelength", SHADER_SOCKET_FLOAT, 500.0f);
        add_output("Color", SHADER_SOCKET_COLOR);
@@ -3059,7 +3059,7 @@ void WavelengthNode::compile(OSLCompiler& compiler)
 /* Blackbody */
 
 BlackbodyNode::BlackbodyNode()
-: ShaderNode("Blackbody")
+: ShaderNode("blackbody")
 {
        add_input("Temperature", SHADER_SOCKET_FLOAT, 1200.0f);
        add_output("Color", SHADER_SOCKET_COLOR);
@@ -3387,7 +3387,7 @@ void RGBCurvesNode::compile(OSLCompiler& compiler)
 /* VectorCurvesNode */
 
 VectorCurvesNode::VectorCurvesNode()
-: ShaderNode("rgb_curves")
+: ShaderNode("vector_curves")
 {
        add_input("Fac", SHADER_SOCKET_FLOAT);
        add_input("Vector", SHADER_SOCKET_VECTOR);
@@ -3645,7 +3645,7 @@ ShaderEnum TangentNode::direction_type_enum = tangent_direction_type_init();
 ShaderEnum TangentNode::axis_enum = tangent_axis_init();
 
 TangentNode::TangentNode()
-: ShaderNode("normal_map")
+: ShaderNode("tangent")
 {
        direction_type = ustring("Radial");
        axis = ustring("X");
index 1c3d31b6625684b66103d264c256b470af7bacd8..c1452a72970b95b5eab5ea2691fc57287b836706 100644 (file)
 #ifndef __DUALCON_H__
 #define __DUALCON_H__
 
+#ifdef WITH_CXX_GUARDEDALLOC
+#  include "MEM_guardedalloc.h"
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 9f5a99e9e20684e9dbde7ceeeba4df43e238a71d..45f60a1060a7bd34cd15a21e06d88af6cba08b05 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef GEOCOMMON_H
-#define GEOCOMMON_H
+#ifndef __GEOCOMMON_H__
+#define __GEOCOMMON_H__
 
 #define UCHAR unsigned char
 #define USHORT unsigned short
@@ -61,4 +61,4 @@ typedef struct {
 } BoundingBoxf;
 
 
-#endif
+#endif  /* __GEOCOMMON_H__ */
index e673d9498d202f4621843fadca268ce7fd38a591..29d82aeb3a2d0fd77264c657cee0187e87cb368b 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef MEMORYALLOCATOR_H
-#define MEMORYALLOCATOR_H
+#ifndef __MEMORYALLOCATOR_H__
+#define __MEMORYALLOCATOR_H__
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -53,6 +53,11 @@ virtual void printInfo( ) = 0;
 virtual int getAllocated( ) = 0;
 virtual int getAll( ) = 0;
 virtual int getBytes( ) = 0;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:VirtualMemoryAllocator")
+#endif
+
 };
 
 /**
@@ -216,6 +221,11 @@ int getBytes( )
 {
        return N;
 };
-};
 
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:MemoryAllocator")
 #endif
+
+};
+
+#endif  /* __MEMORYALLOCATOR_H__ */
index 993c5756531b43bd655163a4746cb58b4ca2a4bb..a72368ef4dc2ecd3e8524a1b327adc947de9ad90 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef MODELREADER_H
-#define MODELREADER_H
+#ifndef __MODELREADER_H__
+#define __MODELREADER_H__
 
 #include "GeoCommon.h"
 
@@ -59,7 +59,11 @@ virtual int getNumVertices( ) = 0;
 virtual void getNextVertex(float v[3]) = 0;
 
 virtual void printInfo( ) = 0;
-};
-
 
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:ModelReader")
 #endif
+
+};
+
+#endif  /* __MODELREADER_H__ */
index f00d998591f01706a3d6a05135e6a26ba7de0077..e85589e3ff55febd5e8190decfa2a05c31a8594c 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#ifdef WITH_CXX_GUARDEDALLOC
+#  include "MEM_guardedalloc.h"
+#endif
+
 #include <math.h>
 #include "Projections.h"
 
index 2cc3320f8e4e950324a36ef555bf3c018ed14e2f..a5086ddca39be744b6de38fe568dde86293c6382 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef PROJECTIONS_H
-#define PROJECTIONS_H
+#ifndef __PROJECTIONS_H__
+#define __PROJECTIONS_H__
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -125,6 +125,11 @@ public:
        int isIntersectingPrimary(int edgeInd) const;
 
        float getIntersectionPrimary(int edgeInd) const;
-};
 
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:CubeTriangleIsect")
 #endif
+
+};
+
+#endif  /* __PROJECTIONS_H__ */
index a2b5b46c72c783029efb25207e7700705532363b..098b883da32343252c4191def9ca39f9eb6660fb 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef QUEUE_H
-#define QUEUE_H
+#ifndef __QUEUE_H__
+#define __QUEUE_H__
 
 struct gridQueueEle {
        int x, y, z;
@@ -99,10 +99,10 @@ int popQueue(int st[3], int& dir)
        return 1;
 }
 
-};
-
-
-
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:GridQueue")
+#endif
 
+};
 
-#endif
+#endif  /* __QUEUE_H__ */
index 8b5125e261a0ddd2e8526b6400599e0a50bd1126..991edebda7ed0898936229e36bc0338395f75c30 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef CUBES_H
-#define CUBES_H
+#ifndef __CUBES_H__
+#define __CUBES_H__
 
 #include "marching_cubes_table.h"
 
@@ -41,6 +41,11 @@ void getTriangle(int mask, int index, int indices[3])
        for (int i = 0; i < 3; i++)
                indices[i] = marching_cubes_tris[mask][index][i];
 }
-};
 
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:Cubes")
 #endif
+
+};
+
+#endif  /* __CUBES_H__ */
index c96415bfb54f44011a36b26e5ddb1a505fda720f..6c3ec4dcc3bc5fedef098a8b6420125124b38c36 100644 (file)
@@ -185,6 +185,11 @@ void printInfo() {
 int getMemory() {
        return sizeof(DualConInputReader);
 }
+
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:DualConInputReader")
+#endif
+
 };
 
 void *dualcon(const DualConInput *input_mesh,
index 1827623f5ff413d30600cc499ceb02ed766bea90..89779fdfe4edf93504c23e57014c2f0428659824 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef MANIFOLD_TABLE_H
-#define MANIFOLD_TABLE_H
+#ifndef __MANIFOLD_TABLE_H__
+#define __MANIFOLD_TABLE_H__
 
 typedef struct {
        int comps;
@@ -30,4 +30,4 @@ typedef struct {
 
 extern const ManifoldIndices manifold_table[256];
 
-#endif
+#endif  /* __MANIFOLD_TABLE_H__ */
index e45e1c609244198940e69b912d1e395cc871a050..e1e44a50961ff8a9cd7dbbee334c7a8abf0e4bf1 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef MARCHING_CUBES_TABLE_H
-#define MARCHING_CUBES_TABLE_H
+#ifndef __MARCHING_CUBES_TABLE_H__
+#define __MARCHING_CUBES_TABLE_H__
 
 /* number of configurations */
 #define TOTCONF 256
index 49c50c8240d4e872ef72566e9c38beb898068dc1..bd7194cf3fd0603fa837a97437d5e3d64bbb462a 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#ifdef WITH_CXX_GUARDEDALLOC
+#  include "MEM_guardedalloc.h"
+#endif
+
 #include "octree.h"
 #include <Eigen/Dense>
 #include <limits>
@@ -102,6 +106,7 @@ Octree::Octree(ModelReader *mr,
 
 Octree::~Octree()
 {
+       delete cubes;
        freeMemory();
 }
 
@@ -1906,11 +1911,13 @@ int Octree::floodFill(LeafNode *leaf, int st[3], int len, int height, int thresh
                                        maxtotal = total;
                                }
                                dc_printf(".\n");
+                               delete queue;
                                continue;
                        }
 
                        if (total >= threshold) {
                                dc_printf("Maintained.\n");
+                               delete queue;
                                continue;
                        }
                        dc_printf("Less then %d, removing...\n", threshold);
@@ -1997,6 +2004,8 @@ int Octree::floodFill(LeafNode *leaf, int st[3], int len, int height, int thresh
                                        }
                                }
                        }
+
+                       delete queue;
                }
        }
 
@@ -2173,7 +2182,7 @@ static void minimize(float rvalue[3], float mp[3], const float pts[12][3],
                        ata[4] += (float)(norm[1] * norm[2]);
                        ata[5] += (float)(norm[2] * norm[2]);
 
-                       double pn = p[0] * norm[0] + p[1] * norm[1] + p[2] * norm[2];
+                       const float pn = p[0] * norm[0] + p[1] * norm[1] + p[2] * norm[2];
 
                        atb[0] += (float)(norm[0] * pn);
                        atb[1] += (float)(norm[1] * pn);
index 544048249de4655d9259ca3d5cf2ff3f62266f77..67eaf3a650b8b32ce71d8229e2643b178502b00f 100644 (file)
@@ -20,8 +20,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef OCTREE_H
-#define OCTREE_H
+#ifndef __OCTREE_H__
+#define __OCTREE_H__
 
 #include <cassert>
 #include <cstring>
@@ -1388,6 +1388,10 @@ class Octree
                removeInternal(num - 1, par);
                return npar;
        }
-};
 
+#ifdef WITH_CXX_GUARDEDALLOC
+       MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:Octree")
 #endif
+};
+
+#endif  /* __OCTREE_H__ */
index d49dc4b4dd90bd86edeea147aa9377b3227839f0..0939fe1cf86999402a825f465cbe0ad9a452aeea 100644 (file)
@@ -98,6 +98,7 @@ extern "C" {
         * newly allocated block.  */
        void *MEM_dupallocN(const void *vmemh)
 #if MEM_GNU_ATTRIBUTES
+       __attribute__((malloc))
        __attribute__((warn_unused_result))
 #endif
        ;
@@ -107,8 +108,9 @@ extern "C" {
         * allocated block, the old one is freed. this is not as optimized
         * as a system realloc but just makes a new allocation and copies
         * over from existing memory. */
-       void *MEM_reallocN(void *vmemh, size_t len)
+       void *MEM_reallocN_id(void *vmemh, size_t len, const char *str)
 #if MEM_GNU_ATTRIBUTES
+       __attribute__((malloc))
        __attribute__((warn_unused_result))
        __attribute__((alloc_size(2)))
 #endif
@@ -117,19 +119,24 @@ extern "C" {
        /**
         * A variant of realloc which zeros new bytes
         */
-       void *MEM_recallocN(void *vmemh, size_t len)
+       void *MEM_recallocN_id(void *vmemh, size_t len, const char *str)
 #if MEM_GNU_ATTRIBUTES
+       __attribute__((malloc))
        __attribute__((warn_unused_result))
        __attribute__((alloc_size(2)))
 #endif
        ;
 
+#define MEM_reallocN(vmemh, len) MEM_reallocN_id(vmemh, len, __func__)
+#define MEM_recallocN(vmemh, len) MEM_recallocN_id(vmemh, len, __func__)
+
        /**
         * Allocate a block of memory of size len, with tag name str. The
         * memory is cleared. The name must be static, because only a
         * pointer to it is stored ! */
        void *MEM_callocN(size_t len, const char *str)
 #if MEM_GNU_ATTRIBUTES
+       __attribute__((malloc))
        __attribute__((warn_unused_result))
        __attribute__((nonnull(2)))
        __attribute__((alloc_size(1)))
@@ -142,6 +149,7 @@ extern "C" {
         * */
        void *MEM_mallocN(size_t len, const char *str)
 #if MEM_GNU_ATTRIBUTES
+       __attribute__((malloc))
        __attribute__((warn_unused_result))
        __attribute__((nonnull(2)))
        __attribute__((alloc_size(1)))
@@ -154,6 +162,7 @@ extern "C" {
         * */
        void *MEM_mapallocN(size_t len, const char *str)
 #if MEM_GNU_ATTRIBUTES
+       __attribute__((malloc))
        __attribute__((warn_unused_result))
        __attribute__((nonnull(2)))
        __attribute__((alloc_size(1)))
@@ -210,6 +219,8 @@ extern "C" {
 #endif
        ;
 
+#define MEM_SAFE_FREE(v) if (v) { MEM_freeN(v); v = NULL; } (void)0
+
 #ifndef NDEBUG
 const char *MEM_name_ptr(void *vmemh);
 #endif
index 4a72089f8f7aae20d5c3c22b644bb1648178458f..08ac2ce6effefea7cecc91346ccd6b185722dfbf 100644 (file)
@@ -371,7 +371,7 @@ void *MEM_dupallocN(const void *vmemh)
        return newp;
 }
 
-void *MEM_reallocN(void *vmemh, size_t len)
+void *MEM_reallocN_id(void *vmemh, size_t len, const char *str)
 {
        void *newp = NULL;
        
@@ -394,13 +394,13 @@ void *MEM_reallocN(void *vmemh, size_t len)
                MEM_freeN(vmemh);
        }
        else {
-               newp = MEM_mallocN(len, __func__);
+               newp = MEM_mallocN(len, str);
        }
 
        return newp;
 }
 
-void *MEM_recallocN(void *vmemh, size_t len)
+void *MEM_recallocN_id(void *vmemh, size_t len, const char *str)
 {
        void *newp = NULL;
 
@@ -428,7 +428,7 @@ void *MEM_recallocN(void *vmemh, size_t len)
                MEM_freeN(vmemh);
        }
        else {
-               newp = MEM_callocN(len, __func__);
+               newp = MEM_callocN(len, str);
        }
 
        return newp;
index a6597986c0a6b5e3a1cc07e5afb90a8fbb546225..018869f36b6caccd6cc36d3c6d5a6584f3bcd95d 100644 (file)
@@ -426,7 +426,7 @@ typedef struct {
        int index;
 } STmpVert;
 
-const int g_iCells = 2048;
+static const int g_iCells = 2048;
 
 #ifdef _MSC_VER
        #define NOINLINE __declspec(noinline)
index 58e355c0d521c1a438d520c170183f0fc924dd58..5724d1992d9c05621030c72117a4195d1dceda47 100644 (file)
@@ -57,6 +57,7 @@ subject to the following restrictions:
  */
 
 #include <stdio.h>
+#include <errno.h>
 
 #include "RBI_api.h"
 
@@ -218,8 +219,13 @@ void RB_dworld_export(rbDynamicsWorld *world, const char *filename)
        world->dynamicsWorld->serialize(serializer);
        
        FILE *file = fopen(filename, "wb");
-       fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file);
-       fclose(file);
+       if (file) {
+               fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file);
+               fclose(file);
+       }
+       else {
+                fprintf(stderr, "RB_dworld_export: %s\n", strerror(errno));
+       }
 }
 
 /* ********************************** */
index 1da45a9f415994fed477316ec0aa3c88bb2c12b7..f365351766a8715cf661de5634687c3757ca5589 100644 (file)
@@ -72,6 +72,7 @@ class SpellChecker():
         "bandnoise",
         "bindcode",
         "bitrate",
+        "blackbody",
         "blendfile",
         "blendin",
         "bonesize",
@@ -361,6 +362,7 @@ class SpellChecker():
         "timecode",
         "voronoi",
         "voxel", "voxels",
+        "vsync",
         "wireframe",
         "zmask",
         "ztransp",
index 17d353eb09c412333eb203944d4da2899dd3fc91..0477f5aa4c134a23b91ce5c0f0942b760cc452a7 100644 (file)
@@ -119,6 +119,7 @@ kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
 kmi = km.keymap_items.new('marker.move', 'EVT_TWEAK_S', 'ANY')
 kmi = km.keymap_items.new('marker.duplicate', 'D', 'PRESS', shift=True)
 kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS')
+kmi.properties.extend = False
 kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', shift=True)
 kmi.properties.extend = True
 kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', ctrl=True)
@@ -721,6 +722,7 @@ kmi.properties.data_path = 'space_data.show_floor'
 km = kc.keymaps.new('Animation Channels', space_type='EMPTY', region_type='WINDOW', modal=False)
 
 kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS')
+kmi.properties.extend = False
 kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS', shift=True)
 kmi.properties.extend = True
 kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True)
index bacb5d7b5e09646cb3659c6c659cd8a6baf333b8..a61da0b09d24dc43f40cdf767b251888ece3dbc4 100644 (file)
@@ -186,8 +186,11 @@ kmi = km.keymap_items.new('marker.add', 'M', 'PRESS')
 kmi = km.keymap_items.new('marker.move', 'EVT_TWEAK_S', 'ANY')
 kmi = km.keymap_items.new('marker.duplicate', 'D', 'PRESS', ctrl=True)
 kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS')
+kmi.properties.extend = False
+kmi.properties.camera = False
 kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', shift=True)
 kmi.properties.extend = True
+kmi.properties.camera = False
 kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', ctrl=True)
 kmi.properties.extend = False
 kmi.properties.camera = True
@@ -352,6 +355,7 @@ kmi = km.keymap_items.new('object.select_grouped', 'G', 'PRESS', shift=True)
 kmi = km.keymap_items.new('object.select_mirror', 'M', 'PRESS', shift=True, ctrl=True)
 kmi = km.keymap_items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS')
 kmi.properties.direction = 'PARENT'
+kmi.properties.extend = False
 kmi = km.keymap_items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True)
 kmi.properties.direction = 'PARENT'
 kmi.properties.extend = True
@@ -601,11 +605,23 @@ km = kc.keymaps.new('Mesh', space_type='EMPTY', region_type='WINDOW', modal=Fals
 
 kmi = km.keymap_items.new('mesh.loopcut_slide', 'R', 'PRESS', ctrl=True)
 kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True)
+kmi.properties.extend = False
+kmi.properties.deselect = False
+kmi.properties.toggle = False
+kmi.properties.ring = False
 kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
 kmi.properties.extend = True
+kmi.properties.deselect = False
+kmi.properties.toggle = False
+kmi.properties.ring = False
 kmi = km.keymap_items.new('mesh.edgering_select', 'RIGHTMOUSE', 'PRESS', ctrl=True, alt=True)
+kmi.properties.extend = False
+kmi.properties.deselect = False
+kmi.properties.toggle = False
 kmi = km.keymap_items.new('mesh.edgering_select', 'RIGHTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
 kmi.properties.extend = True
+kmi.properties.deselect = False
+kmi.properties.toggle = False
 kmi = km.keymap_items.new('mesh.select_all', 'A', 'PRESS', ctrl=True)
 kmi.properties.action = 'TOGGLE'
 kmi = km.keymap_items.new('mesh.select_more', 'PERIOD', 'PRESS', shift=True)
@@ -615,6 +631,7 @@ kmi.properties.action = 'INVERT'
 kmi = km.keymap_items.new('mesh.select_non_manifold', 'M', 'PRESS', shift=True, ctrl=True, alt=True)
 kmi = km.keymap_items.new('mesh.select_linked', 'L', 'PRESS', ctrl=True)
 kmi = km.keymap_items.new('mesh.select_linked_pick', 'L', 'PRESS')
+kmi.properties.deselect = False
 kmi = km.keymap_items.new('mesh.select_linked_pick', 'L', 'PRESS', shift=True)
 kmi.properties.deselect = True
 kmi = km.keymap_items.new('mesh.faces_select_linked_flat', 'F', 'PRESS', shift=True, ctrl=True, alt=True)
@@ -623,6 +640,7 @@ kmi = km.keymap_items.new('mesh.select_similar', 'G', 'PRESS', shift=True)
 kmi = km.keymap_items.new('wm.call_menu', 'RIGHTMOUSE', 'PRESS')
 kmi.properties.name = 'VIEW3D_MT_edit_mesh_select_mode'
 kmi = km.keymap_items.new('mesh.hide', 'H', 'PRESS', ctrl=True)
+kmi.properties.unselected = False
 kmi = km.keymap_items.new('mesh.hide', 'H', 'PRESS', alt=True)
 kmi.properties.unselected = True
 kmi = km.keymap_items.new('mesh.reveal', 'H', 'PRESS', shift=True, ctrl=True)
@@ -1049,6 +1067,7 @@ kmi.properties.value = 'VERTEX'
 km = kc.keymaps.new('Animation Channels', space_type='EMPTY', region_type='WINDOW', modal=False)
 
 kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS')
+kmi.properties.extend = False
 kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'CLICK', shift=True)
 kmi.properties.extend = True
 kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True)
@@ -1436,6 +1455,7 @@ km = kc.keymaps.new('File Browser Main', space_type='FILE_BROWSER', region_type=
 kmi = km.keymap_items.new('file.execute', 'LEFTMOUSE', 'DOUBLE_CLICK')
 kmi.properties.need_active = True
 kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK')
+kmi.properties.extend = False
 kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK', shift=True)
 kmi.properties.extend = True
 kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK', alt=True)
index 91b8fa5a060aa94fad7734044478b63cb495f692..a2d48c724de75e1fcbfab9e0e4a120dd427fea7a 100644 (file)
@@ -44,8 +44,6 @@
 
 #include "avi_mjpeg.h"
 
-#define PADUP(num, amt) ((num + (amt - 1)) & ~(amt - 1))
-
 static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize);
 static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize);
 
@@ -294,56 +292,13 @@ static void deinterlace(int odd, unsigned char *to, unsigned char *from, int wid
 
 static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, int width, int height, int bufsize)
 {
-       /* JPEG's are always multiples of 16, extra is cropped out AVI's */
-       if ((width & 0xF) || (height & 0xF)) {
-               int i, rrowstride, jrowstride;
-               int jwidth = PADUP(width, 16);
-               int jheight = PADUP(height, 16);
-               unsigned char *tmpbuf = MEM_mallocN(jwidth * jheight * 3, "avi.check_and_decode_jpeg");
-               int ret = Decode_JPEG(inbuf, tmpbuf, jwidth, jheight, bufsize);
-
-               /* crop the tmpbuf into the real buffer */
-               rrowstride = width * 3;
-               jrowstride = jwidth * 3;
-               for (i = 0; i < height; i++)
-                       memcpy(&outbuf[i * rrowstride], &tmpbuf[i * jrowstride], rrowstride);
-               MEM_freeN(tmpbuf);
-               
-               return ret;
-       }
-       else {
-               return Decode_JPEG(inbuf, outbuf, width, height, bufsize);
-       }
+       return Decode_JPEG(inbuf, outbuf, width, height, bufsize);
 }
 
 static void check_and_compress_jpeg(int quality, unsigned char *outbuf, const unsigned char *inbuf,
                                     int width, int height, int bufsize)
 {
-       /* JPEG's are always multiples of 16, extra is ignored in AVI's */
-       if ((width & 0xF) || (height & 0xF)) {
-               int i, rrowstride, jrowstride;
-               int jwidth = PADUP(width, 16);
-               int jheight = PADUP(height, 16);
-               unsigned char *tmpbuf = MEM_mallocN(jwidth * jheight * 3, "avi.check_and_compress_jpeg");
-
-               /* resize the realbuf into the tmpbuf */
-               rrowstride = width * 3;
-               jrowstride = jwidth * 3;
-               for (i = 0; i < jheight; i++) {
-                       if (i < height)
-                               memcpy(&tmpbuf[i * jrowstride], &inbuf[i * rrowstride], rrowstride);
-                       else
-                               memset(&tmpbuf[i * jrowstride], 0, rrowstride);
-                       memset(&tmpbuf[i * jrowstride + rrowstride], 0, jrowstride - rrowstride);
-               }
-
-               Compress_JPEG(quality, outbuf, tmpbuf, jwidth, jheight, bufsize);
-
-               MEM_freeN(tmpbuf);
-       }
-       else {
-               Compress_JPEG(quality, outbuf, inbuf, width, height, bufsize);
-       }
+       Compress_JPEG(quality, outbuf, inbuf, width, height, bufsize);
 }
 
 void *avi_converter_from_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, int *size)
index fd8bd1967177cdaa3de4313851d2b7987957d6d0..8f77f8c984dc1801b9936d49db686795b5175c5b 100644 (file)
@@ -149,11 +149,11 @@ void BLF_shadow_offset(int fontid, int x, int y);
 /* Set the buffer, size and number of channels to draw, one thing to take care is call
  * this function with NULL pointer when we finish, for example:
  *
- *     BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4, TRUE);
+ *     BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4, TRUE, NULL);
  *
  *     ... set color, position and draw ...
  *
- *     BLF_buffer(NULL, NULL, 0, 0, 0, FALSE);
+ *     BLF_buffer(NULL, NULL, NULL, 0, 0, FALSE, NULL);
  */
 void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display);
 
index 3422f783eeb017d14e25ab5050692cefcabc6ee8..2ece90183bd10b2b5efccb35c2a2f27d2d480889 100644 (file)
@@ -530,7 +530,9 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask)
        }
 
        /* copy texture space */
-       BKE_mesh_texspace_copy_from_object(&tmp, ob);
+       if (ob) {
+               BKE_mesh_texspace_copy_from_object(&tmp, ob);
+       }
        
        /* not all DerivedMeshes store their verts/edges/faces in CustomData, so
         * we set them here in case they are missing */
@@ -2633,9 +2635,9 @@ void DM_add_tangent_layer(DerivedMesh *dm)
        
        /* new computation method */
        {
-               SGLSLMeshToTangent mesh2tangent = {0};
-               SMikkTSpaceContext sContext = {0};
-               SMikkTSpaceInterface sInterface = {0};
+               SGLSLMeshToTangent mesh2tangent = {NULL};
+               SMikkTSpaceContext sContext = {NULL};
+               SMikkTSpaceInterface sInterface = {NULL};
 
                mesh2tangent.precomputedFaceNormals = nors;
                mesh2tangent.mtface = mtface;
index 70fbf2d39e8584ce7fb8beabe7d58b6353b747f8..80e40efd1fb3a839c74ccd919f9ec33b0614c0ec 100644 (file)
@@ -616,6 +616,10 @@ void BKE_pose_channels_hash_free(bPose *pose)
 
 void BKE_pose_channel_free(bPoseChannel *pchan)
 {
+       if (pchan->custom) {
+               id_us_min(&pchan->custom->id);
+               pchan->custom = NULL;
+       }
 
        if (pchan->mpath) {
                animviz_free_motionpath(pchan->mpath);
index 29a8a615601a5f8630fb8f2a55eac9166038f311..26f481e5341efb853e948622d1b066c93455cddb 100644 (file)
@@ -816,7 +816,7 @@ int BKE_undo_save_file(const char *filename)
         * to avoid writing to a symlink - use 'O_EXCL' (CVE-2008-1103) */
        errno = 0;
        file = BLI_open(filename, flag, 0666);
-       if (file == -1) {
+       if (file < 0) {
                if (errno == EEXIST) {
                        errno = 0;
                        file = BLI_open(filename, flag & ~O_CREAT, 0666);
index b8d851d082ac15b077b74de576a38c44f343223a..eda770ddf30ffe04611477d7153901010be3d0ce 100644 (file)
@@ -1227,7 +1227,7 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
                                
                                copy_v3_v3(totmat[3], vec);
                                
-                               mul_serie_m4(ct->matrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL);
+                               mul_m4_m4m4(ct->matrix, ct->tar->obmat, totmat);
                        }
                }
        }
@@ -1253,7 +1253,7 @@ static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *
                mat4_to_size(size, cob->matrix);
                
                /* apply targetmat - containing location on path, and rotation */
-               mul_serie_m4(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL);
+               mul_m4_m4m4(cob->matrix, ct->matrix, obmat);
                
                /* un-apply scaling caused by path */
                if ((data->followflag & FOLLOWPATH_RADIUS) == 0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */
@@ -2080,6 +2080,8 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT
                        axis = data->type - 20;
                }
                
+               BLI_assert((unsigned int)axis < 3);
+
                /* Target defines the animation */
                s = (vec[axis] - data->min) / (data->max - data->min);
                CLAMP(s, 0, 1);
@@ -3120,7 +3122,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
                                unit_m4(totmat);
                                copy_v3_v3(totmat[3], vec);
                                
-                               mul_serie_m4(targetMatrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL);
+                               mul_m4_m4m4(targetMatrix, ct->tar->obmat, totmat);
                        }
                }
                
index dcbbd776228965d4c73e9e4f3970608a562dce03..a62ca530bf91a4f80680b708bb0ccff7c0a6242b 100644 (file)
@@ -3290,7 +3290,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
 
        if (!brush->dm) return 0;
        {
-               BVHTreeFromMesh treeData = {0};
+               BVHTreeFromMesh treeData = {NULL};
                float avg_brushNor[3] = {0.0f};
                float brush_radius = brush->paint_distance * surface->radius_scale;
                int numOfVerts;
@@ -4977,7 +4977,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
                                /* make sure we're dealing with a brush */
                                if (pmd2->brush) {
                                        DynamicPaintBrushSettings *brush = pmd2->brush;
-                                       BrushMaterials bMats = {0};
+                                       BrushMaterials bMats = {NULL};
 
                                        /* calculate brush speed vectors if required */
                                        if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && brush->flags & MOD_DPAINT_DO_SMUDGE) {
index feb18c3babeeeaab8522b4b96b755506c066d054..e8e56c6f17b7515a112d541bb09b1889843532bd 100644 (file)
@@ -1064,7 +1064,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
        const float (*vertexNos)[3];
        const float (*polyNos)[3];
        BMFace *efa;
-       DMVertexAttribs attribs = {{{0}}};
+       DMVertexAttribs attribs = {{{NULL}}};
        GPUVertexAttribs gattribs;
        int i, matnr, new_matnr;
 
index 915c75a0e7f003e2fdfaf07f09ea53f9279dc51f..f24edfea136974e627854a7d76a00b07239c996b 100644 (file)
@@ -144,12 +144,8 @@ static void fcm_generator_verify(FModifier *fcm)
                        const int arraysize_new = data->poly_order + 1;
                        /* arraysize needs to be order+1, so resize if not */
                        if (data->arraysize != arraysize_new) {
-                               if (data->coefficients) {
-                                       data->coefficients = MEM_recallocN(data->coefficients, sizeof(float) * arraysize_new);
-                               }
-                               else {
-                                       data->coefficients = MEM_callocN(sizeof(float) * arraysize_new, "FMod_Generator_Coefs");
-                               }
+                               data->coefficients = MEM_recallocN(data->coefficients,
+                                                                  sizeof(float) * arraysize_new);
                                data->arraysize = arraysize_new;
                        }
                        break;
@@ -159,12 +155,8 @@ static void fcm_generator_verify(FModifier *fcm)
                        const int arraysize_new = data->poly_order * 2;
                        /* arraysize needs to be (2 * order), so resize if not */
                        if (data->arraysize != arraysize_new) {
-                               if (data->coefficients) {
-                                       data->coefficients = MEM_recallocN(data->coefficients, sizeof(float) * arraysize_new);
-                               }
-                               else {
-                                       data->coefficients = MEM_callocN(sizeof(float) * arraysize_new, "FMod_Generator_Coefs");
-                               }
+                               data->coefficients = MEM_recallocN(data->coefficients,
+                                                                  sizeof(float) * arraysize_new);
                                data->arraysize = arraysize_new;
                        }
                        break;
index 1a444d497a04791c8ec9ec7fcf00aa1a28c02676..63d0df76a6f572b4647ccd424287aa688ceeac24 100644 (file)
@@ -597,7 +597,8 @@ Image *BKE_image_load(Main *bmain, const char *filepath)
 
        /* exists? */
        file = BLI_open(str, O_BINARY | O_RDONLY, 0);
-       if (file == -1) return NULL;
+       if (file < 0)
+               return NULL;
        close(file);
 
        /* create a short library name */
index eda22a095ef353e965e850b43f73a83f91007c6a..71b4f9947a4ee974c45a1b72924f15c05deb3ac5 100644 (file)
@@ -336,7 +336,7 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
        }
 
        /* cleanup the buffer. */
-       BLF_buffer(mono, NULL, NULL, 0, 0, 0, FALSE);
+       BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL);
 }
 
 void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, int width, int height)
index 5b8929e49fe7f77dd8770acb7be7baaef92f01ab..d2d2cb1c2d002705e6812c31f35d72493e029825 100644 (file)
@@ -190,7 +190,8 @@ Key *BKE_key_copy_nolib(Key *key)
        Key *keyn;
        KeyBlock *kbn, *kb;
        
-       if (key == 0) return 0;
+       if (key == NULL)
+               return NULL;
        
        keyn = MEM_dupallocN(key);
 
index 7eb4a3a2a8d7ebe9670d4c9e3e13d046df383f22..c23fa097d3eba1fe5463a42a94f46ec49c61723a 100644 (file)
@@ -1264,17 +1264,13 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name)
 static bool check_for_dupid(ListBase *lb, ID *id, char *name)
 {
        ID *idtest;
-       int nr = 0, nrtest, a, left_len;
+       int nr = 0, a, left_len;
 #define MAX_IN_USE 64
        bool in_use[MAX_IN_USE];
        /* to speed up finding unused numbers within [1 .. MAX_IN_USE - 1] */
 
        char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8];
 
-       /* make sure input name is terminated properly */
-       /* if ( strlen(name) > MAX_ID_NAME-3 ) name[MAX_ID_NAME-3] = 0; */
-       /* removed since this is only ever called from one place - campbell */
-
        while (true) {
 
                /* phase 1: id already exists? */
@@ -1301,6 +1297,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
                }
 
                for (idtest = lb->first; idtest; idtest = idtest->next) {
+                       int nrtest;
                        if ( (id != idtest) &&
                             (idtest->lib == NULL) &&
                             (*name == *(idtest->name + 2)) &&
@@ -1315,8 +1312,8 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
                                        nr = nrtest + 1;    /* track largest unused */
                        }
                }
-               /* At this point, nr will be at least 1. */
-               BLI_assert(nr >= 1);
+               /* At this point, 'nr' will typically be at least 1. (but not always) */
+               // BLI_assert(nr >= 1);
 
                /* decide which value of nr to use */
                for (a = 0; a < MAX_IN_USE; a++) {
index e8550e12e4f29a129e89bd7d4c668ee3b4c92d64..bf4a63c52a8c12caf4c86fe02aa69843d836f763 100644 (file)
@@ -625,7 +625,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
 
        /* exists? */
        file = BLI_open(str, O_BINARY | O_RDONLY, 0);
-       if (file == -1)
+       if (file < 0)
                return NULL;
        close(file);
 
@@ -1439,21 +1439,19 @@ void BKE_movieclip_unlink(Main *bmain, MovieClip *clip)
                bConstraint *con;
 
                for (con = ob->constraints.first; con; con = con->next) {
-                       bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
-
-                       if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
+                       if (con->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
                                bFollowTrackConstraint *data = (bFollowTrackConstraint *) con->data;
 
                                if (data->clip == clip)
                                        data->clip = NULL;
                        }
-                       else if (cti->type == CONSTRAINT_TYPE_CAMERASOLVER) {
+                       else if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) {
                                bCameraSolverConstraint *data = (bCameraSolverConstraint *) con->data;
 
                                if (data->clip == clip)
                                        data->clip = NULL;
                        }
-                       else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
+                       else if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
                                bObjectSolverConstraint *data = (bObjectSolverConstraint *) con->data;
 
                                if (data->clip == clip)
index 95bf56d00f2969ca30122b6077015e491ecc67f2..32ca3ea6d5a5845e4270eba43fd6753bd81cdb25 100644 (file)
@@ -245,7 +245,7 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
 static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
 {
        MDisps *mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS,
-                                             CD_CALLOC, 0, me->totloop);
+                                             CD_CALLOC, NULL, me->totloop);
        int gridsize = ccg_gridsize(level);
        int gridarea = gridsize * gridsize;
        int i, j, k;
index 75e6ce9837df0bd1f893397af51c92d228538490..1d662ae3116038d439573b05926fdeefd0312d07 100644 (file)
@@ -440,9 +440,6 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
        int ntris = 0, *recastData = NULL;
        unsigned short *tris = NULL;
 
-       /* Don't bother converting if there is nothing to convert */
-       if (!*nverts) return 0;
-
        res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
        if (!res) {
                printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
index 7aa23dc6c2b8c096446eb3812a44ba3f2fc7683c..150c20d047db2d400b9e8cb5ee96b3be17c43336 100644 (file)
@@ -2038,15 +2038,13 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4
                                }
                        }
                        
-                       if (ok) mul_serie_m4(totmat, par->obmat, tmat,
-                                                NULL, NULL, NULL, NULL, NULL, NULL);
+                       if (ok) mul_m4_m4m4(totmat, par->obmat, tmat);
                        else copy_m4_m4(totmat, par->obmat);
                        
                        break;
                case PARBONE:
                        ob_parbone(ob, par, tmat);
-                       mul_serie_m4(totmat, par->obmat, tmat,
-                                    NULL, NULL, NULL, NULL, NULL, NULL);
+                       mul_m4_m4m4(totmat, par->obmat, tmat);
                        break;
                
                case PARVERT1:
@@ -2062,8 +2060,7 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4
                case PARVERT3:
                        ob_parvert3(ob, par, tmat);
                        
-                       mul_serie_m4(totmat, par->obmat, tmat,
-                                    NULL, NULL, NULL, NULL, NULL, NULL);
+                       mul_m4_m4m4(totmat, par->obmat, tmat);
                        break;
                
                case PARSKEL:
@@ -2072,10 +2069,8 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4
        }
        
        /* total */
-       mul_serie_m4(tmat, totmat, ob->parentinv,
-                    NULL, NULL, NULL, NULL, NULL, NULL);
-       mul_serie_m4(obmat, tmat, locmat,         
-                    NULL, NULL, NULL, NULL, NULL, NULL);
+       mul_m4_m4m4(tmat, totmat, ob->parentinv);
+       mul_m4_m4m4(obmat, tmat, locmat);
        
        if (simul) {
 
index 11d58c945fd0491c71e72f5942a1b984897ca076..62ea16b9fb4d28cf280542e5348041f43ccd5e7b 100644 (file)
@@ -202,7 +202,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
         * and create a PackedFile structure */
 
        file = BLI_open(name, O_BINARY | O_RDONLY, 0);
-       if (file <= 0) {
+       if (file < 0) {
                BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path '%s' not found", name);
        }
        else {
@@ -327,20 +327,21 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
        BLI_make_existing_file(name);
        
        file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
-       if (file >= 0) {
+       if (file < 0) {
+               BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", name);
+               ret_value = RET_ERROR;
+       }
+       else {
                if (write(file, pf->data, pf->size) != pf->size) {
                        BKE_reportf(reports, RPT_ERROR, "Error writing file '%s'", name);
                        ret_value = RET_ERROR;
                }
-               else
+               else {
                        BKE_reportf(reports, RPT_INFO, "Saved packed file to: %s", name);
+               }
                
                close(file);
        }
-       else {
-               BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", name);
-               ret_value = RET_ERROR;
-       }
        
        if (remove_tmp) {
                if (ret_value == RET_ERROR) {
index a0cc37dcf3f676c2788bcb45da060512fe3f07d8..205159c94a1aad6001084b054a904770caa4039f 100644 (file)
@@ -753,7 +753,7 @@ void BKE_pbvh_search_gather(PBVH *bvh,
                             PBVHNode ***r_array, int *r_tot)
 {
        PBVHIter iter;
-       PBVHNode **array = NULL, **newarray, *node;
+       PBVHNode **array = NULL, *node;
        int tot = 0, space = 0;
 
        pbvh_iter_begin(&iter, bvh, scb, search_data);
@@ -763,14 +763,7 @@ void BKE_pbvh_search_gather(PBVH *bvh,
                        if (tot == space) {
                                /* resize array if needed */
                                space = (tot == 0) ? 32 : space * 2;
-                               newarray = MEM_callocN(sizeof(PBVHNode) * space, "PBVHNodeSearch");
-
-                               if (array) {
-                                       memcpy(newarray, array, sizeof(PBVHNode) * tot);
-                                       MEM_freeN(array);
-                               }
-
-                               array = newarray;
+                               array = MEM_recallocN_id(array, sizeof(PBVHNode *) * space, __func__);
                        }
 
                        array[tot] = node;
@@ -845,12 +838,12 @@ static void free_tree(node_tree *tree)
 {
        if (tree->left) {
                free_tree(tree->left);
-               tree->left = 0;
+               tree->left = NULL;
        }
 
        if (tree->right) {
                free_tree(tree->right);
-               tree->right = 0;
+               tree->right = NULL;
        }
 
        free(tree);
@@ -867,7 +860,7 @@ static void BKE_pbvh_search_callback_occluded(PBVH *bvh,
 {
        PBVHIter iter;
        PBVHNode *node;
-       node_tree *tree = 0;
+       node_tree *tree = NULL;
 
        pbvh_iter_begin(&iter, bvh, scb, search_data);
 
@@ -1363,7 +1356,7 @@ void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *pro
                if (proxy_count) *proxy_count = node->proxy_count;
        }
        else {
-               if (proxies) *proxies = 0;
+               if (proxies) *proxies = NULL;
                if (proxy_count) *proxy_count = 0;
        }
 }
@@ -1795,11 +1788,11 @@ void BKE_pbvh_node_free_proxies(PBVHNode *node)
 
                for (p = 0; p < node->proxy_count; p++) {
                        MEM_freeN(node->proxies[p].co);
-                       node->proxies[p].co = 0;
+                       node->proxies[p].co = NULL;
                }
 
                MEM_freeN(node->proxies);
-               node->proxies = 0;
+               node->proxies = NULL;
 
                node->proxy_count = 0;
        }
@@ -1807,7 +1800,7 @@ void BKE_pbvh_node_free_proxies(PBVHNode *node)
 
 void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array,  int *r_tot)
 {
-       PBVHNode **array = NULL, **newarray, *node;
+       PBVHNode **array = NULL, *node;
        int tot = 0, space = 0;
        int n;
 
@@ -1818,14 +1811,7 @@ void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array,  int *r_tot)
                        if (tot == space) {
                                /* resize array if needed */
                                space = (tot == 0) ? 32 : space * 2;
-                               newarray = MEM_callocN(sizeof(PBVHNode) * space, "BKE_pbvh_gather_proxies");
-
-                               if (array) {
-                                       memcpy(newarray, array, sizeof(PBVHNode) * tot);
-                                       MEM_freeN(array);
-                               }
-
-                               array = newarray;
+                               array = MEM_recallocN_id(array, sizeof(PBVHNode *) * space, __func__);
                        }
 
                        array[tot] = node;
@@ -1850,10 +1836,10 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
        int *grid_indices, *vert_indices;
        int totgrid, gridsize, uniq_verts, totvert;
        
-       vi->grid = 0;
-       vi->no = 0;
-       vi->fno = 0;
-       vi->mvert = 0;
+       vi->grid = NULL;
+       vi->no = NULL;
+       vi->fno = NULL;
+       vi->mvert = NULL;
        
        BKE_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids, NULL);
        BKE_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert);
index 100659105325bcd96b6c33a3e9205c9016781112..b9843ad061944de850aedf43db2a534b69e777de 100644 (file)
@@ -86,7 +86,7 @@ void space_transform_from_matrixs(SpaceTransform *data, float local[4][4], float
 {
        float itarget[4][4];
        invert_m4_m4(itarget, target);
-       mul_serie_m4(data->local2target, itarget, local, NULL, NULL, NULL, NULL, NULL, NULL);
+       mul_m4_m4m4(data->local2target, itarget, local);
        invert_m4_m4(data->target2local, data->local2target);
 }
 
@@ -428,7 +428,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
        BVHTreeNearest nearest  = NULL_BVHTreeNearest;
 
        /* Create a bvh-tree of the given target */
-       TIMEIT_BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6), bvhtree_faces);
+       bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6);
        if (treeData.tree == NULL) {
                OUT_OF_MEMORY();
                return;
index 707d97a1cf1405d2fa986706359fa7500a3ed5a1..bbd637a0a77ac63bee57eb9d53b823534c6a337e 100644 (file)
@@ -487,7 +487,7 @@ void sk_endContinuousStroke(SK_Stroke *stk)
 void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk)
 {
        if (stk) {
-               memcpy(&sketch->next_point, stk->points[stk->nb_points - 1].p, sizeof(SK_Point));
+               memcpy(&(sketch->next_point), &(stk->points[stk->nb_points - 1]), sizeof(SK_Point));
        }
 }
 
index 789b0ec5823e9c05c3a0de81a4dc251c1e46c0e3..bb65955e3b5328917cfef797860d31392b047a94 100644 (file)
@@ -722,7 +722,7 @@ static void obstacles_from_derivedmesh(Object *coll_ob, SmokeDomainSettings *sds
                DerivedMesh *dm = NULL;
                MVert *mvert = NULL;
                MFace *mface = NULL;
-               BVHTreeFromMesh treeData = {0};
+               BVHTreeFromMesh treeData = {NULL};
                int numverts, i, z;
 
                float surface_distance = 0.6;
@@ -1573,7 +1573,7 @@ static void emit_from_derivedmesh(Object *flow_ob, SmokeDomainSettings *sds, Smo
                MVert *mvert_orig = NULL;
                MFace *mface = NULL;
                MTFace *tface = NULL;
-               BVHTreeFromMesh treeData = {0};
+               BVHTreeFromMesh treeData = {NULL};
                int numOfVerts, i, z;
                float flow_center[3] = {0};
 
@@ -2108,7 +2108,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
                                // float scene_subframe = scene->r.subframe;  // UNUSED
                                int subframe;
                                for (subframe = 0; subframe <= subframes; subframe++) {
-                                       EmissionMap em_temp = {0};
+                                       EmissionMap em_temp = {NULL};
                                        float sample_size = 1.0f / (float)(subframes+1);
                                        float prev_frame_pos = sample_size * (float)(subframe+1);
                                        float sdt = dt * sample_size;
index cc33727030af0bcc7c8bf1b124273222785f55b8..35482d9553dc51e0d2ab899304c5f549a48d69f6 100644 (file)
@@ -3139,7 +3139,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
        int numTex, numCol;
        int hasPCol, hasOrigSpace;
        int gridInternalEdges;
-       WeightTable wtable = {0};
+       WeightTable wtable = {NULL};
        /* MCol *mcol; */ /* UNUSED */
        MEdge *medge = NULL;
        /* MFace *mface = NULL; */
index 12c2967afcfa4fde1121c78d31e59c8ffdc35f17..4c3632928984804bb8b3fb6ac037a923b8be717d 100644 (file)
@@ -654,7 +654,7 @@ void BKE_tracking_track_flag_clear(MovieTrackingTrack *track, int area, int flag
  */
 int BKE_tracking_track_has_marker_at_frame(MovieTrackingTrack *track, int framenr)
 {
-       return BKE_tracking_marker_get_exact(track, framenr) != 0;
+       return BKE_tracking_marker_get_exact(track, framenr) != NULL;
 }
 
 /* Check whether track has got enabled marker at specified frame.
index 879ef8696530522b132b42c5801fd7b3b41e0c40..461b56e157fdf35cf12bf786ee4cb6d57f6a852f 100644 (file)
@@ -57,7 +57,7 @@ enum {
        BLI_Buffer name_ = { \
        /* clear the static memory if this is a calloc'd array */ \
        ((void)((flag_ & BLI_BUFFER_USE_CALLOC) ? \
-                 memset(name_ ## _static_, 0, sizeof(name_ ## _static_)) : 0\
+                 memset(name_ ## _static_, 0, sizeof(name_ ## _static_)) : NULL \
        ), /* memset-end */ \
                            name_ ## _static_), \
                            sizeof(type_), \
index e05783004c73ca1d3d776172b3759ef7f021772a..e163c06440ca9c927129ff226e4443cefcb81b38 100644 (file)
@@ -36,10 +36,6 @@ extern "C" {
 
 #include "BLI_math_inline.h"
 
-#if BLI_MATH_DO_INLINE
-#include "intern/math_vector_inline.c"
-#endif
-
 /************************************* Init ***********************************/
 
 #ifdef BLI_MATH_GCC_WARN_PRAGMA
@@ -286,6 +282,12 @@ void fill_vn_i(int *array_tar, const int size, const int val);
 void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned short val);
 void fill_vn_fl(float *array_tar, const int size, const float val);
 
+/**************************** Inline Definitions ******************************/
+
+#if BLI_MATH_DO_INLINE
+#include "intern/math_vector_inline.c"
+#endif
+
 #ifdef BLI_MATH_GCC_WARN_PRAGMA
 #  pragma GCC diagnostic pop
 #endif
index 092bb639b91b644341375d5681ea3046ed44e88c..d54dab42e0568a86bd5caf7f070400ba2ad2436e 100644 (file)
@@ -55,6 +55,7 @@ typedef struct MemArena MemArena;
 
 struct MemArena    *BLI_memarena_new(const int bufsize, const char *name)
 #if MEM_GNU_ATTRIBUTES
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull(2)))
 #endif
@@ -85,6 +86,7 @@ __attribute__((nonnull(1)))
 
 void               *BLI_memarena_alloc(struct MemArena *ma, int size)
 #if MEM_GNU_ATTRIBUTES
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull(1)))
 __attribute__((alloc_size(2)))
index a1cbad73239190c70f3a12b43b7c3770fc9aa71e..1c470d590623b1ee7f6e5853da61ad92466c71c4 100644 (file)
@@ -50,17 +50,20 @@ typedef struct BLI_mempool BLI_mempool;
 
 BLI_mempool *BLI_mempool_create(int esize, int totelem, int pchunk, int flag)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 #endif
 ;
 void        *BLI_mempool_alloc(BLI_mempool *pool)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull(1)))
 #endif
 ;
 void        *BLI_mempool_calloc(BLI_mempool *pool)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull(1)))
 #endif
@@ -86,14 +89,29 @@ __attribute__((warn_unused_result))
 __attribute__((nonnull(1)))
 #endif
 ;
-void        BLI_mempool_as_array(BLI_mempool *pool, void **data)
+void        BLI_mempool_as_table(BLI_mempool *pool, void **data)
 #ifdef __GNUC__
-__attribute__((nonnull(1)))
+__attribute__((nonnull(1, 2)))
+#endif
+;
+
+void      **BLI_mempool_as_tableN(BLI_mempool *pool, const char *allocstr)
+#ifdef __GNUC__
+__attribute__((malloc))
+__attribute__((warn_unused_result))
+__attribute__((nonnull(1, 2)))
+#endif
+;
+
+void        BLI_mempool_as_array(BLI_mempool *pool, void *data)
+#ifdef __GNUC__
+__attribute__((nonnull(1, 2)))
 #endif
 ;
 
-void *BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr)
+void       *BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull(1, 2)))
 #endif
index 4816ac19fce9299b0e78fb5c2bb074ed02b2ba27..6c66d2f4e189feea213afe93388d4c48c84e3c57 100644 (file)
@@ -40,6 +40,7 @@ extern "C" {
 
 char *BLI_strdupn(const char *str, const size_t len)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull))
 #endif
@@ -47,6 +48,7 @@ __attribute__((nonnull))
 
 char *BLI_strdup(const char *str)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull))
 #endif
@@ -54,6 +56,7 @@ __attribute__((nonnull))
 
 char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull))
 #endif
@@ -81,6 +84,7 @@ __attribute__((nonnull))
 
 char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull))
 #endif
@@ -88,6 +92,7 @@ __attribute__((nonnull))
 
 char *BLI_replacestrN(const char *__restrict str, const char *__restrict substr_old, const char *__restrict substr_new)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__((warn_unused_result))
 __attribute__((nonnull))
 #endif
@@ -108,6 +113,7 @@ __attribute__ ((format(printf, 3, 0)))
 
 char *BLI_sprintfN(const char *__restrict format, ...)
 #ifdef __GNUC__
+__attribute__((malloc))
 __attribute__ ((format(printf, 1, 2)))
 __attribute__((warn_unused_result))
 __attribute__((nonnull))
@@ -183,4 +189,4 @@ __attribute__((nonnull))
 }
 #endif
 
-#endif
+#endif  /* __BLI_STRING_H__ */
index c645db4c15e87ca7123e8d93d6bd6ac40cc30279..0aaa3e13b3fcb55888e3dae7a1c6dbe70aa07ec9 100644 (file)
@@ -163,7 +163,7 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
 {
        HeapNode *node;
 
-       if (UNLIKELY((heap->size + 1) > heap->bufsize)) {
+       if (UNLIKELY(heap->size >= heap->bufsize)) {
                heap->bufsize *= 2;
                heap->tree = MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree));
        }
@@ -184,7 +184,7 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
 
        heap->size++;
 
-       heap_up(heap, heap->size - 1);
+       heap_up(heap, node->index);
 
        return node;
 }
@@ -230,6 +230,8 @@ void BLI_heap_remove(Heap *heap, HeapNode *node)
 {
        unsigned int i = node->index;
 
+       BLI_assert(heap->size != 0);
+
        while (i > 0) {
                unsigned int p = HEAP_PARENT(i);
 
index f370f32c31df1cd37a5fa4d9d0797d9ba5351162..bb326a23d590ae39c3d736e600b5988623ee9dbf 100644 (file)
@@ -334,38 +334,57 @@ void *BLI_mempool_findelem(BLI_mempool *pool, int index)
 }
 
 /**
+ * Fill in \a data with pointers to each element of the mempool,
+ * to create lookup table.
+ *
  * \param data array of pointers at least the size of 'pool->totused'
  */
-void BLI_mempool_as_array(BLI_mempool *pool, void **data)
+void BLI_mempool_as_table(BLI_mempool *pool, void **data)
 {
        BLI_mempool_iter iter;
        void *elem;
        void **p = data;
        BLI_assert(pool->flag & BLI_MEMPOOL_ALLOW_ITER);
        BLI_mempool_iternew(pool, &iter);
-       for (elem = BLI_mempool_iterstep(&iter); elem; elem = BLI_mempool_iterstep(&iter)) {
+       while ((elem = BLI_mempool_iterstep(&iter))) {
                *p++ = elem;
        }
        BLI_assert((p - data) == pool->totused);
 }
 
 /**
- * Allocate an array from the mempool.
+ * A version of #BLI_mempool_as_table that allocates and returns the data.
  */
-void *BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr)
+void **BLI_mempool_as_tableN(BLI_mempool *pool, const char *allocstr)
 {
-       char *data = MEM_mallocN((size_t)(pool->totused * pool->esize), allocstr);
+       void **data = MEM_mallocN((size_t)pool->totused * sizeof(void *), allocstr);
+       BLI_mempool_as_table(pool, data);
+       return data;
+}
+
+/**
+ * Fill in \a data with the contents of the mempool.
+ */
+void BLI_mempool_as_array(BLI_mempool *pool, void *data)
+{
+       BLI_mempool_iter iter;
+       char *elem, *p = data;
        BLI_assert(pool->flag & BLI_MEMPOOL_ALLOW_ITER);
-       if (data) {
-               BLI_mempool_iter iter;
-               char *elem, *p = data;
-               BLI_mempool_iternew(pool, &iter);
-               for (elem = BLI_mempool_iterstep(&iter); elem; elem = BLI_mempool_iterstep(&iter)) {
-                       memcpy(p, elem, (size_t)pool->esize);
-                       p += pool->esize;
-               }
-               BLI_assert((p - data) == pool->totused * pool->esize);
+       BLI_mempool_iternew(pool, &iter);
+       while ((elem = BLI_mempool_iterstep(&iter))) {
+               memcpy(p, elem, (size_t)pool->esize);
+               p += pool->esize;
        }
+       BLI_assert((p - (char *)data) == pool->totused * pool->esize);
+}
+
+/**
+ * A version of #BLI_mempool_as_array that allocates and returns the data.
+ */
+void *BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr)
+{
+       char *data = MEM_mallocN((size_t)(pool->totused * pool->esize), allocstr);
+       BLI_mempool_as_array(pool, data);
        return data;
 }
 
index aac3a3bc3f357ff8bcb180b40a4e97b116ed57b9..36fb04a7bb76f20acd681f863cbf823e1ba53cfe 100644 (file)
@@ -34,9 +34,12 @@ static void *buffer_alloc(BLI_Buffer *buffer, int len)
 
 static void *buffer_realloc(BLI_Buffer *buffer, int len)
 {
-       return ((buffer->flag & BLI_BUFFER_USE_CALLOC) ?
-               MEM_recallocN : MEM_reallocN)
-               (buffer->data, (buffer->elem_size * len));
+       if (buffer->flag & BLI_BUFFER_USE_CALLOC) {
+               return MEM_recallocN(buffer->data, buffer->elem_size * len);
+       }
+       else {
+               return MEM_reallocN(buffer->data, buffer->elem_size * len);
+       }
 }
 
 void BLI_buffer_resize(BLI_Buffer *buffer, int new_count)
index 99342c4d6dcb1a00ff971f5cb374aa3397758159..611b3298c380fa10c61b20b11982f8eb36b3fd4a 100644 (file)
@@ -433,6 +433,8 @@ void mul_m4_v4d(float mat[4][4], double r[4])
 
 void mul_v3_m3v3(float r[3], float M[3][3], const float a[3])
 {
+       BLI_assert(r != a);
+
        r[0] = M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
        r[1] = M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
        r[2] = M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
@@ -440,6 +442,8 @@ void mul_v3_m3v3(float r[3], float M[3][3], const float a[3])
 
 void mul_v2_m3v3(float r[2], float M[3][3], const float a[3])
 {
+       BLI_assert(r != a);
+
        r[0] = M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
        r[1] = M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
 }
index 873ce302b9cf0167489fbd337cf8850c807b2c71..c7163874dcad6545fa407a66c4cb7a774e8d19b2 100644 (file)
@@ -379,10 +379,10 @@ static ScanFillVertLink *addedgetoscanlist(ScanFillContext *sf_ctx, ScanFillEdge
        sc = (ScanFillVertLink *)bsearch(&scsearch, sf_ctx->_scdata, len,
                                         sizeof(ScanFillVertLink), vergscdata);
 
-       if (sc == 0) printf("Error in search edge: %p\n", (void *)eed);
+       if (sc == NULL) printf("Error in search edge: %p\n", (void *)eed);
        else if (addedgetoscanvert(sc, eed) == 0) return sc;
 
-       return 0;
+       return NULL;
 }
 
 static short boundinsideEV(ScanFillEdge *eed, ScanFillVert *eve)
@@ -669,7 +669,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
                                a = verts;
                                break;
                        }
-                       if (ed2 == 0) {
+                       if (ed2 == NULL) {
                                sc->edge_first = sc->edge_last = NULL;
                                /* printf("just 1 edge to vert\n"); */
                                BLI_addtail(&sf_ctx->filledgebase, ed1);
@@ -1051,7 +1051,7 @@ int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float no
                        eed = nexted;
                }
        }
-       if (sf_ctx->filledgebase.first == 0) {
+       if (sf_ctx->filledgebase.first == NULL) {
                /* printf("All edges removed\n"); */
                return 0;
        }
index 7a5450900901ee7faae1695cfdd71d455d789e6d..3f6adff1edaede0e3b013aaec99c82084997bd59 100644 (file)
@@ -121,7 +121,7 @@ static VoronoiParabola *voronoiParabola_new(void)
        parabola->is_leaf = FALSE;
        parabola->event = NULL;
        parabola->edge = NULL;
-       parabola->parent = 0;
+       parabola->parent = NULL;
 
        return parabola;
 }
@@ -134,7 +134,7 @@ static VoronoiParabola *voronoiParabola_newSite(float site[2])
        parabola->is_leaf = TRUE;
        parabola->event = NULL;
        parabola->edge = NULL;
-       parabola->parent = 0;
+       parabola->parent = NULL;
 
        return parabola;
 }
index 72b426a155a7618621e605ce1409ed5666ea7b81..b1c89846e90e1d2f846f9b908b6462ed8b0b8cac 100644 (file)
@@ -7278,7 +7278,7 @@ static void link_global(FileData *fd, BlendFileData *bfd)
        }
 }
 
-void convert_tface_mt(FileData *fd, Main *main)
+static void convert_tface_mt(FileData *fd, Main *main)
 {
        Main *gmain;
        
@@ -8174,12 +8174,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        for (ob = main->object.first; ob; ob = ob->id.next) {
                                bConstraint *con;
                                for (con = ob->constraints.first; con; con = con->next) {
-                                       bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
-                                       
-                                       if (!cti)
-                                               continue;
-                                       
-                                       if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
+                                       if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
                                                bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
                                                
                                                if (data->invmat[3][3] == 0.0f)
index d6fd2f924439e9c74932a044b2db5eb4d4cc279f..ca9f2faf998f5917a5e119054f5453204916bb0a 100644 (file)
@@ -72,7 +72,7 @@ int BLO_is_a_runtime(const char *path)
        int datastart;
        char buf[8];
 
-       if (fd == -1)
+       if (fd < 0)
                goto cleanup;
        
        lseek(fd, -12, SEEK_END);
@@ -104,7 +104,7 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
 
        fd = BLI_open(path, O_BINARY | O_RDONLY, 0);
 
-       if (fd == -1) {
+       if (fd < 0) {
                BKE_reportf(reports, RPT_ERROR, "Unable to open '%s': %s", path, strerror(errno));
                goto cleanup;
        }
index 12804e8042d241fbf19352d36103d3d6d2c96984..4f0ccd3c62652fb7acdb181286bf1dea43835765 100644 (file)
@@ -2394,7 +2394,7 @@ static void write_region(WriteData *wd, ARegion *ar, int spacetype)
        }
 }
 
-static void write_soops(WriteData *wd, SpaceOops *so)
+static void write_soops(WriteData *wd, SpaceOops *so, LinkNode **tmp_mem_list)
 {
        BLI_mempool *ts = so->treestore;
        
@@ -2402,18 +2402,35 @@ static void write_soops(WriteData *wd, SpaceOops *so)
                int elems = BLI_mempool_count(ts);
                /* linearize mempool to array */
                TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
-               TreeStore ts_flat = {elems, elems, data};
-               
-               /* temporarily replace mempool-treestore by flat-treestore */
-               so->treestore = (BLI_mempool *)&ts_flat;
-               writestruct(wd, DATA, "SpaceOops", 1, so);
-               /* restore old treestore */
-               so->treestore = ts;
-               writestruct(wd, DATA, "TreeStore", 1, &ts_flat);
+
                if (data) {
+                       TreeStore *ts_flat = MEM_callocN(sizeof(TreeStore), "TreeStore");
+
+                       ts_flat->usedelem = elems;
+                       ts_flat->totelem = elems;
+                       ts_flat->data = data;
+                       
+                       /* temporarily replace mempool-treestore by flat-treestore */
+                       so->treestore = (BLI_mempool *)ts_flat;
+                       writestruct(wd, DATA, "SpaceOops", 1, so);
+
+                       writestruct(wd, DATA, "TreeStore", 1, ts_flat);
                        writestruct(wd, DATA, "TreeStoreElem", elems, data);
-                       MEM_freeN(data);
+
+                       /* we do not free the pointers immediately, because if we have multiple
+                        * outliners in a screen we might get the same address on the next
+                        * malloc, which makes the address no longer unique and so invalid for
+                        * lookups on file read, causing crashes or double frees */
+                       BLI_linklist_append(tmp_mem_list, ts_flat);
+                       BLI_linklist_append(tmp_mem_list, data);
+               }
+               else {
+                       so->treestore = NULL;
+                       writestruct(wd, DATA, "SpaceOops", 1, so);
                }
+
+               /* restore old treestore */
+               so->treestore = ts;
        } else {
                writestruct(wd, DATA, "SpaceOops", 1, so);
        }
@@ -2425,6 +2442,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
        ScrArea *sa;
        ScrVert *sv;
        ScrEdge *se;
+       LinkNode *tmp_mem_list = NULL;
 
        sc= scrbase->first;
        while (sc) {
@@ -2501,7 +2519,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
                                }
                                else if (sl->spacetype==SPACE_OUTLINER) {
                                        SpaceOops *so= (SpaceOops *)sl;
-                                       write_soops(wd, so);
+                                       write_soops(wd, so, &tmp_mem_list);
                                }
                                else if (sl->spacetype==SPACE_IMAGE) {
                                        SpaceImage *sima= (SpaceImage *)sl;
@@ -2566,6 +2584,8 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
 
                sc= sc->id.next;
        }
+
+       BLI_linklist_freeN(tmp_mem_list);
        
        /* flush helps the compression for undo-save */
        mywrite(wd, MYWRITE_FLUSH, 0);
@@ -3396,7 +3416,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
        BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
 
        file = BLI_open(tempname, O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
-       if (file == -1) {
+       if (file < 0) {
                BKE_reportf(reports, RPT_ERROR, "Cannot open file %s for writing: %s", tempname, strerror(errno));
                return 0;
        }
index 1f7ace1ba6dbf9aa20ae46e25f0241f200bb0f19..35a5a2230ada102c55dfff6b03e8bfce396e8cde 100644 (file)
@@ -523,7 +523,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int len, const
        /* --- */
 
        /* create edges and find the winding (if faces are attached to any existing edges) */
-       vert_arr_map = MEM_mallocN(sizeof(BMVert **) * len, __func__);
+       vert_arr_map = MEM_mallocN(sizeof(BMVert *) * len, __func__);
 
        for (i = 0; i < len; i++) {
                vert_arr_map[i] = vert_arr[vang[i].index];
index f9e711a0dc3bf13f0fa3220e3d170111203878e3..8d3c47d2cd13eb98d357865925a092e6c19331b0 100644 (file)
@@ -1420,7 +1420,9 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
        e->l = NULL;
        if (l_next) {
                BMLoop *l_new, *l;
+#ifndef NDEBUG
                int radlen = bmesh_radial_length(l_next);
+#endif
                int first1 = 0, first2 = 0;
 
                /* Take the next loop. Remove it from radial. Split it. Append to appropriate radials */
@@ -1763,10 +1765,10 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
 
        /* validate that for each face, each vertex has another edge in its disk cycle that is
         * not e, and not shared. */
-       if (bmesh_radial_face_find(l_f1->next->e, f2) ||
-           bmesh_radial_face_find(l_f1->prev->e, f2) ||
-           bmesh_radial_face_find(l_f2->next->e, f1) ||
-           bmesh_radial_face_find(l_f2->prev->e, f1) )
+       if (BM_edge_in_face(l_f1->next->e, f2) ||
+           BM_edge_in_face(l_f1->prev->e, f2) ||
+           BM_edge_in_face(l_f2->next->e, f1) ||
+           BM_edge_in_face(l_f2->prev->e, f1) )
        {
                return NULL;
        }
index a484bd2fa278ac6bc8c0c5acc955dbaffefbd1d7..1f052bd206a29add66aacc4f238dedb63a46b0e5 100644 (file)
@@ -56,7 +56,7 @@ static int bm_vert_other_tag(BMVert *v, BMVert *v_prev,
                              BMEdge **r_e)
 {
        BMIter iter;
-       BMEdge *e, *e_next;
+       BMEdge *e, *e_next = NULL;
        unsigned int count = 0;
 
        BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
index 269501e1f02182cea052a7db80e4bccf87b46338..b71d5a7e7d4f1b7722c361760ffb64eb536277d3 100644 (file)
@@ -507,13 +507,13 @@ bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na
 void *BMO_slot_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int *len)
 {
        BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
-       void *ret;
+       void **ret;
 
        /* could add support for mapping type */
        BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
 
-       ret = MEM_mallocN(sizeof(void **) * slot->len, __func__);
-       memcpy(ret, slot->data.buf, sizeof(void **) * slot->len);
+       ret = MEM_mallocN(sizeof(void *) * slot->len, __func__);
+       memcpy(ret, slot->data.buf, sizeof(void *) * slot->len);
        *len = slot->len;
        return ret;
 }
index eea5ec596746c8dd493328290096f674e32ab0e4..43b261c118d7ad1696e6f3159089efb6f0f05e56 100644 (file)
@@ -95,7 +95,7 @@ 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, float n[3])
+static void bm_face_calc_poly_normal(const BMFace *f, float n[3])
 {
        BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
        BMLoop *l_iter  = l_first;
@@ -173,7 +173,7 @@ static void bm_face_calc_poly_center_mean_vertex_cos(BMFace *f, float r_cent[3],
  * \param r_loops  Store face loop pointers, (f->len)
  * \param r_index  Store triangle triples, indicies into \a r_loops,  ((f->len - 2) * 3)
  */
-int BM_face_calc_tessellation(BMFace *f, BMLoop **r_loops, int (*_r_index)[3])
+int BM_face_calc_tessellation(const BMFace *f, BMLoop **r_loops, int (*_r_index)[3])
 {
        int *r_index = (int *)_r_index;
        BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
@@ -579,7 +579,7 @@ void BM_vert_normal_update_all(BMVert *v)
  * is passed in as well.
  */
 
-void BM_face_calc_normal(BMFace *f, float r_no[3])
+void BM_face_calc_normal(const BMFace *f, float r_no[3])
 {
        BMLoop *l;
 
index 91fe94f8e48aa184a5ca52221554f4c99dbfb324..e5dc5c081c356d9776b5d1be714f612ea9f53ec6 100644 (file)
  *  \ingroup bmesh
  */
 
-int   BM_face_calc_tessellation(BMFace *f, BMLoop **r_loops, int (*r_index)[3])
+int   BM_face_calc_tessellation(const BMFace *f, BMLoop **r_loops, int (*r_index)[3])
 #ifdef __GNUC__
        __attribute__((warn_unused_result))
        __attribute__((nonnull))
 #endif
 ;
-void  BM_face_calc_normal(BMFace *f, float r_no[3]);
+void  BM_face_calc_normal(const BMFace *f, float r_no[3]);
 void  BM_face_calc_normal_vcos(BMesh *bm, BMFace *f, float r_no[3],
                                float const (*vertexCos)[3]);
 float BM_face_calc_area(BMFace *f);
index 6fd18c07179ec13fb77659176c95a25f5fa8d1d9..7ec418b2253e3c476cf05913c4cbeadca6d8bce1 100644 (file)
@@ -53,8 +53,8 @@ int bmesh_elem_check(void *element, const char htype);
        } (void)0
 #endif
 
-int bmesh_radial_length(BMLoop *l);
-int bmesh_disk_count(BMVert *v);
+int bmesh_radial_length(const BMLoop *l);
+int bmesh_disk_count(const BMVert *v);
 
 /**
  * Internal BMHeader.api_flag
index 0e2984c53cccd18d320c5b96a680dd1b5c5efa53..0eb3b0a6443b5bc91983921a20c16d9258c2df37 100644 (file)
@@ -336,7 +336,7 @@ bool BM_verts_in_face(BMFace *f, BMVert **varr, int len)
 /**
  * Returns whether or not a given edge is is part of a given face.
  */
-bool BM_edge_in_face(BMFace *f, BMEdge *e)
+bool BM_edge_in_face(BMEdge *e, BMFace *f)
 {
        if (e->l) {
                BMLoop *l_iter, *l_first;
@@ -644,7 +644,7 @@ int BM_vert_face_count(BMVert *v)
  * Tests whether or not the vertex is part of a wire edge.
  * (ie: has no faces attached to it)
  */
-bool BM_vert_is_wire(BMVert *v)
+bool BM_vert_is_wire(const BMVert *v)
 {
        if (v->e) {
                BMEdge *e_first, *e_iter;
@@ -667,7 +667,7 @@ bool BM_vert_is_wire(BMVert *v)
  * Tests whether or not the edge is part of a wire.
  * (ie: has no faces attached to it)
  */
-bool BM_edge_is_wire(BMEdge *e)
+bool BM_edge_is_wire(const BMEdge *e)
 {
        return (e->l == NULL);
 }
@@ -679,7 +679,7 @@ bool BM_edge_is_wire(BMEdge *e)
  * 3: Is part of a an edge with more than 2 faces.
  * 4: Is part of a wire edge.
  */
-bool BM_vert_is_manifold(BMVert *v)
+bool BM_vert_is_manifold(const BMVert *v)
 {
        BMEdge *e, *e_old;
        BMLoop *l;
@@ -744,7 +744,7 @@ bool BM_vert_is_manifold(BMVert *v)
  */
 
 #if 1 /* fast path for checking manifold */
-bool BM_edge_is_manifold(BMEdge *e)
+bool BM_edge_is_manifold(const BMEdge *e)
 {
        const BMLoop *l = e->l;
        return (l && (l->radial_next != l) &&             /* not 0 or 1 face users */
@@ -767,7 +767,7 @@ int BM_edge_is_manifold(BMEdge *e)
  * Tests that the edge is manifold and
  * that both its faces point the same way.
  */
-bool BM_edge_is_contiguous(BMEdge *e)
+bool BM_edge_is_contiguous(const BMEdge *e)
 {
        const BMLoop *l = e->l;
        const BMLoop *l_other;
@@ -780,7 +780,7 @@ bool BM_edge_is_contiguous(BMEdge *e)
  * Check if the edge is convex or concave
  * (depends on face winding)
  */
-bool BM_edge_is_convex(BMEdge *e)
+bool BM_edge_is_convex(const BMEdge *e)
 {
        if (BM_edge_is_manifold(e)) {
                BMLoop *l1 = e->l;
@@ -803,7 +803,7 @@ bool BM_edge_is_convex(BMEdge *e)
  */
 
 #if 1 /* fast path for checking boundary */
-bool BM_edge_is_boundary(BMEdge *e)
+bool BM_edge_is_boundary(const BMEdge *e)
 {
        const BMLoop *l = e->l;
        return (l && (l->radial_next == l));
@@ -821,7 +821,7 @@ int BM_edge_is_boundary(BMEdge *e)
 }
 #endif
 
-bool BM_vert_is_boundary(BMVert *v)
+bool BM_vert_is_boundary(const BMVert *v)
 {
        if (v->e) {
                BMEdge *e_first, *e_iter;
@@ -884,15 +884,15 @@ bool BM_face_share_face_check(BMFace *f1, BMFace *f2)
 /**
  *  Counts the number of edges two faces share (if any)
  */
-int BM_face_share_edge_count(BMFace *f1, BMFace *f2)
+int BM_face_share_edge_count(BMFace *f_a, BMFace *f_b)
 {
        BMLoop *l_iter;
        BMLoop *l_first;
        int count = 0;
        
-       l_iter = l_first = BM_FACE_FIRST_LOOP(f1);
+       l_iter = l_first = BM_FACE_FIRST_LOOP(f_a);
        do {
-               if (bmesh_radial_face_find(l_iter->e, f2)) {
+               if (BM_edge_in_face(l_iter->e, f_b)) {
                        count++;
                }
        } while ((l_iter = l_iter->next) != l_first);
@@ -910,7 +910,7 @@ bool BM_face_share_edge_check(BMFace *f1, BMFace *f2)
 
        l_iter = l_first = BM_FACE_FIRST_LOOP(f1);
        do {
-               if (bmesh_radial_face_find(l_iter->e, f2)) {
+               if (BM_edge_in_face(l_iter->e, f2)) {
                        return true;
                }
        } while ((l_iter = l_iter->next) != l_first);
@@ -930,7 +930,7 @@ bool BM_edge_share_face_check(BMEdge *e1, BMEdge *e2)
                l = e1->l;
                do {
                        f = l->f;
-                       if (bmesh_radial_face_find(e2, f)) {
+                       if (BM_edge_in_face(e2, f)) {
                                return true;
                        }
                        l = l->radial_next;
@@ -952,7 +952,7 @@ bool BM_edge_share_quad_check(BMEdge *e1, BMEdge *e2)
                do {
                        f = l->f;
                        if (f->len == 4) {
-                               if (bmesh_radial_face_find(e2, f)) {
+                               if (BM_edge_in_face(e2, f)) {
                                        return true;
                                }
                        }
@@ -1047,8 +1047,8 @@ BMLoop *BM_face_edge_share_loop(BMFace *f, BMEdge *e)
  * \note This is in fact quite a simple check, mainly include this function so the intent is more obvious.
  * We know these 2 verts will _always_ make up the loops edge
  */
-void BM_edge_ordered_verts_ex(BMEdge *edge, BMVert **r_v1, BMVert **r_v2,
-                              BMLoop *edge_loop)
+void BM_edge_ordered_verts_ex(const BMEdge *edge, BMVert **r_v1, BMVert **r_v2,
+                              const BMLoop *edge_loop)
 {
        BLI_assert(edge_loop->e == edge);
        (void)edge; /* quiet warning in release build */
@@ -1056,7 +1056,7 @@ void BM_edge_ordered_verts_ex(BMEdge *edge, BMVert **r_v1, BMVert **r_v2,
        *r_v2 = edge_loop->next->v;
 }
 
-void BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2)
+void BM_edge_ordered_verts(const BMEdge *edge, BMVert **r_v1, BMVert **r_v2)
 {
        BM_edge_ordered_verts_ex(edge, r_v1, r_v2, edge->l);
 }
@@ -1065,7 +1065,7 @@ void BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2)
  * Check if the loop is convex or concave
  * (depends on face normal)
  */
-bool BM_loop_is_convex(BMLoop *l)
+bool BM_loop_is_convex(const BMLoop *l)
 {
        float e_dir_prev[3];
        float e_dir_next[3];
@@ -1182,11 +1182,11 @@ void BM_loop_calc_face_tangent(BMLoop *l, float r_tangent[3])
  *
  * \return angle in radians
  */
-float BM_edge_calc_face_angle(BMEdge *e)
+float BM_edge_calc_face_angle(const BMEdge *e)
 {
        if (BM_edge_is_manifold(e)) {
-               BMLoop *l1 = e->l;
-               BMLoop *l2 = e->l->radial_next;
+               const BMLoop *l1 = e->l;
+               const BMLoop *l2 = e->l->radial_next;
                return angle_normalized_v3v3(l1->f->no, l2->f->no);
        }
        else {
@@ -1202,7 +1202,7 @@ float BM_edge_calc_face_angle(BMEdge *e)
  *
  * \return angle in radians
  */
-float BM_edge_calc_face_angle_signed(BMEdge *e)
+float BM_edge_calc_face_angle_signed(const BMEdge *e)
 {
        if (BM_edge_is_manifold(e)) {
                BMLoop *l1 = e->l;
@@ -1228,7 +1228,7 @@ float BM_edge_calc_face_angle_signed(BMEdge *e)
  * \param r_tangent The loop corner tangent to set
  */
 
-void BM_edge_calc_face_tangent(BMEdge *e, BMLoop *e_loop, float r_tangent[3])
+void BM_edge_calc_face_tangent(const BMEdge *e, const BMLoop *e_loop, float r_tangent[3])
 {
        float tvec[3];
        BMVert *v1, *v2;
@@ -1685,13 +1685,13 @@ bool BM_face_exists_multi_edge(BMEdge **earr, int len)
 }
 
 /* convenience functions for checking flags */
-bool BM_edge_is_any_vert_flag_test(BMEdge *e, const char hflag)
+bool BM_edge_is_any_vert_flag_test(const BMEdge *e, const char hflag)
 {
        return (BM_elem_flag_test(e->v1, hflag) ||
                BM_elem_flag_test(e->v2, hflag));
 }
 
-bool BM_face_is_any_vert_flag_test(BMFace *f, const char hflag)
+bool BM_face_is_any_vert_flag_test(const BMFace *f, const char hflag)
 {
        BMLoop *l_iter;
        BMLoop *l_first;
@@ -1705,7 +1705,7 @@ bool BM_face_is_any_vert_flag_test(BMFace *f, const char hflag)
        return false;
 }
 
-bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag)
+bool BM_face_is_any_edge_flag_test(const BMFace *f, const char hflag)
 {
        BMLoop *l_iter;
        BMLoop *l_first;
@@ -1722,7 +1722,7 @@ bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag)
 /**
  * Use within assert's to check normals are valid.
  */
-bool BM_face_is_normal_valid(BMFace *f)
+bool BM_face_is_normal_valid(const BMFace *f)
 {
        const float eps = 0.0001f;
        float no[3];
@@ -1731,7 +1731,7 @@ bool BM_face_is_normal_valid(BMFace *f)
        return len_squared_v3v3(no, f->no) < (eps * eps);
 }
 
-static void bm_mesh_calc_volume_face(BMFace *f, float *r_vol)
+static void bm_mesh_calc_volume_face(const BMFace *f, float *r_vol)
 {
        int tottri = f->len - 2;
        BMLoop **loops     = BLI_array_alloca(loops, f->len);
index 151d1de9b5b5f3e68754f62eb3601b965cf83ef7..2c931de995ed28aaf4038bf8f432a5256cf70a75 100644 (file)
@@ -33,7 +33,7 @@ bool    BM_vert_in_face(BMFace *f, BMVert *v);
 int     BM_verts_in_face_count(BMFace *f, BMVert **varr, int len);
 bool    BM_verts_in_face(BMFace *f, BMVert **varr, int len);
 
-bool    BM_edge_in_face(BMFace *f, BMEdge *e);
+bool    BM_edge_in_face(BMEdge *e, BMFace *f);
 bool    BM_edge_in_loop(BMEdge *e, BMLoop *l);
 
 bool    BM_vert_in_edge(const BMEdge *e, const BMVert *v);
@@ -58,26 +58,26 @@ int     BM_edge_face_count(BMEdge *e);
 int     BM_vert_face_count(BMVert *v);
 BMEdge *BM_vert_other_disk_edge(BMVert *v, BMEdge *e);
 
-bool    BM_vert_is_wire(BMVert *v);
-bool    BM_edge_is_wire(BMEdge *e);
+bool    BM_vert_is_wire(const BMVert *v);
+bool    BM_edge_is_wire(const BMEdge *e);
 
-bool    BM_vert_is_manifold(BMVert *v);
-bool    BM_edge_is_manifold(BMEdge *e);
-bool    BM_vert_is_boundary(BMVert *v);
-bool    BM_edge_is_boundary(BMEdge *e);
-bool    BM_edge_is_contiguous(BMEdge *e);
-bool    BM_edge_is_convex(BMEdge *e);
+bool    BM_vert_is_manifold(const BMVert *v);
+bool    BM_edge_is_manifold(const BMEdge *e);
+bool    BM_vert_is_boundary(const BMVert *v);
+bool    BM_edge_is_boundary(const BMEdge *e);
+bool    BM_edge_is_contiguous(const BMEdge *e);
+bool    BM_edge_is_convex(const BMEdge *e);
 
-bool    BM_loop_is_convex(BMLoop *l);
+bool    BM_loop_is_convex(const BMLoop *l);
 
 float   BM_loop_calc_face_angle(BMLoop *l);
 void    BM_loop_calc_face_normal(BMLoop *l, float r_normal[3]);
 void    BM_loop_calc_face_direction(BMLoop *l, float r_normal[3]);
 void    BM_loop_calc_face_tangent(BMLoop *l, float r_tangent[3]);
 
-float   BM_edge_calc_face_angle(BMEdge *e);
-float   BM_edge_calc_face_angle_signed(BMEdge *e);
-void    BM_edge_calc_face_tangent(BMEdge *e, BMLoop *e_loop, float r_tangent[3]);
+float   BM_edge_calc_face_angle(const BMEdge *e);
+float   BM_edge_calc_face_angle_signed(const BMEdge *e);
+void    BM_edge_calc_face_tangent(const BMEdge *e, const BMLoop *e_loop, float r_tangent[3]);
 
 float   BM_vert_calc_edge_angle(BMVert *v);
 float   BM_vert_calc_shell_factor(BMVert *v);
@@ -95,7 +95,7 @@ bool    BM_face_exists(BMVert **varr, int len, BMFace **r_existface);
 bool    BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len);
 bool    BM_face_exists_multi_edge(BMEdge **earr, int len);
 
-int     BM_face_share_face_count(BMFace *f1, BMFace *f2);
+int     BM_face_share_face_count(BMFace *f_a, BMFace *f_b);
 int     BM_face_share_edge_count(BMFace *f1, BMFace *f2);
 
 bool    BM_face_share_face_check(BMFace *f1, BMFace *f2);
@@ -108,15 +108,15 @@ BMVert *BM_edge_share_vert(BMEdge *e1, BMEdge *e2);
 BMLoop *BM_face_vert_share_loop(BMFace *f, BMVert *v);
 BMLoop *BM_face_edge_share_loop(BMFace *f, BMEdge *e);
 
-void    BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2);
-void    BM_edge_ordered_verts_ex(BMEdge *edge, BMVert **r_v1, BMVert **r_v2,
-                                 BMLoop *edge_loop);
+void    BM_edge_ordered_verts(const BMEdge *edge, BMVert **r_v1, BMVert **r_v2);
+void    BM_edge_ordered_verts_ex(const BMEdge *edge, BMVert **r_v1, BMVert **r_v2,
+                                 const BMLoop *edge_loop);
 
-bool BM_edge_is_any_vert_flag_test(BMEdge *e, const char hflag);
-bool BM_face_is_any_vert_flag_test(BMFace *f, const char hflag);
-bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag);
+bool BM_edge_is_any_vert_flag_test(const BMEdge *e, const char hflag);
+bool BM_face_is_any_vert_flag_test(const BMFace *f, const char hflag);
+bool BM_face_is_any_edge_flag_test(const BMFace *f, const char hflag);
 
-bool BM_face_is_normal_valid(BMFace *f);
+bool BM_face_is_normal_valid(const BMFace *f);
 
 float BM_mesh_calc_volume(BMesh *bm, bool is_signed);
 
index a0907f0db7a0e8e1fcacea2fee5ff7441400d23d..286425cbacfc416dc8ec57fe69ac0c9b18bf034a 100644 (file)
@@ -45,7 +45,7 @@ bool bmesh_vert_in_edge(const BMEdge *e, const BMVert *v)
        if (e->v1 == v || e->v2 == v) return true;
        return false;
 }
-bool bmesh_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e)
+bool bmesh_verts_in_edge(const BMVert *v1, const BMVert *v2, const BMEdge *e)
 {
        if (e->v1 == v1 && e->v2 == v2) return true;
        else if (e->v1 == v2 && e->v2 == v1) return true;
@@ -130,7 +130,6 @@ bool bmesh_edge_swapverts(BMEdge *e, BMVert *v_orig, BMVert *v_new)
  * Functions relating to this cycle:
  * - #bmesh_radial_append
  * - #bmesh_radial_loop_remove
- * - #bmesh_radial_face_find
  * - #bmesh_radial_facevert_count
  * - #bmesh_radial_faceloop_find_first
  * - #bmesh_radial_faceloop_find_next
@@ -217,7 +216,7 @@ void bmesh_disk_edge_remove(BMEdge *e, BMVert *v)
  *
  * \return Pointer to the next edge in the disk cycle for the vertex v.
  */
-BMEdge *bmesh_disk_edge_next(BMEdge *e, BMVert *v)
+BMEdge *bmesh_disk_edge_next(const BMEdge *e, const BMVert *v)
 {
        if (v == e->v1)
                return e->v1_disk_link.next;
@@ -226,7 +225,7 @@ BMEdge *bmesh_disk_edge_next(BMEdge *e, BMVert *v)
        return NULL;
 }
 
-BMEdge *bmesh_disk_edge_prev(BMEdge *e, BMVert *v)
+BMEdge *bmesh_disk_edge_prev(const BMEdge *e, const BMVert *v)
 {
        if (v == e->v1)
                return e->v1_disk_link.prev;
@@ -235,7 +234,7 @@ BMEdge *bmesh_disk_edge_prev(BMEdge *e, BMVert *v)
        return NULL;
 }
 
-BMEdge *bmesh_disk_edge_exists(BMVert *v1, BMVert *v2)
+BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2)
 {
        BMEdge *e_iter, *e_first;
        
@@ -252,7 +251,7 @@ BMEdge *bmesh_disk_edge_exists(BMVert *v1, BMVert *v2)
        return NULL;
 }
 
-int bmesh_disk_count(BMVert *v)
+int bmesh_disk_count(const BMVert *v)
 {
        if (v->e) {
                BMEdge *e_first, *e_iter;
@@ -305,7 +304,7 @@ bool bmesh_disk_validate(int len, BMEdge *e, BMVert *v)
  * equivalent to counting the number of
  * faces incident upon this vertex
  */
-int bmesh_disk_facevert_count(BMVert *v)
+int bmesh_disk_facevert_count(const BMVert *v)
 {
        /* is there an edge on this vert at all */
        if (v->e) {
@@ -334,29 +333,28 @@ int bmesh_disk_facevert_count(BMVert *v)
  * vert's loops attached
  * to it.
  */
-BMEdge *bmesh_disk_faceedge_find_first(BMEdge *e, BMVert *v)
+BMEdge *bmesh_disk_faceedge_find_first(const BMEdge *e, const BMVert *v)
 {
-       BMEdge *searchedge = NULL;
-       searchedge = e;
+       const BMEdge *e_find = e;
        do {
-               if (searchedge->l && bmesh_radial_facevert_count(searchedge->l, v)) {
-                       return searchedge;
+               if (e_find->l && bmesh_radial_facevert_count(e_find->l, v)) {
+                       return (BMEdge *)e_find;
                }
-       } while ((searchedge = bmesh_disk_edge_next(searchedge, v)) != e);
+       } while ((e_find = bmesh_disk_edge_next(e_find, v)) != e);
 
        return NULL;
 }
 
-BMEdge *bmesh_disk_faceedge_find_next(BMEdge *e, BMVert *v)
+BMEdge *bmesh_disk_faceedge_find_next(const BMEdge *e, const BMVert *v)
 {
-       BMEdge *searchedge = NULL;
-       searchedge = bmesh_disk_edge_next(e, v);
+       BMEdge *e_find = NULL;
+       e_find = bmesh_disk_edge_next(e, v);
        do {
-               if (searchedge->l && bmesh_radial_facevert_count(searchedge->l, v)) {
-                       return searchedge;
+               if (e_find->l && bmesh_radial_facevert_count(e_find->l, v)) {
+                       return e_find;
                }
-       } while ((searchedge = bmesh_disk_edge_next(searchedge, v)) != e);
-       return e;
+       } while ((e_find = bmesh_disk_edge_next(e_find, v)) != e);
+       return (BMEdge *)e;
 }
 
 /*****radial cycle functions, e.g. loops surrounding edges**** */
@@ -436,19 +434,19 @@ void bmesh_radial_loop_remove(BMLoop *l, BMEdge *e)
  * Finds the first loop of v around radial
  * cycle
  */
-BMLoop *bmesh_radial_faceloop_find_first(BMLoop *l, BMVert *v)
+BMLoop *bmesh_radial_faceloop_find_first(const BMLoop *l, const BMVert *v)
 {
-       BMLoop *l_iter;
+       const BMLoop *l_iter;
        l_iter = l;
        do {
                if (l_iter->v == v) {
-                       return l_iter;
+                       return (BMLoop *)l_iter;
                }
        } while ((l_iter = l_iter->radial_next) != l);
        return NULL;
 }
 
-BMLoop *bmesh_radial_faceloop_find_next(BMLoop *l, BMVert *v)
+BMLoop *bmesh_radial_faceloop_find_next(const BMLoop *l, const BMVert *v)
 {
        BMLoop *l_iter;
        l_iter = l->radial_next;
@@ -457,12 +455,12 @@ BMLoop *bmesh_radial_faceloop_find_next(BMLoop *l, BMVert *v)
                        return l_iter;
                }
        } while ((l_iter = l_iter->radial_next) != l);
-       return l;
+       return (BMLoop *)l;
 }
 
-int bmesh_radial_length(BMLoop *l)
+int bmesh_radial_length(const BMLoop *l)
 {
-       BMLoop *l_iter = l;
+       const BMLoop *l_iter = l;
        int i = 0;
 
        if (!l)
@@ -509,28 +507,15 @@ void bmesh_radial_append(BMEdge *e, BMLoop *l)
        l->e = e;
 }
 
-bool bmesh_radial_face_find(BMEdge *e, BMFace *f)
-{
-       BMLoop *l_iter;
-       int i, len;
-
-       len = bmesh_radial_length(e->l);
-       for (i = 0, l_iter = e->l; i < len; i++, l_iter = l_iter->radial_next) {
-               if (l_iter->f == f)
-                       return true;
-       }
-       return false;
-}
-
 /**
  * \brief RADIAL COUNT FACE VERT
  *
  * Returns the number of times a vertex appears
  * in a radial cycle
  */
-int bmesh_radial_facevert_count(BMLoop *l, BMVert *v)
+int bmesh_radial_facevert_count(const BMLoop *l, const BMVert *v)
 {
-       BMLoop *l_iter;
+       const BMLoop *l_iter;
        int count = 0;
        l_iter = l;
        do {
index f10e3a123776691404a5804db91a9cbde048ef9c..f64fb911ab4f44edf7fc4a3eac85eefe77221f3e 100644 (file)
@@ -47,11 +47,11 @@ bool    bmesh_loop_validate(BMFace *f);
 /* DISK CYCLE MANAGMENT */
 void    bmesh_disk_edge_append(BMEdge *e, BMVert *v);
 void    bmesh_disk_edge_remove(BMEdge *e, BMVert *v);
-BMEdge *bmesh_disk_edge_next(BMEdge *e, BMVert *v);
-BMEdge *bmesh_disk_edge_prev(BMEdge *e, BMVert *v);
-int     bmesh_disk_facevert_count(BMVert *v);
-BMEdge *bmesh_disk_faceedge_find_first(BMEdge *e, BMVert *v);
-BMEdge *bmesh_disk_faceedge_find_next(BMEdge *e, BMVert *v);
+BMEdge *bmesh_disk_edge_next(const BMEdge *e, const BMVert *v);
+BMEdge *bmesh_disk_edge_prev(const BMEdge *e, const BMVert *v);
+int     bmesh_disk_facevert_count(const BMVert *v);
+BMEdge *bmesh_disk_faceedge_find_first(const BMEdge *e, const BMVert *v);
+BMEdge *bmesh_disk_faceedge_find_next(const BMEdge *e, const BMVert *v);
 
 /* RADIAL CYCLE MANAGMENT */
 void    bmesh_radial_append(BMEdge *e, BMLoop *l);
@@ -60,19 +60,18 @@ void    bmesh_radial_loop_remove(BMLoop *l, BMEdge *e);
  *      bmesh_radial_loop_next(BMLoop *l) / prev.
  * just use member access l->radial_next, l->radial_prev now */
 
-bool    bmesh_radial_face_find(BMEdge *e, BMFace *f);
-int     bmesh_radial_facevert_count(BMLoop *l, BMVert *v);
-BMLoop *bmesh_radial_faceloop_find_first(BMLoop *l, BMVert *v);
-BMLoop *bmesh_radial_faceloop_find_next(BMLoop *l, BMVert *v);
-BMLoop *bmesh_radial_faceloop_find_vert(BMFace *f, BMVert *v);
+int     bmesh_radial_facevert_count(const BMLoop *l, const BMVert *v);
+BMLoop *bmesh_radial_faceloop_find_first(const BMLoop *l, const BMVert *v);
+BMLoop *bmesh_radial_faceloop_find_next(const BMLoop *l, const BMVert *v);
+BMLoop *bmesh_radial_faceloop_find_vert(const BMFace *f, const BMVert *v);
 bool    bmesh_radial_validate(int radlen, BMLoop *l);
 
 /* EDGE UTILITIES */
 bool    bmesh_vert_in_edge(const BMEdge *e, const BMVert *v);
-bool    bmesh_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e);
+bool    bmesh_verts_in_edge(const BMVert *v1, const BMVert *v2, const BMEdge *e);
 bool    bmesh_edge_swapverts(BMEdge *e, BMVert *orig, BMVert *newv);  /* relink edge */
 BMVert *bmesh_edge_other_vert_get(BMEdge *e, BMVert *v);
-BMEdge *bmesh_disk_edge_exists(BMVert *v1, BMVert *v2);
+BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2);
 bool    bmesh_disk_validate(int len, BMEdge *e, BMVert *v);
 
 #endif /* __BMESH_STRUCTURE_H__ */
index 04edec01a5c3c05092fb91b13ff75a3fa190ef05..80b85ab6eddfae9efe5646d9056716f47b9516a6 100644 (file)
@@ -92,10 +92,11 @@ void BMW_init(BMWalker *walker, BMesh *bm, int type,
 
        if (UNLIKELY(type >= BMW_MAXWALKERS || type < 0)) {
                fprintf(stderr,
-                       "Invalid walker type in BMW_init; type: %d, "
+                       "%s: Invalid walker type in BMW_init; type: %d, "
                        "searchmask: (v:%d, e:%d, f:%d), flag: %d, layer: %d\n",
-                       type, mask_vert, mask_edge, mask_face, flag, layer);
-               BMESH_ASSERT(0);
+                       __func__, type, mask_vert, mask_edge, mask_face, flag, layer);
+               BLI_assert(0);
+               return;
        }
        
        if (type != BMW_CUSTOM) {
index e43c04f7d080ae66b4cb08dffd3e3e78529e25eb..64d0ec6ac275ff21c2bb6ff22a1487bcad624ed6 100644 (file)
@@ -278,7 +278,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
                 * this connectivity could be used rather then treating
                 * them as a bunch of isolated verts. */
 
-               BMVert **vert_arr = MEM_mallocN(sizeof(BMVert **) * totv, __func__);
+               BMVert **vert_arr = MEM_mallocN(sizeof(BMVert *) * totv, __func__);
                BMFace *f;
 
                BMO_iter_as_array(op->slots_in, "geom", BM_VERT, (void **)vert_arr, totv);
index 325b40cb9352a341ef72e753393728c7f27942d8..4e78d1dc494aed3e13353bf71521360394f50a55 100644 (file)
@@ -826,10 +826,8 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E
                }
 
                if (!v2) {
-                       if (path) {
-                               edge_free_path(pathbase, path);
-                               path = NULL;
-                       }
+                       edge_free_path(pathbase, path);
+                       path = NULL;
                        continue;
                }
 
index 91a52cdabefe95e822ab9ab36dbbea36dfc6114d..3f04e23aa7389fe36d4e7b9d750ed16a5a05eda4 100644 (file)
@@ -220,7 +220,7 @@ static void init_laplacian_matrix(LaplacianSystem *sys)
                        v1 = vf[0]->co;
                        v2 = vf[1]->co;
                        v3 = vf[2]->co;
-                       v4 = has_4_vert ? vf[3]->co : 0;
+                       v4 = has_4_vert ? vf[3]->co : NULL;
 
                        if (has_4_vert) {
                                areaf = area_quad_v3(v1, v2, v3, v4);
index fc2e1bbaf3edd93477fd9e3d3bd2139c1d409b80..c07e2c3bbf2d6ff793924c57a650e4a0735306c6 100644 (file)
@@ -177,7 +177,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
 
        /* will over-alloc, but makes for easy lookups by index to keep aligned  */
        BMVert **verts_boundary = use_boundary ?
-                                 MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__) : NULL;
+                                 MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__) : NULL;
 
        float  *verts_relfac    = use_relative_offset ?
                                  MEM_mallocN(sizeof(float) * totvert_orig, __func__) : NULL;
@@ -250,7 +250,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
                BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
        }
 
-       verts_loop = MEM_mallocN(sizeof(BMVert **) * verts_loop_tot, __func__);
+       verts_loop = MEM_mallocN(sizeof(BMVert *) * verts_loop_tot, __func__);
        verts_loop_tot = 0; /* count up again */
 
        BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) {
index d3ffc3485392244970d7c75dda2339a076f5cac1..4b6835a81fe3cee0304b65ab47471666c84264fd 100644 (file)
@@ -345,7 +345,7 @@ static bool bm_decim_triangulate_begin(BMesh *bm)
                        }
 
 #ifdef USE_SAFETY_CHECKS
-                       if (BM_edge_exists(l_a->v, l_b->v) == false)
+                       if (BM_edge_exists(l_a->v, l_b->v) == NULL)
 #endif
                        {
                                BMFace *f_new;
index 9f97d8f4287c39a442db13e89b18372796d8ef6a..310357453a3690c9457e866656b9f4cbf4bed843 100644 (file)
 #include "MEM_guardedalloc.h"
 
 #include "BLI_math.h"
+#include "BLI_heap.h"
 
 #include "bmesh.h"
 #include "bmesh_decimate.h"  /* own include */
 
-#define UNIT_TO_ANGLE DEG2RADF(90.0f)
-#define ANGLE_TO_UNIT (1.0f / UNIT_TO_ANGLE)
+#define COST_INVALID FLT_MAX
+
 
 /* multiply vertex edge angle by face angle
  * this means we are not left with sharp corners between _almost_ planer faces
  * convert angles [0-PI/2] -> [0-1], multiply together, then convert back to radians. */
 static float bm_vert_edge_face_angle(BMVert *v)
 {
+#define UNIT_TO_ANGLE DEG2RADF(90.0f)
+#define ANGLE_TO_UNIT (1.0f / UNIT_TO_ANGLE)
+
        const float angle = BM_vert_calc_edge_angle(v);
        /* note: could be either edge, it doesn't matter */
        if (v->e && BM_edge_is_manifold(v->e)) {
@@ -50,167 +54,184 @@ static float bm_vert_edge_face_angle(BMVert *v)
        else {
                return angle;
        }
-}
 
 #undef UNIT_TO_ANGLE
 #undef ANGLE_TO_UNIT
+}
 
-typedef struct DissolveElemWeight {
-       BMHeader *ele;
-       float weight;
-} DissolveElemWeight;
-
-static int dissolve_elem_cmp(const void *a1, const void *a2)
+static float bm_edge_calc_dissolve_error(const BMEdge *e, const BMO_Delimit delimit)
 {
-       const struct DissolveElemWeight *d1 = a1, *d2 = a2;
+       const bool is_contig = BM_edge_is_contiguous(e);
+       float angle;
+
+       if (!BM_edge_is_manifold(e)) {
+               goto fail;
+       }
+
+       if ((delimit & BMO_DELIM_SEAM) &&
+           (BM_elem_flag_test(e, BM_ELEM_SEAM)))
+       {
+               goto fail;
+       }
+
+       if ((delimit & BMO_DELIM_MATERIAL) &&
+           (e->l->f->mat_nr != e->l->radial_next->f->mat_nr))
+       {
+               goto fail;
+       }
+
+       if ((delimit & BMO_DELIM_NORMAL) &&
+           (is_contig == false))
+       {
+               goto fail;
+       }
+
+       angle = BM_edge_calc_face_angle(e);
+       if (is_contig == false) {
+               angle = (float)M_PI - angle;
+       }
 
-       if      (d1->weight > d2->weight) return  1;
-       else if (d1->weight < d2->weight) return -1;
-       return 0;
+       return angle;
+
+fail:
+       return COST_INVALID;
 }
 
+
 void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                   const BMO_Delimit delimit,
                                   BMVert **vinput_arr, const int vinput_len,
                                   BMEdge **einput_arr, const int einput_len,
                                   const short oflag_out)
 {
-       const float angle_max = (float)M_PI / 2.0f;
-       DissolveElemWeight *weight_elems = MEM_mallocN(max_ii(einput_len, vinput_len) *
-                                                      sizeof(DissolveElemWeight), __func__);
-       int i, tot_found;
-       BMIter iter;
-       BMEdge *e_iter;
-       BMEdge **earray;
+       const int eheap_table_len = do_dissolve_boundaries ? einput_len : max_ii(einput_len, vinput_len);
+       void *_heap_table = MEM_mallocN(sizeof(HeapNode *) * eheap_table_len, __func__);
 
-       int *vert_reverse_lookup;
+       int i;
 
        /* --- first edges --- */
-
-       /* wire -> tag */
-       BM_ITER_MESH (e_iter, &iter, bm, BM_EDGES_OF_MESH) {
-               BM_elem_flag_set(e_iter, BM_ELEM_TAG, BM_edge_is_wire(e_iter));
-       }
-
-       /* go through and split edge */
-       for (i = 0, tot_found = 0; i < einput_len; i++) {
-               BMEdge *e = einput_arr[i];
-               const bool is_contig = BM_edge_is_contiguous(e);
-               float angle;
-
-               angle = BM_edge_calc_face_angle(e);
-               if (is_contig == false) {
-                       angle = (float)M_PI - angle;
+       if (1) {
+               BMEdge **earray;
+               Heap *eheap;
+               HeapNode **eheap_table = _heap_table;
+               HeapNode *enode_top;
+               int *vert_reverse_lookup;
+               BMIter iter;
+               BMEdge *e_iter;
+
+               /* --- setup heap --- */
+               eheap = BLI_heap_new_ex(einput_len);
+               eheap_table = _heap_table;
+
+               /* wire -> tag */
+               BM_ITER_MESH (e_iter, &iter, bm, BM_EDGES_OF_MESH) {
+                       BM_elem_flag_set(e_iter, BM_ELEM_TAG, BM_edge_is_wire(e_iter));
+                       BM_elem_index_set(e_iter, -1);  /* set dirty */
                }
-
-               if (angle < angle_limit) {
-                       tot_found++;
+               bm->elem_index_dirty |= BM_EDGE;
+
+               /* build heap */
+               for (i = 0; i < einput_len; i++) {
+                       BMEdge *e = einput_arr[i];
+                       const float cost = bm_edge_calc_dissolve_error(e, delimit);
+                       eheap_table[i] = BLI_heap_insert(eheap, cost, e);
+                       BM_elem_index_set(e, i);  /* set dirty */
                }
-               weight_elems[i].ele = (BMHeader *)e;
-               weight_elems[i].weight = angle;
-       }
-
-       if (tot_found != 0) {
-               qsort(weight_elems, einput_len, sizeof(DissolveElemWeight), dissolve_elem_cmp);
 
-               for (i = 0; i < tot_found; i++) {
-                       BMEdge *e = (BMEdge *)weight_elems[i].ele;
-                       const bool is_contig = BM_edge_is_contiguous(e);
-                       float angle;
+               while ((BLI_heap_is_empty(eheap) == false) &&
+                      (BLI_heap_node_value((enode_top = BLI_heap_top(eheap))) < angle_limit))
+               {
+                       BMFace *f_new = NULL;
+                       BMEdge *e;
 
-                       /* may have become non-manifold */
-                       if (!BM_edge_is_manifold(e)) {
-                               continue;
-                       }
+                       e = BLI_heap_node_ptr(enode_top);
+                       i = BM_elem_index_get(e);
 
-                       if ((delimit & BMO_DELIM_SEAM) &&
-                           (BM_elem_flag_test(e, BM_ELEM_SEAM)))
-                       {
-                               continue;
-                       }
-
-                       if ((delimit & BMO_DELIM_MATERIAL) &&
-                           (e->l->f->mat_nr != e->l->radial_next->f->mat_nr))
-                       {
-                               continue;
-                       }
-
-                       if ((delimit & BMO_DELIM_NORMAL) &&
-                           (is_contig == false))
-                       {
-                               continue;
-                       }
+                       if (BM_edge_is_manifold(e)) {
+                               f_new = BM_faces_join_pair(bm, e->l->f,
+                                                          e->l->radial_next->f, e,
+                                                          false); /* join faces */
 
-                       /* check twice because cumulative effect could dissolve over angle limit */
-                       angle = BM_edge_calc_face_angle(e);
-                       if (is_contig == false) {
-                               angle = (float)M_PI - angle;
-                       }
+                               if (f_new) {
+                                       BMLoop *l_first, *l_iter;
 
-                       if (angle < angle_limit) {
-                               BMFace *f_new = BM_faces_join_pair(bm, e->l->f,
-                                                                  e->l->radial_next->f,
-                                                                  e,
-                                                                  false); /* join faces */
+                                       BLI_heap_remove(eheap, enode_top);
+                                       eheap_table[i] = NULL;
 
-                               /* there may be some errors, we don't mind, just move on */
-                               if (f_new) {
+                                       /* update normal */
                                        BM_face_normal_update(f_new);
                                        if (oflag_out) {
                                                BMO_elem_flag_enable(bm, f_new, oflag_out);
                                        }
+
+                                       /* re-calculate costs */
+                                       l_iter = l_first = BM_FACE_FIRST_LOOP(f_new);
+                                       do {
+                                               const int j = BM_elem_index_get(l_iter->e);
+                                               if (j != -1 && eheap_table[j]) {
+                                                       const float cost = bm_edge_calc_dissolve_error(l_iter->e, delimit);
+                                                       BLI_heap_remove(eheap, eheap_table[j]);
+                                                       eheap_table[j] = BLI_heap_insert(eheap, cost, l_iter->e);
+                                               }
+                                       } while ((l_iter = l_iter->next) != l_first);
                                }
                                else {
                                        BMO_error_clear(bm);
                                }
                        }
+
+                       if (UNLIKELY(f_new == NULL)) {
+                               BLI_heap_remove(eheap, enode_top);
+                               eheap_table[i] = BLI_heap_insert(eheap, COST_INVALID, e);
+                       }
                }
-       }
 
-       /* prepare for cleanup */
-       BM_mesh_elem_index_ensure(bm, BM_VERT);
-       vert_reverse_lookup = MEM_mallocN(sizeof(int) * bm->totvert, __func__);
-       fill_vn_i(vert_reverse_lookup, bm->totvert, -1);
-       for (i = 0, tot_found = 0; i < vinput_len; i++) {
-               BMVert *v = vinput_arr[i];
-               vert_reverse_lookup[BM_elem_index_get(v)] = i;
-       }
+               /* prepare for cleanup */
+               BM_mesh_elem_index_ensure(bm, BM_VERT);
+               vert_reverse_lookup = MEM_mallocN(sizeof(int) * bm->totvert, __func__);
+               fill_vn_i(vert_reverse_lookup, bm->totvert, -1);
+               for (i = 0; i < vinput_len; i++) {
+                       BMVert *v = vinput_arr[i];
+                       vert_reverse_lookup[BM_elem_index_get(v)] = i;
+               }
 
-       /* --- cleanup --- */
-       earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__);
-       BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) {
-               earray[i] = e_iter;
-       }
-       /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */
-       for (i = bm->totedge - 1; i != -1; i--) {
-               e_iter = earray[i];
-
-               if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == false)) {
-                       /* edge has become wire */
-                       int vidx_reverse;
-                       BMVert *v1 = e_iter->v1;
-                       BMVert *v2 = e_iter->v2;
-                       BM_edge_kill(bm, e_iter);
-                       if (v1->e == NULL) {
-                               vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)];
-                               if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL;
-                               BM_vert_kill(bm, v1);
-                       }
-                       if (v2->e == NULL) {
-                               vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)];
-                               if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL;
-                               BM_vert_kill(bm, v2);
+               /* --- cleanup --- */
+               earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__);
+               BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) {
+                       earray[i] = e_iter;
+               }
+               /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */
+               for (i = bm->totedge - 1; i != -1; i--) {
+                       e_iter = earray[i];
+
+                       if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == false)) {
+                               /* edge has become wire */
+                               int vidx_reverse;
+                               BMVert *v1 = e_iter->v1;
+                               BMVert *v2 = e_iter->v2;
+                               BM_edge_kill(bm, e_iter);
+                               if (v1->e == NULL) {
+                                       vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)];
+                                       if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL;
+                                       BM_vert_kill(bm, v1);
+                               }
+                               if (v2->e == NULL) {
+                                       vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)];
+                                       if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL;
+                                       BM_vert_kill(bm, v2);
+                               }
                        }
                }
-       }
-       MEM_freeN(vert_reverse_lookup);
+               MEM_freeN(vert_reverse_lookup);
+               MEM_freeN(earray);
 
-       MEM_freeN(earray);
+               BLI_heap_free(eheap, NULL);
+       }
 
 
        /* --- second verts --- */
        if (do_dissolve_boundaries) {
-               /* simple version of the branch below, sincve we will dissolve _all_ verts that use 2 edges */
+               /* simple version of the branch below, since we will dissolve _all_ verts that use 2 edges */
                for (i = 0; i < vinput_len; i++) {
                        BMVert *v = vinput_arr[i];
                        if (LIKELY(v != NULL) &&
@@ -221,43 +242,78 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool
                }
        }
        else {
-               for (i = 0, tot_found = 0; i < vinput_len; i++) {
-                       BMVert *v = vinput_arr[i];
-                       const float angle = v ? bm_vert_edge_face_angle(v) : angle_limit;
+               Heap *vheap;
+               HeapNode **vheap_table = _heap_table;
+               HeapNode *vnode_top;
 
-                       if (angle < angle_limit) {
-                               weight_elems[i].ele = (BMHeader *)v;
-                               weight_elems[i].weight = angle;
-                               tot_found++;
-                       }
-                       else {
-                               weight_elems[i].ele = NULL;
-                               weight_elems[i].weight = angle_max;
+               BMVert *v_iter;
+               BMIter iter;
+
+               BM_ITER_MESH (v_iter, &iter, bm, BM_VERTS_OF_MESH) {
+                       BM_elem_index_set(v_iter, -1);  /* set dirty */
+               }
+               bm->elem_index_dirty |= BM_VERT;
+
+               vheap = BLI_heap_new_ex(vinput_len);
+
+               for (i = 0; i < vinput_len; i++) {
+                       BMVert *v = vinput_arr[i];
+                       if (LIKELY(v != NULL)) {
+                               const float cost = bm_vert_edge_face_angle(v);
+                               vheap_table[i] = BLI_heap_insert(vheap, cost, v);
+                               BM_elem_index_set(v, i);  /* set dirty */
                        }
                }
 
-               if (tot_found != 0) {
-                       qsort(weight_elems, vinput_len, sizeof(DissolveElemWeight), dissolve_elem_cmp);
-
-                       for (i = 0; i < tot_found; i++) {
-                               BMVert *v = (BMVert *)weight_elems[i].ele;
-                               if (LIKELY(v != NULL) &&
-                                   /* topology changes may cause this to be un-collapsable */
-                                   (BM_vert_edge_count(v) == 2) &&
-                                   /* check twice because cumulative effect could dissolve over angle limit */
-                                   bm_vert_edge_face_angle(v) < angle_limit)
-                               {
-                                       BMEdge *e_new = BM_vert_collapse_edge(bm, v->e, v, true); /* join edges */
-
-                                       if (e_new && e_new->l) {
-                                               BM_edge_normals_update(e_new);
+               while ((BLI_heap_is_empty(vheap) == false) &&
+                      (BLI_heap_node_value((vnode_top = BLI_heap_top(vheap))) < angle_limit))
+               {
+                       BMEdge *e_new = NULL;
+                       BMVert *v;
+
+                       v = BLI_heap_node_ptr(vnode_top);
+                       i = BM_elem_index_get(v);
+
+                       if (BM_vert_edge_count(v) == 2) {
+                               e_new = BM_vert_collapse_edge(bm, v->e, v, true); /* join edges */
+
+                               if (e_new) {
+
+                                       BLI_heap_remove(vheap, vnode_top);
+                                       vheap_table[i] = NULL;
+
+                                       /* update normal */
+                                       if (e_new->l) {
+                                               BMLoop *l_first, *l_iter;
+                                               l_iter = l_first = e_new->l;
+                                               do {
+                                                       BM_face_normal_update(l_iter->f);
+                                               } while ((l_iter = l_iter->radial_next) != l_first);
+
+                                       }
+
+                                       /* re-calculate costs */
+                                       BM_ITER_ELEM(v_iter, &iter, e_new, BM_VERTS_OF_EDGE) {
+                                               const int j = BM_elem_index_get(v_iter);
+                                               if (j != -1 && vheap_table[j]) {
+                                                       const float cost = bm_vert_edge_face_angle(v_iter);
+                                                       BLI_heap_remove(vheap, vheap_table[j]);
+                                                       vheap_table[j] = BLI_heap_insert(vheap, cost, v_iter);
+                                               }
                                        }
                                }
                        }
+
+                       if (UNLIKELY(e_new == NULL)) {
+                               BLI_heap_remove(vheap, vnode_top);
+                               vheap_table[i] = BLI_heap_insert(vheap, COST_INVALID, v);
+                       }
                }
+
+               BLI_heap_free(vheap, NULL);
        }
 
-       MEM_freeN(weight_elems);
+       MEM_freeN(_heap_table);
 }
 
 void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
index b3ec7c78808e1826bd00041075a9643d0a9df704..c1b99274bed0d877c7af509add1494653434705e 100644 (file)
@@ -425,14 +425,12 @@ set(SRC
        operations/COM_CompositorOperation.cpp
        operations/COM_OutputFileOperation.h
        operations/COM_OutputFileOperation.cpp
-       operations/COM_ViewerBaseOperation.h
-       operations/COM_ViewerBaseOperation.cpp
        operations/COM_ViewerOperation.h
        operations/COM_ViewerOperation.cpp
        operations/COM_PreviewOperation.h
        operations/COM_PreviewOperation.cpp
-       operations/COM_SplitViewerOperation.h
-       operations/COM_SplitViewerOperation.cpp
+       operations/COM_SplitOperation.h
+       operations/COM_SplitOperation.cpp
        operations/COM_ConvertValueToColorProg.h
        operations/COM_ConvertValueToColorProg.cpp
        operations/COM_ConvertColorToValueProg.h
index fc5461888166b2e094cf5fb32f9d685fbd444bb7..204c3237e650a5d3dd3cf87d7b25232fe627971a 100644 (file)
@@ -107,7 +107,7 @@ extern "C" {
  *  - [@ref ChunkExecutionState.COM_ES_EXECUTED]: Chunk is finished
  *
  * @see ExecutionGroup.execute
- * @see ViewerBaseOperation.getChunkOrder
+ * @see ViewerOperation.getChunkOrder
  * @see OrderOfChunks
  *
  * @section interest Area of interest
index 51eaffaa31cecd612acc7efd488c5fee9417b8ca..827b93c350e2be01368e82e6e6c496cafcb46dcd 100644 (file)
@@ -248,7 +248,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
        OrderOfChunks chunkorder = COM_ORDER_OF_CHUNKS_DEFAULT;
 
        if (operation->isViewerOperation()) {
-               ViewerBaseOperation *viewer = (ViewerBaseOperation *)operation;
+               ViewerOperation *viewer = (ViewerOperation *)operation;
                centerX = viewer->getCenterX();
                centerY = viewer->getCenterY();
                chunkorder = viewer->getChunkOrder();
index 9f0a943c8a2f19c50509821059e6781c3fdd27c9..9024cd33745dcd9bcf95d886fce7daf230b3c1aa 100644 (file)
@@ -36,7 +36,7 @@
 #include "COM_GroupNode.h"
 #include "COM_WriteBufferOperation.h"
 #include "COM_ReadBufferOperation.h"
-#include "COM_ViewerBaseOperation.h"
+#include "COM_ViewerOperation.h"
 
 extern "C" {
 #include "BKE_node.h"
@@ -212,7 +212,7 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
                        printf("|");
                }
                if (operation->isViewerOperation()) {
-                       ViewerBaseOperation *viewer = (ViewerBaseOperation *)operation;
+                       ViewerOperation *viewer = (ViewerOperation *)operation;
                        if (viewer->isActiveViewerOutput()) {
                                printf("Active viewer");
                        }
index 5259fbc7dc5fb58134c34bdb35728134e03b360d..74e557c77cec2a1a9477c10bcd06bd4e0b3d317a 100644 (file)
@@ -114,4 +114,7 @@ void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorCon
        testSocketConnection(graph, context, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT));
        testSocketConnection(graph, context, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT));
        testSocketConnection(graph, context, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR));
+       testSocketConnection(graph, context, 28, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_DIRECT));
+       testSocketConnection(graph, context, 29, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_INDIRECT));
+       testSocketConnection(graph, context, 30, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_COLOR));
 }
index 0293f4926dbf6799693d717a24e1840d98793ae8..a9f2d46b62f74f3eb073d3f08c61ce673e7a7c6a 100644 (file)
@@ -23,7 +23,8 @@
 #include "COM_SplitViewerNode.h"
 #include "BKE_global.h"
 
-#include "COM_SplitViewerOperation.h"
+#include "COM_SplitOperation.h"
+#include "COM_ViewerOperation.h"
 #include "COM_ExecutionSystem.h"
 
 SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode)
@@ -42,29 +43,32 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont
        InputSocket *image2Socket = this->getInputSocket(1);
        Image *image = (Image *)this->getbNode()->id;
        ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
-       if (image1Socket->isConnected() && image2Socket->isConnected()) {
-               SplitViewerOperation *splitViewerOperation = new SplitViewerOperation();
-               splitViewerOperation->setImage(image);
-               splitViewerOperation->setImageUser(imageUser);
-               splitViewerOperation->setActive(is_active);
-               splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
 
-               splitViewerOperation->setViewSettings(context->getViewSettings());
-               splitViewerOperation->setDisplaySettings(context->getDisplaySettings());
+       SplitOperation *splitViewerOperation = new SplitOperation();
+       splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
+       splitViewerOperation->setXSplit(!this->getbNode()->custom2);
 
-               /* defaults - the viewer node has these options but not exposed for split view
-                * we could use the split to define an area of interest on one axis at least */
-               splitViewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
-               splitViewerOperation->setCenterX(0.5f);
-               splitViewerOperation->setCenterY(0.5f);
+       image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph);
+       image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1, graph);
 
-               splitViewerOperation->setXSplit(!this->getbNode()->custom2);
-               image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph);
-               image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1, graph);
+       ViewerOperation *viewerOperation = new ViewerOperation();
+       viewerOperation->setImage(image);
+       viewerOperation->setImageUser(imageUser);
+       viewerOperation->setActive(is_active);
+       viewerOperation->setViewSettings(context->getViewSettings());
+       viewerOperation->setDisplaySettings(context->getDisplaySettings());
 
-               if (is_active)
-                       addPreviewOperation(graph, context, splitViewerOperation->getInputSocket(0));
+       /* defaults - the viewer node has these options but not exposed for split view
+        * we could use the split to define an area of interest on one axis at least */
+       viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
+       viewerOperation->setCenterX(0.5f);
+       viewerOperation->setCenterY(0.5f);
 
-               graph->addOperation(splitViewerOperation);
-       }
+       addLink(graph, splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0));
+
+       if (is_active)
+               addPreviewOperation(graph, context, viewerOperation->getInputSocket(0));
+
+       graph->addOperation(splitViewerOperation);
+       graph->addOperation(viewerOperation);
 }
similarity index 62%
rename from source/blender/compositor/operations/COM_SplitViewerOperation.cpp
rename to source/blender/compositor/operations/COM_SplitOperation.cpp
index 7325e32a863b328086ef3a5b313e24a517a7c2b1..a7dbccfc2f7d4d16c6d1a4a11a08227c3b3d7cfb 100644 (file)
@@ -20,7 +20,7 @@
  *             Monique Dewanchand
  */
 
-#include "COM_SplitViewerOperation.h"
+#include "COM_SplitOperation.h"
 #include "COM_SocketConnection.h"
 #include "BLI_listbase.h"
 #include "BKE_image.h"
@@ -35,58 +35,47 @@ extern "C" {
 }
 
 
-SplitViewerOperation::SplitViewerOperation() : ViewerBaseOperation()
+SplitOperation::SplitOperation() : NodeOperation()
 {
        this->addInputSocket(COM_DT_COLOR);
        this->addInputSocket(COM_DT_COLOR);
+       this->addOutputSocket(COM_DT_COLOR);
        this->m_image1Input = NULL;
        this->m_image2Input = NULL;
 }
 
-void SplitViewerOperation::initExecution()
+void SplitOperation::initExecution()
 {
        // When initializing the tree during initial load the width and height can be zero.
        this->m_image1Input = getInputSocketReader(0);
        this->m_image2Input = getInputSocketReader(1);
-       ViewerBaseOperation::initExecution();
 }
 
-void SplitViewerOperation::deinitExecution()
+void SplitOperation::deinitExecution()
 {
        this->m_image1Input = NULL;
        this->m_image2Input = NULL;
-       ViewerBaseOperation::deinitExecution();
 }
 
-
-void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
+void SplitOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
 {
-       float *buffer = this->m_outputBuffer;
-       
-       if (!buffer) return;
-       int x1 = rect->xmin;
-       int y1 = rect->ymin;
-       int x2 = rect->xmax;
-       int y2 = rect->ymax;
-       int offset = (y1 * this->getWidth() + x1) * 4;
-       int x;
-       int y;
        int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f : this->m_splitPercentage * this->getHeight() / 100.0f;
-       for (y = y1; y < y2; y++) {
-               for (x = x1; x < x2; x++) {
-                       bool image1;
-                       image1 = this->m_xSplit ? x > perc : y > perc;
-                       if (image1) {
-                               this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
-                       }
-                       else {
-                               this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
-                       }
-
-                       offset += 4;
-               }
-               offset += (this->getWidth() - (x2 - x1)) * 4;
+       bool image1 = this->m_xSplit ? x > perc : y > perc;
+       if (image1) {
+               this->m_image1Input->read(output, x, y, COM_PS_NEAREST);
+       }
+       else {
+               this->m_image2Input->read(output, x, y, COM_PS_NEAREST);
        }
-       updateImage(rect);
 }
 
+void SplitOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+{
+       unsigned int tempPreferredResolution[2] = {0, 0};
+       unsigned int tempResolution[2];
+
+       this->getInputSocket(0)->determineResolution(tempResolution, tempPreferredResolution);
+       this->setResolutionInputSocketIndex((tempResolution[0] && tempResolution[1]) ? 0 : 1);
+
+       NodeOperation::determineResolution(resolution, preferredResolution);
+}
similarity index 78%
rename from source/blender/compositor/operations/COM_SplitViewerOperation.h
rename to source/blender/compositor/operations/COM_SplitOperation.h
index c759e14e1dd51edc5c74674bd8b17316b2dc1d6f..5a042b789d8cb51757d7a7dd958b42152d557b16 100644 (file)
  *             Monique Dewanchand
  */
 
-#ifndef _COM_SplitViewerOperation_h
-#define _COM_SplitViewerOperation_h
-#include "COM_ViewerBaseOperation.h"
-#include "DNA_image_types.h"
-#include "BLI_rect.h"
+#ifndef _COM_SplitOperation_h
+#define _COM_SplitOperation_h
+#include "COM_NodeOperation.h"
 
-class SplitViewerOperation : public ViewerBaseOperation {
+class SplitOperation : public NodeOperation {
 private:
        SocketReader *m_image1Input;
        SocketReader *m_image2Input;
@@ -34,10 +32,11 @@ private:
        float m_splitPercentage;
        bool m_xSplit;
 public:
-       SplitViewerOperation();
-       void executeRegion(rcti *rect, unsigned int tileNumber);
+       SplitOperation();
        void initExecution();
        void deinitExecution();
+       void executePixel(float output[4], float x, float y, PixelSampler sampler);
+       void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
        void setSplitPercentage(float splitPercentage) { this->m_splitPercentage = splitPercentage; }
        void setXSplit(bool xsplit) { this->m_xSplit = xsplit; }
 };
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
deleted file mode 100644 (file)
index 0722469..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor: 
- *             Jeroen Bakker 
- *             Monique Dewanchand
- */
-
-#include "COM_ViewerBaseOperation.h"
-#include "COM_SocketConnection.h"
-#include "BLI_listbase.h"
-#include "BKE_image.h"
-#include "WM_api.h"
-#include "WM_types.h"
-#include "PIL_time.h"
-#include "BLI_utildefines.h"
-#include "BLI_math_color.h"
-
-extern "C" {
-       #include "MEM_guardedalloc.h"
-       #include "IMB_imbuf.h"
-       #include "IMB_imbuf_types.h"
-       #include "IMB_colormanagement.h"
-}
-
-
-ViewerBaseOperation::ViewerBaseOperation() : NodeOperation()
-{
-       this->setImage(NULL);
-       this->setImageUser(NULL);
-       this->m_outputBuffer = NULL;
-       this->m_depthBuffer = NULL;
-       this->m_active = false;
-       this->m_doDepthBuffer = false;
-       this->m_viewSettings = NULL;
-       this->m_displaySettings = NULL;
-       this->m_ignoreAlpha = false;
-}
-
-void ViewerBaseOperation::initExecution()
-{
-       if (isActiveViewerOutput()) {
-               initImage();
-       }
-}
-
-void ViewerBaseOperation::initImage()
-{
-       Image *anImage = this->m_image;
-       ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock);
-
-       if (!ibuf) return;
-       BLI_lock_thread(LOCK_DRAW_IMAGE);
-       if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
-
-               imb_freerectImBuf(ibuf);
-               imb_freerectfloatImBuf(ibuf);
-               IMB_freezbuffloatImBuf(ibuf);
-               ibuf->x = getWidth();
-               ibuf->y = getHeight();
-               imb_addrectfloatImBuf(ibuf);
-               anImage->ok = IMA_OK_LOADED;
-
-               ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
-
-               BLI_unlock_thread(LOCK_DRAW_IMAGE);
-       }
-
-       if (m_doDepthBuffer) {
-               addzbuffloatImBuf(ibuf);
-       }
-       BLI_unlock_thread(LOCK_DRAW_IMAGE);
-
-       /* now we combine the input with ibuf */
-       this->m_outputBuffer = ibuf->rect_float;
-
-       /* needed for display buffer update */
-       this->m_ibuf = ibuf;
-
-       if (m_doDepthBuffer) {
-               this->m_depthBuffer = ibuf->zbuf_float;
-       }
-
-       BKE_image_release_ibuf(this->m_image, this->m_ibuf, this->m_lock);
-}
-
-void ViewerBaseOperation:: updateImage(rcti *rect)
-{
-       IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, NULL, getWidth(), 0, 0,
-                                         this->m_viewSettings, this->m_displaySettings,
-                                         rect->xmin, rect->ymin, rect->xmax, rect->ymax, FALSE);
-
-       this->updateDraw();
-}
-
-void ViewerBaseOperation::deinitExecution()
-{
-       this->m_outputBuffer = NULL;
-}
-
-const CompositorPriority ViewerBaseOperation::getRenderPriority() const
-{
-       if (this->isActiveViewerOutput()) {
-               return COM_PRIORITY_HIGH;
-       }
-       else {
-               return COM_PRIORITY_LOW;
-       }
-}
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
deleted file mode 100644 (file)
index 7ead96b..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor: 
- *             Jeroen Bakker 
- *             Monique Dewanchand
- */
-
-#ifndef _COM_ViewerBaseOperation_h
-#define _COM_ViewerBaseOperation_h
-#include "COM_NodeOperation.h"
-#include "DNA_image_types.h"
-#include "BLI_rect.h"
-#include "BKE_global.h"
-
-class ViewerBaseOperation : public NodeOperation {
-protected:
-       float *m_outputBuffer;
-       float *m_depthBuffer;
-       Image *m_image;
-       ImageUser *m_imageUser;
-       void *m_lock;
-       bool m_active;
-       float m_centerX;
-       float m_centerY;
-       OrderOfChunks m_chunkOrder;
-       bool m_doDepthBuffer;
-       ImBuf *m_ibuf;
-       bool m_ignoreAlpha;
-
-       const ColorManagedViewSettings *m_viewSettings;
-       const ColorManagedDisplaySettings *m_displaySettings;
-
-public:
-       bool isOutputOperation(bool rendering) const { if (G.background) return false; return isActiveViewerOutput(); }
-       void initExecution();
-       void deinitExecution();
-       void setImage(Image *image) { this->m_image = image; }
-       void setImageUser(ImageUser *imageUser) { this->m_imageUser = imageUser; }
-       const bool isActiveViewerOutput() const { return this->m_active; }
-       void setActive(bool active) { this->m_active = active; }
-       void setCenterX(float centerX) { this->m_centerX = centerX;}
-       void setCenterY(float centerY) { this->m_centerY = centerY;}
-       void setChunkOrder(OrderOfChunks tileOrder) { this->m_chunkOrder = tileOrder; }
-       float getCenterX() { return this->m_centerX; }
-       float getCenterY() { return this->m_centerY; }
-       OrderOfChunks getChunkOrder() { return this->m_chunkOrder; }
-       const CompositorPriority getRenderPriority() const;
-       bool isViewerOperation() { return true; }
-       void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; }
-
-       void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
-       void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }
-protected:
-       ViewerBaseOperation();
-       void updateImage(rcti *rect);
-
-private:
-       void initImage();
-};
-#endif
index 4d10e49aeebfd73cdbbd2a4c4d83dcd8eef5241f..e9f083178e4257d1e7074ef0dedb2f917b6472a7 100644 (file)
@@ -35,11 +35,22 @@ extern "C" {
        #include "MEM_guardedalloc.h"
        #include "IMB_imbuf.h"
        #include "IMB_imbuf_types.h"
+       #include "IMB_colormanagement.h"
 }
 
 
-ViewerOperation::ViewerOperation() : ViewerBaseOperation()
+ViewerOperation::ViewerOperation() : NodeOperation()
 {
+       this->setImage(NULL);
+       this->setImageUser(NULL);
+       this->m_outputBuffer = NULL;
+       this->m_depthBuffer = NULL;
+       this->m_active = false;
+       this->m_doDepthBuffer = false;
+       this->m_viewSettings = NULL;
+       this->m_displaySettings = NULL;
+       this->m_ignoreAlpha = false;
+       
        this->addInputSocket(COM_DT_COLOR);
        this->addInputSocket(COM_DT_VALUE);
        this->addInputSocket(COM_DT_VALUE);
@@ -56,7 +67,10 @@ void ViewerOperation::initExecution()
        this->m_alphaInput = getInputSocketReader(1);
        this->m_depthInput = getInputSocketReader(2);
        this->m_doDepthBuffer = (this->m_depthInput != NULL);
-       ViewerBaseOperation::initExecution();
+       
+       if (isActiveViewerOutput()) {
+               initImage();
+       }
 }
 
 void ViewerOperation::deinitExecution()
@@ -64,10 +78,9 @@ void ViewerOperation::deinitExecution()
        this->m_imageInput = NULL;
        this->m_alphaInput = NULL;
        this->m_depthInput = NULL;
-       ViewerBaseOperation::deinitExecution();
+       this->m_outputBuffer = NULL;
 }
 
-
 void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
 {
        float *buffer = this->m_outputBuffer;
@@ -114,3 +127,63 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
        }
        updateImage(rect);
 }
+
+void ViewerOperation::initImage()
+{
+       Image *ima = this->m_image;
+       void *lock;
+       ImBuf *ibuf = BKE_image_acquire_ibuf(ima, this->m_imageUser, &lock);
+
+       if (!ibuf) return;
+       BLI_lock_thread(LOCK_DRAW_IMAGE);
+       if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
+
+               imb_freerectImBuf(ibuf);
+               imb_freerectfloatImBuf(ibuf);
+               IMB_freezbuffloatImBuf(ibuf);
+               ibuf->x = getWidth();
+               ibuf->y = getHeight();
+               imb_addrectfloatImBuf(ibuf);
+               ima->ok = IMA_OK_LOADED;
+
+               ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+
+               BLI_unlock_thread(LOCK_DRAW_IMAGE);
+       }
+
+       if (m_doDepthBuffer) {
+               addzbuffloatImBuf(ibuf);
+       }
+       BLI_unlock_thread(LOCK_DRAW_IMAGE);
+
+       /* now we combine the input with ibuf */
+       this->m_outputBuffer = ibuf->rect_float;
+
+       /* needed for display buffer update */
+       this->m_ibuf = ibuf;
+
+       if (m_doDepthBuffer) {
+               this->m_depthBuffer = ibuf->zbuf_float;
+       }
+
+       BKE_image_release_ibuf(this->m_image, this->m_ibuf, lock);
+}
+
+void ViewerOperation::updateImage(rcti *rect)
+{
+       IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, NULL, getWidth(), 0, 0,
+                                         this->m_viewSettings, this->m_displaySettings,
+                                         rect->xmin, rect->ymin, rect->xmax, rect->ymax, FALSE);
+
+       this->updateDraw();
+}
+
+const CompositorPriority ViewerOperation::getRenderPriority() const
+{
+       if (this->isActiveViewerOutput()) {
+               return COM_PRIORITY_HIGH;
+       }
+       else {
+               return COM_PRIORITY_LOW;
+       }
+}
index 262efd87dba53baabae65faa36f7af57ced28bf3..0b8d08d3974aa20ffd55f0e481c59d17897804c4 100644 (file)
 #include "COM_NodeOperation.h"
 #include "DNA_image_types.h"
 #include "BLI_rect.h"
-#include "COM_ViewerBaseOperation.h"
+#include "BKE_global.h"
 
-class ViewerOperation : public ViewerBaseOperation {
+class ViewerOperation : public NodeOperation {
 private:
+       float *m_outputBuffer;
+       float *m_depthBuffer;
+       Image *m_image;
+       ImageUser *m_imageUser;
+       bool m_active;
+       float m_centerX;
+       float m_centerY;
+       OrderOfChunks m_chunkOrder;
+       bool m_doDepthBuffer;
+       ImBuf *m_ibuf;
+       bool m_ignoreAlpha;
+       
+       const ColorManagedViewSettings *m_viewSettings;
+       const ColorManagedDisplaySettings *m_displaySettings;
+       
        SocketReader *m_imageInput;
        SocketReader *m_alphaInput;
        SocketReader *m_depthInput;
 
 public:
        ViewerOperation();
-       void executeRegion(rcti *rect, unsigned int tileNumber);
        void initExecution();
        void deinitExecution();
+       void executeRegion(rcti *rect, unsigned int tileNumber);
+       bool isOutputOperation(bool rendering) const { if (G.background) return false; return isActiveViewerOutput(); }
+       void setImage(Image *image) { this->m_image = image; }
+       void setImageUser(ImageUser *imageUser) { this->m_imageUser = imageUser; }
+       const bool isActiveViewerOutput() const { return this->m_active; }
+       void setActive(bool active) { this->m_active = active; }
+       void setCenterX(float centerX) { this->m_centerX = centerX;}
+       void setCenterY(float centerY) { this->m_centerY = centerY;}
+       void setChunkOrder(OrderOfChunks tileOrder) { this->m_chunkOrder = tileOrder; }
+       float getCenterX() const { return this->m_centerX; }
+       float getCenterY() const { return this->m_centerY; }
+       OrderOfChunks getChunkOrder() const { return this->m_chunkOrder; }
+       const CompositorPriority getRenderPriority() const;
+       bool isViewerOperation() { return true; }
+       void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; }
+
+       void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
+       void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }
+
+private:
+       void updateImage(rcti *rect);
+       void initImage();
 };
 #endif
index 4e6cc53f962c155999a2b8f908d2df419fc5d94e..db51e3c2398ba2e70b8d5fa11a2c84c6fc2f237f 100644 (file)
@@ -793,7 +793,7 @@ void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos)
 {
        DLRBT_Tree keys, blocks;
        
-       short locked = (act && act->id.lib != 0);
+       short locked = (act && act->id.lib != NULL);
        
        BLI_dlrbTree_init(&keys);
        BLI_dlrbTree_init(&blocks);
@@ -887,7 +887,7 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree
        bAnimListElem *ale;
        int filter;
        
-       bAnimListElem dummychan = {0};
+       bAnimListElem dummychan = {NULL};
        
        if (sce == NULL)
                return;
@@ -920,8 +920,8 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl
        bAnimListElem *ale;
        int filter;
        
-       bAnimListElem dummychan = {0};
-       Base dummybase = {0};
+       bAnimListElem dummychan = {NULL};
+       Base dummybase = {NULL};
        
        if (ob == NULL)
                return;
index f2b3ce206f1d5f4c978d25042d3d16b7f05c6fef..fe1d2fa3765d8111d2f4b551d2ba81f9d8df0972 100644 (file)
@@ -714,10 +714,10 @@ static void armature_select_less(bArmature *UNUSED(arm), EditBone *ebone)
        }
 }
 
-static void armature_select_more_less(Objectob, bool more)
+static void armature_select_more_less(Object *ob, bool more)
 {
-       bArmaturearm = (bArmature *)ob->data;
-       EditBoneebone;
+       bArmature *arm = (bArmature *)ob->data;
+       EditBone *ebone;
 
        /* XXX, eventually we shouldn't need this - campbell */
        ED_armature_sync_selection(arm->edbo);
index c530faedd6876b91432334fd30dbc93a329e0eba..79ca70a618963c55418a83a18f743ac94769e153 100644 (file)
@@ -815,7 +815,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
                 * just pose values should change, so this should be fine 
                 */
                bPose *dummyPose = NULL;
-               Object workob = {{0}};
+               Object workob = {{NULL}};
                bPoseChannel *pchan;
                
                /* execute animation step for current frame using a dummy copy of the pose */
index 2daab0724356eb4bd40153747b4b0ad86e7ece08..9a9cab9b46cdc8a80fcb88d58e8bd53e3ffb2ed8 100644 (file)
@@ -550,7 +550,11 @@ typedef struct uiStringInfo {
 /* Note: Expects pointers to uiStringInfo structs as parameters.
  *       Will fill them with translated strings, when possible.
  *       Strings in uiStringInfo must be MEM_freeN'ed by caller. */
-void uiButGetStrInfo(struct bContext *C, uiBut *but, ...);
+void uiButGetStrInfo(struct bContext *C, uiBut *but, ...)
+#ifdef __GNUC__
+__attribute__((sentinel))
+#endif
+;
 
 /* Edit i18n stuff. */
 /* Name of the main py op from i18n addon. */
index b3df719d95abe016c9c65ccb3e0522c893dbd01e..622559cd30f26870e870437e001e0f2fa888c01a 100644 (file)
@@ -6623,8 +6623,8 @@ static bool ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *me
                /* am I the last menu (test) */
                ARegion *ar = menu->region->next;
                do {
-                       uiBlock *block = ar->uiblocks.first;
-                       if (block && ui_block_is_menu(block)) {
+                       uiBlock *block_iter = ar->uiblocks.first;
+                       if (block_iter && ui_block_is_menu(block_iter)) {
                                return true;
                        }
                } while ((ar = ar->next));
index 2e80af1b3ad87e623aae8a45973e8104d4ea66b2..079ba97aa9d74f1d2004e1df02fbd92dd28fa294 100644 (file)
@@ -355,7 +355,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
        PropertyType type;
        PropertySubType subtype;
        uiLayout *sub;
-       int a, b;
+       unsigned int a, b;
 
        /* retrieve type and subtype */
        type = RNA_property_type(prop);
@@ -373,8 +373,8 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
                /* special check for layer layout */
                int butw, buth, unit;
                int cols = (len >= 20) ? 2 : 1;
-               int colbuts = len / (2 * cols);
-               int layer_used = 0;
+               const unsigned int colbuts = len / (2 * cols);
+               unsigned int layer_used = 0;
 
                uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE));
 
index 5910909142c48673e01b27831ab514f3150dc355..cfe6e313c580a9ee2b48692d35de3671b2cc5b64 100644 (file)
@@ -704,12 +704,12 @@ static void UI_OT_reports_to_textblock(wmOperatorType *ot)
 /* EditSource Utility funcs and operator,
  * note, this includes utility functions and button matching checks */
 
-struct uiEditSourceStore {
+typedef struct uiEditSourceStore {
        uiBut but_orig;
        GHash *hash;
 } uiEditSourceStore;
 
-struct uiEditSourceButStore {
+typedef struct uiEditSourceButStore {
        char py_dbg_fn[FILE_MAX];
        int py_dbg_ln;
 } uiEditSourceButStore;
index dc780d6a4f14821724b5434e9526ba278bec3055..1ef4d43c9f3aa2fc6f57858f7e401603aaba8322 100644 (file)
@@ -1953,7 +1953,7 @@ void init_userdef_do_versions(void)
        if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
                bTheme *btheme;
                for (btheme = U.themes.first; btheme; btheme = btheme->next) {
-                       if (btheme->tseq.movieclip[0] == 0) {
+                       if (btheme->tseq.movieclip[3] == 0) {
                                rgba_char_args_set(btheme->tseq.movieclip,  32, 32, 143, 255);
                        }
                }
@@ -2002,7 +2002,7 @@ void init_userdef_do_versions(void)
        if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
                bTheme *btheme;
                for (btheme = U.themes.first; btheme; btheme = btheme->next) {
-                       if (btheme->tseq.movieclip[0] == 0) {
+                       if (btheme->tseq.mask[3] == 0) {
                                rgba_char_args_set(btheme->tseq.mask,  152, 78, 62, 255);
                        }
                }
index c524aeb06eed39b2273381ea8a18daa8649c73a9..90796e9eb934736c90ca9e4bd62ce42492a81e89 100644 (file)
@@ -809,8 +809,9 @@ static int mask_select_more_less(bContext *C, bool more)
                }
 
                for (spline = masklay->splines.first; spline; spline = spline->next) {
+                       const bool cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0;
+                       bool start_sel, end_sel, prev_sel, cur_sel;
                        int i;
-                       bool start_sel, end_sel, prev_sel, cur_sel, cyclic = spline->flag & MASK_SPLINE_CYCLIC;
 
                        /* reselect point if any handle is selected to make the result more predictable */
                        for (i = 0; i < spline->tot_point; i++) {
@@ -826,6 +827,10 @@ static int mask_select_more_less(bContext *C, bool more)
                                start_sel = !!MASKPOINT_ISSEL_KNOT(spline->points);
                                end_sel = !!MASKPOINT_ISSEL_KNOT(&spline->points[spline->tot_point - 1]);
                        }
+                       else {
+                               start_sel = false;
+                               end_sel = false;
+                       }
 
                        for (i = 0; i < spline->tot_point; i++) {
                                if (i == 0 && !cyclic) {
index db5635d6ea394c812cf96f3a02cce5a3fbbe6e7b..902906fcf8a092372272184eaa114e3241726749 100644 (file)
@@ -291,49 +291,37 @@ void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags)
        me = BKE_mesh_from_object(ob);
        if (me == NULL) return;
        
-       if (action == SEL_INVERT) {
+       if (action == SEL_TOGGLE) {
+               action = SEL_SELECT;
+
                mpoly = me->mpoly;
                a = me->totpoly;
                while (a--) {
-                       if ((mpoly->flag & ME_HIDE) == 0) {
-                               mpoly->flag ^= ME_FACE_SEL;
+                       if ((mpoly->flag & ME_HIDE) == 0 && mpoly->flag & ME_FACE_SEL) {
+                               action = SEL_DESELECT;
+                               break;
                        }
                        mpoly++;
                }
        }
-       else {
-               if (action == SEL_TOGGLE) {
-                       action = SEL_SELECT;
-
-                       mpoly = me->mpoly;
-                       a = me->totpoly;
-                       while (a--) {
-                               if ((mpoly->flag & ME_HIDE) == 0 && mpoly->flag & ME_FACE_SEL) {
-                                       action = SEL_DESELECT;
-                                       break;
-                               }
-                               mpoly++;
-                       }
-               }
 
-               mpoly = me->mpoly;
-               a = me->totpoly;
-               while (a--) {
-                       if ((mpoly->flag & ME_HIDE) == 0) {
-                               switch (action) {
-                                       case SEL_SELECT:
-                                               mpoly->flag |= ME_FACE_SEL;
-                                               break;
-                                       case SEL_DESELECT:
-                                               mpoly->flag &= ~ME_FACE_SEL;
-                                               break;
-                                       case SEL_INVERT:
-                                               mpoly->flag ^= ME_FACE_SEL;
-                                               break;
-                               }
+       mpoly = me->mpoly;
+       a = me->totpoly;
+       while (a--) {
+               if ((mpoly->flag & ME_HIDE) == 0) {
+                       switch (action) {
+                               case SEL_SELECT:
+                                       mpoly->flag |= ME_FACE_SEL;
+                                       break;
+                               case SEL_DESELECT:
+                                       mpoly->flag &= ~ME_FACE_SEL;
+                                       break;
+                               case SEL_INVERT:
+                                       mpoly->flag ^= ME_FACE_SEL;
+                                       break;
                        }
-                       mpoly++;
                }
+               mpoly++;
        }
 
        if (flush_flags) {
@@ -557,49 +545,37 @@ void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
        me = BKE_mesh_from_object(ob);
        if (me == NULL) return;
        
-       if (action == SEL_INVERT) {
+       if (action == SEL_TOGGLE) {
+               action = SEL_SELECT;
+
                mvert = me->mvert;
                a = me->totvert;
                while (a--) {
-                       if ((mvert->flag & ME_HIDE) == 0) {
-                               mvert->flag ^= SELECT;
+                       if ((mvert->flag & ME_HIDE) == 0 && mvert->flag & SELECT) {
+                               action = SEL_DESELECT;
+                               break;
                        }
                        mvert++;
                }
        }
-       else {
-               if (action == SEL_TOGGLE) {
-                       action = SEL_SELECT;
-
-                       mvert = me->mvert;
-                       a = me->totvert;
-                       while (a--) {
-                               if ((mvert->flag & ME_HIDE) == 0 && mvert->flag & SELECT) {
-                                       action = SEL_DESELECT;
-                                       break;
-                               }
-                               mvert++;
-                       }
-               }
 
-               mvert = me->mvert;
-               a = me->totvert;
-               while (a--) {
-                       if ((mvert->flag & ME_HIDE) == 0) {
-                               switch (action) {
-                                       case SEL_SELECT:
-                                               mvert->flag |= SELECT;
-                                               break;
-                                       case SEL_DESELECT:
-                                               mvert->flag &= ~SELECT;
-                                               break;
-                                       case SEL_INVERT:
-                                               mvert->flag ^= SELECT;
-                                               break;
-                               }
+       mvert = me->mvert;
+       a = me->totvert;
+       while (a--) {
+               if ((mvert->flag & ME_HIDE) == 0) {
+                       switch (action) {
+                               case SEL_SELECT:
+                                       mvert->flag |= SELECT;
+                                       break;
+                               case SEL_DESELECT:
+                                       mvert->flag &= ~SELECT;
+                                       break;
+                               case SEL_INVERT:
+                                       mvert->flag ^= SELECT;
+                                       break;
                        }
-                       mvert++;
                }
+               mvert++;
        }
 
        /* handle mselect */
index 3c1b210d171661237ae37caf1158f8fa4a92e6d8..892b773b1badc3e5fae91d801214da5dec7d5496 100644 (file)
@@ -125,9 +125,9 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed,
        l = eed->l;
 
        /* find correct order for v[1] */
-       if (!(BM_edge_in_face(l->f, eed) && BM_edge_in_face(l->f, lasteed))) {
+       if (!(BM_edge_in_face(eed, l->f) && BM_edge_in_face(lasteed, l->f))) {
                BM_ITER_ELEM (l, &liter, l, BM_LOOPS_OF_LOOP) {
-                       if (BM_edge_in_face(l->f, eed) && BM_edge_in_face(l->f, lasteed))
+                       if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(lasteed, l->f))
                                break;
                }
        }
index 868db4fa7466299007b13bb58606bf46e2110ccf..629618fd3538a3923c107f708e00b1ce43d671ad 100644 (file)
@@ -428,8 +428,9 @@ static int edbm_add_edge_face__smooth_get(BMesh *bm)
  * Function used to get a fixed number of edges linked to a vertex that passes a test function.
  * This is used so we can request all boundary edges connected to a vertex for eg.
  */
-static int edbm_add_edge_face_exec__vert_edge_lookup(BMVert *v, BMEdge *e_used, BMEdge **e_arr, const int e_arr_len,
-                                                     bool (* func)(BMEdge *))
+static int edbm_add_edge_face_exec__vert_edge_lookup(
+        BMVert *v, BMEdge *e_used, BMEdge **e_arr, const int e_arr_len,
+        bool (* func)(const BMEdge *))
 {
        BMIter iter;
        BMEdge *e_iter;
@@ -3038,6 +3039,17 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot)
 /* -------------------------------------------------------------------- */
 /* Dissolve */
 
+static void edbm_dissolve_prop__use_verts(wmOperatorType *ot)
+{
+       RNA_def_boolean(ot->srna, "use_verts", 0, "Dissolve Verts",
+                       "Dissolve remaining vertices");
+}
+static void edbm_dissolve_prop__use_face_split(wmOperatorType *ot)
+{
+       RNA_def_boolean(ot->srna, "use_face_split", 0, "Face Split",
+                       "Split off face corners to maintain surrounding geometry");
+}
+
 static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
@@ -3067,8 +3079,7 @@ void MESH_OT_dissolve_verts(wmOperatorType *ot)
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
-       RNA_def_boolean(ot->srna, "use_face_split", 0, "Face Split",
-                       "Split off face corners to maintain surrounding geometry");
+       edbm_dissolve_prop__use_face_split(ot);
 }
 
 static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op)
@@ -3105,9 +3116,8 @@ void MESH_OT_dissolve_edges(wmOperatorType *ot)
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
-       RNA_def_boolean(ot->srna, "use_verts", 0, "Dissolve Verts", "Dissolve remaining vertices");
-       RNA_def_boolean(ot->srna, "use_face_split", 0, "Face Split",
-                       "Split off face corners to maintain surrounding geometry");
+       edbm_dissolve_prop__use_verts(ot);
+       edbm_dissolve_prop__use_face_split(ot);
 }
 
 static int edbm_dissolve_faces_exec(bContext *C, wmOperator *op)
@@ -3117,8 +3127,14 @@ static int edbm_dissolve_faces_exec(bContext *C, wmOperator *op)
 
        const bool use_verts = RNA_boolean_get(op->ptr, "use_verts");
 
-       if (!EDBM_op_callf(em, op, "dissolve_faces faces=%hf use_verts=%b", BM_ELEM_SELECT, use_verts))
+       if (!EDBM_op_call_and_selectf(
+               em, op,
+               "region.out", true,
+               "dissolve_faces faces=%hf use_verts=%b",
+               BM_ELEM_SELECT, use_verts))
+       {
                return OPERATOR_CANCELLED;
+       }
 
        EDBM_update_generic(em, true, true);
 
@@ -3139,10 +3155,44 @@ void MESH_OT_dissolve_faces(wmOperatorType *ot)
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
-       RNA_def_boolean(ot->srna, "use_verts", 0, "Dissolve Verts", "Dissolve remaining vertices");
+       edbm_dissolve_prop__use_verts(ot);
 }
 
 
+static int edbm_dissolve_mode_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit = CTX_data_edit_object(C);
+       BMEditMesh *em = BKE_editmesh_from_object(obedit);
+
+       if (em->selectmode & SCE_SELECT_VERTEX) {
+               return edbm_dissolve_verts_exec(C, op);
+       }
+       else if (em->selectmode & SCE_SELECT_EDGE) {
+               return edbm_dissolve_edges_exec(C, op);
+       }
+       else {
+               return edbm_dissolve_faces_exec(C, op);
+       }
+}
+
+void MESH_OT_dissolve_mode(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Dissolve Selection";
+       ot->description = "Dissolve geometry based on the selection mode";
+       ot->idname = "MESH_OT_dissolve_mode";
+
+       /* api callbacks */
+       ot->exec = edbm_dissolve_mode_exec;
+       ot->poll = ED_operator_editmesh;
+
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+       edbm_dissolve_prop__use_verts(ot);
+       edbm_dissolve_prop__use_face_split(ot);
+}
+
 static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
@@ -3236,7 +3286,7 @@ static int edbm_delete_edgeloop_exec(bContext *C, wmOperator *op)
                BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false);
 
                BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
-                       if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
+                       if (BM_elem_flag_test(e, BM_ELEM_SELECT) && e->l) {
                                BMLoop *l_iter = e->l;
                                do {
                                        BM_elem_flag_enable(l_iter->f, BM_ELEM_TAG);
index 44cc89cb23cf62948cd083d10ab30e3b0d8eb03a..46cab3b44162c1195e09fbe09437043297ffb47a 100644 (file)
@@ -1483,7 +1483,7 @@ static BMFace *edge_ray_cast(struct BMBVHTree *tree, const float co[3], const fl
 {
        BMFace *f = BKE_bmbvh_ray_cast(tree, co, dir, NULL, r_hitout, NULL);
 
-       if (f && BM_edge_in_face(f, e))
+       if (f && BM_edge_in_face(e, f))
                return NULL;
 
        return f;
index b2d6e87220669e556d227cc3799d51d990b922ed..1dcc0e64183e32aace6b36e3bc46221a83b7eb40 100644 (file)
@@ -204,6 +204,7 @@ void MESH_OT_tris_convert_to_quads(struct wmOperatorType *ot);
 void MESH_OT_dissolve_verts(struct wmOperatorType *ot);
 void MESH_OT_dissolve_edges(struct wmOperatorType *ot);
 void MESH_OT_dissolve_faces(struct wmOperatorType *ot);
+void MESH_OT_dissolve_mode(struct wmOperatorType *ot);
 void MESH_OT_dissolve_limited(struct wmOperatorType *ot);
 void MESH_OT_delete_edgeloop(struct wmOperatorType *ot);
 void MESH_OT_edge_face_add(struct wmOperatorType *ot);
index 3d8718ef887e0f70143bc225dd5e2ae414e21b60..66e577975b680b5db47feca122168989a4357a10 100644 (file)
@@ -461,7 +461,7 @@ static int navmesh_create_exec(bContext *C, wmOperator *op)
                unsigned int lay = 0;
 
                int nverts = 0, ntris = 0;
-               int *tris = 0;
+               int *tris = NULL;
                float *verts = NULL;
 
                createVertsTrisData(C, obs, &nverts, &verts, &ntris, &tris, &lay);
index 90dc803ea50b0a1f1bbf09fbe0db148ea05d2859..b5352fb35f456400ee926314fbb4eba2965b8868 100644 (file)
@@ -109,6 +109,7 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_dissolve_verts);
        WM_operatortype_append(MESH_OT_dissolve_edges);
        WM_operatortype_append(MESH_OT_dissolve_faces);
+       WM_operatortype_append(MESH_OT_dissolve_mode);
        WM_operatortype_append(MESH_OT_dissolve_limited);
        WM_operatortype_append(MESH_OT_delete_edgeloop);
        WM_operatortype_append(MESH_OT_faces_shade_smooth);
@@ -384,6 +385,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
 
        WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", XKEY, KM_PRESS, 0, 0);
        WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", DELKEY, KM_PRESS, 0, 0);
+
+       WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", XKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", DELKEY, KM_PRESS, KM_CTRL, 0);
        
        kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0);
        RNA_boolean_set(kmi->ptr, "use_occlude_geometry", true);
index 059f8de71085f974a188d5a5f7557744fdd33f14..d012a8ac656d4447d1721e3c40c040c8fb9192bf 100644 (file)
@@ -1336,7 +1336,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
                const float mval_f[2] = {(float)mval[0],
                                         (float)mval[1]};
 
-               VertPickData data = {0};
+               VertPickData data = {NULL};
 
                ED_view3d_init_mats_rv3d(ob, rv3d);
 
index c8baa0d84dcc0f1ed13b2372e8fdf770082617eb..5b20489c9cba697f81cd6f7244316cbc3afcdd90 100644 (file)
@@ -713,11 +713,11 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op)
                        mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
                        
                        invert_m4_m4(imat, mat);
-                       mul_serie_m4(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
+                       mul_m4_m4m4(hmd->parentinv, imat, ob->obmat);
                }
                else {
                        invert_m4_m4(hmd->object->imat, hmd->object->obmat);
-                       mul_serie_m4(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
+                       mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->obmat);
                }
        }
        
index b9c97c32fc996d48fecb430716a5874bb90a2a86..03d51fcbe82dd3a18893bb1ed62909633aca7fe1 100644 (file)
@@ -873,9 +873,9 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
        Scene *scene = CTX_data_scene(C);
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
-       int mode_orig = ob ? ob->mode : 0;
+       int mode_orig = ob->mode;
        
-       if (!ob || !md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
+       if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
                return OPERATOR_CANCELLED;
 
        WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -919,7 +919,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
 
-       if (!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md))
+       if (!md || !ED_object_modifier_move_up(op->reports, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -958,7 +958,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
 
-       if (!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md))
+       if (!md || !ED_object_modifier_move_down(op->reports, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -999,7 +999,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
        int apply_as = RNA_enum_get(op->ptr, "apply_as");
 
-       if (!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) {
+       if (!md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) {
                return OPERATOR_CANCELLED;
        }
 
@@ -1049,7 +1049,7 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
        
-       if (!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md))
+       if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -1088,7 +1088,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
 
-       if (!ob || !md || !ED_object_modifier_copy(op->reports, ob, md))
+       if (!md || !ED_object_modifier_copy(op->reports, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
index 9b3f1a4f3acedaf58a74b83259a47cc37f181f8b..294b0632015a6ab71d71b5c24478f1983555ccc8 100644 (file)
@@ -547,7 +547,6 @@ static void vgroup_normalize_active(Object *ob, eVGroupSelect subset_type)
                        ED_mesh_defvert_mirror_update_em(ob, eve_act, -1, -1, cd_dvert_offset);
                }
                else {
-                       int v_act = BKE_mesh_mselect_active_get(me, ME_VSEL);
                        ED_mesh_defvert_mirror_update_ob(ob, -1, v_act);
                }
        }
index bc4ca82392f70b9762fd987b099ca8c284b22851..3a6bd05df0bd1eacd3e5bc0f8323cd01c0633e27 100644 (file)
@@ -1120,7 +1120,7 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
                                glEnable(GL_BLEND);
                                glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                                glaDrawPixelsTex(rres.xof, rres.yof, rres.rectx, rres.recty, GL_RGBA, GL_FLOAT,
-                                                GL_LINEAR, rres.rectf);
+                                                GL_NEAREST, rres.rectf);
                                glDisable(GL_BLEND);
 
                                IMB_colormanagement_finish_glsl_draw();
@@ -1139,7 +1139,7 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
                        glEnable(GL_BLEND);
                        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                        glaDrawPixelsAuto(rres.xof, rres.yof, rres.rectx, rres.recty, GL_RGBA, GL_UNSIGNED_BYTE,
-                                         GL_LINEAR, display_buffer);
+                                         GL_NEAREST, display_buffer);
                        glDisable(GL_BLEND);
 
                        MEM_freeN(display_buffer);
index b4532e0571c19deda268c64bc899dc9000331d97..e21e889d99dedf1e05b2722e0ff23a08629d83df 100644 (file)
@@ -684,6 +684,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent
                        /* render frame? */
                        if (oglrender->timer == event->customdata)
                                break;
+                       /* fall-through */
                default:
                        /* nothing to do */
                        return OPERATOR_RUNNING_MODAL;
index 1f1da35f8239375550d83d06eda6624e5a9c27c8..e805b3f30fc48879e8ccaa81344eaa899ac49986 100644 (file)
@@ -387,7 +387,7 @@ void ED_region_set(const bContext *C, ARegion *ar)
        ar->drawrct = ar->winrct;
        
        /* note; this sets state, so we can use wmOrtho and friends */
-       wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct);
+       wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, true);
        
        UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0);
        
@@ -401,24 +401,25 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
        wmWindow *win = CTX_wm_window(C);
        ScrArea *sa = CTX_wm_area(C);
        ARegionType *at = ar->type;
-       
+       bool scissor_pad;
+
        /* see BKE_spacedata_draw_locks() */
        if (at->do_lock)
                return;
        
        /* if no partial draw rect set, full rect */
-       if (ar->drawrct.xmin == ar->drawrct.xmax)
+       if (ar->drawrct.xmin == ar->drawrct.xmax) {
                ar->drawrct = ar->winrct;
+               scissor_pad = true;
+       }
        else {
-               /* extra clip for safety (intersect the rects, could use API func) */
-               ar->drawrct.xmin = max_ii(ar->winrct.xmin, ar->drawrct.xmin);
-               ar->drawrct.ymin = max_ii(ar->winrct.ymin, ar->drawrct.ymin);
-               ar->drawrct.xmax = min_ii(ar->winrct.xmax, ar->drawrct.xmax);
-               ar->drawrct.ymax = min_ii(ar->winrct.ymax, ar->drawrct.ymax);
+               /* extra clip for safety */
+               BLI_rcti_isect(&ar->winrct, &ar->drawrct, &ar->drawrct);
+               scissor_pad = false;
        }
        
        /* note; this sets state, so we can use wmOrtho and friends */
-       wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct);
+       wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, scissor_pad);
        
        UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);
        
index 3ecde56b5d0956b80ee43fc5c597e59b1dda9226..d376bd3180fa27411a28562c89e913d837b33c62 100644 (file)
@@ -412,7 +412,7 @@ void BRUSH_OT_curve_preset(wmOperatorType *ot)
 /* face-select ops */
 static int paint_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       paintface_select_linked(C, CTX_data_active_object(C), NULL, 2);
+       paintface_select_linked(C, CTX_data_active_object(C), NULL, true);
        ED_region_tag_redraw(CTX_wm_region(C));
        return OPERATOR_FINISHED;
 }
index 3ac3564ed45c9b06505f1426ef8bfc03a02c2185..2c65450701554ccd82120c6b76fc98ceb4ef65c0 100644 (file)
@@ -3364,7 +3364,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
        const bool is_interactive = (gesture != NULL);
        DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
 
-       DMGradient_userData data = {0};
+