Merging r42648 through r42722 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 19 Dec 2011 10:39:40 +0000 (10:39 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 19 Dec 2011 10:39:40 +0000 (10:39 +0000)
201 files changed:
CMakeLists.txt
build_files/scons/config/win32-mingw-config.py
intern/cycles/app/cycles_xml.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/kernel/CMakeLists.txt
intern/cycles/kernel/osl/nodes/CMakeLists.txt
intern/cycles/kernel/osl/nodes/node_gamma.osl [new file with mode: 0644]
intern/cycles/kernel/osl/nodes/node_normal.osl [new file with mode: 0644]
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_gamma.h [new file with mode: 0644]
intern/cycles/kernel/svm/svm_normal.h [new file with mode: 0644]
intern/cycles/kernel/svm/svm_types.h
intern/cycles/render/graph.cpp
intern/cycles/render/graph.h
intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h
release/scripts/startup/bl_ui/space_node.py
source/blender/avi/intern/avi.c
source/blender/avi/intern/codecs.c
source/blender/avi/intern/endian.c
source/blender/avi/intern/mjpeg.c
source/blender/avi/intern/options.c
source/blender/avi/intern/rgb32.c
source/blender/blenkernel/BKE_customdata.h
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/CCGSubSurf.c
source/blender/blenkernel/intern/CCGSubSurf.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/boids.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/image_gen.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/ocean.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/suggestions.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/BLI_ghash.h
source/blender/blenlib/BLI_math_base.h
source/blender/blenlib/BLI_math_matrix.h
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/BLI_utildefines.h
source/blender/blenlib/intern/BLI_dynstr.c
source/blender/blenlib/intern/BLI_ghash.c
source/blender/blenlib/intern/BLI_linklist.c
source/blender/blenlib/intern/BLI_memarena.c
source/blender/blenlib/intern/bpath.c
source/blender/blenlib/intern/edgehash.c
source/blender/blenlib/intern/math_base_inline.c
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/math_rotation.c
source/blender/blenlib/intern/math_vector.c
source/blender/blenlib/intern/rand.c
source/blender/blenlib/intern/winstuff.c
source/blender/collada/AnimationExporter.cpp
source/blender/collada/AnimationImporter.cpp
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/ArmatureImporter.cpp
source/blender/collada/DocumentImporter.cpp
source/blender/collada/TransformReader.cpp
source/blender/collada/TransformWriter.cpp
source/blender/collada/collada_utils.cpp
source/blender/editors/animation/keyingsets.c
source/blender/editors/armature/editarmature.c
source/blender/editors/curve/curve_ops.c
source/blender/editors/curve/editcurve.c
source/blender/editors/include/ED_mesh.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/mesh/editmesh_lib.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_navmesh.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/physics_pointcache.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_action/action_select.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_graph/graph_select.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_node/node_state.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_view3d/drawanimviz.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_buttons.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_constraints.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_ops.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/gpu/intern/gpu_material.c
source/blender/ikplugin/intern/iksolver_plugin.c
source/blender/ikplugin/intern/itasc_plugin.cpp
source/blender/imbuf/intern/anim_movie.c
source/blender/imbuf/intern/bmp.c
source/blender/imbuf/intern/jp2.c
source/blender/imbuf/intern/util.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_nodetree_types.h
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_space.c
source/blender/modifiers/intern/MOD_array.c
source/blender/modifiers/intern/MOD_boolean_util.c
source/blender/modifiers/intern/MOD_cast.c
source/blender/modifiers/intern/MOD_hook.c
source/blender/modifiers/intern/MOD_meshdeform.c
source/blender/modifiers/intern/MOD_mirror.c
source/blender/modifiers/intern/MOD_screw.c
source/blender/modifiers/intern/MOD_solidify.c
source/blender/modifiers/intern/MOD_uvproject.c
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_wave.c
source/blender/modifiers/intern/MOD_weightvgproximity.c
source/blender/nodes/CMakeLists.txt
source/blender/nodes/NOD_shader.h
source/blender/nodes/shader/nodes/node_shader_gamma.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_normal.c
source/blender/python/generic/bgl.c
source/blender/python/generic/idprop_py_api.c
source/blender/python/generic/py_capi_utils.c
source/blender/python/intern/bpy_app.c
source/blender/python/intern/bpy_app_handlers.c
source/blender/python/intern/bpy_driver.c
source/blender/python/intern/bpy_props.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_rna_anim.c
source/blender/python/intern/bpy_rna_callback.c
source/blender/python/intern/gpu.c
source/blender/python/mathutils/mathutils.c
source/blender/python/mathutils/mathutils.h
source/blender/python/mathutils/mathutils_Color.c
source/blender/python/mathutils/mathutils_Euler.c
source/blender/python/mathutils/mathutils_Matrix.c
source/blender/python/mathutils/mathutils_Matrix.h
source/blender/python/mathutils/mathutils_Quaternion.c
source/blender/python/mathutils/mathutils_Vector.c
source/blender/python/mathutils/mathutils_Vector.h
source/blender/python/mathutils/mathutils_geometry.c
source/blender/python/mathutils/mathutils_noise.c
source/blender/quicktime/apple/qtkit_export.m
source/blender/quicktime/apple/quicktime_export.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/pointdensity.c
source/blender/render/intern/source/render_texture.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/shadeinput.c
source/blender/render/intern/source/strand.c
source/blender/render/intern/source/volumetric.c
source/blender/render/intern/source/zbuf.c
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_init_exit.c
source/gameengine/Converter/BL_ArmatureChannel.cpp
source/gameengine/Ketsji/BL_Texture.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Rasterizer/RAS_2DFilterManager.cpp

index eaa75ddb1f9089a7291f4437e310af44effb020f..af111c27f4fabf734490ebef7e84f4fe9fba3b58 100644 (file)
@@ -649,10 +649,6 @@ elseif(WIN32)
                set(ICONV_LIBPATH ${ICONV}/lib)
        endif()
 
-       set(PNG "${LIBDIR}/png")
-       set(PNG_INCLUDE_DIR "${PNG}/include")
-       set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
-
        set(JPEG "${LIBDIR}/jpeg")
        set(JPEG_INCLUDE_DIR "${JPEG}/include")
        set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
@@ -733,6 +729,10 @@ elseif(WIN32)
                        set(PNG_LIBRARIES libpng_st)
                endif()
                set(JPEG_LIBRARIES libjpeg)
+               
+               set(PNG "${LIBDIR}/png")
+               set(PNG_INCLUDE_DIR "${PNG}/include")
+               set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
 
                set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include)
                if(CMAKE_CL_64)
@@ -913,6 +913,10 @@ elseif(WIN32)
                        set(GETTEXT_LIBPATH ${GETTEXT}/lib)
                        set(GETTEXT_LIBRARIES intl)
                endif()
+               
+               set(PNG "${LIBDIR}/gcc/png")
+               set(PNG_INCLUDE_DIR "${PNG}/include")
+               set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
 
                set(JPEG_LIBRARIES libjpeg)
                set(PNG_LIBRARIES png)
index 51f438e0a4d0a45f19f452d1f017f21411601b0f..bc2bbbba07ad981c185423d3c77662ee436c8f03 100644 (file)
@@ -64,7 +64,7 @@ BF_JPEG_LIB = 'liblibjpeg'
 BF_JPEG_LIBPATH = '${BF_JPEG}/lib'
 
 WITH_BF_PNG = True
-BF_PNG = LIBDIR + '/png'
+BF_PNG = LIBDIR + 'gcc/png'
 BF_PNG_INC = '${BF_PNG}/include'
 BF_PNG_LIB = 'png'
 BF_PNG_LIBPATH = '${BF_PNG}/lib'
index 530a4ad14d88c9ae792c869f3ddc265ed0f7c4e6..f5cc01cd0626528419e8dfaf73263adc3d1091e4 100644 (file)
@@ -368,6 +368,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
                        xml_read_enum(&wood->type, WaveTextureNode::type_enum, node, "type");
                        snode = wood;
                }
+               else if(string_iequals(node.name(), "normal")) {
+                       snode = new NormalNode();
+               }
                else if(string_iequals(node.name(), "mapping")) {
                        snode = new MappingNode();
                }
@@ -443,6 +446,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
                        xml_read_enum(&mix->type, MixNode::type_enum, node, "type");
                        snode = mix;
                }
+               else if(string_iequals(node.name(), "gamma")) {
+                       snode = new GammaNode();
+               }
                else if(string_iequals(node.name(), "combine_rgb")) {
                        snode = new CombineRGBNode();
                }
index b0dd6988457aaf5a1c7e05877f9e8a38a69fc0d9..5c39a3f169d132677f97a0b3df59672510b0beac 100644 (file)
@@ -50,28 +50,6 @@ void BlenderSync::find_shader(BL::ID id, vector<uint>& used_shaders, int default
 
 /* Graph */
 
-static BL::NodeSocket get_node_input(BL::Node *b_group_node, BL::NodeSocket b_in)
-{
-       if(b_group_node) {
-
-               BL::NodeTree b_ntree = BL::NodeGroup(*b_group_node).node_tree();
-               BL::NodeTree::links_iterator b_link;
-
-               for(b_ntree.links.begin(b_link); b_link != b_ntree.links.end(); ++b_link) {
-                       if(b_link->to_socket().ptr.data == b_in.ptr.data) {
-                               BL::Node::inputs_iterator b_gin;
-
-                               for(b_group_node->inputs.begin(b_gin); b_gin != b_group_node->inputs.end(); ++b_gin)
-                                       if(b_gin->group_socket().ptr.data == b_link->from_socket().ptr.data)
-                                               return *b_gin;
-
-                       }
-               }
-       }
-
-       return b_in;
-}
-
 static BL::NodeSocket get_node_output(BL::Node b_node, const string& name)
 {
        BL::Node::outputs_iterator b_out;
@@ -121,7 +99,7 @@ static void get_tex_mapping(TextureMapping *mapping, BL::ShaderNodeMapping b_map
        mapping->scale = get_float3(b_mapping.scale());
 }
 
-static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *b_group_node, BL::ShaderNode b_node)
+static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::ShaderNode b_node)
 {
        ShaderNode *node = NULL;
 
@@ -132,7 +110,6 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                case BL::ShaderNode::type_GEOMETRY: break;
                case BL::ShaderNode::type_MATERIAL: break;
                case BL::ShaderNode::type_MATERIAL_EXT: break;
-               case BL::ShaderNode::type_NORMAL: break;
                case BL::ShaderNode::type_OUTPUT: break;
                case BL::ShaderNode::type_SCRIPT: break;
                case BL::ShaderNode::type_SQUEEZE: break;
@@ -161,6 +138,10 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        node = new InvertNode();
                        break;
                }
+               case BL::ShaderNode::type_GAMMA: {
+                       node = new GammaNode();
+                       break;
+               }
                case BL::ShaderNode::type_MIX_RGB: {
                        BL::ShaderNodeMixRGB b_mix_node(b_node);
                        MixNode *mix = new MixNode();
@@ -198,6 +179,17 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        node = vmath;
                        break;
                }
+               case BL::ShaderNode::type_NORMAL: {
+                       BL::Node::outputs_iterator out_it;
+                       b_node.outputs.begin(out_it);
+                       BL::NodeSocketVectorNone vec_sock(*out_it);
+
+                       NormalNode *norm = new NormalNode();
+                       norm->direction = get_float3(vec_sock.default_value());
+
+                       node = norm;
+                       break;
+               }
                case BL::ShaderNode::type_MAPPING: {
                        BL::ShaderNodeMapping b_mapping_node(b_node);
                        MappingNode *mapping = new MappingNode();
@@ -456,59 +448,115 @@ static SocketPair node_socket_map_pair(PtrNodeMap& node_map, BL::Node b_node, BL
        return SocketPair(node_map[b_node.ptr.data], name);
 }
 
-static void add_nodes(BL::BlendData b_data, ShaderGraph *graph, BL::ShaderNodeTree b_ntree, BL::Node *b_group_node, PtrSockMap& sockets_map)
+static ShaderSocketType convert_socket_type(BL::NodeSocket::type_enum b_type)
+{
+       switch (b_type) {
+       case BL::NodeSocket::type_VALUE:
+               return SHADER_SOCKET_FLOAT;
+       case BL::NodeSocket::type_VECTOR:
+               return SHADER_SOCKET_VECTOR;
+       case BL::NodeSocket::type_RGBA:
+               return SHADER_SOCKET_COLOR;
+       case BL::NodeSocket::type_SHADER:
+               return SHADER_SOCKET_CLOSURE;
+       
+       case BL::NodeSocket::type_BOOLEAN:
+       case BL::NodeSocket::type_MESH:
+       case BL::NodeSocket::type_INT:
+       default:
+               return SHADER_SOCKET_FLOAT;
+       }
+}
+
+static void set_default_value(ShaderInput *input, BL::NodeSocket sock)
+{
+       /* copy values for non linked inputs */
+       switch(input->type) {
+       case SHADER_SOCKET_FLOAT: {
+               BL::NodeSocketFloatNone value_sock(sock);
+               input->set(value_sock.default_value());
+               break;
+       }
+       case SHADER_SOCKET_COLOR: {
+               BL::NodeSocketRGBA rgba_sock(sock);
+               input->set(get_float3(rgba_sock.default_value()));
+               break;
+       }
+       case SHADER_SOCKET_NORMAL:
+       case SHADER_SOCKET_POINT:
+       case SHADER_SOCKET_VECTOR: {
+               BL::NodeSocketVectorNone vec_sock(sock);
+               input->set(get_float3(vec_sock.default_value()));
+               break;
+       }
+       case SHADER_SOCKET_CLOSURE:
+               break;
+       }
+}
+
+static void add_nodes(BL::BlendData b_data, ShaderGraph *graph, BL::ShaderNodeTree b_ntree, PtrSockMap& sockets_map)
 {
        /* add nodes */
        BL::ShaderNodeTree::nodes_iterator b_node;
        PtrNodeMap node_map;
-       map<void*, PtrSockMap> node_groups;
+       PtrSockMap proxy_map;
 
        for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
                if(b_node->is_a(&RNA_NodeGroup)) {
+                       /* add proxy converter nodes for inputs and outputs */
                        BL::NodeGroup b_gnode(*b_node);
                        BL::ShaderNodeTree b_group_ntree(b_gnode.node_tree());
-
-                       node_groups[b_node->ptr.data] = PtrSockMap();
-                       add_nodes(b_data, graph, b_group_ntree, &b_gnode, node_groups[b_node->ptr.data]);
+                       BL::Node::inputs_iterator b_input;
+                       BL::Node::outputs_iterator b_output;
+                       
+                       PtrSockMap group_sockmap;
+                       
+                       for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
+                               ShaderSocketType extern_type = convert_socket_type(b_input->type());
+                               ShaderSocketType intern_type = convert_socket_type(b_input->group_socket().type());
+                               ShaderNode *proxy = graph->add(new ProxyNode(extern_type, intern_type));
+                               
+                               /* map the external node socket to the proxy node socket */
+                               proxy_map[b_input->ptr.data] = SocketPair(proxy, proxy->inputs[0]->name);
+                               /* map the internal group socket to the proxy node socket */
+                               group_sockmap[b_input->group_socket().ptr.data] = SocketPair(proxy, proxy->outputs[0]->name);
+                               
+                               /* default input values of the group node */
+                               set_default_value(proxy->inputs[0], *b_input);
+                       }
+                       
+                       for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
+                               ShaderSocketType extern_type = convert_socket_type(b_output->type());
+                               ShaderSocketType intern_type = convert_socket_type(b_output->group_socket().type());
+                               ShaderNode *proxy = graph->add(new ProxyNode(intern_type, extern_type));
+                               
+                               /* map the external node socket to the proxy node socket */
+                               proxy_map[b_output->ptr.data] = SocketPair(proxy, proxy->outputs[0]->name);
+                               /* map the internal group socket to the proxy node socket */
+                               group_sockmap[b_output->group_socket().ptr.data] = SocketPair(proxy, proxy->inputs[0]->name);
+                               
+                               /* default input values of internal, unlinked group outputs */
+                               set_default_value(proxy->inputs[0], b_output->group_socket());
+                       }
+                       
+                       add_nodes(b_data, graph, b_group_ntree, group_sockmap);
                }
                else {
-                       ShaderNode *node = add_node(b_data, graph, b_group_node, BL::ShaderNode(*b_node));
-
+                       ShaderNode *node = add_node(b_data, graph, BL::ShaderNode(*b_node));
+                       
                        if(node) {
                                BL::Node::inputs_iterator b_input;
-                               BL::Node::outputs_iterator b_output;
-
+                               
                                node_map[b_node->ptr.data] = node;
-
+                               
                                for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
                                        SocketPair pair = node_socket_map_pair(node_map, *b_node, *b_input);
                                        ShaderInput *input = pair.first->input(pair.second.c_str());
-                                       BL::NodeSocket sock(get_node_input(b_group_node, *b_input));
-
+                                       
                                        assert(input);
-
+                                       
                                        /* copy values for non linked inputs */
-                                       switch(input->type) {
-                                               case SHADER_SOCKET_FLOAT: {
-                                                       BL::NodeSocketFloatNone value_sock(sock);
-                                                       input->set(value_sock.default_value());
-                                                       break;
-                                               }
-                                               case SHADER_SOCKET_COLOR: {
-                                                       BL::NodeSocketRGBA rgba_sock(sock);
-                                                       input->set(get_float3(rgba_sock.default_value()));
-                                                       break;
-                                               }
-                                               case SHADER_SOCKET_NORMAL:
-                                               case SHADER_SOCKET_POINT:
-                                               case SHADER_SOCKET_VECTOR: {
-                                                       BL::NodeSocketVectorNone vec_sock(sock);
-                                                       input->set(get_float3(vec_sock.default_value()));
-                                                       break;
-                                               }
-                                               case SHADER_SOCKET_CLOSURE:
-                                                       break;
-                                       }
+                                       set_default_value(input, *b_input);
                                }
                        }
                }
@@ -525,54 +573,34 @@ static void add_nodes(BL::BlendData b_data, ShaderGraph *graph, BL::ShaderNodeTr
                BL::NodeSocket b_from_sock = b_link->from_socket();
                BL::NodeSocket b_to_sock = b_link->to_socket();
 
-               /* if link with group socket, add to map so we can connect it later */
-               if(b_group_node) {
-                       if(!b_from_node) {
-                               sockets_map[b_from_sock.ptr.data] =
-                                       node_socket_map_pair(node_map, b_to_node, b_to_sock);
-
-                               continue;
-                       }
-                       else if(!b_to_node) {
-                               sockets_map[b_to_sock.ptr.data] =
-                                       node_socket_map_pair(node_map, b_from_node, b_from_sock);
-
-                               continue;
-                       }
-               }
-
                SocketPair from_pair, to_pair;
 
+               /* links without a node pointer are connections to group inputs/outputs */
+
                /* from sock */
-               if(b_from_node.is_a(&RNA_NodeGroup)) {
-                       /* group node */
-                       BL::NodeSocket group_sock = b_from_sock.group_socket();
-                       from_pair = node_groups[b_from_node.ptr.data][group_sock.ptr.data];
-               }
-               else {
-                       /* regular node */
-                       from_pair = node_socket_map_pair(node_map, b_from_node, b_from_sock);
+               if(b_from_node) {
+                       if (b_from_node.is_a(&RNA_NodeGroup))
+                               from_pair = proxy_map[b_from_sock.ptr.data];
+                       else
+                               from_pair = node_socket_map_pair(node_map, b_from_node, b_from_sock);
                }
+               else
+                       from_pair = sockets_map[b_from_sock.ptr.data];
 
                /* to sock */
-               if(b_to_node.is_a(&RNA_NodeGroup)) {
-                       /* group node */
-                       BL::NodeSocket group_sock = b_to_sock.group_socket();
-                       to_pair = node_groups[b_to_node.ptr.data][group_sock.ptr.data];
-               }
-               else {
-                       /* regular node */
-                       to_pair = node_socket_map_pair(node_map, b_to_node, b_to_sock);
+               if(b_to_node) {
+                       if (b_to_node.is_a(&RNA_NodeGroup))
+                               to_pair = proxy_map[b_to_sock.ptr.data];
+                       else
+                               to_pair = node_socket_map_pair(node_map, b_to_node, b_to_sock);
                }
+               else
+                       to_pair = sockets_map[b_to_sock.ptr.data];
 
-               /* in case of groups there may not actually be a node inside the group
-                  that the group socket connects to, so from_node or to_node may be NULL */
-               if(from_pair.first && to_pair.first) {
-                       ShaderOutput *output = from_pair.first->output(from_pair.second.c_str());
-                       ShaderInput *input = to_pair.first->input(to_pair.second.c_str());
+               ShaderOutput *output = from_pair.first->output(from_pair.second.c_str());
+               ShaderInput *input = to_pair.first->input(to_pair.second.c_str());
 
-                       graph->connect(output, input);
-               }
+               graph->connect(output, input);
        }
 }
 
@@ -599,7 +627,7 @@ void BlenderSync::sync_materials()
                                PtrSockMap sock_to_node;
                                BL::ShaderNodeTree b_ntree(b_mat->node_tree());
 
-                               add_nodes(b_data, graph, b_ntree, NULL, sock_to_node);
+                               add_nodes(b_data, graph, b_ntree, sock_to_node);
                        }
                        else {
                                ShaderNode *closure, *out;
@@ -640,7 +668,7 @@ void BlenderSync::sync_world()
                        PtrSockMap sock_to_node;
                        BL::ShaderNodeTree b_ntree(b_world.node_tree());
 
-                       add_nodes(b_data, graph, b_ntree, NULL, sock_to_node);
+                       add_nodes(b_data, graph, b_ntree, sock_to_node);
                }
                else if(b_world) {
                        ShaderNode *closure, *out;
@@ -689,7 +717,7 @@ void BlenderSync::sync_lamps()
                                PtrSockMap sock_to_node;
                                BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
 
-                               add_nodes(b_data, graph, b_ntree, NULL, sock_to_node);
+                               add_nodes(b_data, graph, b_ntree, sock_to_node);
                        }
                        else {
                                ShaderNode *closure, *out;
index a0803f37cb9bdb89904ccccae20032979bb03282..e17544bf7afbcd1b2b2adc80df9aa09de0fcb573 100644 (file)
@@ -59,6 +59,7 @@ set(SRC_SVM_HEADERS
        svm/svm_convert.h
        svm/svm_displace.h
        svm/svm_fresnel.h
+       svm/svm_gamma.h
        svm/svm_geometry.h
        svm/svm_gradient.h
        svm/svm_hsv.h
@@ -72,6 +73,7 @@ set(SRC_SVM_HEADERS
        svm/svm_musgrave.h
        svm/svm_noise.h
        svm/svm_noisetex.h
+       svm/svm_normal.h
        svm/svm_sepcomb_rgb.h
        svm/svm_sky.h
        svm/svm_tex_coord.h
index 433fc2155fec1f72f464cbe133437c725a25eb58..1a207d6c139ed2446ebff9b6de5595f04e735127 100644 (file)
@@ -19,6 +19,7 @@ set(SRC_OSL
        node_emission.osl
        node_environment_texture.osl
        node_fresnel.osl
+       node_gamma.osl
        node_geometry.osl
        node_glass_bsdf.osl
        node_glossy_bsdf.osl
@@ -33,6 +34,7 @@ set(SRC_OSL
        node_mix.osl
        node_mix_closure.osl
        node_musgrave_texture.osl
+       node_normal.osl
        node_blend_weight_texture.osl
        node_noise_texture.osl
        node_output_displacement.osl
diff --git a/intern/cycles/kernel/osl/nodes/node_gamma.osl b/intern/cycles/kernel/osl/nodes/node_gamma.osl
new file mode 100644 (file)
index 0000000..4dae07d
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_gamma(
+       color ColorIn = color(0.8, 0.8, 0.8),
+       float Gamma = 1.0,
+       output ColorOut = color(0.8, 0.8, 0.8)
+{
+       int i;
+       for (i=0;i<3;i++) {
+               if (ColorIn[i] > 0.0)
+                       ColorIn[i] = powf(ColorIn[i], Gamma);
+       }
+
+       ColorOut = ColorIn;
+}
diff --git a/intern/cycles/kernel/osl/nodes/node_normal.osl b/intern/cycles/kernel/osl/nodes/node_normal.osl
new file mode 100644 (file)
index 0000000..038a33c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_normal(
+       normal Direction = normal(0.0, 0.0, 0.0),
+       normal NormalIn = normal(0.0, 0.0, 0.0),
+       output normal NormalOut = normal(0.0, 0.0, 0.0),
+       output float Dot = 1.0
+{
+       Direction = normalize(Direction);
+       NormalOut = Direction;
+       Dot = dot(Direction, NormalIn);
+}
+
index 5fde44e276990dfc15f5dd07957922dfe0df6876..5a8d6d62c7947e89d91f04835de5367fa9077075 100644 (file)
@@ -130,10 +130,12 @@ CCL_NAMESPACE_END
 #include "svm_geometry.h"
 #include "svm_hsv.h"
 #include "svm_image.h"
+#include "svm_gamma.h"
 #include "svm_invert.h"
 #include "svm_light_path.h"
 #include "svm_magic.h"
 #include "svm_mapping.h"
+#include "svm_normal.h"
 #include "svm_wave.h"
 #include "svm_math.h"
 #include "svm_mix.h"
@@ -261,6 +263,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
                        case NODE_INVERT:
                                svm_node_invert(sd, stack, node.y, node.z, node.w);
                                break;
+                       case NODE_GAMMA:
+                               svm_node_gamma(sd, stack, node.y, node.z, node.w);
+                               break;
                        case NODE_MIX:
                                svm_node_mix(kg, sd, stack, node.y, node.z, node.w, &offset);
                                break;
@@ -300,6 +305,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
                        case NODE_VECTOR_MATH:
                                svm_node_vector_math(kg, sd, stack, node.y, node.z, node.w, &offset);
                                break;
+                       case NODE_NORMAL:
+                               svm_node_normal(kg, sd, stack, node.y, node.z, node.w, &offset);
+                               break;
                        case NODE_MAPPING:
                                svm_node_mapping(kg, sd, stack, node.y, node.z, &offset);
                                break;
diff --git a/intern/cycles/kernel/svm/svm_gamma.h b/intern/cycles/kernel/svm/svm_gamma.h
new file mode 100644 (file)
index 0000000..4a89670
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+__device void svm_node_gamma(ShaderData *sd, float *stack, uint in_gamma, uint in_color, uint out_color)
+{
+       float3 color = stack_load_float3(stack, in_color);
+       float gamma = stack_load_float(stack, in_gamma);
+
+       if (color.x > 0.0)
+               color.x = powf(color.x, gamma);
+       if (color.y > 0.0)
+               color.y = powf(color.y, gamma);
+       if (color.z > 0.0)
+               color.z = powf(color.z, gamma);
+
+       if (stack_valid(out_color))
+               stack_store_float3(stack, out_color, color);
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/svm/svm_normal.h b/intern/cycles/kernel/svm/svm_normal.h
new file mode 100644 (file)
index 0000000..0b3f63b
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+__device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset)
+{
+       /* read extra data */
+       uint4 node1 = read_node(kg, offset);
+       float3 normal = stack_load_float3(stack, in_normal_offset);
+
+       float3 direction;
+       direction.x = node1.x;
+       direction.y = node1.y;
+       direction.z = node1.z;
+       direction = normalize(direction);
+
+       if (stack_valid(out_normal_offset))
+               stack_store_float3(stack, out_normal_offset, direction);
+
+       if (stack_valid(out_dot_offset))
+               stack_store_float(stack, out_dot_offset, dot(direction, normalize(normal)));
+}
+
+CCL_NAMESPACE_END
+
index efec5c7650d6fcba3981aa75434ec98624983a36..c46df3f08c8bf7fe77b892d91b4f6886544203c0 100644 (file)
@@ -84,7 +84,9 @@ typedef enum NodeType {
        NODE_COMBINE_RGB = 5100,
        NODE_HSV = 5200,
        NODE_CAMERA = 5300,
-       NODE_INVERT = 5400
+       NODE_INVERT = 5400,
+       NODE_NORMAL = 5500,
+       NODE_GAMMA = 5600
 } NodeType;
 
 typedef enum NodeAttributeType {
index cdded403cbe0d72bd5db91d10e04c1fd78220c1c..cc29047f0487cad59dd33afe311e0cea216383bb 100644 (file)
@@ -292,6 +292,42 @@ void ShaderGraph::copy_nodes(set<ShaderNode*>& nodes, map<ShaderNode*, ShaderNod
        }
 }
 
+void ShaderGraph::remove_proxy_nodes(vector<bool>& removed)
+{
+       foreach(ShaderNode *node, nodes) {
+               ProxyNode *proxy = dynamic_cast<ProxyNode*>(node);
+               if (proxy) {
+                       ShaderInput *input = proxy->inputs[0];
+                       ShaderOutput *output = proxy->outputs[0];
+                       
+                       /* temp. copy of the output links list.
+                        * output->links is modified when we disconnect!
+                        */
+                       vector<ShaderInput*> links(output->links);
+                       ShaderOutput *from = input->link;
+                       
+                       /* bypass the proxy node */
+                       if (from) {
+                               disconnect(input);
+                               foreach(ShaderInput *to, links) {
+                                       disconnect(to);
+                                       connect(from, to);
+                               }
+                       }
+                       else {
+                               foreach(ShaderInput *to, links) {
+                                       disconnect(to);
+                                       
+                                       /* transfer the default input value to the target socket */
+                                       to->set(input->value);
+                               }
+                       }
+                       
+                       removed[proxy->id] = true;
+               }
+       }
+}
+
 void ShaderGraph::break_cycles(ShaderNode *node, vector<bool>& visited, vector<bool>& on_stack)
 {
        visited[node->id] = true;
@@ -322,15 +358,28 @@ void ShaderGraph::clean()
           nodes that don't feed into the output. how cycles are broken is
           undefined, they are invalid input, the important thing is to not crash */
 
+       vector<bool> removed(nodes.size(), false);
        vector<bool> visited(nodes.size(), false);
        vector<bool> on_stack(nodes.size(), false);
+       
+       list<ShaderNode*> newnodes;
+       
+       /* remove proxy nodes */
+       remove_proxy_nodes(removed);
+       
+       foreach(ShaderNode *node, nodes) {
+               if(!removed[node->id])
+                       newnodes.push_back(node);
+               else
+                       delete node;
+       }
+       nodes = newnodes;
+       newnodes.clear();
 
        /* break cycles */
        break_cycles(output(), visited, on_stack);
 
        /* remove unused nodes */
-       list<ShaderNode*> newnodes;
-       
        foreach(ShaderNode *node, nodes) {
                if(visited[node->id])
                        newnodes.push_back(node);
index 2a2df5e1377c5e8c1b43d64f0c4456d6905ee1fe..91ec83aba210728b0a553656d572c95553516092 100644 (file)
@@ -217,6 +217,7 @@ protected:
        void find_dependencies(set<ShaderNode*>& dependencies, ShaderInput *input);
        void copy_nodes(set<ShaderNode*>& nodes, map<ShaderNode*, ShaderNode*>& nnodemap);
 
+       void remove_proxy_nodes(vector<bool>& removed);
        void break_cycles(ShaderNode *node, vector<bool>& visited, vector<bool>& on_stack);
        void clean();
        void bump_from_displacement();
index 45f0ab417753a2c53c5db2bc51570bfbab4c02a6..7d873221cd6ece18cda70d8052db7cd979444442 100644 (file)
@@ -713,6 +713,41 @@ void MagicTextureNode::compile(OSLCompiler& compiler)
        compiler.add(this, "node_magic_texture");
 }
 
+/* Normal */
+
+NormalNode::NormalNode()
+: ShaderNode("normal")
+{
+       direction = make_float3(0.0f, 0.0f, 1.0f);
+
+       add_input("Normal", SHADER_SOCKET_NORMAL);
+       add_output("Normal", SHADER_SOCKET_NORMAL);
+       add_output("Dot",  SHADER_SOCKET_FLOAT);
+}
+
+void NormalNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *normal_in = input("Normal");
+       ShaderOutput *normal_out = output("Normal");
+       ShaderOutput *dot_out = output("Dot");
+
+       compiler.stack_assign(normal_in);
+       compiler.stack_assign(normal_out);
+       compiler.stack_assign(dot_out);
+
+       compiler.add_node(NODE_NORMAL, normal_in->stack_offset, normal_out->stack_offset, dot_out->stack_offset);
+       compiler.add_node(
+               __float_as_int(direction.x),
+               __float_as_int(direction.y),
+               __float_as_int(direction.z));
+}
+
+void NormalNode::compile(OSLCompiler& compiler)
+{
+       compiler.parameter_vector("Direction", direction);
+       compiler.add(this, "node_normal");
+}
+
 /* Mapping */
 
 MappingNode::MappingNode()
@@ -834,6 +869,26 @@ void ConvertNode::compile(OSLCompiler& compiler)
                assert(0);
 }
 
+/* Proxy */
+
+ProxyNode::ProxyNode(ShaderSocketType from_, ShaderSocketType to_)
+: ShaderNode("proxy")
+{
+       from = from_;
+       to = to_;
+
+       add_input("Input", from);
+       add_output("Output", to);
+}
+
+void ProxyNode::compile(SVMCompiler& compiler)
+{
+}
+
+void ProxyNode::compile(OSLCompiler& compiler)
+{
+}
+
 /* BSDF Closure */
 
 BsdfNode::BsdfNode()
@@ -1691,6 +1746,33 @@ void CombineRGBNode::compile(OSLCompiler& compiler)
        compiler.add(this, "node_combine_rgb");
 }
 
+/* Gamma */
+GammaNode::GammaNode()
+: ShaderNode("gamma")
+{
+       add_input("Color", SHADER_SOCKET_COLOR);
+       add_input("Gamma", SHADER_SOCKET_FLOAT);
+       add_output("Color", SHADER_SOCKET_COLOR);
+}
+
+void GammaNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *color_in = input("Color");
+       ShaderInput *gamma_in = input("Gamma");
+       ShaderOutput *color_out = output("Color");
+
+       compiler.stack_assign(color_in);
+       compiler.stack_assign(gamma_in);
+       compiler.stack_assign(color_out);
+
+       compiler.add_node(NODE_GAMMA, gamma_in->stack_offset, color_in->stack_offset, color_out->stack_offset);
+}
+
+void GammaNode::compile(OSLCompiler& compiler)
+{
+       compiler.add(this, "node_gamma");
+}
+
 /* Separate RGB */
 SeparateRGBNode::SeparateRGBNode()
 : ShaderNode("separate_rgb")
index e08651cf1ebf7959a112aad3b0be296d4318996a..f0a669f3f8761f74f44abeb90ddf963dbde35e63 100644 (file)
@@ -158,6 +158,14 @@ public:
        ShaderSocketType from, to;
 };
 
+class ProxyNode : public ShaderNode {
+public:
+       ProxyNode(ShaderSocketType from, ShaderSocketType to);
+       SHADER_NODE_BASE_CLASS(ProxyNode)
+
+       ShaderSocketType from, to;
+};
+
 class BsdfNode : public ShaderNode {
 public:
        SHADER_NODE_CLASS(BsdfNode)
@@ -302,6 +310,11 @@ public:
        SHADER_NODE_CLASS(CombineRGBNode)
 };
 
+class GammaNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(GammaNode)
+};
+
 class SeparateRGBNode : public ShaderNode {
 public:
        SHADER_NODE_CLASS(SeparateRGBNode)
@@ -343,6 +356,13 @@ public:
        static ShaderEnum type_enum;
 };
 
+class NormalNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(NormalNode)
+
+       float3 direction;
+};
+
 class VectorMathNode : public ShaderNode {
 public:
        SHADER_NODE_CLASS(VectorMathNode)
index 69766b54e9755c54db9943fc9ee5da98f1bf4570..318ba8eab8ad7f21be8f036be94eecd88754d811 100644 (file)
@@ -156,6 +156,7 @@ class NODE_MT_node(Menu):
         layout.operator("node.mute_toggle")
         layout.operator("node.preview_toggle")
         layout.operator("node.hide_socket_toggle")
+        layout.operator("node.options_toggle")
 
         layout.separator()
 
index a021695b7c9d7b2fbd814f1c82e0668f1501557e..c6fdd2e1adc5de2ae311b013291cf8a350b2fde9 100644 (file)
@@ -63,7 +63,8 @@ char *tcc_to_char (unsigned int tcc);
 
 /* implemetation */
 
-unsigned int GET_FCC (FILE *fp) {
+unsigned int GET_FCC (FILE *fp)
+{
        unsigned char tmp[4];
 
        tmp[0] = getc(fp);
@@ -74,7 +75,8 @@ unsigned int GET_FCC (FILE *fp) {
        return FCC (tmp);
 }
 
-unsigned int GET_TCC (FILE *fp) {
+unsigned int GET_TCC (FILE *fp)
+{
        char tmp[5];
 
        tmp[0] = getc(fp);
@@ -85,7 +87,8 @@ unsigned int GET_TCC (FILE *fp) {
        return FCC (tmp);
 }
 
-char *fcc_to_char (unsigned int fcc) {
+char *fcc_to_char (unsigned int fcc)
+{
        DEBUG_FCC[0]= (fcc)&127;
        DEBUG_FCC[1]= (fcc>>8)&127;
        DEBUG_FCC[2]= (fcc>>16)&127;
@@ -94,7 +97,8 @@ char *fcc_to_char (unsigned int fcc) {
        return DEBUG_FCC;       
 }
 
-char *tcc_to_char (unsigned int tcc) {
+char *tcc_to_char (unsigned int tcc)
+{
        DEBUG_FCC[0]= (tcc)&127;
        DEBUG_FCC[1]= (tcc>>8)&127;
        DEBUG_FCC[2]= 0;
@@ -103,7 +107,8 @@ char *tcc_to_char (unsigned int tcc) {
        return DEBUG_FCC;       
 }
 
-int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num) {
+int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num)
+{
        int cur_stream;
 
        if (movie == NULL)
@@ -121,7 +126,8 @@ int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num) {
        return -AVI_ERROR_FOUND;
 }
 
-static int fcc_get_stream (int fcc) {
+static int fcc_get_stream (int fcc)
+{
        char fccs[4];
 
        fccs[0] = fcc;
@@ -132,7 +138,8 @@ static int fcc_get_stream (int fcc) {
        return 10*(fccs[0]-'0') + (fccs[1]-'0');
 }
 
-static int fcc_is_data (int fcc) {
+static int fcc_is_data (int fcc)
+{
        char fccs[4];
 
        fccs[0] = fcc;
@@ -148,7 +155,8 @@ static int fcc_is_data (int fcc) {
        return 1;
 }
 
-AviError AVI_print_error (AviError in_error) {
+AviError AVI_print_error (AviError in_error)
+{
        int error;
 
        if ((int) in_error < 0)
@@ -190,12 +198,14 @@ AviError AVI_print_error (AviError in_error) {
        return in_error;
 }
 /*
-void AVI_set_debug (int mode) {
+void AVI_set_debug (int mode)
+{
        AVI_DEBUG= mode;
 }
 */
 /*
-int AVI_is_avi (char *name) {
+int AVI_is_avi (char *name)
+{
        FILE *fp;
        int ret;
        
@@ -216,7 +226,8 @@ int AVI_is_avi (char *name) {
 }
 */
 
-int AVI_is_avi (const char *name) {
+int AVI_is_avi (const char *name)
+{
        int temp, fcca, j;
        AviMovie movie= {NULL};
        AviMainHeader header;
@@ -407,7 +418,8 @@ int AVI_is_avi (const char *name) {
 
 }
 
-AviError AVI_open_movie (const char *name, AviMovie *movie) {
+AviError AVI_open_movie (const char *name, AviMovie *movie)
+{
        int temp, fcca, size, j;
        
        DEBUG_PRINT("opening movie\n");
@@ -619,7 +631,11 @@ AviError AVI_open_movie (const char *name, AviMovie *movie) {
                        movie->entries[temp].Offset = GET_FCC (movie->fp);
                        movie->entries[temp].Size = GET_FCC (movie->fp);
                        
-                       if (AVI_DEBUG) printf ("Index entry %04d: ChunkId:%s Flags:%d Offset:%d Size:%d\n", temp, fcc_to_char(movie->entries[temp].ChunkId), movie->entries[temp].Flags, movie->entries[temp].Offset, movie->entries[temp].Size);
+                       if (AVI_DEBUG) {
+                               printf("Index entry %04d: ChunkId:%s Flags:%d Offset:%d Size:%d\n",
+                                      temp, fcc_to_char(movie->entries[temp].ChunkId), movie->entries[temp].Flags,
+                                      movie->entries[temp].Offset, movie->entries[temp].Size);
+                       }
                }
 
 /* Some AVI's have offset entries in absolute coordinates
@@ -637,7 +653,8 @@ AviError AVI_open_movie (const char *name, AviMovie *movie) {
        return AVI_ERROR_NONE;
 }
 
-void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream) {
+void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream)
+{
        int cur_frame=-1, temp, i=0, rewind=1;
        void *buffer;
 
@@ -681,7 +698,8 @@ void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream)
        return buffer;
 }
 
-AviError AVI_close (AviMovie *movie) {
+AviError AVI_close (AviMovie *movie)
+{
        int i;
 
        fclose (movie->fp);
@@ -703,7 +721,8 @@ AviError AVI_close (AviMovie *movie) {
        return AVI_ERROR_NONE;
 }
 
-AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...) {
+AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...)
+{
        va_list ap;
        AviList list;
        AviChunk chunk;
@@ -892,7 +911,8 @@ AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...) {
        return AVI_ERROR_NONE;
 }
 
-AviError AVI_write_frame (AviMovie *movie, int frame_num, ...) {
+AviError AVI_write_frame (AviMovie *movie, int frame_num, ...)
+{
        AviList list;
        AviChunk chunk;
        AviIndexEntry *temp;
@@ -999,7 +1019,8 @@ AviError AVI_write_frame (AviMovie *movie, int frame_num, ...) {
        return AVI_ERROR_NONE;
 }
 
-AviError AVI_close_compress (AviMovie *movie) {
+AviError AVI_close_compress (AviMovie *movie)
+{
        int temp, movi_size, i;
 
        fseek (movie->fp, 0L, SEEK_END);
index 78d8d4a32b2861ffce142319c84608489e3aeb2e..73af709799425e2faaeb577740de135fc95b292b 100644 (file)
@@ -40,7 +40,8 @@
 #include "mjpeg.h"
 #include "rgb32.h"
 
-void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) {
+void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size)
+{
        if (from == to)
                return buffer;
 
@@ -82,7 +83,8 @@ void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat f
        return buffer;
 }
 
-int avi_get_data_id (AviFormat format, int stream) {
+int avi_get_data_id (AviFormat format, int stream)
+{
        char fcc[5];
 
        if (avi_get_format_type (format) == FCC("vids"))
@@ -95,7 +97,8 @@ int avi_get_data_id (AviFormat format, int stream) {
        return FCC(fcc);
 }
 
-int avi_get_format_type (AviFormat format) {
+int avi_get_format_type (AviFormat format)
+{
        switch (format) {
        case AVI_FORMAT_RGB24:
        case AVI_FORMAT_RGB32:
@@ -109,7 +112,8 @@ int avi_get_format_type (AviFormat format) {
        }
 }
 
-int avi_get_format_fcc (AviFormat format) {
+int avi_get_format_fcc (AviFormat format)
+{
        switch (format) {
        case AVI_FORMAT_RGB24:
        case AVI_FORMAT_RGB32:
@@ -125,7 +129,8 @@ int avi_get_format_fcc (AviFormat format) {
        }
 }
 
-int avi_get_format_compression (AviFormat format) {
+int avi_get_format_compression (AviFormat format)
+{
        switch (format) {
        case AVI_FORMAT_RGB24:
        case AVI_FORMAT_RGB32:
index 194880605b6eebaafdca3b836cbf118b152f7bef..29b3047eca4ba0f6f69a721cec6226dd3a3f9b76 100644 (file)
@@ -43,7 +43,8 @@
 #include "avi_intern.h"
 
 #ifdef __BIG_ENDIAN__
-static void invert (int *num) {
+static void invert (int *num)
+{
        int new=0,i,j;
 
        for (j=0; j < 4; j++) {
@@ -55,7 +56,8 @@ static void invert (int *num) {
        *num = new;
 }
 
-static void sinvert (short int *num) {
+static void sinvert (short int *num)
+{
        short int new=0;
        int i,j;
 
@@ -68,20 +70,23 @@ static void sinvert (short int *num) {
        *num = new;
 }
 
-static void Ichunk (AviChunk *chunk) {
+static void Ichunk (AviChunk *chunk)
+{
        invert (&chunk->fcc);
        invert (&chunk->size);
 }
 #endif
 
 #ifdef __BIG_ENDIAN__
-static void Ilist (AviList *list){
+static void Ilist (AviList *list)
+{
        invert (&list->fcc);
        invert (&list->size);
        invert (&list->ids);
 }
 
-static void Imainh (AviMainHeader *mainh) {
+static void Imainh (AviMainHeader *mainh)
+{
        invert (&mainh->fcc);
        invert (&mainh->size);
        invert (&mainh->MicroSecPerFrame);
@@ -100,7 +105,8 @@ static void Imainh (AviMainHeader *mainh) {
        invert (&mainh->Reserved[3]);
 }
 
-static void Istreamh (AviStreamHeader *streamh) {
+static void Istreamh (AviStreamHeader *streamh)
+{
        invert (&streamh->fcc);
        invert (&streamh->size);
        invert (&streamh->Type);
@@ -122,7 +128,8 @@ static void Istreamh (AviStreamHeader *streamh) {
        sinvert (&streamh->bottom);
 }
 
-static void Ibitmaph (AviBitmapInfoHeader *bitmaph) {
+static void Ibitmaph (AviBitmapInfoHeader *bitmaph)
+{
        invert (&bitmaph->fcc);
        invert (&bitmaph->size);
        invert (&bitmaph->Size);
@@ -138,7 +145,8 @@ static void Ibitmaph (AviBitmapInfoHeader *bitmaph) {
        invert (&bitmaph->ClrImportant);
 }
 
-static void Imjpegu (AviMJPEGUnknown *mjpgu) {
+static void Imjpegu (AviMJPEGUnknown *mjpgu)
+{
        invert (&mjpgu->a);
        invert (&mjpgu->b);
        invert (&mjpgu->c);
@@ -148,7 +156,8 @@ static void Imjpegu (AviMJPEGUnknown *mjpgu) {
        invert (&mjpgu->g);
 }
 
-static void Iindexe (AviIndexEntry *indexe) {
+static void Iindexe (AviIndexEntry *indexe)
+{
        invert (&indexe->ChunkId);
        invert (&indexe->Flags);
        invert (&indexe->Offset);
@@ -156,7 +165,8 @@ static void Iindexe (AviIndexEntry *indexe) {
 }
 #endif /* __BIG_ENDIAN__ */
 
-void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int type) {
+void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int type)
+{
 #ifdef __BIG_ENDIAN__
        void *data;
 
index e55549bd05eb70e436530a3a50b411446320423a..dab0b213d9545922cb6b8ff86dcbddaa45bd908c 100644 (file)
@@ -50,7 +50,8 @@ static void jpegmemsrcmgr_build (j_decompress_ptr dinfo, unsigned char *buffer,
 
 static int numbytes;
 
-static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) {
+static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)
+{
        if (*htblptr == NULL)
                *htblptr = jpeg_alloc_huff_table((j_common_ptr) dinfo);
 
@@ -64,7 +65,8 @@ static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const U
 /* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
 /* IMPORTANT: these are only valid for 8-bit data precision! */
 
-static void std_huff_tables (j_decompress_ptr dinfo) {
+static void std_huff_tables (j_decompress_ptr dinfo)
+{
        static const UINT8 bits_dc_luminance[17] =
        { /* 0-base */
                0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0       };
@@ -142,7 +144,8 @@ static void std_huff_tables (j_decompress_ptr dinfo) {
                bits_ac_chrominance, val_ac_chrominance);
 }
 
-static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, int bufsize) {
+static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, int bufsize)
+{
        int rowstride;
        unsigned int y;
        struct jpeg_decompress_struct dinfo;
@@ -194,7 +197,8 @@ static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsign
        return 1;
 }
 
-static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *inBuffer, int width, int height, int bufsize) {
+static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *inBuffer, int width, int height, int bufsize)
+{
        int i, rowstride;
        unsigned int y;
        struct jpeg_compress_struct cinfo;
@@ -255,7 +259,8 @@ static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *
        jpeg_destroy_compress(&cinfo);
 }
 
-static void interlace(unsigned char *to, unsigned char *from, int width, int height) {
+static void interlace(unsigned char *to, unsigned char *from, int width, int height)
+{
        int i, rowstride= width*3;
        
        for (i=0; i<height; i++) {
@@ -266,7 +271,8 @@ static void interlace(unsigned char *to, unsigned char *from, int width, int hei
        }
 }
 
-static void deinterlace(int odd, unsigned char *to, unsigned char *from, int width, int height) {
+static void deinterlace(int odd, unsigned char *to, unsigned char *from, int width, int height)
+{
        int i, rowstride= width*3;
        
        for (i=0; i<height; i++) {
@@ -277,7 +283,8 @@ 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) {
+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;
@@ -299,7 +306,8 @@ static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, in
        }
 }
 
-static void check_and_compress_jpeg(int quality, unsigned char *outbuf, unsigned char *inbuf, int width, int height, int bufsize) {
+static void check_and_compress_jpeg(int quality, unsigned char *outbuf, 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;
@@ -326,7 +334,8 @@ static void check_and_compress_jpeg(int quality, unsigned char *outbuf, unsigned
        }
 }
 
-void *avi_converter_from_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size) {
+void *avi_converter_from_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size)
+{
        int deint;
        unsigned char *buf;
 
@@ -349,7 +358,8 @@ void *avi_converter_from_mjpeg (AviMovie *movie, int stream, unsigned char *buff
        return buf;
 }
 
-void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size) {
+void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size)
+{
        unsigned char *buf;
        int bufsize= *size;
        
@@ -380,22 +390,26 @@ void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer
 
 /* Compression from memory */
 
-static void jpegmemdestmgr_init_destination(j_compress_ptr cinfo) {
+static void jpegmemdestmgr_init_destination(j_compress_ptr cinfo)
+{
        (void)cinfo; /* unused */
 }
 
-static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo) {
+static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo)
+{
        (void)cinfo; /* unused */
        return TRUE;
 }
 
-static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo) {
+static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo)
+{
        numbytes-= cinfo->dest->free_in_buffer;
 
        MEM_freeN(cinfo->dest);
 }
 
-static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize) {
+static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize)
+{
        cinfo->dest= MEM_mallocN(sizeof(*(cinfo->dest)), "avi.jpegmemdestmgr_build");
        
        cinfo->dest->init_destination= jpegmemdestmgr_init_destination;
@@ -410,11 +424,13 @@ static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, in
 
 /* Decompression from memory */
 
-static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo) {
+static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo)
+{
        (void)dinfo;
 }
 
-static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo) {
+static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo)
+{
        unsigned char *buf= (unsigned char*) dinfo->src->next_input_byte-2;
        
                /* if we get called, must have run out of data */
@@ -429,7 +445,8 @@ static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo) {
        return TRUE;
 }
 
-static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt) {
+static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt)
+{
        if (dinfo->src->bytes_in_buffer<skipcnt)
                skipcnt= dinfo->src->bytes_in_buffer;
 
@@ -437,13 +454,15 @@ static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt)
        dinfo->src->bytes_in_buffer-= skipcnt;
 }
 
-static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo) {
+static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo)
+{
        numbytes-= dinfo->src->bytes_in_buffer;
        
        MEM_freeN(dinfo->src);
 }
 
-static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize) {
+static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize)
+{
        dinfo->src= MEM_mallocN(sizeof(*(dinfo->src)), "avi.jpegmemsrcmgr_build");
        
        dinfo->src->init_source= jpegmemsrcmgr_init_source;
index bda153d0cd3e05f93ce8d2cf17e3a3092e1ff3f5..483b708bee65375270dcef2ac5907214d4233c01 100644 (file)
@@ -43,7 +43,8 @@
 
 /* avi_set_compress_options gets its own file... now don't WE feel important? */
 
-AviError AVI_set_compress_option (AviMovie *movie, int option_type, int stream, AviOption option, void *opt_data) {
+AviError AVI_set_compress_option (AviMovie *movie, int option_type, int stream, AviOption option, void *opt_data)
+{
        int i;
        int useconds;
 
index 4d088377c9ef19393372920e7397ca11aafe06d3..e3be082cca67f71bbee605c0d7919c2f1c0528a2 100644 (file)
@@ -40,7 +40,8 @@
 #include "MEM_guardedalloc.h"
 #include "rgb32.h"
 
-void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) {
+void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size)
+{
        int y, x, rowstridea, rowstrideb;
        unsigned char *buf;
 
@@ -65,7 +66,8 @@ void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buff
        return buf;
 }
 
-void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) {
+void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size)
+{
        int i;
        unsigned char *buf;
        unsigned char *to, *from;
index f6b4240a026a2972936794773c32a3f0eefd9ff6..1d344c6e81091e7a2daa88d63c26ce7a2bcfd24d 100644 (file)
@@ -121,9 +121,9 @@ int CustomData_number_of_layers(const struct CustomData *data, int type);
 
 /* duplicate data of a layer with flag NOFREE, and remove that flag.
  * returns the layer data */
-void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type);
+void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int type, const int totelem);
 void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
-                                                                                                 int type, const char *name);
+                                                                                                 const int type, const char *name, const int totelem);
 
 /* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is
  * zero for the layer type, so only layer types specified by the mask
index 5dbf22b54bf8fe453d35a873a5573670e709a513..378e587279171de76f6b4f98e2062ad3c4692798 100644 (file)
@@ -521,6 +521,7 @@ struct ShadeResult;
 #define SH_NODE_LAYER_WEIGHT                   160
 #define SH_NODE_VOLUME_TRANSPARENT             161
 #define SH_NODE_VOLUME_ISOTROPIC               162
+#define SH_NODE_GAMMA                          163
 
 /* custom defines options for Material node */
 #define SH_NODE_MAT_DIFF   1
index b5a5090a5ebf832291e76b9ed5685ff57c4c0b5a..828b0b47e3a932839c47a79d623cdd60a480741d 100644 (file)
@@ -120,6 +120,8 @@ void BKE_scene_foreach_display_point(
         const short flag,
         void (*func_cb)(const float[3], void *), void *user_data);
 
+int BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob);
+
 void solve_tracking (struct Object *ob, float targetmat[][4]);
 int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]);
 
index 140f596f78c0a3f052f8d1ffa6494c67a60636b1..3ab52a7c17ba7c5975b8bbc92e40844ddbf90f02 100644 (file)
@@ -218,7 +218,7 @@ static CCGAllocatorIFC *_getStandardAllocatorIFC(void) {
 
 /***/
 
-static int VertDataEqual(float *a, float *b) {
+static int VertDataEqual(const float *a, const float *b) {
        return a[0]==b[0] && a[1]==b[1] && a[2]==b[2];
 }
 #define VertDataZero(av)                               { float *_a = (float*) av; _a[0] = _a[1] = _a[2] = 0.0f; }
@@ -238,7 +238,7 @@ static int VertDataEqual(float *a, float *b) {
 #define NormAdd(av, bv)                                        { float *_a = (float*) av, *_b = (float*) bv; _a[0]+=_b[0]; _a[1]+=_b[1]; _a[2]+=_b[2]; }
 
 
-static int _edge_isBoundary(CCGEdge *e);
+static int _edge_isBoundary(const CCGEdge *e);
 
 /***/
 
@@ -392,7 +392,7 @@ static void _vert_addFace(CCGVert *v, CCGFace *f, CCGSubSurf *ss) {
        v->faces = CCGSUBSURF_realloc(ss, v->faces, (v->numFaces+1)*sizeof(*v->faces), v->numFaces*sizeof(*v->faces));
        v->faces[v->numFaces++] = f;
 }
-static CCGEdge *_vert_findEdgeTo(CCGVert *v, CCGVert *vQ) {
+static CCGEdge *_vert_findEdgeTo(const CCGVert *v, const CCGVert *vQ) {
        int i;
        for (i=0; i<v->numEdges; i++) {
                CCGEdge *e = v->edges[v->numEdges-1-i]; // XXX, note reverse
@@ -402,7 +402,7 @@ static CCGEdge *_vert_findEdgeTo(CCGVert *v, CCGVert *vQ) {
        }
        return NULL;
 }
-static int _vert_isBoundary(CCGVert *v) {
+static int _vert_isBoundary(const CCGVert *v) {
        int i;
        for (i=0; i<v->numEdges; i++)
                if (_edge_isBoundary(v->edges[i]))
@@ -423,7 +423,7 @@ static void _vert_free(CCGVert *v, CCGSubSurf *ss) {
        CCGSUBSURF_free(ss, v);
 }
 
-static int VERT_seam(CCGVert *v) {
+static int VERT_seam(const CCGVert *v) {
        return ((v->flags & Vert_eSeam) != 0);
 }
 
@@ -462,7 +462,7 @@ static void _edge_addFace(CCGEdge *e, CCGFace *f, CCGSubSurf *ss) {
        e->faces = CCGSUBSURF_realloc(ss, e->faces, (e->numFaces+1)*sizeof(*e->faces), e->numFaces*sizeof(*e->faces));
        e->faces[e->numFaces++] = f;
 }
-static int _edge_isBoundary(CCGEdge *e) {
+static int _edge_isBoundary(const CCGEdge *e) {
        return e->numFaces<2;
 }
 
@@ -900,7 +900,7 @@ CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL) {
        return eCCGError_None;
 }
 
-CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData, int seam, CCGVert **v_r) {
+CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertData, int seam, CCGVert **v_r) {
        void **prevp;
        CCGVert *v = NULL;
        short seamflag = (seam)? Vert_eSeam: 0;
@@ -2484,13 +2484,13 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i
 
 /*** External API accessor functions ***/
 
-int ccgSubSurf_getNumVerts(CCGSubSurf *ss) {
+int ccgSubSurf_getNumVerts(const CCGSubSurf *ss) {
        return ss->vMap->numEntries;
 }
-int ccgSubSurf_getNumEdges(CCGSubSurf *ss) {
+int ccgSubSurf_getNumEdges(const CCGSubSurf *ss) {
        return ss->eMap->numEntries;
 }
-int ccgSubSurf_getNumFaces(CCGSubSurf *ss) {
+int ccgSubSurf_getNumFaces(const CCGSubSurf *ss) {
        return ss->fMap->numEntries;
 }
 
@@ -2504,23 +2504,23 @@ CCGFace *ccgSubSurf_getFace(CCGSubSurf *ss, CCGFaceHDL f) {
        return (CCGFace*) _ehash_lookup(ss->fMap, f);
 }
 
-int ccgSubSurf_getSubdivisionLevels(CCGSubSurf *ss) {
+int ccgSubSurf_getSubdivisionLevels(const CCGSubSurf *ss) {
        return ss->subdivLevels;
 }
-int ccgSubSurf_getEdgeSize(CCGSubSurf *ss) {
+int ccgSubSurf_getEdgeSize(const CCGSubSurf *ss) {
        return ccgSubSurf_getEdgeLevelSize(ss, ss->subdivLevels);
 }
-int ccgSubSurf_getEdgeLevelSize(CCGSubSurf *ss, int level) {
+int ccgSubSurf_getEdgeLevelSize(const CCGSubSurf *ss, int level) {
        if (level<1 || level>ss->subdivLevels) {
                return -1;
        } else {
                return 1 + (1<<level);
        }
 }
-int ccgSubSurf_getGridSize(CCGSubSurf *ss) {
+int ccgSubSurf_getGridSize(const CCGSubSurf *ss) {
        return ccgSubSurf_getGridLevelSize(ss, ss->subdivLevels);
 }
-int ccgSubSurf_getGridLevelSize(CCGSubSurf *ss, int level) {
+int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level) {
        if (level<1 || level>ss->subdivLevels) {
                return -1;
        } else {
@@ -2736,19 +2736,19 @@ void ccgFaceIterator_free(CCGFaceIterator *vi) {
 
 /*** Extern API final vert/edge/face interface ***/
 
-int ccgSubSurf_getNumFinalVerts(CCGSubSurf *ss) {
+int ccgSubSurf_getNumFinalVerts(const CCGSubSurf *ss) {
        int edgeSize = 1 + (1<<ss->subdivLevels);
        int gridSize = 1 + (1<<(ss->subdivLevels-1));
        int numFinalVerts = ss->vMap->numEntries + ss->eMap->numEntries*(edgeSize-2) + ss->fMap->numEntries + ss->numGrids*((gridSize-2) + ((gridSize-2)*(gridSize-2)));
        return numFinalVerts;
 }
-int ccgSubSurf_getNumFinalEdges(CCGSubSurf *ss) {
+int ccgSubSurf_getNumFinalEdges(const CCGSubSurf *ss) {
        int edgeSize = 1 + (1<<ss->subdivLevels);
        int gridSize = 1 + (1<<(ss->subdivLevels-1));
        int numFinalEdges = ss->eMap->numEntries*(edgeSize-1) + ss->numGrids*((gridSize-1) + 2*((gridSize-2)*(gridSize-1)));
        return numFinalEdges;
 }
-int ccgSubSurf_getNumFinalFaces(CCGSubSurf *ss) {
+int ccgSubSurf_getNumFinalFaces(const CCGSubSurf *ss) {
        int gridSize = 1 + (1<<(ss->subdivLevels-1));
        int numFinalFaces = ss->numGrids*((gridSize-1)*(gridSize-1));
        return numFinalFaces;
index 457ad2af3535f9bf90adebf50759fd0bce42e46a..543411f26f433182fd4e6e74fed3489b5b9822d9 100644 (file)
@@ -56,7 +56,7 @@ CCGError      ccgSubSurf_sync (CCGSubSurf *ss);
 CCGError       ccgSubSurf_initFullSync         (CCGSubSurf *ss);
 CCGError       ccgSubSurf_initPartialSync      (CCGSubSurf *ss);
 
-CCGError       ccgSubSurf_syncVert             (CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData, int seam, CCGVert **v_r);
+CCGError       ccgSubSurf_syncVert             (CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertData, int seam, CCGVert **v_r);
 CCGError       ccgSubSurf_syncEdge             (CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1, float crease, CCGEdge **e_r);
 CCGError       ccgSubSurf_syncFace             (CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs, CCGFace **f_r);
 
@@ -84,15 +84,15 @@ CCGError    ccgSubSurf_setCalcVertexNormals         (CCGSubSurf *ss, int useVertNormals, i
 
 /***/
 
-int                    ccgSubSurf_getNumVerts                          (CCGSubSurf *ss);
-int                    ccgSubSurf_getNumEdges                          (CCGSubSurf *ss);
-int                    ccgSubSurf_getNumFaces                          (CCGSubSurf *ss);
+int                    ccgSubSurf_getNumVerts                          (const CCGSubSurf *ss);
+int                    ccgSubSurf_getNumEdges                          (const CCGSubSurf *ss);
+int                    ccgSubSurf_getNumFaces                          (const CCGSubSurf *ss);
 
-int                    ccgSubSurf_getSubdivisionLevels         (CCGSubSurf *ss);
-int                    ccgSubSurf_getEdgeSize                          (CCGSubSurf *ss);
-int                    ccgSubSurf_getEdgeLevelSize                     (CCGSubSurf *ss, int level);
-int                    ccgSubSurf_getGridSize                          (CCGSubSurf *ss);
-int                    ccgSubSurf_getGridLevelSize                     (CCGSubSurf *ss, int level);
+int                    ccgSubSurf_getSubdivisionLevels         (const CCGSubSurf *ss);
+int                    ccgSubSurf_getEdgeSize                          (const CCGSubSurf *ss);
+int                    ccgSubSurf_getEdgeLevelSize                     (const CCGSubSurf *ss, int level);
+int                    ccgSubSurf_getGridSize                          (const CCGSubSurf *ss);
+int                    ccgSubSurf_getGridLevelSize                     (const CCGSubSurf *ss, int level);
 
 CCGVert*       ccgSubSurf_getVert                                      (CCGSubSurf *ss, CCGVertHDL v);
 CCGVertHDL     ccgSubSurf_getVertVertHandle            (CCGVert *v);
@@ -135,9 +135,9 @@ void*               ccgSubSurf_getFaceGridEdgeData          (CCGSubSurf *ss, CCGFace *f, int gridInde
 void*          ccgSubSurf_getFaceGridDataArray         (CCGSubSurf *ss, CCGFace *f, int gridIndex);
 void*          ccgSubSurf_getFaceGridData                      (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y);
 
-int                    ccgSubSurf_getNumFinalVerts             (CCGSubSurf *ss);
-int                    ccgSubSurf_getNumFinalEdges             (CCGSubSurf *ss);
-int                    ccgSubSurf_getNumFinalFaces             (CCGSubSurf *ss);
+int                    ccgSubSurf_getNumFinalVerts             (const CCGSubSurf *ss);
+int                    ccgSubSurf_getNumFinalEdges             (const CCGSubSurf *ss);
+int                    ccgSubSurf_getNumFinalFaces             (const CCGSubSurf *ss);
 
 /***/
 
index 0087b91c6158f37858c90032e4df1f545a2c8d89..3bc2ee61e7bd9ea4054cbf0938d08bf44474f3f3 100644 (file)
@@ -642,67 +642,71 @@ enum {
        CALC_WP_AUTO_NORMALIZE= (1<<1)
 };
 
+void weightpaint_color(unsigned char r_col[4], ColorBand *coba, const float input)
+{
+       float colf[4];
+
+       if(coba) do_colorband(coba, input, colf);
+       else     weight_to_rgb(colf, input);
+
+       r_col[3] = (unsigned char)(colf[0] * 255.0f);
+       r_col[2] = (unsigned char)(colf[1] * 255.0f);
+       r_col[1] = (unsigned char)(colf[2] * 255.0f);
+       r_col[0] = 255;
+}
+
+
 static void calc_weightpaint_vert_color(
-        Object *ob, const int defbase_tot, ColorBand *coba, int vert, unsigned char *col,
-        const char *dg_flags, int selected, int UNUSED(unselected), const int draw_flag)
+        unsigned char r_col[4],
+        MDeformVert *dv, ColorBand *coba,
+        const int defbase_tot, const int defbase_act,
+        const char *dg_flags,
+        const int selected, const int draw_flag)
 {
-       Mesh *me = ob->data;
        float input = 0.0f;
        
        int make_black= FALSE;
 
-       if (me->dvert) {
-               MDeformVert *dvert= &me->dvert[vert];
-
-               if ((selected > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
-                       int was_a_nonzero= FALSE;
-                       int i;
-
-                       MDeformWeight *dw= dvert->dw;
-                       for (i = dvert->totweight; i > 0; i--, dw++) {
-                               /* in multipaint, get the average if auto normalize is inactive
-                                * get the sum if it is active */
-                               if (dw->def_nr < defbase_tot) {
-                                       if (dg_flags[dw->def_nr]) {
-                                               if (dw->weight) {
-                                                       input += dw->weight;
-                                                       was_a_nonzero= TRUE;
-                                               }
+       if ((selected > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
+               int was_a_nonzero= FALSE;
+               int i;
+
+               MDeformWeight *dw= dv->dw;
+               for (i = dv->totweight; i > 0; i--, dw++) {
+                       /* in multipaint, get the average if auto normalize is inactive
+                        * get the sum if it is active */
+                       if (dw->def_nr < defbase_tot) {
+                               if (dg_flags[dw->def_nr]) {
+                                       if (dw->weight) {
+                                               input += dw->weight;
+                                               was_a_nonzero= TRUE;
                                        }
                                }
                        }
+               }
 
-                       /* make it black if the selected groups have no weight on a vertex */
-                       if (was_a_nonzero == FALSE) {
-                               make_black = TRUE;
-                       }
-                       else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) {
-                               input /= selected; /* get the average */
-                       }
+               /* make it black if the selected groups have no weight on a vertex */
+               if (was_a_nonzero == FALSE) {
+                       make_black = TRUE;
                }
-               else {
-                       /* default, non tricky behavior */
-                       input= defvert_find_weight(dvert, ob->actdef-1);
+               else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) {
+                       input /= selected; /* get the average */
                }
        }
-       
-       if (make_black) {
-               col[3] = 0;
-               col[2] = 0;
-               col[1] = 0;
-               col[0] = 255;
+       else {
+               /* default, non tricky behavior */
+               input= defvert_find_weight(dv, defbase_act);
+       }
+
+       if (make_black) { /* TODO, theme color */
+               r_col[3] = 0;
+               r_col[2] = 0;
+               r_col[1] = 0;
+               r_col[0] = 255;
        }
        else {
-               float colf[4];
                CLAMP(input, 0.0f, 1.0f);
-
-               if(coba) do_colorband(coba, input, colf);
-               else     weight_to_rgb(colf, input);
-
-               col[3] = (unsigned char)(colf[0] * 255.0f);
-               col[2] = (unsigned char)(colf[1] * 255.0f);
-               col[1] = (unsigned char)(colf[2] * 255.0f);
-               col[0] = 255;
+               weightpaint_color(r_col, coba, input);
        }
 }
 
@@ -716,28 +720,41 @@ void vDM_ColorBand_store(ColorBand *coba)
 static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int const draw_flag)
 {
        Mesh *me = ob->data;
-       MFace *mf = me->mface;
        ColorBand *coba= stored_cb;     /* warning, not a local var */
-       unsigned char *wtcol;
-       int i;
-       
-       int defbase_tot = BLI_countlist(&ob->defbase);
-       char *defbase_sel = MEM_mallocN(defbase_tot * sizeof(char), __func__);
-       int selected = get_selected_defgroups(ob, defbase_sel, defbase_tot);
-       int unselected = defbase_tot - selected;
 
-       wtcol = MEM_callocN (sizeof (unsigned char) * me->totface*4*4, "weightmap");
-       
-       memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
-       for (i=0; i<me->totface; i++, mf++) {
-               calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v1, &wtcol[(i*4 + 0)*4], defbase_sel, selected, unselected, draw_flag);
-               calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v2, &wtcol[(i*4 + 1)*4], defbase_sel, selected, unselected, draw_flag);
-               calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v3, &wtcol[(i*4 + 2)*4], defbase_sel, selected, unselected, draw_flag);
-               if (mf->v4)
-                       calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v4, &wtcol[(i*4 + 3)*4], defbase_sel, selected, unselected, draw_flag);
+       unsigned char *wtcol = MEM_mallocN (sizeof (unsigned char) * me->totface*4*4, "weightmap");
+
+       if (me->dvert) {
+               MDeformVert *dvert= me->dvert;
+               MFace *mf = me->mface;
+
+               const int defbase_tot = BLI_countlist(&ob->defbase);
+               const int defbase_act = ob->actdef-1;
+               char *dg_flags = MEM_mallocN(defbase_tot * sizeof(char), __func__);
+               const int selected = get_selected_defgroups(ob, dg_flags, defbase_tot);
+               /* const int unselected = defbase_tot - selected; */ /* UNUSED */
+
+               int i;
+
+               memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
+               for (i=0; i<me->totface; i++, mf++) {
+                       unsigned int fidx= mf->v4 ? 3:2;
+                       do {
+                               calc_weightpaint_vert_color(&wtcol[(i*4 + fidx)*4],
+                                                           &dvert[*(&mf->v1 + fidx)], coba,
+                                                           defbase_tot, defbase_act,
+                                                           dg_flags, selected, draw_flag);
+                       } while (fidx--);
+               }
+
+               MEM_freeN(dg_flags);
+       }
+       else {
+               /* no weights, fill in zero */
+               int col_i;
+               weightpaint_color((unsigned char *)&col_i, coba, 0.0f);
+               fill_vn_i((int *)wtcol, me->totface*4, col_i);
        }
-       
-       MEM_freeN(defbase_sel);
 
        CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, dm->numFaceData);
 }
@@ -2006,13 +2023,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                tfdata = fdata;
 
        /* calc auto bump scale if necessary */
-#if 0
        if(dm->auto_bump_scale<=0.0f)
                DM_calc_auto_bump_scale(dm);
-#else
-       dm->auto_bump_scale = 1.0f; // will revert this after release
-#endif
-
 
        /* add a tangent layer if necessary */
        for(b = 0; b < gattribs->totlayer; b++)
index 0cd8845c53b44ff0265b72a7160f6e1687dfbe9e..89bad72044efb109418ad56db7f1726304816c20 100644 (file)
@@ -726,10 +726,10 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
                        if(!is_zero_v3(group->dupli_ofs)) {
                                copy_m4_m4(tmat, go->ob->obmat);
                                sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
-                               mul_m4_m4m4(mat, tmat, ob->obmat);
+                               mult_m4_m4m4(mat, ob->obmat, tmat);
                        }
                        else {
-                               mul_m4_m4m4(mat, go->ob->obmat, ob->obmat);
+                               mult_m4_m4m4(mat, ob->obmat, go->ob->obmat);
                        }
                        
                        dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
@@ -955,7 +955,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                                           when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
                                        */
                                        if(par_space_mat)
-                                               mul_m4_m4m4(vdd.obmat, ob->obmat, par_space_mat);
+                                               mult_m4_m4m4(vdd.obmat, par_space_mat, ob->obmat);
                                        else
                                                copy_m4_m4(vdd.obmat, ob->obmat);
 
@@ -1084,7 +1084,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                           when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
                                        */
                                        if(par_space_mat)
-                                               mul_m4_m4m4(ob__obmat, ob->obmat, par_space_mat);
+                                               mult_m4_m4m4(ob__obmat, par_space_mat, ob->obmat);
                                        else
                                                copy_m4_m4(ob__obmat, ob->obmat);
                                        
@@ -1143,21 +1143,17 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                                                madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv1], w);
                                                                madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv2], w);
                                                                madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv3], w);
-                                                               if(mv4)
+                                                               if (mv4) {
                                                                        madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv4], w);
+                                                               }
                                                        }
 
                                                        if(mtface) {
-                                                               dob->uv[0] += w*mtface[a].uv[0][0];
-                                                               dob->uv[1] += w*mtface[a].uv[0][1];
-                                                               dob->uv[0] += w*mtface[a].uv[1][0];
-                                                               dob->uv[1] += w*mtface[a].uv[1][1];
-                                                               dob->uv[0] += w*mtface[a].uv[2][0];
-                                                               dob->uv[1] += w*mtface[a].uv[2][1];
-
-                                                               if(mv4) {
-                                                                       dob->uv[0] += w*mtface[a].uv[3][0];
-                                                                       dob->uv[1] += w*mtface[a].uv[3][1];
+                                                               madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[0], w);
+                                                               madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[1], w);
+                                                               madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[2], w);
+                                                               if (mv4) {
+                                                                       madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[3], w);
                                                                }
                                                        }
                                                }
@@ -1396,15 +1392,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                        if(!is_zero_v3(part->dup_group->dupli_ofs)) {
                                                copy_m4_m4(tmat, oblist[b]->obmat);
                                                sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs);
-                                               mul_m4_m4m4(tmat, tmat, pamat);
+                                               mult_m4_m4m4(tmat, pamat, tmat);
                                        }
                                        else {
-                                               mul_m4_m4m4(tmat, oblist[b]->obmat, pamat);
+                                               mult_m4_m4m4(tmat, pamat, oblist[b]->obmat);
                                        }
 
                                        mul_mat3_m4_fl(tmat, size*scale);
                                        if(par_space_mat)
-                                               mul_m4_m4m4(mat, tmat, par_space_mat);
+                                               mult_m4_m4m4(mat, par_space_mat, tmat);
                                        else
                                                copy_m4_m4(mat, tmat);
 
@@ -1435,15 +1431,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                 * remove the real emitter's transformation before 2nd order duplication.
                                 */
                                if(par_space_mat && GS(id->name) != ID_GR)
-                                       mul_m4_m4m4(mat, pamat, psys->imat);
+                                       mult_m4_m4m4(mat, psys->imat, pamat);
                                else
                                        copy_m4_m4(mat, pamat);
 
-                               mul_m4_m4m4(tmat, obmat, mat);
+                               mult_m4_m4m4(tmat, mat, obmat);
                                mul_mat3_m4_fl(tmat, size*scale);
 
                                if(par_space_mat)
-                                       mul_m4_m4m4(mat, tmat, par_space_mat);
+                                       mult_m4_m4m4(mat, par_space_mat, tmat);
                                else
                                        copy_m4_m4(mat, tmat);
 
index 4035db36a39ff4eec0f789ce0d3fe57d562be9c9..ae04b7760c2b4a27af5a5db7b9fd2028b65534ca 100644 (file)
@@ -505,9 +505,9 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
                if(prev->bone->segments==1) {
                        /* find the previous roll to interpolate */
                        if(rest)
-                               mul_m4_m4m4(difmat, prev->bone->arm_mat, imat);
+                               mult_m4_m4m4(difmat, imat, prev->bone->arm_mat);
                        else
-                               mul_m4_m4m4(difmat, prev->pose_mat, imat);
+                               mult_m4_m4m4(difmat, imat, prev->pose_mat);
                        copy_m3_m4(result, difmat);                             // the desired rotation at beginning of next bone
                        
                        vec_roll_to_mat3(h1, 0.0f, mat3);                       // the result of vec_roll without roll
@@ -538,9 +538,9 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
                
                /* find the next roll to interpolate as well */
                if(rest)
-                       mul_m4_m4m4(difmat, next->bone->arm_mat, imat);
+                       mult_m4_m4m4(difmat, imat, next->bone->arm_mat);
                else
-                       mul_m4_m4m4(difmat, next->pose_mat, imat);
+                       mult_m4_m4m4(difmat, imat, next->pose_mat);
                copy_m3_m4(result, difmat);                             // the desired rotation at beginning of next bone
                
                vec_roll_to_mat3(h2, 0.0f, mat3);                       // the result of vec_roll without roll
@@ -837,7 +837,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
        
        invert_m4_m4(obinv, target->obmat);
        copy_m4_m4(premat, target->obmat);
-       mul_m4_m4m4(postmat, armOb->obmat, obinv);
+       mult_m4_m4m4(postmat, obinv, armOb->obmat);
        invert_m4_m4(premat, postmat);
 
        /* bone defmats are already in the channels, chan_mat */
@@ -1103,7 +1103,7 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4])
        invert_m4_m4(obmat, ob->obmat);
        
        /* multiply given matrix by object's-inverse to find pose-space matrix */
-       mul_m4_m4m4(outmat, obmat, inmat);
+       mult_m4_m4m4(outmat, inmat, obmat);
 }
 
 /* Convert Wolrd-Space Location to Pose-Space Location
@@ -1174,7 +1174,7 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
         * This should leave behind the effects of restpose + 
         * parenting + constraints
         */
-       mul_m4_m4m4(pc_posemat, inv_trans, pose_mat);
+       mult_m4_m4m4(pc_posemat, pose_mat, inv_trans);
        
        /* get the inverse of the leftovers so that we can remove 
         * that component from the supplied matrix
@@ -1182,7 +1182,7 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
        invert_m4_m4(inv_posemat, pc_posemat);
        
        /* get the new matrix */
-       mul_m4_m4m4(outmat, inmat, inv_posemat);
+       mult_m4_m4m4(outmat, inv_posemat, inmat);
 }
 
 /* Convert Pose-Space Location to Bone-Space Location
@@ -1237,7 +1237,7 @@ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float
        float imat[4][4];
        
        invert_m4_m4(imat, arm_mat);
-       mul_m4_m4m4(delta_mat, pose_mat, imat);
+       mult_m4_m4m4(delta_mat, imat, pose_mat);
 }
 
 /* **************** Rotation Mode Conversions ****************************** */
@@ -1410,7 +1410,7 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
                offs_bone[3][1]+= prevbone->length;
                
                /* Compose the matrix for this bone  */
-               mul_m4_m4m4(bone->arm_mat, offs_bone, prevbone->arm_mat);
+               mult_m4_m4m4(bone->arm_mat, prevbone->arm_mat, offs_bone);
        }
        else {
                copy_m4_m3(bone->arm_mat, bone->bone_mat);
@@ -2310,7 +2310,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
                        /* extract the scale of the parent matrix */
                        mat4_to_size(tscale, parchan->pose_mat);
                        size_to_mat4(tsmat, tscale);
-                       mul_m4_m4m4(tmat, tmat, tsmat);
+                       mult_m4_m4m4(tmat, tsmat, tmat);
 
                        mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
                }
@@ -2344,7 +2344,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
                }
        }
        else {
-               mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
+               mult_m4_m4m4(pchan->pose_mat, bone->arm_mat, pchan->chan_mat);
 
                /* optional location without arm_mat rotation */
                if(bone->flag & BONE_NO_LOCAL_LOCATION)
@@ -2466,7 +2466,7 @@ void where_is_pose (Scene *scene, Object *ob)
        for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
                if(pchan->bone) {
                        invert_m4_m4(imat, pchan->bone->arm_mat);
-                       mul_m4_m4m4(pchan->chan_mat, imat, pchan->pose_mat);
+                       mult_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
                }
        }
 }
index 6656d06e72e6d1ec1cb6d827a50fd1c86cc29a70..ec2e6b3c0782b7bc8f557ca8e334f1f034cd5df6 100644 (file)
@@ -1514,7 +1514,8 @@ BoidState *boid_new_state(BoidSettings *boids)
        return state;
 }
 
-BoidState *boid_duplicate_state(BoidSettings *boids, BoidState *state) {
+BoidState *boid_duplicate_state(BoidSettings *boids, BoidState *state)
+{
        BoidState *staten = MEM_dupallocN(state);
 
        BLI_duplicatelist(&staten->rules, &state->rules);
index 2bd973d779968f4a18e99d68a7dc2580cd64341f..f55ceab7de8b94c120064d47f28bdc39df6337a0 100644 (file)
@@ -159,7 +159,7 @@ float object_camera_dof_distance(Object *ob)
                copy_m4_m4(obmat, ob->obmat);
                normalize_m4(obmat);
                invert_m4_m4(imat, obmat);
-               mul_m4_m4m4(mat, cam->dof_ob->obmat, imat);
+               mult_m4_m4m4(mat, imat, cam->dof_ob->obmat);
                return fabsf(mat[3][2]);
        }
        return cam->YF_dofdist;
index d4d83fec0eb2e92934be5f5470867acf516c5f76..6f088b8abf75aaa93f3c5df08e85043792640319 100644 (file)
@@ -657,7 +657,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
        float *nors= dm->getFaceDataArray(dm, CD_NORMAL);
        MTFace *tf = DM_get_face_data_layer(dm, CD_MTFACE);
        int i, j, orig, *index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
-       int startFace = 0, lastFlag = 0xdeadbeef;
+       int startFace = 0 /*, lastFlag = 0xdeadbeef */ /* UNUSED */;
        MCol *mcol = dm->getFaceDataArray(dm, CD_WEIGHT_MCOL);
        if(!mcol)
                mcol = dm->getFaceDataArray(dm, CD_MCOL);
@@ -776,7 +776,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
                        int next_actualFace= dm->drawObject->triangle_to_mface[0];
 
                        glShadeModel( GL_SMOOTH );
-                       lastFlag = 0;
+                       /* lastFlag = 0; */ /* UNUSED */
                        for(i = 0; i < tottri; i++) {
                                int actualFace = next_actualFace;
                                int flag = 1;
@@ -1870,7 +1870,7 @@ void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
        int i;
 
        /* this will just return the pointer if it wasn't a referenced layer */
-       vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
+       vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
        cddm->mvert = vert;
 
        for(i = 0; i < dm->numVertData; ++i, ++vert)
@@ -1884,7 +1884,7 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3])
        int i;
 
        /* this will just return the pointer if it wasn't a referenced layer */
-       vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
+       vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
        cddm->mvert = vert;
 
        for(i = 0; i < dm->numVertData; ++i, ++vert)
@@ -1899,7 +1899,7 @@ void CDDM_calc_normals(DerivedMesh *dm)
        if(dm->numVertData == 0) return;
 
        /* we don't want to overwrite any referenced layers */
-       cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
+       cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
 
        /* make a face normal layer if not present */
        face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
index 831d4d1bc0703af88fb15f3193036e625fa68209..820f6b9ef5a03c98209aea12c406bbed08aa5c63 100644 (file)
@@ -153,7 +153,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata,
                                }
                                
                                /* matrix in world-space */
-                               mul_m4_m4m4(cob->matrix, cob->pchan->pose_mat, ob->obmat);
+                               mult_m4_m4m4(cob->matrix, ob->obmat, cob->pchan->pose_mat);
                        }
                        else
                                unit_m4(cob->matrix);
@@ -182,7 +182,7 @@ void constraints_clear_evalob (bConstraintOb *cob)
        
        /* calculate delta of constraints evaluation */
        invert_m4_m4(imat, cob->startmat);
-       mul_m4_m4m4(delta, imat, cob->matrix);
+       mult_m4_m4m4(delta, cob->matrix, imat);
        
        /* copy matrices back to source */
        switch (cob->type) {
@@ -203,7 +203,7 @@ void constraints_clear_evalob (bConstraintOb *cob)
                        /* cob->ob or cob->pchan might not exist */
                        if (cob->ob && cob->pchan) {
                                /* copy new pose-matrix back to owner */
-                               mul_m4_m4m4(cob->pchan->pose_mat, cob->matrix, cob->ob->imat);
+                               mult_m4_m4m4(cob->pchan->pose_mat, cob->ob->imat, cob->matrix);
                                
                                /* copy inverse of delta back to owner */
                                invert_m4_m4(cob->pchan->constinv, delta);
@@ -242,7 +242,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                /* world to pose */
                                invert_m4_m4(imat, ob->obmat);
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(mat, tempmat, imat);
+                               mult_m4_m4m4(mat, imat, tempmat);
                                
                                /* use pose-space as stepping stone for other spaces... */
                                if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) {
@@ -256,7 +256,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                /* pose to world */
                                if (to == CONSTRAINT_SPACE_WORLD) {
                                        copy_m4_m4(tempmat, mat);
-                                       mul_m4_m4m4(mat, tempmat, ob->obmat);
+                                       mult_m4_m4m4(mat, ob->obmat, tempmat);
                                }
                                /* pose to local */
                                else if (to == CONSTRAINT_SPACE_LOCAL) {
@@ -281,12 +281,12 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                                                offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
                                                                mul_m4_v3(pchan->parent->pose_mat, tmat[3]);
                                                                
-                                                               mul_m4_m4m4(diff_mat, offs_bone, tmat);
+                                                               mult_m4_m4m4(diff_mat, tmat, offs_bone);
                                                                invert_m4_m4(imat, diff_mat);
                                                        }
                                                        else {
                                                                /* pose_mat = par_pose_mat * bone_mat * chan_mat */
-                                                               mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat);
+                                                               mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone);
                                                                invert_m4_m4(imat, diff_mat);
                                                        }
                                                }
@@ -296,7 +296,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                                }
                                                
                                                copy_m4_m4(tempmat, mat);
-                                               mul_m4_m4m4(mat, tempmat, imat);
+                                               mult_m4_m4m4(mat, imat, tempmat);
                                        }
                                }
                                /* pose to local with parent */
@@ -304,7 +304,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                        if (pchan->bone) {
                                                invert_m4_m4(imat, pchan->bone->arm_mat);
                                                copy_m4_m4(tempmat, mat);
-                                               mul_m4_m4m4(mat, tempmat, imat);
+                                               mult_m4_m4m4(mat, imat, tempmat);
                                        }
                                }
                        }
@@ -334,22 +334,22 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                                        zero_v3(offs_bone[3]);
                                                        mul_m4_v3(pchan->parent->pose_mat, tmat[3]);
                                                        
-                                                       mul_m4_m4m4(diff_mat, offs_bone, tmat);
+                                                       mult_m4_m4m4(diff_mat, tmat, offs_bone);
                                                        copy_m4_m4(tempmat, mat);
-                                                       mul_m4_m4m4(mat, tempmat, diff_mat);
+                                                       mult_m4_m4m4(mat, diff_mat, tempmat);
                                                }
                                                else {
                                                        /* pose_mat = par_pose_mat * bone_mat * chan_mat */
-                                                       mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat);
+                                                       mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone);
                                                        copy_m4_m4(tempmat, mat);
-                                                       mul_m4_m4m4(mat, tempmat, diff_mat);
+                                                       mult_m4_m4m4(mat, diff_mat, tempmat);
                                                }
                                        }
                                        else {
                                                copy_m4_m4(diff_mat, pchan->bone->arm_mat);
                                                
                                                copy_m4_m4(tempmat, mat);
-                                               mul_m4_m4m4(mat, tempmat, diff_mat);
+                                               mult_m4_m4m4(mat, diff_mat, tempmat);
                                        }
                                }
                                
@@ -366,7 +366,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                if (pchan->bone) {                                      
                                        copy_m4_m4(diff_mat, pchan->bone->arm_mat);
                                        copy_m4_m4(tempmat, mat);
-                                       mul_m4_m4m4(mat, diff_mat, tempmat);
+                                       mult_m4_m4m4(mat, tempmat, diff_mat);
                                }
                                
                                /* use pose-space as stepping stone for other spaces */
@@ -384,10 +384,10 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                        /* check if object has a parent */
                        if (ob->parent) {
                                /* 'subtract' parent's effects from owner */
-                               mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
+                               mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
                                invert_m4_m4(imat, diff_mat);
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(mat, tempmat, imat);
+                               mult_m4_m4m4(mat, imat, tempmat);
                        }
                        else {
                                /* Local space in this case will have to be defined as local to the owner's 
@@ -399,7 +399,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                
                                invert_m4_m4(imat, diff_mat);
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(mat, tempmat, imat);
+                               mult_m4_m4m4(mat, imat, tempmat);
                        }
                }
                else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) {
@@ -407,8 +407,8 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                        if (ob->parent) {
                                /* 'add' parent's effect back to owner */
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
-                               mul_m4_m4m4(mat, tempmat, diff_mat);
+                               mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
+                               mult_m4_m4m4(mat, diff_mat, tempmat);
                        }
                        else {
                                /* Local space in this case will have to be defined as local to the owner's 
@@ -419,7 +419,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                zero_v3(diff_mat[3]);
                                
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(mat, tempmat, diff_mat);
+                               mult_m4_m4m4(mat, diff_mat, tempmat);
                        }
                }
        }
@@ -612,7 +612,7 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float
                         */
                        if (headtail < 0.000001f) {
                                /* skip length interpolation if set to head */
-                               mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat);
+                               mult_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
                        }
                        else {
                                float tempmat[4][4], loc[3];
@@ -624,7 +624,7 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float
                                copy_m4_m4(tempmat, pchan->pose_mat);   
                                copy_v3_v3(tempmat[3], loc);
                                
-                               mul_m4_m4m4(mat, tempmat, ob->obmat);
+                               mult_m4_m4m4(mat, ob->obmat, tempmat);
                        }
                } 
                else
@@ -836,12 +836,12 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
                        /* multiply target (parent matrix) by offset (parent inverse) to get 
                         * the effect of the parent that will be exherted on the owner
                         */
-                       mul_m4_m4m4(parmat, data->invmat, ct->matrix);
+                       mult_m4_m4m4(parmat, ct->matrix, data->invmat);
                        
                        /* now multiply the parent matrix by the owner matrix to get the 
                         * the effect of this constraint (i.e.  owner is 'parented' to parent)
                         */
-                       mul_m4_m4m4(cob->matrix, cob->matrix, parmat);
+                       mult_m4_m4m4(cob->matrix, parmat, cob->matrix);
                }
                else {
                        float invmat[4][4], tempmat[4][4];
@@ -878,13 +878,13 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
                        /* multiply target (parent matrix) by offset (parent inverse) to get 
                         * the effect of the parent that will be exherted on the owner
                         */
-                       mul_m4_m4m4(parmat, invmat, ct->matrix);
+                       mult_m4_m4m4(parmat, ct->matrix, invmat);
                        
                        /* now multiply the parent matrix by the owner matrix to get the 
                         * the effect of this constraint (i.e.  owner is 'parented' to parent)
                         */
                        copy_m4_m4(tempmat, cob->matrix);
-                       mul_m4_m4m4(cob->matrix, tempmat, parmat);
+                       mult_m4_m4m4(cob->matrix, parmat, tempmat);
 
                        /* without this, changes to scale and rotation can change location
                         * of a parentless bone or a disconnected bone. Even though its set
@@ -1294,7 +1294,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
                                if (data->followflag & FOLLOWPATH_RADIUS) {
                                        float tmat[4][4], rmat[4][4];
                                        scale_m4_fl(tmat, radius);
-                                       mul_m4_m4m4(rmat, totmat, tmat);
+                                       mult_m4_m4m4(rmat, tmat, totmat);
                                        copy_m4_m4(totmat, rmat);
                                }
                                
@@ -2237,7 +2237,7 @@ static void actcon_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListB
                 * function has already taken care of everything else.
                 */
                copy_m4_m4(temp, cob->matrix);
-               mul_m4_m4m4(cob->matrix, ct->matrix, temp);
+               mult_m4_m4m4(cob->matrix, temp, ct->matrix);
        }
 }
 
@@ -2928,7 +2928,7 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar
                if (data->flag & MINMAX_USEROT) {
                        /* take rotation of target into account by doing the transaction in target's localspace */
                        invert_m4_m4(imat, tarmat);
-                       mul_m4_m4m4(tmat, obmat, imat);
+                       mult_m4_m4m4(tmat, imat, obmat);
                        copy_m4_m4(obmat, tmat);
                        unit_m4(tarmat);
                }
@@ -2981,7 +2981,7 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar
                        }
                        if (data->flag & MINMAX_USEROT) {
                                /* get out of localspace */
-                               mul_m4_m4m4(tmat, obmat, ct->matrix);
+                               mult_m4_m4m4(tmat, ct->matrix, obmat);
                                copy_m4_m4(cob->matrix, tmat);
                        } 
                        else {                  
@@ -3992,7 +3992,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
                        else {
                                BKE_get_tracking_mat(cob->scene, camob, mat);
 
-                               mul_m4_m4m4(cob->matrix, mat, obmat);
+                               mult_m4_m4m4(cob->matrix, obmat, mat);
                                translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
                        }
                }
@@ -4043,7 +4043,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
 
                                copy_m4_m4(rmat, camob->obmat);
                                zero_v3(rmat[3]);
-                               mul_m4_m4m4(cob->matrix, rmat, cob->matrix);
+                               mult_m4_m4m4(cob->matrix, cob->matrix, rmat);
 
                                copy_v3_v3(cob->matrix[3], disp);
                        }
@@ -4062,7 +4062,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
                                /* apply camera rotation so Z-axis would be co-linear */
                                copy_m4_m4(rmat, camob->obmat);
                                zero_v3(rmat[3]);
-                               mul_m4_m4m4(cob->matrix, rmat, cob->matrix);
+                               mult_m4_m4m4(cob->matrix, cob->matrix, rmat);
 
                                copy_v3_v3(cob->matrix[3], disp);
                        }
@@ -4121,7 +4121,7 @@ static void camerasolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
 
                copy_m4_m4(obmat, cob->matrix);
 
-               mul_m4_m4m4(cob->matrix, mat, obmat);
+               mult_m4_m4m4(cob->matrix, obmat, mat);
        }
 }
 
@@ -4187,7 +4187,7 @@ static void objectsolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
                        BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, mat);
 
                        invert_m4_m4(camimat, cammat);
-                       mul_m4_m4m4(parmat, data->invmat, cammat);
+                       mult_m4_m4m4(parmat, cammat, data->invmat);
 
                        copy_m4_m4(cammat, camob->obmat);
                        copy_m4_m4(obmat, cob->matrix);
index 6efd0a2727f71b81215eaa734b721e9fbbeee8db..5305372402b18b012b7a60f7ccd531ca1fb67b26 100644 (file)
@@ -1404,7 +1404,7 @@ int CustomData_number_of_layers(const CustomData *data, int type)
        return number;
 }
 
-void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type)
+void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int type, const int totelem)
 {
        CustomDataLayer *layer;
        int layer_index;
@@ -1416,7 +1416,20 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type)
        layer = &data->layers[layer_index];
 
        if (layer->flag & CD_FLAG_NOFREE) {
-               layer->data = MEM_dupallocN(layer->data);
+               /* MEM_dupallocN won’t work in case of complex layers, like e.g.
+                * CD_MDEFORMVERT, which has pointers to allocated data...
+                * So in case a custom copy function is defined, use it!
+                */
+               const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
+
+               if(typeInfo->copy) {
+                       char *dest_data = MEM_mallocN(typeInfo->size * totelem, "CD duplicate ref layer");
+                       typeInfo->copy(layer->data, dest_data, totelem);
+                       layer->data = dest_data;
+               }
+               else
+                       layer->data = MEM_dupallocN(layer->data);
+
                layer->flag &= ~CD_FLAG_NOFREE;
        }
 
@@ -1424,7 +1437,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type)
 }
 
 void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
-                                                                                                 int type, const char *name)
+                                                                                                 const int type, const char *name, const int totelem)
 {
        CustomDataLayer *layer;
        int layer_index;
@@ -1436,7 +1449,20 @@ void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
        layer = &data->layers[layer_index];
 
        if (layer->flag & CD_FLAG_NOFREE) {
-               layer->data = MEM_dupallocN(layer->data);
+               /* MEM_dupallocN won’t work in case of complex layers, like e.g.
+                * CD_MDEFORMVERT, which has pointers to allocated data...
+                * So in case a custom copy function is defined, use it!
+                */
+               const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
+
+               if(typeInfo->copy) {
+                       char *dest_data = MEM_mallocN(typeInfo->size * totelem, "CD duplicate ref layer");
+                       typeInfo->copy(layer->data, dest_data, totelem);
+                       layer->data = dest_data;
+               }
+               else
+                       layer->data = MEM_dupallocN(layer->data);
+
                layer->flag &= ~CD_FLAG_NOFREE;
        }
 
@@ -1995,7 +2021,8 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
                        CustomData_add_layer(ldata, CD_MLOOPCOL, CD_CALLOC, &(fdata->layers[i].name), 0);
        }               
 }
-void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total){
+void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total)
+{
        int i;
        for(i=0; i < pdata->totlayer; i++){
                if(pdata->layers[i].type == CD_MTEXPOLY)
@@ -2008,7 +2035,8 @@ void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData
 }
 
 
-void CustomData_bmesh_init_pool(CustomData *data, int allocsize){
+void CustomData_bmesh_init_pool(CustomData *data, int allocsize)
+{
        if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize, FALSE, FALSE);
 }
 
index f7f10276ee49b8eab9072a9998a590b9b8375cd0..6fb4164d6c6efd87383e1c467ecffb0ab360560e 100644 (file)
@@ -213,7 +213,7 @@ void defvert_normalize_lock(MDeformVert *dvert, const int def_nr_lock)
                dvert->dw[0].weight= 1.0f;
        }
        else {
-               MDeformWeight *dw_lock;
+               MDeformWeight *dw_lock = NULL;
                MDeformWeight *dw;
                unsigned int i;
                float tot_weight= 0.0f;
index b592e078db333e8fc5261c9cd0d6ea8c4da1a1a7..955e747eded06708542cff9bca30f8ce207dac95 100644 (file)
@@ -3220,7 +3220,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
                                                /* hit data     */
                                                float hitCoord[3];
                                                int hitFace = -1;
-                                               short hitQuad;
+                                               short hitQuad = 0;
 
                                                /* Supersampling factor */
                                                if (samples > 1 && surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ)
@@ -4647,7 +4647,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc
        #pragma omp parallel for schedule(static)
        for (index=0; index<sData->total_points; index++)
        {
-               float prev_point[3];
+               float prev_point[3] = {0.0f, 0.0f, 0.0f};
                if (do_velocity_data && !new_bdata) {
                        copy_v3_v3(prev_point, bData->realCoord[bData->s_pos[index]].v);
                }
index d01e3de0796a77fd51c917018e522b44644bc668..b9947c506d10fe98f01862ed4e3cb7c99a809988 100644 (file)
@@ -1283,7 +1283,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
                }
                else {
                        /* worldspace matrix */
-                       mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat);
+                       mult_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
                }
        }
        else {
index fb734ea4f3d506edfbb351f29a6e9637805042ea..25ff7b5fa04d3d19f193314dadff84fd86602fea 100644 (file)
@@ -1508,10 +1508,7 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
 
        int ok;
 
-       if(imtype == -1) {
-               /* use whatever existing image type is set by 'ibuf' */
-       }
-       else if(imtype== R_IMF_IMTYPE_IRIS) {
+       if(imtype== R_IMF_IMTYPE_IRIS) {
                ibuf->ftype= IMAGIC;
        }
 #ifdef WITH_HDR
@@ -2277,7 +2274,10 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
        ibuf->x= rres.rectx;
        ibuf->y= rres.recty;
        
-       if(ibuf->rect_float!=rectf || rect) /* ensure correct redraw */
+       /* free rect buffer if float buffer changes, so it can be recreated with
+          the updated result, and also in case we got byte buffer from sequencer,
+          so we don't keep reference to freed buffer */
+       if(ibuf->rect_float!=rectf || rect || !rectf)
                imb_freerectImBuf(ibuf);
 
        if(rect)
index 751980f61e89ca39fdc7ec3b1cba5f5c8a200b48..a93d0221cf09de3e745e86d4a8a3627ea28e0cdd 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "BKE_image.h"
 #include "BLI_math_color.h"
+#include "BLI_math_base.h"
 #include "BLF_api.h"
 
 void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4])
@@ -161,21 +162,6 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
 #define BLEND_FLOAT(real, add)  (real+add <= 1.0f) ? (real+add) : 1.0f
 #define BLEND_CHAR(real, add) ((real + (char)(add * 255.0f)) <= 255) ? (real + (char)(add * 255.0f)) : 255
 
-static int is_pow2(int n)
-{
-       return ((n)&(n-1))==0;
-}
-static int larger_pow2(int n)
-{
-       if (is_pow2(n))
-               return n;
-
-       while(!is_pow2(n))
-               n= n&(n-1);
-
-       return n*2;
-}
-
 static void checker_board_color_fill(unsigned char *rect, float *rect_float, int width, int height)
 {
        int hue_step, y, x;
@@ -183,7 +169,7 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
 
        sat= 1.0;
 
-       hue_step= larger_pow2(width / 8);
+       hue_step= power_of_2_max_i(width / 8);
        if(hue_step < 8) hue_step= 8;
 
        for(y= 0; y < height; y++)
index fe07662795ea772f729071d720b5f2b605667dbf..4c30789db73b79530a3a09bf592c5e517c4d8d30 100644 (file)
@@ -316,7 +316,7 @@ void init_latt_deform(Object *oblatt, Object *ob)
        else {
                /* in deformspace, calc matrix */
                invert_m4_m4(imat, oblatt->obmat);
-               mul_m4_m4m4(lt->latmat, ob->obmat, imat);
+               mult_m4_m4m4(lt->latmat, imat, ob->obmat);
        
                /* back: put in deform array */
                invert_m4_m4(imat, lt->latmat);
@@ -470,7 +470,7 @@ typedef struct {
 static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc)
 {
        invert_m4_m4(ob->imat, ob->obmat);
-       mul_m4_m4m4(cd->objectspace, par->obmat, ob->imat);
+       mult_m4_m4m4(cd->objectspace, ob->imat, par->obmat);
        invert_m4_m4(cd->curvespace, cd->objectspace);
        copy_m3_m4(cd->objectspace3, cd->objectspace);
        
index 0883ec121d6f32e6ac1e863d27dedbccabe36967..57fc747386091c22094716402d7140036f1e3e0d 100644 (file)
@@ -1679,7 +1679,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
                                        temp2[3][1]= ml->y;
                                        temp2[3][2]= ml->z;
 
-                                       mul_m4_m4m4(temp1, temp3, temp2);
+                                       mult_m4_m4m4(temp1, temp2, temp3);
                                
                                        /* make a copy because of duplicates */
                                        mainb[a]= new_pgn_element(sizeof(MetaElem));
@@ -1691,9 +1691,9 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
                                        
                                        /* mat is the matrix to transform from mball into the basis-mball */
                                        invert_m4_m4(obinv, obmat);
-                                       mul_m4_m4m4(temp2, bob->obmat, obinv);
+                                       mult_m4_m4m4(temp2, obinv, bob->obmat);
                                        /* MetaBall transformation */
-                                       mul_m4_m4m4(mat, temp1, temp2);
+                                       mult_m4_m4m4(mat, temp2, temp1);
 
                                        invert_m4_m4(imat,mat);                         
 
index 7be6ef9968dde664847f19dd6501459a5f7f242a..cc49e8465b9e6c796efe5d7e5c8a868c993d63c1 100644 (file)
@@ -1899,6 +1899,7 @@ static void registerShaderNodes(bNodeTreeType *ttype)
        register_node_type_sh_output(ttype);
        register_node_type_sh_material(ttype);
        register_node_type_sh_camera(ttype);
+       register_node_type_sh_gamma(ttype);
        register_node_type_sh_value(ttype);
        register_node_type_sh_rgb(ttype);
        register_node_type_sh_mix_rgb(ttype);
index 13b6919683cb17b7057d5a75b9af25849924f8bc..28c1aacdec51ba8b923da0edb0ec9b48e6c6020f 100644 (file)
@@ -1363,7 +1363,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
         *   this is closer to making a copy of the object - in-place. */
        if(gob) {
                ob->rotmode= target->rotmode;
-               mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat);
+               mult_m4_m4m4(ob->obmat, gob->obmat, target->obmat);
                if(gob->dup_group) { /* should always be true */
                        float tvec[3];
                        copy_v3_v3(tvec, gob->dup_group->dupli_ofs);
@@ -1589,9 +1589,9 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
 
        if(use_parent && ob->parent) {
                float rmat[4][4], diff_mat[4][4], imat[4][4];
-               mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
+               mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
                invert_m4_m4(imat, diff_mat);
-               mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */
+               mult_m4_m4m4(rmat, imat, mat); /* get the parent relative matrix */
                object_apply_mat4(ob, rmat, use_compat, FALSE);
                
                /* same as below, use rmat rather than mat */
@@ -1715,7 +1715,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
                if(cu->flag & CU_PATH_RADIUS) {
                        float tmat[4][4], rmat[4][4];
                        scale_m4_fl(tmat, radius);
-                       mul_m4_m4m4(rmat, mat, tmat);
+                       mult_m4_m4m4(rmat, tmat, mat);
                        copy_m4_m4(mat, rmat);
                }
 
@@ -2473,6 +2473,14 @@ void object_tfm_restore(Object *ob, void *obtfm_pt)
        copy_m4_m4(ob->imat, obtfm->imat);
 }
 
+int BKE_object_parent_loop_check(const Object *par, const Object *ob)
+{
+       /* test if 'ob' is a parent somewhere in par's parents */
+       if(par == NULL) return 0;
+       if(ob == par) return 1;
+       return BKE_object_parent_loop_check(par->parent, ob);
+}
+
 /* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
 /*           local_object->proxy      == pointer to library object, saved in files and read */
 
@@ -2512,7 +2520,7 @@ void object_handle_update(Scene *scene, Object *ob)
                                if(ob->proxy_from->proxy_group) {/* transform proxy into group space */
                                        Object *obg= ob->proxy_from->proxy_group;
                                        invert_m4_m4(obg->imat, obg->obmat);
-                                       mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat);
+                                       mult_m4_m4m4(ob->obmat, obg->imat, ob->proxy_from->obmat);
                                        if(obg->dup_group) { /* should always be true */
                                                add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs);
                                        }
index ae622358fd2192b5c134e46ed5c3ec1b9de789bc..15ce2e377b641e7a3e7a8f454c7227b0dd076cf9 100644 (file)
@@ -1343,7 +1343,8 @@ typedef struct Ocean {
 } Ocean;
 
 
-float BKE_ocean_jminus_to_foam(float UNUSED(jminus), float UNUSED(coverage)) {
+float BKE_ocean_jminus_to_foam(float UNUSED(jminus), float UNUSED(coverage))
+{
        return 0.0f;
 }
 
index 000df5e721d3ad8486d1742aeab5833036b90e3a..a3e13b48fe4032c7fe2d34b08f92950e96c93216 100644 (file)
@@ -709,8 +709,8 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
        psys->childcachebufs.first = psys->childcachebufs.last = NULL;
 
        copy_m4_m4(data->winmat, winmat);
-       mul_m4_m4m4(data->viewmat, ob->obmat, viewmat);
-       mul_m4_m4m4(data->mat, data->viewmat, winmat);
+       mult_m4_m4m4(data->viewmat, viewmat, ob->obmat);
+       mult_m4_m4m4(data->mat, winmat, data->viewmat);
        data->winx= winx;
        data->winy= winy;
 
@@ -3374,7 +3374,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa
 
        psys_mat_hair_to_object(ob, dm, from, pa, facemat);
 
-       mul_m4_m4m4(hairmat, facemat, ob->obmat);
+       mult_m4_m4m4(hairmat, ob->obmat, facemat);
 }
 
 /************************************************/
index 5445c990a9bdfeb021eddf2c14c120e149760831..411e77de858ee94f1da18750521263cde20a6978 100644 (file)
@@ -1491,7 +1491,7 @@ static int ptcache_old_elemsize(PTCacheID *pid)
 static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *fra1, int *fra2)
 {
        if(pid->cache->flag & PTCACHE_DISK_CACHE) {
-               int cfra1=frame-1, cfra2=frame+1;
+               int cfra1=frame, cfra2=frame+1;
 
                while(cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
                        cfra1--;
@@ -1518,7 +1518,7 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *
                PTCacheMem *pm = pid->cache->mem_cache.first;
                PTCacheMem *pm2 = pid->cache->mem_cache.last;
 
-               while(pm->next && pm->next->frame < frame)
+               while(pm->next && pm->next->frame <= frame)
                        pm= pm->next;
 
                if(pm2->frame < frame) {
@@ -1841,7 +1841,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
 /* possible to get old or interpolated result */
 int BKE_ptcache_read(PTCacheID *pid, float cfra)
 {
-       int cfrai = (int)cfra, cfra1=0, cfra2=0;
+       int cfrai = (int)floor(cfra), cfra1=0, cfra2=0;
        int ret = 0;
 
        /* nothing to read to */
index f7cf0122269758c794576730efe00965b5117b46..374ef3512e81e8253222cb0d44bc1122943cd1fe 100644 (file)
@@ -225,6 +225,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
        CCGVertHDL fverts[4];
        EdgeHash *ehash;
        float creaseFactor = (float)ccgSubSurf_getSubdivisionLevels(ss);
+       float uv[3]= {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */
 
        limit[0]= limit[1]= STD_UV_CONNECT_LIMIT;
        vmap= make_uv_vert_map(mface, tface, totface, totvert, 0, limit);
@@ -248,11 +249,8 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
                        if (v->separate) {
                                CCGVert *ssv;
                                CCGVertHDL vhdl = SET_INT_IN_POINTER(v->f*4 + v->tfindex);
-                               float uv[3];
 
-                               uv[0]= (tface+v->f)->uv[v->tfindex][0];
-                               uv[1]= (tface+v->f)->uv[v->tfindex][1];
-                               uv[2]= 0.0f;
+                               copy_v2_v2(uv, (tface+v->f)->uv[v->tfindex]);
 
                                ccgSubSurf_syncVert(ss, vhdl, uv, seam, &ssv);
                        }
@@ -359,15 +357,10 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
 
                        for(y = 0; y < gridFaces; y++) {
                                for(x = 0; x < gridFaces; x++) {
-                                       float *a = faceGridData[(y + 0)*gridSize + x + 0].co;
-                                       float *b = faceGridData[(y + 0)*gridSize + x + 1].co;
-                                       float *c = faceGridData[(y + 1)*gridSize + x + 1].co;
-                                       float *d = faceGridData[(y + 1)*gridSize + x + 0].co;
-
-                                       tf->uv[0][0] = a[0]; tf->uv[0][1] = a[1];
-                                       tf->uv[1][0] = d[0]; tf->uv[1][1] = d[1];
-                                       tf->uv[2][0] = c[0]; tf->uv[2][1] = c[1];
-                                       tf->uv[3][0] = b[0]; tf->uv[3][1] = b[1];
+                                       copy_v2_v2(tf->uv[0], faceGridData[(y + 0)*gridSize + x + 0].co);
+                                       copy_v2_v2(tf->uv[1], faceGridData[(y + 1)*gridSize + x + 0].co);
+                                       copy_v2_v2(tf->uv[2], faceGridData[(y + 1)*gridSize + x + 1].co);
+                                       copy_v2_v2(tf->uv[3], faceGridData[(y + 0)*gridSize + x + 1].co);
 
                                        tf++;
                                }
index 48bc4926a8553a74f17d71f09a214667773caec6..e1e872c42b6107d3f5d9626ce5c62312ecf018d3 100644 (file)
@@ -47,7 +47,8 @@ static SuggList suggestions = {NULL, NULL, NULL, NULL, NULL};
 static char *documentation = NULL;
 //static int doc_lines = 0;
 
-static int txttl_cmp(const char *first, const char *second, int len) { 
+static int txttl_cmp(const char *first, const char *second, int len)
+{
        int cmp, i;
        for (cmp=0, i=0; i<len; i++) {
                if ( (cmp= toupper(first[i])-toupper(second[i])) ) {
@@ -57,7 +58,8 @@ static int txttl_cmp(const char *first, const char *second, int len) {
        return cmp;
 }
 
-static void txttl_free_suggest(void) {
+static void txttl_free_suggest(void)
+{
        SuggItem *item, *prev;
        for (item = suggestions.last; item; item=prev) {
                prev = item->prev;
@@ -69,7 +71,8 @@ static void txttl_free_suggest(void) {
        suggestions.top = 0;
 }
 
-static void txttl_free_docs(void) {
+static void txttl_free_docs(void)
+{
        if (documentation) {
                MEM_freeN(documentation);
                documentation = NULL;
@@ -80,23 +83,27 @@ static void txttl_free_docs(void) {
 /* General tool functions */
 /**************************/
 
-void free_texttools(void) {
+void free_texttools(void)
+{
        txttl_free_suggest();
        txttl_free_docs();
 }
 
-void texttool_text_set_active(Text *text) {
+void texttool_text_set_active(Text *text)
+{
        if (activeToolText == text) return;
        texttool_text_clear();
        activeToolText = text;
 }
 
-void texttool_text_clear(void) {
+void texttool_text_clear(void)
+{
        free_texttools();
        activeToolText = NULL;
 }
 
-short texttool_text_is_active(Text *text) {
+short texttool_text_is_active(Text *text)
+{
        return activeToolText==text ? 1 : 0;
 }
 
@@ -104,7 +111,8 @@ short texttool_text_is_active(Text *text) {
 /* Suggestion list methods */
 /***************************/
 
-void texttool_suggest_add(const char *name, char type) {
+void texttool_suggest_add(const char *name, char type)
+{
        SuggItem *newitem, *item;
        int len, cmp;
 
@@ -154,7 +162,8 @@ void texttool_suggest_add(const char *name, char type) {
        suggestions.top= 0;
 }
 
-void texttool_suggest_prefix(const char *prefix) {
+void texttool_suggest_prefix(const char *prefix)
+{
        SuggItem *match, *first, *last;
        int cmp, len = strlen(prefix), top = 0;
 
@@ -194,27 +203,33 @@ void texttool_suggest_prefix(const char *prefix) {
        }
 }
 
-void texttool_suggest_clear(void) {
+void texttool_suggest_clear(void)
+{
        txttl_free_suggest();
 }
 
-SuggItem *texttool_suggest_first(void) {
+SuggItem *texttool_suggest_first(void)
+{
        return suggestions.firstmatch;
 }
 
-SuggItem *texttool_suggest_last(void) {
+SuggItem *texttool_suggest_last(void)
+{
        return suggestions.lastmatch;
 }
 
-void texttool_suggest_select(SuggItem *sel) {
+void texttool_suggest_select(SuggItem *sel)
+{
        suggestions.selected = sel;
 }
 
-SuggItem *texttool_suggest_selected(void) {
+SuggItem *texttool_suggest_selected(void)
+{
        return suggestions.selected;
 }
 
-int *texttool_suggest_top(void) {
+int *texttool_suggest_top(void)
+{
        return &suggestions.top;
 }
 
@@ -222,7 +237,8 @@ int *texttool_suggest_top(void) {
 /* Documentation methods */
 /*************************/
 
-void texttool_docs_show(const char *docs) {
+void texttool_docs_show(const char *docs)
+{
        int len;
 
        if (!docs) return;
@@ -246,10 +262,12 @@ void texttool_docs_show(const char *docs) {
        documentation[len] = '\0';
 }
 
-char *texttool_docs_get(void) {
+char *texttool_docs_get(void)
+{
        return documentation;
 }
 
-void texttool_docs_clear(void) {
+void texttool_docs_clear(void)
+{
        txttl_free_docs();
 }
index 60cc029bf6e0d336fa4013b511d3186fc433476f..7e102bc9854162b749d57d37a106240f8bf0df95 100644 (file)
@@ -2851,7 +2851,8 @@ void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsign
 /* Returns the first matching marker on the specified line between two points.
    If the group or flags fields are non-zero the returned flag must be in the
    specified group and have at least the specified flags set. */
-TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) {
+TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags)
+{
        TextMarker *marker, *next;
        int lineno= txt_get_span(text->lines.first, line);
        
@@ -2918,7 +2919,8 @@ short txt_clear_markers(Text *text, int group, int flags)
 
 /* Finds the marker at the specified line and cursor position with at least the
    specified flags set in the given group (if non-zero). */
-TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int flags) {
+TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int flags)
+{
        TextMarker *marker;
        int lineno= txt_get_span(text->lines.first, line);
        
@@ -2936,7 +2938,8 @@ TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int
 
 /* Finds the previous marker in the same group. If no other is found, the same
    marker will be returned */
-TextMarker *txt_prev_marker(Text *text, TextMarker *marker) {
+TextMarker *txt_prev_marker(Text *text, TextMarker *marker)
+{
        TextMarker *tmp= marker;
        while (tmp) {
                if (tmp->prev) tmp= tmp->prev;
@@ -2949,7 +2952,8 @@ TextMarker *txt_prev_marker(Text *text, TextMarker *marker) {
 
 /* Finds the next marker in the same group. If no other is found, the same
    marker will be returned */
-TextMarker *txt_next_marker(Text *text, TextMarker *marker) {
+TextMarker *txt_next_marker(Text *text, TextMarker *marker)
+{
        TextMarker *tmp= marker;
        while (tmp) {
                if (tmp->next) tmp= tmp->next;
index 262c0576186b2599df146befb84f8b1ce4ad5e46..06680dc9da40a4e623b52142261226a5242e761d 100644 (file)
@@ -1228,7 +1228,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
 
        #pragma omp parallel for private(a) shared(ibuf_new, ok) if(map_size>1)
        for(a= 0; a<map_size; a++) {
-               TrackContext *track_context;
+               TrackContext *track_context = NULL;
                MovieTrackingTrack *track;
                MovieTrackingMarker *marker;
 
@@ -1572,7 +1572,7 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M
                        }
 
                        if(origin_set)
-                               mul_m4_m4m4(mat, mat, imat);
+                               mult_m4_m4m4(mat, imat, mat);
 
                        copy_m4_m4(reconstructed[reconstruction->camnr].mat, mat);
                        reconstructed[reconstruction->camnr].framenr= a;
@@ -2036,7 +2036,7 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject
                float imat[4][4];
 
                invert_m4_m4(imat, camera->mat);
-               mul_m4_m4m4(mat, imat, winmat);
+               mult_m4_m4m4(mat, winmat, imat);
        } else copy_m4_m4(mat, winmat);
 }
 
index 976519c281afcd589574daadf30ebd3a3f6d7ec1..f2a7e73e5e0dd7d0936c1c9f1722ba3b8998e6fa 100644 (file)
@@ -142,6 +142,16 @@ int                                BLI_ghashutil_strcmp    (const void *a, const void *b);
 unsigned int   BLI_ghashutil_inthash   (const void *ptr);
 int                            BLI_ghashutil_intcmp    (const void *a, const void *b);
 
+typedef struct GHashPair {
+       const void *first;
+       int second;
+} GHashPair;
+
+GHashPair*             BLI_ghashutil_pairalloc (const void *first, int second);
+unsigned int   BLI_ghashutil_pairhash  (const void *ptr);
+int                            BLI_ghashutil_paircmp   (const void *a, const void *b);
+void                   BLI_ghashutil_pairfree  (void *ptr);
+
 #ifdef __cplusplus
 }
 #endif
index 204ec9b5159e86d9b52fba17229e0b2b432ff177..53db77dc203bdc6ee2c1935f917fefb1249fc29a 100644 (file)
@@ -167,6 +167,11 @@ MINLINE float signf(float f);
 
 MINLINE float power_of_2(float f);
 
+/* these dont really fit anywhere but were being copied about a lot */
+MINLINE int is_power_of_2_i(int n);
+MINLINE int power_of_2_max_i(int n);
+MINLINE int power_of_2_min_i(int n);
+
 MINLINE float shell_angle_to_dist(float angle);
 
 #if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS)
index 008d2ad49ceb20241ff0efd89186fd88b077bbb9..4d3a4dfe44555b479a79c3c09bb2203ef22384f5 100644 (file)
@@ -68,10 +68,12 @@ void sub_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]);
 void sub_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
 
 void mul_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]);
-void mul_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
 void mul_m4_m3m4(float R[4][4], float A[3][3], float B[4][4]);
 void mul_m4_m4m3(float R[4][4], float A[4][4], float B[3][3]);
-void mul_m3_m3m4(float R[3][3], float A[3][3], float B[4][4]);
+/* note: the A,B arguments are reversed compared to previous mul_m4_m4m4
+   function, for consistency with above functions & math notation. */
+void mult_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
+void mult_m3_m3m4(float R[3][3], float A[4][4], float B[3][3]);
 
 void mul_serie_m3(float R[3][3],
        float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3],
index d8e880a9dec7d77ad1c11a785c6f45504ea0222b..e9e44ed7b2c5fb4334e05ccf2ab1c2c21eceab25 100644 (file)
@@ -198,6 +198,7 @@ double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int s
 float normalize_vn_vn(float *array_tar, const float *array_src, const int size);
 float normalize_vn(float *array_tar, const int size);
 void range_vn_i(int *array_tar, const int size, const int start);
+void range_vn_fl(float *array_tar, const int size, const float start, const float step);
 void negate_vn(float *array_tar, const int size);
 void negate_vn_vn(float *array_tar, const float *array_src, const int size);
 void mul_vn_fl(float *array_tar, const int size, const float f);
index a6b4f2c9b922c280d8c5a6204a58c98153a0838a..94189af34faa22831eae42c74a8bcbacb5e9a9e2 100644 (file)
 #  endif
 #  if defined(__GNUC__) || defined(_MSC_VER) /* check __func__ is available */
 #    define BLI_assert(a)                                                     \
-do {                                                                          \
-       if (!(a)) {                                                               \
+       (void)((!(a)) ?  (                                                        \
+               (                                                                     \
                fprintf(stderr,                                                       \
                        "BLI_assert failed: %s, %s(), %d at \'%s\'\n",                    \
-                       __FILE__, __func__, __LINE__, STRINGIFY(a));                      \
-               _dummy_abort();                                                       \
-       }                                                                         \
-} while (0)
+                       __FILE__, __func__, __LINE__, STRINGIFY(a)),                      \
+               _dummy_abort(),                                                       \
+               NULL)) : NULL)
 #  else
-#    define BLI_assert(a) \
-do {                                                                          \
-       if (0 == (a)) {                                                           \
+#    define BLI_assert(a)                                                     \
+       (void)((!(a)) ?  (                                                        \
+               (                                                                     \
                fprintf(stderr,                                                       \
                        "BLI_assert failed: %s, %d at \'%s\'\n",                          \
-                       __FILE__, __LINE__, STRINGIFY(a));                                \
-               _dummy_abort();                                                       \
-       }                                                                         \
-} while (0)
+                       __FILE__, __LINE__, STRINGIFY(a)),                                \
+               _dummy_abort(),                                                       \
+               NULL)) : NULL)
 #  endif
 #else
 #  define BLI_assert(a) (void)0
index 5cdadce7c01b02356405d13f53a829d5f037107d..349bc3492e78df611f8657b2792207c245693d70 100644 (file)
@@ -94,7 +94,8 @@ void BLI_dynstr_append(DynStr *ds, const char *cstr)
        ds->curlen+= cstrlen;
 }
 
-void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len) {
+void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len)
+{
        DynStrElem *dse= malloc(sizeof(*dse));
        int cstrlen= BLI_strnlen(cstr, len);
 
@@ -225,7 +226,8 @@ int BLI_dynstr_get_len(DynStr *ds)
        return ds->curlen;
 }
 
-char *BLI_dynstr_get_cstring(DynStr *ds) {
+char *BLI_dynstr_get_cstring(DynStr *ds)
+{
        char *s, *rets= MEM_mallocN(ds->curlen+1, "dynstr_cstring");
        DynStrElem *dse;
        
@@ -241,7 +243,8 @@ char *BLI_dynstr_get_cstring(DynStr *ds) {
        return rets;
 }
 
-void BLI_dynstr_free(DynStr *ds) {
+void BLI_dynstr_free(DynStr *ds)
+{
        DynStrElem *dse;
        
        for (dse= ds->elems; dse; ) {
index c1894088300809a058f00a4612df5d8688d01038..9f388b68c3880b43b4ed37fb205a8c1aef6da289 100644 (file)
@@ -56,7 +56,8 @@ static unsigned int hashsizes[]= {
 
 /***/
 
-GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) {
+GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info)
+{
        GHash *gh= MEM_mallocN(sizeof(*gh), info);
        gh->hashfp= hashfp;
        gh->cmpfp= cmpfp;
@@ -72,11 +73,13 @@ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) {
        return gh;
 }
 
-int BLI_ghash_size(GHash *gh) {
+int BLI_ghash_size(GHash *gh)
+{
        return gh->nentries;
 }
 
-void BLI_ghash_insert(GHash *gh, void *key, void *val) {
+void BLI_ghash_insert(GHash *gh, void *key, void *val)
+{
        unsigned int hash= gh->hashfp(key)%gh->nbuckets;
        Entry *e= (Entry*) BLI_mempool_alloc(gh->entrypool);
 
@@ -109,7 +112,8 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val) {
        }
 }
 
-void *BLI_ghash_lookup(GHash *gh, const void *key) {
+void *BLI_ghash_lookup(GHash *gh, const void *key)
+{
        if(gh) {
                unsigned int hash= gh->hashfp(key)%gh->nbuckets;
                Entry *e;
@@ -151,7 +155,8 @@ int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFr
        return 0;
 }
 
-int BLI_ghash_haskey(GHash *gh, void *key) {
+int BLI_ghash_haskey(GHash *gh, void *key)
+{
        unsigned int hash= gh->hashfp(key)%gh->nbuckets;
        Entry *e;
 
@@ -162,7 +167,8 @@ int BLI_ghash_haskey(GHash *gh, void *key) {
        return 0;
 }
 
-void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) {
+void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
+{
        int i;
        
        if (keyfreefp || valfreefp) {
@@ -190,7 +196,8 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreef
 
 /***/
 
-GHashIterator *BLI_ghashIterator_new(GHash *gh) {
+GHashIterator *BLI_ghashIterator_new(GHash *gh)
+{
        GHashIterator *ghi= MEM_mallocN(sizeof(*ghi), "ghash iterator");
        ghi->gh= gh;
        ghi->curEntry= NULL;
@@ -203,7 +210,8 @@ GHashIterator *BLI_ghashIterator_new(GHash *gh) {
        }
        return ghi;
 }
-void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh) {
+void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
+{
        ghi->gh= gh;
        ghi->curEntry= NULL;
        ghi->curBucket= -1;
@@ -214,18 +222,22 @@ void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh) {
                ghi->curEntry= ghi->gh->buckets[ghi->curBucket];
        }
 }
-void BLI_ghashIterator_free(GHashIterator *ghi) {
+void BLI_ghashIterator_free(GHashIterator *ghi)
+{
        MEM_freeN(ghi);
 }
 
-void *BLI_ghashIterator_getKey(GHashIterator *ghi) {
+void *BLI_ghashIterator_getKey(GHashIterator *ghi)
+{
        return ghi->curEntry?ghi->curEntry->key:NULL;
 }
-void *BLI_ghashIterator_getValue(GHashIterator *ghi) {
+void *BLI_ghashIterator_getValue(GHashIterator *ghi)
+{
        return ghi->curEntry?ghi->curEntry->val:NULL;
 }
 
-void BLI_ghashIterator_step(GHashIterator *ghi) {
+void BLI_ghashIterator_step(GHashIterator *ghi)
+{
        if (ghi->curEntry) {
                ghi->curEntry= ghi->curEntry->next;
                while (!ghi->curEntry) {
@@ -236,23 +248,27 @@ void BLI_ghashIterator_step(GHashIterator *ghi) {
                }
        }
 }
-int BLI_ghashIterator_isDone(GHashIterator *ghi) {
+int BLI_ghashIterator_isDone(GHashIterator *ghi)
+{
        return !ghi->curEntry;
 }
 
 /***/
 
-unsigned int BLI_ghashutil_ptrhash(const void *key) {
+unsigned int BLI_ghashutil_ptrhash(const void *key)
+{
        return (unsigned int)(intptr_t)key;
 }
-int BLI_ghashutil_ptrcmp(const void *a, const void *b) {
+int BLI_ghashutil_ptrcmp(const void *a, const void *b)
+{
        if (a==b)
                return 0;
        else
                return (a<b)?-1:1;
 }
 
-unsigned int BLI_ghashutil_inthash(const void *ptr) {
+unsigned int BLI_ghashutil_inthash(const void *ptr)
+{
        uintptr_t key = (uintptr_t)ptr;
 
        key += ~(key << 16);
@@ -265,14 +281,16 @@ unsigned int BLI_ghashutil_inthash(const void *ptr) {
        return (unsigned int)(key & 0xffffffff);
 }
 
-int BLI_ghashutil_intcmp(const void *a, const void *b) {
+int BLI_ghashutil_intcmp(const void *a, const void *b)
+{
        if (a==b)
                return 0;
        else
                return (a<b)?-1:1;
 }
 
-unsigned int BLI_ghashutil_strhash(const void *ptr) {
+unsigned int BLI_ghashutil_strhash(const void *ptr)
+{
        const char *s= ptr;
        unsigned int i= 0;
        unsigned char c;
@@ -282,6 +300,39 @@ unsigned int BLI_ghashutil_strhash(const void *ptr) {
                
        return i;
 }
-int BLI_ghashutil_strcmp(const void *a, const void *b) {
+int BLI_ghashutil_strcmp(const void *a, const void *b)
+{
        return strcmp(a, b);
 }
+
+GHashPair *BLI_ghashutil_pairalloc(const void *first, int second)
+{
+       GHashPair *pair = MEM_mallocN(sizeof(GHashPair), "GHashPair");
+       pair->first = first;
+       pair->second = second;
+       return pair;
+}
+
+unsigned int BLI_ghashutil_pairhash(const void *ptr)
+{
+       const GHashPair *pair = ptr;
+       unsigned int hash = BLI_ghashutil_ptrhash(pair->first);
+       return hash ^ BLI_ghashutil_inthash(SET_INT_IN_POINTER(pair->second));
+}
+
+int BLI_ghashutil_paircmp(const void *a, const void *b)
+{
+       const GHashPair *A = a;
+       const GHashPair *B = b;
+
+       int cmp = BLI_ghashutil_ptrcmp(A->first, B->first);
+       if(cmp == 0)
+               return BLI_ghashutil_intcmp(SET_INT_IN_POINTER(A->second), SET_INT_IN_POINTER(B->second));
+       return cmp;
+}
+
+void BLI_ghashutil_pairfree(void *ptr)
+{
+       MEM_freeN((void*)ptr);
+}
+
index a9b8cbb646721b1fb150672050d79b40ec9814f3..6300817ec0318ff0d7e372c05d774add747bff6d 100644 (file)
@@ -35,7 +35,8 @@
 #include "BLI_linklist.h"
 #include "BLI_memarena.h"
 
-int BLI_linklist_length(LinkNode *list) {
+int BLI_linklist_length(LinkNode *list)
+{
        if (0) {
                return list?(1+BLI_linklist_length(list->next)):0;
        } else {
@@ -70,7 +71,8 @@ LinkNode *BLI_linklist_find(LinkNode *list, int index)
        return NULL;
 }
 
-void BLI_linklist_reverse(LinkNode **listp) {
+void BLI_linklist_reverse(LinkNode **listp)
+{
        LinkNode *rhead= NULL, *cur= *listp;
        
        while (cur) {
@@ -85,7 +87,8 @@ void BLI_linklist_reverse(LinkNode **listp) {
        *listp= rhead;
 }
 
-void BLI_linklist_prepend(LinkNode **listp, void *ptr) {
+void BLI_linklist_prepend(LinkNode **listp, void *ptr)
+{
        LinkNode *nlink= MEM_mallocN(sizeof(*nlink), "nlink");
        nlink->link= ptr;
        
@@ -93,7 +96,8 @@ void BLI_linklist_prepend(LinkNode **listp, void *ptr) {
        *listp= nlink;
 }
 
-void BLI_linklist_append(LinkNode **listp, void *ptr) {
+void BLI_linklist_append(LinkNode **listp, void *ptr)
+{
        LinkNode *nlink= MEM_mallocN(sizeof(*nlink), "nlink");
        LinkNode *node = *listp;
        
@@ -110,7 +114,8 @@ void BLI_linklist_append(LinkNode **listp, void *ptr) {
        }
 }
 
-void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, MemArena *ma) {
+void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, MemArena *ma)
+{
        LinkNode *nlink= BLI_memarena_alloc(ma, sizeof(*nlink));
        nlink->link= ptr;
        
@@ -118,7 +123,8 @@ void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, MemArena *ma) {
        *listp= nlink;
 }
 
-void BLI_linklist_insert_after(LinkNode **listp, void *ptr) {
+void BLI_linklist_insert_after(LinkNode **listp, void *ptr)
+{
        LinkNode *nlink= MEM_mallocN(sizeof(*nlink), "nlink");
        LinkNode *node = *listp;
 
@@ -134,7 +140,8 @@ void BLI_linklist_insert_after(LinkNode **listp, void *ptr) {
        }
 }
 
-void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc) {
+void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc)
+{
        while (list) {
                LinkNode *next= list->next;
                
@@ -146,7 +153,8 @@ void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc) {
        }
 }
 
-void BLI_linklist_apply(LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata) {
+void BLI_linklist_apply(LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata)
+{
        for (; list; list= list->next)
                applyfunc(list->link, userdata);
 }
index 308fc6a61e632fe5d589572c0a1ef2c3babe7dc5..4debe1a4b0415a5982b4bf13fa4c4ca8a755f560 100644 (file)
@@ -48,7 +48,8 @@ struct MemArena {
        LinkNode *bufs;
 };
 
-MemArena *BLI_memarena_new(int bufsize, const char *name) {
+MemArena *BLI_memarena_new(int bufsize, const char *name)
+{
        MemArena *ma= MEM_callocN(sizeof(*ma), "memarena");
        ma->bufsize= bufsize;
        ma->align = 8;
@@ -57,20 +58,24 @@ MemArena *BLI_memarena_new(int bufsize, const char *name) {
        return ma;
 }
 
-void BLI_memarena_use_calloc(MemArena *ma) {
+void BLI_memarena_use_calloc(MemArena *ma)
+{
        ma->use_calloc= 1;
 }
 
-void BLI_memarena_use_malloc(MemArena *ma) {
+void BLI_memarena_use_malloc(MemArena *ma)
+{
        ma->use_calloc= 0;
 }
 
-void BLI_memarena_use_align(struct MemArena *ma, int align) {
+void BLI_memarena_use_align(struct MemArena *ma, int align)
+{
        /* align should be a power of two */
        ma->align = align;
 }
 
-void BLI_memarena_free(MemArena *ma) {
+void BLI_memarena_free(MemArena *ma)
+{
        BLI_linklist_free(ma->bufs, (void(*)(void*)) MEM_freeN);
        MEM_freeN(ma);
 }
@@ -78,7 +83,8 @@ void BLI_memarena_free(MemArena *ma) {
        /* amt must be power of two */
 #define PADUP(num, amt)        ((num+(amt-1))&~(amt-1))
 
-void *BLI_memarena_alloc(MemArena *ma, int size) {
+void *BLI_memarena_alloc(MemArena *ma, int size)
+{
        void *ptr;
 
                /* ensure proper alignment by rounding
index 140e1752648789e2292fb92325c5ba5bedd2a3ca..861efcfe6c5fabbdddb0154c5fc2319f9be9e02a 100644 (file)
@@ -199,7 +199,11 @@ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports)
  - filesize: filesize for the file
 */
 #define MAX_RECUR 16
-static int findFileRecursive(char *filename_new, const char *dirname, const char *filename, int *filesize, int *recur_depth)
+static int findFileRecursive(char *filename_new,
+                             const char *dirname,
+                             const char *filename,
+                             int *filesize,
+                             int *recur_depth)
 {
        /* file searching stuff */
        DIR *dir;
@@ -314,7 +318,11 @@ static int rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *abs
        }
 }
 
-static int rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR], char path_file[FILE_MAXFILE], BPathVisitor visit_cb, const char *absbase, void *userdata)
+static int rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR],
+                                      char path_file[FILE_MAXFILE],
+                                      BPathVisitor visit_cb,
+                                      const char *absbase,
+                                      void *userdata)
 {
        char path_src[FILE_MAX];
        char path_dst[FILE_MAX];
@@ -496,7 +504,8 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla
                                SEQ_BEGIN(scene->ed, seq) {
                                        if (SEQ_HAS_PATH(seq)) {
                                                if (ELEM(seq->type, SEQ_MOVIE, SEQ_SOUND)) {
-                                                       rewrite_path_fixed_dirfile(seq->strip->dir, seq->strip->stripdata->name, visit_cb, absbase, bpath_user_data);
+                                                       rewrite_path_fixed_dirfile(seq->strip->dir, seq->strip->stripdata->name,
+                                                                                  visit_cb, absbase, bpath_user_data);
                                                }
                                                else if (seq->type == SEQ_IMAGE) {
                                                        /* might want an option not to loop over all strips */
@@ -510,7 +519,8 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla
                                                        }
 
                                                        for(i= 0; i < len; i++, se++) {
-                                                               rewrite_path_fixed_dirfile(seq->strip->dir, se->name, visit_cb, absbase, bpath_user_data);
+                                                               rewrite_path_fixed_dirfile(seq->strip->dir, se->name,
+                                                                                          visit_cb, absbase, bpath_user_data);
                                                        }
                                                }
                                                else {
index 0eda3e788245f69335784c4923be3c60b0697d97..7ae68101154650dec362a08e2c8766a15fd0fb76 100644 (file)
@@ -64,7 +64,8 @@ struct EdgeHash {
 
 /***/
 
-EdgeHash *BLI_edgehash_new(void) {
+EdgeHash *BLI_edgehash_new(void)
+{
        EdgeHash *eh= MEM_mallocN(sizeof(*eh), "EdgeHash");
        eh->cursize= 0;
        eh->nentries= 0;
@@ -76,7 +77,8 @@ EdgeHash *BLI_edgehash_new(void) {
        return eh;
 }
 
-void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val) {
+void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val)
+{
        unsigned int hash;
        Entry *e= malloc(sizeof(*e));
 
@@ -117,7 +119,8 @@ void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val) {
        }
 }
 
-void** BLI_edgehash_lookup_p(EdgeHash *eh, int v0, int v1) {
+void** BLI_edgehash_lookup_p(EdgeHash *eh, int v0, int v1)
+{
        unsigned int hash;
        Entry *e;
 
@@ -134,21 +137,25 @@ void** BLI_edgehash_lookup_p(EdgeHash *eh, int v0, int v1) {
        return NULL;
 }
 
-void* BLI_edgehash_lookup(EdgeHash *eh, int v0, int v1) {
+void* BLI_edgehash_lookup(EdgeHash *eh, int v0, int v1)
+{
        void **value_p = BLI_edgehash_lookup_p(eh,v0,v1);
 
        return value_p?*value_p:NULL;
 }
 
-int BLI_edgehash_haskey(EdgeHash *eh, int v0, int v1) {
+int BLI_edgehash_haskey(EdgeHash *eh, int v0, int v1)
+{
        return BLI_edgehash_lookup_p(eh, v0, v1)!=NULL;
 }
 
-int BLI_edgehash_size(EdgeHash *eh) {
+int BLI_edgehash_size(EdgeHash *eh)
+{
        return eh->nentries;
 }
 
-void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp) {
+void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp)
+{
        int i;
        
        for (i=0; i<eh->nbuckets; i++) {
@@ -168,7 +175,8 @@ void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp) {
        eh->nentries= 0;
 }
 
-void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp) {
+void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp)
+{
        BLI_edgehash_clear(eh, valfreefp);
        
        free(eh->buckets);
@@ -184,7 +192,8 @@ struct EdgeHashIterator {
        Entry *curEntry;
 };
 
-EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) {
+EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh)
+{
        EdgeHashIterator *ehi= malloc(sizeof(*ehi));
        ehi->eh= eh;
        ehi->curEntry= NULL;
@@ -197,26 +206,31 @@ EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) {
        }
        return ehi;
 }
-void BLI_edgehashIterator_free(EdgeHashIterator *ehi) {
+void BLI_edgehashIterator_free(EdgeHashIterator *ehi)
+{
        free(ehi);
 }
 
-void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, int *v0_r, int *v1_r) {
+void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, int *v0_r, int *v1_r)
+{
        if (ehi->curEntry) {
                *v0_r = ehi->curEntry->v0;
                *v1_r = ehi->curEntry->v1;
        }
 }
-void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi) {
+void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi)
+{
        return ehi->curEntry?ehi->curEntry->val:NULL;
 }
 
-void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val) {
+void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val)
+{
        if(ehi->curEntry)
                ehi->curEntry->val= val;
 }
 
-void BLI_edgehashIterator_step(EdgeHashIterator *ehi) {
+void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
+{
        if (ehi->curEntry) {
                ehi->curEntry= ehi->curEntry->next;
                while (!ehi->curEntry) {
@@ -227,7 +241,8 @@ void BLI_edgehashIterator_step(EdgeHashIterator *ehi) {
                }
        }
 }
-int BLI_edgehashIterator_isDone(EdgeHashIterator *ehi) {
+int BLI_edgehashIterator_isDone(EdgeHashIterator *ehi)
+{
        return !ehi->curEntry;
 }
 
index 0b2411af009d9b69e63f6aff38030a6f24100767..7e04e0ae566ce7b0c48af2d567d6aa6b6fdbc765 100644 (file)
@@ -115,6 +115,31 @@ MINLINE float power_of_2(float val)
        return (float)pow(2.0, ceil(log((double)val) / M_LN2));
 }
 
+MINLINE int is_power_of_2_i(int n)
+{
+       return (n & (n - 1)) == 0;
+}
+
+MINLINE int power_of_2_max_i(int n)
+{
+       if (is_power_of_2_i(n))
+               return n;
+
+       while(!is_power_of_2_i(n))
+               n = n & (n - 1);
+
+       return n * 2;
+}
+
+MINLINE int power_of_2_min_i(int n)
+{
+       while (!is_power_of_2_i(n))
+               n = n & (n - 1);
+
+       return n;
+}
+
+
 MINLINE float minf(float a, float b)
 {
        return (a < b)? a: b;
@@ -130,5 +155,6 @@ MINLINE float signf(float f)
        return (f < 0.f)? -1.f: 1.f;
 }
 
+
 #endif /* BLI_MATH_BASE_INLINE_H */
 
index 19aa86ee941af627b73b0ee61de21d8646813671..cd54c944ba9c84b89d084b761fa007ee0c82220a 100644 (file)
@@ -142,7 +142,7 @@ void swap_m4m4(float m1[][4], float m2[][4])
 
 /******************************** Arithmetic *********************************/
 
-void mul_m4_m4m4(float m1[][4], float m2_[][4], float m3_[][4])
+void mult_m4_m4m4(float m1[][4], float m3_[][4], float m2_[][4])
 {
        float m2[4][4], m3[4][4];
 
@@ -215,7 +215,7 @@ void mul_m4_m4m3(float (*m1)[4], float (*m3_)[4], float (*m2_)[3])
 }
 
 /* m1 = m2 * m3, ignore the elements on the 4th row/column of m3*/
-void mul_m3_m3m4(float m1[][3], float m2[][3], float m3[][4])
+void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3])
 {
        /* m1[i][j] = m2[i][k] * m3[k][j] */
        m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] +m2[0][2] * m3[2][0];
@@ -286,19 +286,19 @@ void mul_serie_m4(float answ[][4], float m1[][4],
        
        if(m1==NULL || m2==NULL) return;
        
-       mul_m4_m4m4(answ, m2, m1);
+       mult_m4_m4m4(answ, m1, m2);
        if(m3) {
-               mul_m4_m4m4(temp, m3, answ);
+               mult_m4_m4m4(temp, answ, m3);
                if(m4) {
-                       mul_m4_m4m4(answ, m4, temp);
+                       mult_m4_m4m4(answ, temp, m4);
                        if(m5) {
-                               mul_m4_m4m4(temp, m5, answ);
+                               mult_m4_m4m4(temp, answ, m5);
                                if(m6) {
-                                       mul_m4_m4m4(answ, m6, temp);
+                                       mult_m4_m4m4(answ, temp, m6);
                                        if(m7) {
-                                               mul_m4_m4m4(temp, m7, answ);
+                                               mult_m4_m4m4(temp, answ, m7);
                                                if(m8) {
-                                                       mul_m4_m4m4(answ, m8, temp);
+                                                       mult_m4_m4m4(answ, temp, m8);
                                                }
                                                else copy_m4_m4(answ, temp);
                                        }
index e4664798f5d7b81658e1d75f60a3764e69fc21e1..5596b6f9f222b05c8a37985965f6b650a692385c 100644 (file)
@@ -1433,7 +1433,7 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
 
        /* split scaling and rotation, there is probably a faster way to do
           this, it's done like this now to correctly get negative scaling */
-       mul_m4_m4m4(baseRS, basemat, mat);
+       mult_m4_m4m4(baseRS, mat, basemat);
        mat4_to_size(scale,baseRS);
 
        copy_v3_v3(dscale, scale);
@@ -1452,10 +1452,10 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
                copy_v3_v3(baseR[3], baseRS[3]);
 
                invert_m4_m4(baseinv, basemat);
-               mul_m4_m4m4(R, baseinv, baseR);
+               mult_m4_m4m4(R, baseR, baseinv);
 
                invert_m4_m4(baseRinv, baseR);
-               mul_m4_m4m4(S, baseRS, baseRinv);
+               mult_m4_m4m4(S, baseRinv, baseRS);
 
                /* set scaling part */
                mul_serie_m4(dq->scale, basemat, S, baseinv, NULL, NULL, NULL, NULL, NULL);
index a9ea90ef5556e02b878a5b3df456e2afac5b238d..590a48e808565f0ce43eb2aa0cfa9335bc0338cb 100644 (file)
@@ -416,6 +416,15 @@ void range_vn_i(int *array_tar, const int size, const int start)
        while(i--) { *(array_pt--) = j--; }
 }
 
+void range_vn_fl(float *array_tar, const int size, const float start, const float step)
+{
+       float *array_pt= array_tar + (size-1);
+       int i= size;
+       while(i--) {
+               *(array_pt--) = start + step * (float)(i);
+       }
+}
+
 void negate_vn(float *array_tar, const int size)
 {
        float *array_pt= array_tar + (size-1);
index b1b7ebed18ecf0cc7f45cc1e3c2cb2baa1c7e86c..28dc5a696d5c875b0df3a2a013f9c5c45cffc138 100644 (file)
@@ -78,11 +78,13 @@ void rng_free(RNG* rng)
        MEM_freeN(rng);
 }
 
-void rng_seed(RNG *rng, unsigned int seed) {
+void rng_seed(RNG *rng, unsigned int seed)
+{
        rng->X= (((r_uint64) seed)<<16) | LOWSEED;
 }
 
-void rng_srandom(RNG *rng, unsigned int seed) {
+void rng_srandom(RNG *rng, unsigned int seed)
+{
        rng_seed(rng, seed + hash[seed & 255]);
        seed= rng_getInt(rng);
        rng_seed(rng, seed + hash[seed & 255]);
@@ -90,16 +92,19 @@ void rng_srandom(RNG *rng, unsigned int seed) {
        rng_seed(rng, seed + hash[seed & 255]);
 }
 
-int rng_getInt(RNG *rng) {
+int rng_getInt(RNG *rng)
+{
        rng->X= (MULTIPLIER*rng->X + ADDEND)&MASK;
        return (int) (rng->X>>17);
 }
 
-double rng_getDouble(RNG *rng) {
+double rng_getDouble(RNG *rng)
+{
        return (double) rng_getInt(rng)/0x80000000;
 }
 
-float rng_getFloat(RNG *rng) {
+float rng_getFloat(RNG *rng)
+{
        return (float) rng_getInt(rng)/0x80000000;
 }
 
@@ -135,28 +140,34 @@ void rng_skip(RNG *rng, int n)
 static RNG theBLI_rng = {0};
 
 /* note, this one creates periodical patterns */
-void BLI_srand(unsigned int seed) {
+void BLI_srand(unsigned int seed)
+{
        rng_seed(&theBLI_rng, seed);
 }
 
 /* using hash table to create better seed */
-void BLI_srandom(unsigned int seed) {
+void BLI_srandom(unsigned int seed)
+{
        rng_srandom(&theBLI_rng, seed);
 }
 
-int BLI_rand(void) {
+int BLI_rand(void)
+{
        return rng_getInt(&theBLI_rng);
 }
 
-double BLI_drand(void) {
+double BLI_drand(void)
+{
        return rng_getDouble(&theBLI_rng);
 }
 
-float BLI_frand(void) {
+float BLI_frand(void)
+{
        return rng_getFloat(&theBLI_rng);
 }
 
-void BLI_fillrand(void *addr, int len) {
+void BLI_fillrand(void *addr, int len)
+{
        RNG rng;
        unsigned char *p= addr;
 
@@ -188,11 +199,13 @@ void BLI_thread_srandom(int thread, unsigned int seed)
        rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
 }
 
-int BLI_thread_rand(int thread) {
+int BLI_thread_rand(int thread)
+{
        return rng_getInt(&rng_tab[thread]);
 }
 
-float BLI_thread_frand(int thread) {
+float BLI_thread_frand(int thread)
+{
        return rng_getFloat(&rng_tab[thread]);
 }
 
index 1b5bb60738623c07285b94b99e29dea173025156..b2002b63a223942e355c77ecd3ec1a3f3a362826 100644 (file)
@@ -49,7 +49,8 @@
 
  /* FILE_MAX */
 
-int BLI_getInstallationDir( char * str ) {
+int BLI_getInstallationDir( char * str )
+{
        char dir[FILE_MAXDIR];
        int a;
        
@@ -73,7 +74,8 @@ void RegisterBlendExtension_Fail(HKEY root)
        TerminateProcess(GetCurrentProcess(),1);
 }
 
-void RegisterBlendExtension(void) {
+void RegisterBlendExtension(void)
+{
        LONG lresult;
        HKEY hkey = 0;
        HKEY root = 0;
@@ -167,7 +169,8 @@ void RegisterBlendExtension(void) {
        TerminateProcess(GetCurrentProcess(),0);
 }
 
-DIR *opendir (const char *path) {
+DIR *opendir (const char *path)
+{
        if (GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY) {
                DIR *newd= MEM_mallocN(sizeof(DIR), "opendir");
 
@@ -185,7 +188,8 @@ DIR *opendir (const char *path) {
        }
 }
 
-struct dirent *readdir(DIR *dp) {
+struct dirent *readdir(DIR *dp)
+{
        if (dp->direntry.d_name) {
                MEM_freeN(dp->direntry.d_name);
                dp->direntry.d_name= NULL;
@@ -208,7 +212,8 @@ struct dirent *readdir(DIR *dp) {
        }
 }
 
-int closedir (DIR *dp) {
+int closedir (DIR *dp)
+{
        if (dp->direntry.d_name) MEM_freeN(dp->direntry.d_name);
        if (dp->handle!=INVALID_HANDLE_VALUE) FindClose(dp->handle);
 
@@ -217,7 +222,8 @@ int closedir (DIR *dp) {
        return 0;
 }
 
-void get_default_root(char* root) {
+void get_default_root(char* root)
+{
        char str[MAX_PATH+1];
        
        /* the default drive to resolve a directory without a specified drive 
index 7bd70e9f289a664104044e5c4365bb86caa8e1d8..7b57ed243a17167350572b20e270153e1cc3ce57 100644 (file)
@@ -767,7 +767,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames , Ob
                // compute bone local mat
                if (bone->parent) {
                        invert_m4_m4(ipar, parchan->pose_mat);
-                       mul_m4_m4m4(mat, pchan->pose_mat, ipar);
+                       mult_m4_m4m4(mat, ipar, pchan->pose_mat);
                }
                else
                        copy_m4_m4(mat, pchan->pose_mat);
@@ -1274,7 +1274,7 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i
                // compute bone local mat
                if (bone->parent) {
                        invert_m4_m4(ipar, parchan->pose_mat);
-                       mul_m4_m4m4(mat, pchan->pose_mat, ipar);
+                       mult_m4_m4m4(mat, ipar, pchan->pose_mat);
                }
                else
                        copy_m4_m4(mat, pchan->pose_mat);
index 9b4e47615f7f8ee2fd66c1fd39f52e1736713fd0..c47e024aba4ea283a3dfda02b607f4746af6ca42 100644 (file)
@@ -723,7 +723,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
 
                        // calc M
                        calc_joint_parent_mat_rest(par, NULL, root, node);
-                       mul_m4_m4m4(temp, matfra, par);
+                       mult_m4_m4m4(temp, par, matfra);
 
                        // evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra);
 
@@ -1276,7 +1276,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
 
                        // calc M
                        calc_joint_parent_mat_rest(par, NULL, root, node);
-                       mul_m4_m4m4(temp, matfra, par);
+                       mult_m4_m4m4(temp, par, matfra);
 
                        // evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra);
 
@@ -1434,7 +1434,7 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
                float temp[4][4];
                copy_m4_m4(temp, mat);
 
-               mul_m4_m4m4(mat, m, temp);
+               mult_m4_m4m4(mat, temp, m);
        }
 }
 
@@ -1597,7 +1597,7 @@ void AnimationImporter::get_joint_rest_mat(float mat[4][4], COLLADAFW::Node *roo
 
                calc_joint_parent_mat_rest(par, NULL, root, node);
                get_node_mat(m, node, NULL, NULL);
-               mul_m4_m4m4(mat, m, par);
+               mult_m4_m4m4(mat, par, m);
        }
 }
 
@@ -1616,7 +1616,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], float par[4]
                if (par) {
                        float temp[4][4];
                        get_node_mat(temp, node, NULL, NULL);
-                       mul_m4_m4m4(m, temp, par);
+                       mult_m4_m4m4(m, par, temp);
                }
                else {
                        get_node_mat(m, node, NULL, NULL);
@@ -1656,7 +1656,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
                        float temp[4][4], ipar[4][4];
                        invert_m4_m4(ipar, par_job->obmat);
                        copy_m4_m4(temp, mat);
-                       mul_m4_m4m4(mat, temp, ipar);
+                       mult_m4_m4m4(mat, ipar, temp);
                }
 
                TransformBase::decompose(mat, job->loc, NULL, job->quat, job->size);
@@ -1689,7 +1689,7 @@ bool AnimationImporter::evaluate_joint_world_transform_at_frame(float mat[4][4],
        if (par) {
                float temp[4][4];
                evaluate_transform_at_frame(temp, node, node == end ? fra : 0.0f);
-               mul_m4_m4m4(m, temp, par);
+               mult_m4_m4m4(m, par, temp);
        }
        else {
                evaluate_transform_at_frame(m, node, node == end ? fra : 0.0f);
index df786c38c716a5868465ebb3a74107d8b340a178..fcfc197ce804a3de2b51296cda96bb07733896b1 100644 (file)
@@ -218,11 +218,11 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
 
                float invpar[4][4];
                invert_m4_m4(invpar, parchan->pose_mat);
-               mul_m4_m4m4(mat, pchan->pose_mat, invpar);
+               mult_m4_m4m4(mat, invpar, pchan->pose_mat);
        }
        else {
                // get world-space from armature-space
-               mul_m4_m4m4(mat, pchan->pose_mat, ob_arm->obmat);
+               mult_m4_m4m4(mat, ob_arm->obmat, pchan->pose_mat);
        }
 
        TransformWriter::add_node_transform(node, mat,NULL );
@@ -374,7 +374,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
                        float inv_bind_mat[4][4];
 
                        // make world-space matrix, arm_mat is armature-space
-                       mul_m4_m4m4(world, pchan->bone->arm_mat, ob_arm->obmat);
+                       mult_m4_m4m4(world, ob_arm->obmat, pchan->bone->arm_mat);
                        
                        invert_m4_m4(mat, world);
                        converter.mat4_to_dae(inv_bind_mat, mat);
index bababf880a6fb055b417a01051a3b8e492a3bf2b..4bc0c18551a23446f7d4d8443df165d3c6eb94ac 100644 (file)
@@ -99,7 +99,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
 
        // get world-space
        if (parent){
-               mul_m4_m4m4(mat, obmat, parent_mat);
+               mult_m4_m4m4(mat, parent_mat, obmat);
 
        }
        else {
@@ -185,7 +185,7 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
 
                // get world-space
                if (parent)
-                       mul_m4_m4m4(mat, obmat, parent_mat);
+                       mult_m4_m4m4(mat, parent_mat, obmat);
                else
                        copy_m4_m4(mat, obmat);
 
@@ -584,17 +584,17 @@ void ArmatureImporter::set_pose ( Object * ob_arm ,  COLLADAFW::Node * root_node
 
        // get world-space
        if (parentname){
-               mul_m4_m4m4(mat, obmat, parent_mat);
+               mult_m4_m4m4(mat, parent_mat, obmat);
                bPoseChannel *parchan = get_pose_channel(ob_arm->pose, parentname);
 
-               mul_m4_m4m4(pchan->pose_mat, mat , parchan->pose_mat);
+               mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat );
 
        }
        else {
                copy_m4_m4(mat, obmat);
                float invObmat[4][4];
                invert_m4_m4(invObmat, ob_arm->obmat);
-               mul_m4_m4m4(pchan->pose_mat, mat, invObmat);
+               mult_m4_m4m4(pchan->pose_mat, invObmat, mat);
        }
 
        mat4_to_axis_angle(ax,&angle,mat);
index 267aa925c74b0c2e1dbcec03ccffe7657eeee9a1..05b2b3b738d0db67a396117a154b6d9b4a5afcc3 100644 (file)
@@ -335,7 +335,7 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
                                }
                        }
                        // calc new matrix and apply
-                       mul_m4_m4m4(obn->obmat, mat, obn->obmat);
+                       mult_m4_m4m4(obn->obmat, obn->obmat, mat);
                        object_apply_mat4(obn, obn->obmat, 0, 0);
                }
        }
index 26049398c26818f4749620803451ff989319d7fb..a73d52436240ab7c5935e3f279a28efd4327a893 100644 (file)
@@ -63,7 +63,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
                        }
 
                copy_m4_m4(copy, mat);
-               mul_m4_m4m4(mat, cur, copy);
+               mult_m4_m4m4(mat, copy, cur);
 
                if (animation_map) {
                        // AnimationList that drives this Transformation
index 2b4864ec32bf6f1a7a56ee6166a85bf7ad4dc359..379a0619040a9ff13dd716eab1255378d3f7e3c0 100644 (file)
@@ -40,7 +40,7 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4],
        if (parent_mat) {
                float invpar[4][4];
                invert_m4_m4(invpar, parent_mat);
-               mul_m4_m4m4(local, mat, invpar);
+               mult_m4_m4m4(local, invpar, mat);
        }
        else {
                copy_m4_m4(local, mat);
@@ -77,7 +77,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob)
                // calculate local mat
 
                invert_m4_m4(imat, ob->parent->obmat);
-               mul_m4_m4m4(mat, tmat, imat);
+               mult_m4_m4m4(mat, imat, tmat);
 
                // done
 
index 6a82446f0358d31326149944da29710297a6942e..c3aa73510d1cc8bcb4a4ee0bb42f3969ce996326 100644 (file)
@@ -89,7 +89,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
                where_is_object(sce, par);
 
                // move child obmat into world space
-               mul_m4_m4m4(mat, ob->obmat, par->obmat);
+               mult_m4_m4m4(mat, par->obmat, ob->obmat);
                copy_m4_m4(ob->obmat, mat);
        }
        
index 682b40affc2979a25867d9794358667216a62c64..25432260387473e86e3586896a014acb658d9b83 100644 (file)
@@ -776,7 +776,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
         *      - only include entry if it exists
         */
        if (scene->active_keyingset) {
-               uiItemIntO(layout, "Active Keying Set", ICON_NONE, op_name, "type", i++);
+               uiItemEnumO(layout, op_name, "Active Keying Set", ICON_NONE, "type", i++);
                uiItemS(layout);
        }
        else
@@ -788,7 +788,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
        if (scene->keyingsets.first) {
                for (ks= scene->keyingsets.first; ks; ks=ks->next, i++) {
                        if (ANIM_keyingset_context_ok_poll(C, ks))
-                               uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i);
+                               uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i);
                }
                uiItemS(layout);
        }
@@ -798,7 +798,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
        for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) {
                /* only show KeyingSet if context is suitable */
                if (ANIM_keyingset_context_ok_poll(C, ks))
-                       uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i);
+                       uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i);
        }
        
        uiPupMenuEnd(C, pup);
index 6dbb08e115fa29a40f908b27b3b013bada459dc9..48f3f78b8496559caa63743cf20591ead92b5cf1 100644 (file)
@@ -936,7 +936,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
                        
                        /* Find the difference matrix */
                        invert_m4_m4(oimat, ob->obmat);
-                       mul_m4_m4m4(mat, base->object->obmat, oimat);
+                       mult_m4_m4m4(mat, oimat, base->object->obmat);
                        
                        /* Copy bones and posechannels from the object to the edit armature */
                        for (pchan=opose->chanbase.first; pchan; pchan=pchann) {
@@ -972,7 +972,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
                                        
                                        /* Find the roll */
                                        invert_m4_m4(imat, premat);
-                                       mul_m4_m4m4(difmat, postmat, imat);
+                                       mult_m4_m4m4(difmat, imat, postmat);
                                        
                                        curbone->roll -= (float)atan2(difmat[2][0], difmat[2][2]);
                                }
index 8df54670bd4a15905704766b091dfe1c8e154e06..8b2e1bba6cf8aee3bc305ab9bbe3ac69e119e048 100644 (file)
@@ -151,8 +151,7 @@ void ED_operatormacros_curve(void)
 
        ot= WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
        ot->description = "Extrude curve and move result";
-       otmacro= WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
-       RNA_enum_set(otmacro->ptr, "type", 1);
+       WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
        otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
        RNA_enum_set(otmacro->ptr, "proportional", 0);
        RNA_boolean_set(otmacro->ptr, "mirror", 0);
index a679fa3e2bf4540627b870c625a87526345add5f..762564c1cc9c2d23ae643de8e4cbd4301d3d6c40 100644 (file)
@@ -6056,7 +6056,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
                        
                                if(cu->nurb.first) {
                                        /* watch it: switch order here really goes wrong */
-                                       mul_m4_m4m4(cmat, base->object->obmat, imat);
+                                       mult_m4_m4m4(cmat, imat, base->object->obmat);
                                        
                                        nu= cu->nurb.first;
                                        while(nu) {
index 2cd610e1fe4558b9e055b8c7b3aef383ce97bdc1..f75f2921e5150266fa86283a1a1fd8db381bdb46 100644 (file)
@@ -87,8 +87,8 @@ struct rcti;
 
 /* meshtools.c */
 
-intptr_t       mesh_octree_table(struct Object *ob, struct EditMesh *em, float *co, char mode);
-long           mesh_mirrtopo_table(struct Object *ob, char mode);
+intptr_t   mesh_octree_table(struct Object *ob, struct EditMesh *em, float *co, char mode);
+int        mesh_mirrtopo_table(struct Object *ob, char mode);
 
 struct EditVert   *editmesh_get_x_mirror_vert(struct Object *ob, struct EditMesh *em, struct EditVert *eve, float *co, int index);
 int                    mesh_get_x_mirror_vert(struct Object *ob, int index);
index a10de9a8a426c947224f2b88720a3f50a44c3997..1bad61be3242fec36ea6615ad59343b042b61102 100644 (file)
@@ -2833,7 +2833,7 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x1, i
         */
 static int findBitIndex(unsigned int x)
 {
-       if (!x || (x&(x-1))!=0) {       /* x&(x-1) strips lowest bit */
+       if (!x || !is_power_of_2_i(x)) { /* is_power_of_2_i(x) strips lowest bit */
                return -1;
        } else {
                int idx= 0;
index 06b7822ad05fba9e3906d8d7a0ad71f95723ab24..6ebb67af67a9ac174a530cdcd31765b1652fa7aa 100644 (file)
@@ -389,17 +389,7 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
                glEnable( GL_BLEND );
        }
        
-       /* solid part */
-       uiDrawBox(GL_POLYGON, minx, miny, maxx, maxy, rad);
-       
-       /* set antialias line */
-       glEnable( GL_LINE_SMOOTH );
-       glEnable( GL_BLEND );
-       
-       uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
-       
-       glDisable( GL_BLEND );
-       glDisable( GL_LINE_SMOOTH );
+       ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad);
 }
 
 
index d6460f9046e7fde8a11f77c044c0de27addf2f26..e4cc605e3f582d9dfb192701de92ecff2d09ec87 100644 (file)
@@ -462,6 +462,7 @@ extern int ui_button_is_active(struct ARegion *ar);
 
 /* interface_widgets.c */
 void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
+void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad);
 void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
 void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
 int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol);
index 1edfa2f4ea69d4426de30ebe0474ac9254cba92a..c21bc09ff27f8f296f361263c5a8c968e884af88 100644 (file)
@@ -330,7 +330,6 @@ static void uiPanelPop(uiBlock *UNUSED(block))
 #endif
 
 /* triangle 'icon' for panel header */
-/* NOTE - this seems to be only used for hiding nodes now */
 void UI_DrawTriIcon(float x, float y, char dir)
 {
        if(dir=='h') {
index b89a80bb0d759d466d978e85ab6b2e933f4b9691..c535f2c1ad0caa33ea1c1750433cc459d1f8d712 100644 (file)
@@ -1071,18 +1071,16 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
                /* copy to int, gets projected if possible too */
                x1= x1f; y1= y1f; x2= x2f; y2= y2f; 
                
-               if(butregion) {
-                       if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
-                               UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1);
-                               UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2);
-                       }
-                       
-                       x1 += butregion->winrct.xmin;
-                       x2 += butregion->winrct.xmin;
-                       y1 += butregion->winrct.ymin;
-                       y2 += butregion->winrct.ymin;
+               if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
+                       UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1);
+                       UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2);
                }
-               
+
+               x1 += butregion->winrct.xmin;
+               x2 += butregion->winrct.xmin;
+               y1 += butregion->winrct.ymin;
+               y2 += butregion->winrct.ymin;
+
                wm_window_get_size(CTX_wm_window(C), &winx, &winy);
                
                if(x2 > winx) {
@@ -1096,7 +1094,8 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
                                x2= winx;
                        }
                }
-               if(y1 < 0) { /* XXX butregion NULL check?, there is one above */
+
+               if(y1 < 0) {
                        int newy1;
                        UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, NULL, &newy1);
                        newy1 += butregion->winrct.ymin;
index 9a438070e1eac8b9d600d8724c60a088a8fcc6c3..0da4d3895e00aecbf949eac5140b805f79e86a5e 100644 (file)
@@ -200,7 +200,25 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
 
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisable(GL_BLEND);
+}
+
+void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad)
+{
+       float color[4];
+       int j;
+       
+       glEnable(GL_BLEND);
+       glGetFloatv(GL_CURRENT_COLOR, color);
+       color[3] *= 0.125f;
+       glColor4fv(color);
        
+       for(j=0; j<8; j++) {
+               glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
+               uiDrawBox(mode, minx, miny, maxx, maxy, rad);
+               glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
+       }
+
+       glDisable(GL_BLEND);
 }
 
 static void widget_init(uiWidgetBase *wtb)
index 845cc29c91bb40d230112909aabd449ae1114acd..5e8105d507a05f3f4f1fb7c6325cc567c9a4a1a1 100644 (file)
@@ -1316,7 +1316,7 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short UNUSED(flag),
                                if (mmd->mirror_ob) {
                                        float imtx[4][4];
                                        invert_m4_m4(imtx, mmd->mirror_ob->obmat);
-                                       mul_m4_m4m4(mtx, obedit->obmat, imtx);
+                                       mult_m4_m4m4(mtx, imtx, obedit->obmat);
                                }
 
                                for (eed= em->edges.first; eed; eed= eed->next) {
@@ -1603,7 +1603,7 @@ short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor, int
                                if (mmd->mirror_ob) {
                                        float imtx[4][4];
                                        invert_m4_m4(imtx, mmd->mirror_ob->obmat);
-                                       mul_m4_m4m4(mtx, obedit->obmat, imtx);
+                                       mult_m4_m4m4(mtx, imtx, obedit->obmat);
                                }
 
                                for (eed= em->edges.first; eed; eed= eed->next) {
index 2e5fc51533081b9d97f5457eefe175599e0d3bb9..37d3d5b587ce34089fc7ab7e8aaab4b23c1560f7 100644 (file)
@@ -7246,7 +7246,7 @@ static int sort_faces_exec(bContext *C, wmOperator *op)
                float cur[3];
                
                if (event == 1)
-                       mul_m4_m4m4(mat, OBACT->obmat, rv3d->viewmat); /* apply the view matrix to the object matrix */
+                       mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */
                else if (event == 2) { /* sort from cursor */
                        if( v3d && v3d->localvd ) {
                                VECCOPY(cur, v3d->cursor);
index 48d2c6291486460cec4d203ce1eb4eb25770deb5..973659cbb35e0611ffd06248b5e38fc08ec14613 100644 (file)
@@ -534,7 +534,8 @@ void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-static int compare(const void * a, const void * b){  
+static int compare(const void * a, const void * b)
+{
        return ( *(int*)a - *(int*)b );
 }
 
index 707936351cf94f50abd78e36db2879f77ae284cc..dd82f055f14bd747e02727033270e58e92698582 100644 (file)
@@ -327,7 +327,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
                                /* if this is the object we're merging into, no need to do anything */
                                if(base->object != ob) {
                                        /* watch this: switch matmul order really goes wrong */
-                                       mul_m4_m4m4(cmat, base->object->obmat, imat);
+                                       mult_m4_m4m4(cmat, imat, base->object->obmat);
                                        
                                        /* transform vertex coordinates into new space */
                                        for(a=0, mv=mvert; a < me->totvert; a++, mv++) {
@@ -671,17 +671,17 @@ static void mesh_octree_free_node(MocNode **bt)
 
 
 /* temporal define, just to make nicer code below */
-#define MOC_ADDNODE(vx, vy, vz)        mesh_octree_add_node(basetable + ((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz), index)
+#define MOC_INDEX(vx, vy, vz)  (((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz))
 
 static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, float *div, intptr_t index)
 {
        float fx, fy, fz;
        int vx, vy, vz;
        
-       if (!finite(co[0]) ||
-               !finite(co[1]) ||
-               !finite(co[2])
-       {
+       if ( !finite(co[0]) ||
+            !finite(co[1]) ||
+            !finite(co[2]))
+       {
                return;
        }
        
@@ -692,33 +692,33 @@ static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, f
        CLAMP(fy, 0.0f, MOC_RES-MOC_THRESH);
        CLAMP(fz, 0.0f, MOC_RES-MOC_THRESH);
        
-       vx= floor(fx);
-       vy= floor(fy);
-       vz= floor(fz);
-       
-       MOC_ADDNODE(vx, vy, vz);
-       
-       if( vx>0 )
-               iffx-((float)vx)-MOC_THRESH < 0.0f)
-                       MOC_ADDNODE(vx-1, vy, vz);
-       if( vx<MOC_RES-2 )
-               iffx-((float)vx)+MOC_THRESH > 1.0f)
-                       MOC_ADDNODE(vx+1, vy, vz);
-
-       if( vy>0 )
-               if( fy-((float)vy)-MOC_THRESH < 0.0f) 
-                       MOC_ADDNODE(vx, vy-1, vz);
-       if( vy<MOC_RES-2 )
-               if( fy-((float)vy)+MOC_THRESH > 1.0f) 
-                       MOC_ADDNODE(vx, vy+1, vz);
-
-       if( vz>0 )
-               if( fz-((float)vz)-MOC_THRESH < 0.0f) 
-                       MOC_ADDNODE(vx, vy, vz-1);
-       if( vz<MOC_RES-2 )
-               if( fz-((float)vz)+MOC_THRESH > 1.0f) 
-                       MOC_ADDNODE(vx, vy, vz+1);
-       
+       vx= (int)floorf(fx);
+       vy= (int)floorf(fy);
+       vz= (int)floorf(fz);
+
+       mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz), index);
+
+       if (vx > 0)
+               if (fx-((float)vx)-MOC_THRESH < 0.0f)
+                       mesh_octree_add_node(basetable + MOC_INDEX(vx - 1, vy, vz), index);
+       if (vx < MOC_RES - 2)
+               if (fx-((float)vx)+MOC_THRESH > 1.0f)
+                       mesh_octree_add_node(basetable + MOC_INDEX(vx + 1, vy, vz), index);
+
+       if (vy > 0)
+               if (fy-((float)vy)-MOC_THRESH < 0.0f)
+                       mesh_octree_add_node(basetable + MOC_INDEX(vx, vy - 1, vz), index);
+       if (vy < MOC_RES - 2)
+               if (fy-((float)vy)+MOC_THRESH > 1.0f)
+                       mesh_octree_add_node(basetable + MOC_INDEX(vx, vy + 1, vz), index);
+
+       if (vz > 0)
+               if (fz-((float)vz)-MOC_THRESH < 0.0f)
+                       mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz - 1), index);
+       if (vz <MOC_RES - 2)
+               if (fz-((float)vz)+MOC_THRESH > 1.0f)
+                       mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz + 1), index);
+
 }
 
 static intptr_t mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co)
@@ -851,41 +851,45 @@ intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode)
 
 /* ********************* MESH VERTEX MIRR TOPO LOOKUP *************** */
 
-#define MIRRHASH_TYPE int
+typedef int MirrTopoHash_t;
 
-typedef struct MirrTopoPair {
-       long hash;
-       int vIndex;
-} MirrTopoPair;
+typedef struct MirrTopoPair_t {
+       MirrTopoHash_t  hash;
+       int            vIndex;
+} MirrTopoPair_t;
 
 static int MirrTopo_long_sort(const void *l1, const void *l2)
 {
-       if(                     (MIRRHASH_TYPE)(intptr_t)l1 > (MIRRHASH_TYPE)(intptr_t)l2 ) return  1;
-       else if(        (MIRRHASH_TYPE)(intptr_t)l1 < (MIRRHASH_TYPE)(intptr_t)l2 ) return -1;
+       if       ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2 ) return  1;
+       else if  ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2 ) return -1;
        return 0;
 }
 
 static int MirrTopo_item_sort(const void *v1, const void *v2)
 {
-       if(                     ((MirrTopoPair *)v1)->hash > ((MirrTopoPair *)v2)->hash ) return  1;
-       else if(        ((MirrTopoPair *)v1)->hash < ((MirrTopoPair *)v2)->hash ) return -1;
+       if      (((MirrTopoPair_t *)v1)->hash > ((MirrTopoPair_t *)v2)->hash ) return  1;
+       else if (((MirrTopoPair_t *)v1)->hash < ((MirrTopoPair_t *)v2)->hash ) return -1;
        return 0;
 }
 
-static long *mesh_topo_lookup = NULL;
-static int  mesh_topo_lookup_tot = -1;
-static int  mesh_topo_lookup_mode = -1;
+static intptr_t *mesh_topo_lookup = NULL;
+static int  mesh_topo_lookup_vert_tot = -1;
+static int  mesh_topo_lookup_edge_tot = -1;
+static int  mesh_topo_lookup_mode     = -1;
 
 /* mode is 's' start, or 'e' end, or 'u' use */
 /* if end, ob can be NULL */
-long mesh_mirrtopo_table(Object *ob, char mode)
+/* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */
+int mesh_mirrtopo_table(Object *ob, char mode)
 {
        if(mode=='u') {         /* use table */
                Mesh *me= ob->data;
                if(     (mesh_topo_lookup==NULL) ||
                        (mesh_topo_lookup_mode != ob->mode) ||
-                       (me->edit_mesh && me->edit_mesh->totvert != mesh_topo_lookup_tot) ||
-                       (me->edit_mesh==NULL && me->totvert != mesh_topo_lookup_tot)
+                       (me->edit_mesh && (me->edit_mesh->totvert != mesh_topo_lookup_vert_tot)) ||
+                       (me->edit_mesh && (me->edit_mesh->totedge != mesh_topo_lookup_edge_tot)) ||
+                       (me->edit_mesh==NULL && me->totvert != mesh_topo_lookup_vert_tot) ||
+                       (me->edit_mesh==NULL && me->totedge != mesh_topo_lookup_edge_tot)
                ) {
                        mesh_mirrtopo_table(ob, 's');
                }
@@ -899,12 +903,13 @@ long mesh_mirrtopo_table(Object *ob, char mode)
                /* editmode*/
                EditEdge *eed;
 
-               int a, last, totvert;
+               int a, last;
+               int totvert, totedge;
                int totUnique= -1, totUniqueOld= -1;
 
-               MIRRHASH_TYPE *MirrTopoHash = NULL;
-               MIRRHASH_TYPE *MirrTopoHash_Prev = NULL;
-               MirrTopoPair *MirrTopoPairs;
+               MirrTopoHash_t *MirrTopoHash = NULL;
+               MirrTopoHash_t *MirrTopoHash_Prev = NULL;
+               MirrTopoPair_t *MirrTopoPairs;
                mesh_topo_lookup_mode= ob->mode;
 
                /* reallocate if needed */
@@ -926,16 +931,20 @@ long mesh_mirrtopo_table(Object *ob, char mode)
                        totvert = me->totvert;
                }
 
-               MirrTopoHash = MEM_callocN( totvert * sizeof(MIRRHASH_TYPE), "TopoMirr" );
+               MirrTopoHash = MEM_callocN( totvert * sizeof(MirrTopoHash_t), "TopoMirr" );
 
                /* Initialize the vert-edge-user counts used to detect unique topology */
                if(em) {
-                       for(eed=em->edges.first; eed; eed= eed->next) {
+                       totedge= 0;
+
+                       for(eed=em->edges.first; eed; eed= eed->next, totedge++) {
                                MirrTopoHash[eed->v1->tmp.l]++;
                                MirrTopoHash[eed->v2->tmp.l]++;
                        }
                } else {
-                       for(a=0, medge=me->medge; a<me->totedge; a++, medge++) {
+                       totedge= me->totedge;
+
+                       for(a=0, medge=me->medge; a < me->totedge; a++, medge++) {
                                MirrTopoHash[medge->v1]++;
                                MirrTopoHash[medge->v2]++;
                        }
@@ -959,10 +968,10 @@ long mesh_mirrtopo_table(Object *ob, char mode)
                                        MirrTopoHash[medge->v2] += MirrTopoHash_Prev[medge->v1];
                                }
                        }
-                       memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MIRRHASH_TYPE) * totvert);
+                       memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MirrTopoHash_t) * totvert);
 
                        /* sort so we can count unique values */
-                       qsort(MirrTopoHash_Prev, totvert, sizeof(MIRRHASH_TYPE), MirrTopo_long_sort);
+                       qsort(MirrTopoHash_Prev, totvert, sizeof(MirrTopoHash_t), MirrTopo_long_sort);
 
                        totUnique = 1; /* account for skiping the first value */
                        for(a=1; a<totvert; a++) {
@@ -979,7 +988,7 @@ long mesh_mirrtopo_table(Object *ob, char mode)
                                totUniqueOld = totUnique;
                        }
                        /* Copy the hash calculated this iter, so we can use them next time */
-                       memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MIRRHASH_TYPE) * totvert);
+                       memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MirrTopoHash_t) * totvert);
                }
 
                /* restore eve->tmp.* */
@@ -996,7 +1005,7 @@ long mesh_mirrtopo_table(Object *ob, char mode)
                
                
                /* Hash/Index pairs are needed for sorting to find index pairs */
-               MirrTopoPairs= MEM_callocN( sizeof(MirrTopoPair) * totvert, "MirrTopoPairs");
+               MirrTopoPairs= MEM_callocN( sizeof(MirrTopoPair_t) * totvert, "MirrTopoPairs");
 
                /* since we are looping through verts, initialize these values here too */
                mesh_topo_lookup = MEM_mallocN( totvert * sizeof(long), "mesh_topo_lookup" );
@@ -1014,7 +1023,7 @@ long mesh_mirrtopo_table(Object *ob, char mode)
                        mesh_topo_lookup[a] = -1;
                }
 
-               qsort(MirrTopoPairs, totvert, sizeof(MirrTopoPair), MirrTopo_item_sort);
+               qsort(MirrTopoPairs, totvert, sizeof(MirrTopoPair_t), MirrTopo_item_sort);
 
                /* Since the loop starts at 2, we must define the last index where the hash's differ */
                last = ((totvert >= 2) && (MirrTopoPairs[0].hash == MirrTopoPairs[1].hash)) ? 0 : 1;
@@ -1026,8 +1035,8 @@ long mesh_mirrtopo_table(Object *ob, char mode)
                        if ((a==totvert) || (MirrTopoPairs[a-1].hash != MirrTopoPairs[a].hash)) {
                                if (a-last==2) {
                                        if(em) {
-                                               mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] =   (long)EM_get_vert_for_index(MirrTopoPairs[a-2].vIndex);
-                                               mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] =   (long)EM_get_vert_for_index(MirrTopoPairs[a-1].vIndex);
+                                               mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] =   (intptr_t)EM_get_vert_for_index(MirrTopoPairs[a-2].vIndex);
+                                               mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] =   (intptr_t)EM_get_vert_for_index(MirrTopoPairs[a-1].vIndex);
                                        } else {
                                                mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] =   MirrTopoPairs[a-2].vIndex;
                                                mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] =   MirrTopoPairs[a-1].vIndex;
@@ -1046,14 +1055,16 @@ long mesh_mirrtopo_table(Object *ob, char mode)
                MEM_freeN( MirrTopoHash );
                MEM_freeN( MirrTopoHash_Prev );
 
-               mesh_topo_lookup_tot = totvert;
+               mesh_topo_lookup_vert_tot = totvert;
+               mesh_topo_lookup_edge_tot = totedge;
 
        } else if(mode=='e') { /* end table */
                if (mesh_topo_lookup) {
                        MEM_freeN(mesh_topo_lookup);
                }
                mesh_topo_lookup = NULL;
-               mesh_topo_lookup_tot= -1;
+               mesh_topo_lookup_vert_tot= -1;
+               mesh_topo_lookup_edge_tot= -1;
        }
        return 0;
 }
@@ -1113,7 +1124,7 @@ static EditVert *editmesh_get_x_mirror_vert_spacial(Object *ob, EditMesh *em, fl
 
 static EditVert *editmesh_get_x_mirror_vert_topo(Object *ob, struct EditMesh *em, EditVert *eve, int index)
 {
-       long poinval;
+       intptr_t poinval;
        if (mesh_mirrtopo_table(ob, 'u')==-1)
                return NULL;
 
index 8c60a4d5868b7ba312bf6988e8b1d4a2be9bcec1..1547c5daf54c61ea5c9aa40f65372e3ce0d41bfd 100644 (file)