Merging r50192 through r50223 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Sun, 26 Aug 2012 14:12:09 +0000 (14:12 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sun, 26 Aug 2012 14:12:09 +0000 (14:12 +0000)
102 files changed:
extern/recastnavigation/Recast/Source/RecastFilter.cpp
release/scripts/modules/bpy/utils.py
release/scripts/modules/bpy_extras/anim_utils.py
release/scripts/modules/rna_xml.py
release/scripts/startup/bl_operators/wm.py
release/scripts/templates/addon_add_object.py
source/blender/blenkernel/BKE_mask.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/mask.c
source/blender/blenkernel/intern/mask_evaluate.c [new file with mode: 0644]
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/nla.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/sound.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenlib/BLI_math_base.h
source/blender/blenlib/BLI_math_rotation.h
source/blender/blenlib/BLI_pbvh.h
source/blender/blenlib/BLI_string.h
source/blender/blenlib/BLI_utildefines.h
source/blender/blenlib/intern/math_rotation.c
source/blender/blenlib/intern/pbvh.c
source/blender/blenlib/intern/string.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_250.c
source/blender/blenloader/intern/versioning_legacy.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_error.h
source/blender/bmesh/intern/bmesh_mods.c
source/blender/bmesh/intern/bmesh_mods.h
source/blender/bmesh/intern/bmesh_opdefines.c
source/blender/bmesh/intern/bmesh_operator_api.h
source/blender/bmesh/operators/bmo_connect.c
source/blender/collada/AnimationExporter.h
source/blender/collada/AnimationImporter.cpp
source/blender/collada/TransformReader.h
source/blender/collada/collada_internal.h
source/blender/editors/animation/fmodifier_ui.c
source/blender/editors/curve/editcurve.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/io/io_collada.c
source/blender/editors/mask/mask_add.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/object/object_group.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/render/render_internal.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_clip/clip_dopesheet_ops.c
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_logic/logic_window.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/uvedit/uvedit_parametrizer.c
source/blender/imbuf/IMB_imbuf.h
source/blender/imbuf/IMB_thumbs.h
source/blender/imbuf/intern/anim_movie.c
source/blender/imbuf/intern/imbuf_cocoa.m
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/imbuf/intern/util.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_tracking.c
source/blender/modifiers/intern/MOD_displace.c
source/blender/python/bmesh/bmesh_py_api.c
source/blender/python/bmesh/bmesh_py_ops.c
source/blender/python/bmesh/bmesh_py_types.c
source/blender/python/bmesh/bmesh_py_types_customdata.c
source/blender/python/bmesh/bmesh_py_types_meshdata.c
source/blender/python/bmesh/bmesh_py_types_select.c
source/blender/python/bmesh/bmesh_py_utils.c
source/blender/python/intern/bpy_rna.c
source/blender/python/mathutils/mathutils_Euler.c
source/blender/python/mathutils/mathutils_Euler.h
source/blender/python/mathutils/mathutils_Matrix.c
source/blender/quicktime/apple/qtkit_export.m
source/blender/quicktime/apple/qtkit_import.m
source/blender/render/intern/include/rayobject.h
source/blender/windowmanager/WM_api.h
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/creator.c
source/gameengine/Converter/KX_ConvertSensors.cpp
source/gameengine/Expressions/BoolValue.cpp
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
source/gameengine/Ketsji/KX_Camera.cpp
source/gameengine/SceneGraph/SG_ParentRelation.h
source/gameengine/VideoTexture/VideoFFmpeg.cpp

index bf985c3..9df71ea 100644 (file)
@@ -128,7 +128,7 @@ void rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight, const int walk
                                        rcSpan* ns = solid.spans[dx + dy*w];
                                        int nbot = -walkableClimb;
                                        int ntop = ns ? (int)ns->smin : MAX_HEIGHT;
-                                       // Skip neightbour if the gap between the spans is too small.
+                                       // Skip neighbor if the gap between the spans is too small.
                                        if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)
                                                minh = rcMin(minh, nbot - bot);
                                        
@@ -137,7 +137,7 @@ void rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight, const int walk
                                        {
                                                nbot = (int)ns->smax;
                                                ntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT;
-                                               // Skip neightbour if the gap between the spans is too small.
+                                               // Skip neighbor if the gap between the spans is too small.
                                                if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)
                                                {
                                                        minh = rcMin(minh, nbot - bot);
index 09deb33..e24b61a 100644 (file)
@@ -33,6 +33,9 @@ __all__ = (
     "refresh_script_paths",
     "register_class",
     "register_module",
+    "register_manual_map",
+    "unregister_manual_map",
+    "manual_map",
     "resource_path",
     "script_path_user",
     "script_path_pref",
@@ -56,7 +59,6 @@ import addon_utils as _addon_utils
 
 _script_module_dirs = "startup", "modules"
 
-
 def _test_import(module_name, loaded_modules):
     use_time = _bpy.app.debug_python
 
@@ -595,3 +597,40 @@ def unregister_module(module, verbose=False):
             traceback.print_exc()
     if verbose:
         print("done.\n")
+
+
+# -----------------------------------------------------------------------------
+# Manual lookups, each function has to return a basepath and a sequence
+# of...
+
+# we start with the built-in default mapping
+def _blender_default_map():
+    import sys
+    import rna_wiki_reference as ref_mod
+    ret = (ref_mod.url_manual_prefix, ref_mod.url_manual_mapping)
+    # avoid storing in memory
+    del sys.modules["rna_wiki_reference"]
+    return ret
+
+# hooks for doc lookups
+_manual_map = [_blender_default_map]
+
+def register_manual_map(manual_hook):
+    _manual_map.append(manual_hook)
+
+def unregister_manual_map(manual_hook):
+    _manual_map.remove(manual_hook)
+
+def manual_map():
+    # reverse so default is called last
+    for cb in reversed(_manual_map):
+        try:
+            prefix, url_manual_mapping = cb()
+        except:
+            print("Error calling %r" % cb)
+            import traceback
+            traceback.print_exc()
+            continue
+
+        yield prefix, url_manual_mapping
+
index c4ec805..b8d0862 100644 (file)
@@ -181,6 +181,9 @@ def bake_action(frame_start,
             while pbone.constraints:
                 pbone.constraints.remove(pbone.constraints[0])
 
+        # create compatible eulers
+        euler_prev = None
+
         for f in frame_range:
             f_step = (f - frame_start) // frame_step
             matrix = pose_info[f_step][name]["matrix_key"]
@@ -198,8 +201,19 @@ def bake_action(frame_start,
             elif rotation_mode == 'AXIS_ANGLE':
                 pbone.keyframe_insert("rotation_axis_angle", -1, f, name)
             else:  # euler, XYZ, ZXY etc
+
+                if euler_prev is not None:
+                    euler = pbone.rotation_euler.copy()
+                    euler.make_compatible(euler_prev)
+                    pbone.rotation_euler = euler
+                    euler_prev = euler
+                    del euler
+
                 pbone.keyframe_insert("rotation_euler", -1, f, name)
 
+                if euler_prev is None:
+                    euler_prev = pbone.rotation_euler.copy()
+
             pbone.keyframe_insert("scale", -1, f, name)
 
     # object. TODO. multiple objects
@@ -208,6 +222,9 @@ def bake_action(frame_start,
             while obj.constraints:
                 obj.constraints.remove(obj.constraints[0])
 
+        # create compatible eulers
+        euler_prev = None
+
         for f in frame_range:
             matrix = obj_info[(f - frame_start) // frame_step]["matrix_key"]
             obj.matrix_local = matrix
@@ -221,8 +238,18 @@ def bake_action(frame_start,
             elif rotation_mode == 'AXIS_ANGLE':
                 obj.keyframe_insert("rotation_axis_angle", -1, f)
             else:  # euler, XYZ, ZXY etc
+                if euler_prev is not None:
+                    euler = obj.rotation_euler.copy()
+                    euler.make_compatible(euler_prev)
+                    obj.rotation_euler = euler
+                    euler_prev = euler
+                    del euler
+
                 obj.keyframe_insert("rotation_euler", -1, f)
 
+                if euler_prev is None:
+                    euler_prev = obj.rotation_euler.copy()
+
             obj.keyframe_insert("scale", -1, f)
 
     scene.frame_set(frame_back)
index 5354fd1..a259a4e 100644 (file)
@@ -99,11 +99,11 @@ def rna2xml(fw=print_ln,
             subvalue = getattr(value, prop)
             subvalue_type = type(subvalue)
 
-            if subvalue_type in (int, bool, float):
+            if subvalue_type in {int, bool, float}:
                 node_attrs.append("%s=\"%s\"" % (prop, number_to_str(subvalue, subvalue_type)))
             elif subvalue_type is str:
                 node_attrs.append("%s=%s" % (prop, quoteattr(subvalue)))
-            elif subvalue_type == set:
+            elif subvalue_type is set:
                 node_attrs.append("%s=%s" % (prop, quoteattr("{" + ",".join(list(subvalue)) + "}")))
             elif subvalue is None:
                 node_attrs.append("%s=\"NONE\"" % prop)
@@ -137,7 +137,7 @@ def rna2xml(fw=print_ln,
                             # default
                             def str_recursive(s):
                                 subsubvalue_type = type(s)
-                                if subsubvalue_type in (int, float, bool):
+                                if subsubvalue_type in {int, float, bool}:
                                     return number_to_str(s, subsubvalue_type)
                                 else:
                                     return " ".join([str_recursive(si) for si in s])
index b34c427..ed4d5dd 100644 (file)
@@ -862,26 +862,24 @@ class WM_OT_doc_view_manual(Operator):
         if rna_id is None:
             return {'PASS_THROUGH'}
 
-        import rna_wiki_reference
-        rna_ref = self._find_reference(rna_id, rna_wiki_reference.url_manual_mapping)
+        url = None
 
-        if rna_ref is None:
-            self.report({'WARNING'}, "No reference available '%s', "
-                                     "Update info in %r" %
-                                     (self.doc_id, rna_wiki_reference.__file__))
-
-        import sys
-        del sys.modules["rna_wiki_reference"]
+        for prefix, url_manual_mapping in bpy.utils.manual_map():
+            rna_ref = self._find_reference(rna_id, url_manual_mapping)
+            if rna_ref is not None:
+                url = prefix + rna_ref
+                break
 
-        if rna_ref is None:
+        if url is None:
+            self.report({'WARNING'}, "No reference available %r, "
+                                     "Update info in 'rna_wiki_reference.py' "
+                                     " or callback to bpy.utils.manual_map()" %
+                                     self.doc_id)
             return {'CANCELLED'}
         else:
-            url = rna_wiki_reference.url_manual_prefix + rna_ref
-
-        import webbrowser
-        webbrowser.open(url)
-
-        return {'FINISHED'}
+            import webbrowser
+            webbrowser.open(url)
+            return {'FINISHED'}
 
 
 class WM_OT_doc_view(Operator):
index a2d7315..d7fc23f 100644 (file)
@@ -68,13 +68,23 @@ def add_object_button(self, context):
         icon='PLUGIN')
 
 
+# This allows you to right click on a button and link to the manual
+def add_object_manual_map():
+    url_manual_prefix = "http://wiki.blender.org/index.php/Doc:2.6/Manual/"
+    url_manual_mapping = (
+        ("bpy.ops.mesh.add_object", "Modeling/Objects"),
+        )
+    return url_manual_prefix, url_manual_mapping
+
+
 def register():
     bpy.utils.register_class(OBJECT_OT_add_object)
+    bpy.utils.register_manual_map(add_object_manual_map)
     bpy.types.INFO_MT_mesh_add.append(add_object_button)
 
-
 def unregister():
     bpy.utils.unregister_class(OBJECT_OT_add_object)
+    bpy.utils.unregister_manual_map(add_object_manual_map)
     bpy.types.INFO_MT_mesh_add.remove(add_object_button)
 
 
index b46aefe..a1c36d5 100644 (file)
@@ -19,7 +19,8 @@
  * All rights reserved.
  *
  * Contributor(s): Blender Foundation,
- *                 Sergey Sharybin
+ *                 Sergey Sharybin,
+ *                 Campbell Barton
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -63,29 +64,12 @@ void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, struct ListBase *
 
 /* splines */
 struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay);
-
-unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height);
-unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height);
-
-int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, const unsigned int resol);
-
-float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2];
-float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2];
-
-float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, int *tot_diff_point,
-                                                         const unsigned int resol))[2];
-void    BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point);
-float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2];
-float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, int *tot_feather_point,
-                                                                         const unsigned int resol, const int do_feather_isect))[2];
-float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height,
-                                                                      int *tot_feather_point, const int do_feather_isect))[2];
-
-float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];
-
 void BKE_mask_point_direction_switch(struct MaskSplinePoint *point);
 void BKE_mask_spline_direction_switch(struct MaskLayer *masklay, struct MaskSpline *spline);
 
+struct BezTriple *BKE_mask_spline_point_next_bezt(struct MaskSpline *spline, struct MaskSplinePoint *points_array,
+                                                  struct MaskSplinePoint *point);
+
 typedef enum {
        MASK_PROJ_NEG = -1,
        MASK_PROJ_ANY = 0,
@@ -205,6 +189,26 @@ int BKE_mask_get_duration(struct Mask *mask);
 
 #define MASK_RESOL_MAX 128
 
+/* mask_evaluate.c */
+unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height);
+unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height);
+int          BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, const unsigned int resol);
+
+float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2];
+float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2];
+
+float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, int *tot_diff_point,
+                                                         const unsigned int resol))[2];
+void    BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point);
+float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2];
+float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, int *tot_feather_point,
+                                                                         const unsigned int resol, const int do_feather_isect))[2];
+float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height,
+                                                                      int *tot_feather_point, const int do_feather_isect))[2];
+
+float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];
+
+
 /* mask_rasterize.c */
 struct MaskRasterHandle;
 typedef struct MaskRasterHandle MaskRasterHandle;
index 0a06351..afa3998 100644 (file)
@@ -101,6 +101,7 @@ set(SRC
        intern/lamp.c
        intern/lattice.c
        intern/library.c
+       intern/mask_evaluate.c
        intern/mask_rasterize.c
        intern/mask.c
        intern/material.c
index a8a3d0c..a294846 100644 (file)
@@ -541,7 +541,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
        CustomData_free(&me->pdata, me->totpoly);
 
        /* ok, this should now use new CD shapekey data,
-        * which shouuld be fed through the modifier
+        * which should be fed through the modifier
         * stack*/
        if (tmp.totvert != me->totvert && !did_shapekeys && me->key) {
                printf("%s: YEEK! this should be recoded! Shape key loss!: ID '%s'\n", __func__, tmp.id.name);
@@ -1793,7 +1793,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                {
                        finaldm->recalcTessellation(finaldm);
                }
-               /* Even if tessellation is not needed, some modifiers migh have modified CD layers
+               /* Even if tessellation is not needed, some modifiers might have modified CD layers
                 * (like mloopcol or mloopuv), hence we have to update those. */
                else if (finaldm->dirty & DM_DIRTY_TESS_CDLAYERS) {
                        /* A tessellation already exists, it should always have a CD_POLYINDEX. */
index 6e857ba..9b4f0a3 100644 (file)
@@ -282,7 +282,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
 
 /* ........ */
 
-/* Note on evaluation optimisations:
+/* Note on evaluation optimizations:
  * Optimisations currently used here play tricks with the depsgraph in order to try and 
  * evaluate as few objects as strictly necessary to get nicer performance under standard
  * production conditions. For those people who really need the accurate version, 
@@ -323,7 +323,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
 /* update scene for current frame */
 static void motionpaths_calc_update_scene(Scene *scene)
 {
-#if 1 // 'production' optimisations always on
+#if 1 // 'production' optimizations always on
        Base *base, *last = NULL;
        
        /* only stuff that moves or needs display still */
@@ -431,7 +431,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
        if (efra <= sfra) return;
        
        /* optimize the depsgraph for faster updates */
-       /* TODO: whether this is used should depend on some setting for the level of optimisations used */
+       /* TODO: whether this is used should depend on some setting for the level of optimizations used */
        motionpaths_calc_optimise_depsgraph(scene, targets);
        
        /* calculate path over requested range */
index 79ee0e9..0458579 100644 (file)
@@ -1463,7 +1463,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3])
         *
         * was 0.0000000000001, caused bug [#31333], smaller values give unstable
         * roll when toggling editmode again...
-        * No good value here, trying 0.000000001 as best compromize. :/
+        * No good value here, trying 0.000000001 as best compromise. :/
         */
        if (dot_v3v3(axis, axis) > 1.0e-9f) {
                /* if nor is *not* a multiple of target ... */
index e2bb1aa..a2f8878 100644 (file)
@@ -1165,7 +1165,7 @@ void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float
 static void forward_diff_bezier_cotangent(const float p0[3], const float p1[3], const float p2[3], const float p3[3],
                                           float p[3], int it, int stride)
 {
-       /* note that these are not purpendicular to the curve
+       /* note that these are not perpendicular to the curve
         * they need to be rotated for this,
         *
         * This could also be optimized like BKE_curve_forward_diff_bezier */
@@ -3047,29 +3047,6 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code)
        }
 }
 
-static void swapdata(void *adr1, void *adr2, int len)
-{
-
-       if (len <= 0) return;
-
-       if (len < 65) {
-               char adr[64];
-
-               memcpy(adr, adr1, len);
-               memcpy(adr1, adr2, len);
-               memcpy(adr2, adr, len);
-       }
-       else {
-               char *adr;
-
-               adr = (char *)MEM_mallocN(len, "curve swap");
-               memcpy(adr, adr1, len);
-               memcpy(adr1, adr2, len);
-               memcpy(adr2, adr, len);
-               MEM_freeN(adr);
-       }
-}
-
 void BKE_nurb_direction_switch(Nurb *nu)
 {
        BezTriple *bezt1, *bezt2;
@@ -3077,7 +3054,9 @@ void BKE_nurb_direction_switch(Nurb *nu)
        float *fp1, *fp2, *tempf;
        int a, b;
 
-       if (nu->pntsu == 1 && nu->pntsv == 1) return;
+       if (nu->pntsu == 1 && nu->pntsv == 1) {
+               return;
+       }
 
        if (nu->type == CU_BEZIER) {
                a = nu->pntsu;
@@ -3086,19 +3065,22 @@ void BKE_nurb_direction_switch(Nurb *nu)
                if (a & 1) a += 1;  /* if odd, also swap middle content */
                a /= 2;
                while (a > 0) {
-                       if (bezt1 != bezt2)
+                       if (bezt1 != bezt2) {
                                SWAP(BezTriple, *bezt1, *bezt2);
+                       }
+
+                       swap_v3_v3(bezt1->vec[0], bezt1->vec[2]);
 
-                       swapdata(bezt1->vec[0], bezt1->vec[2], 12);
-                       if (bezt1 != bezt2)
-                               swapdata(bezt2->vec[0], bezt2->vec[2], 12);
+                       if (bezt1 != bezt2) {
+                               swap_v3_v3(bezt2->vec[0], bezt2->vec[2]);
+                       }
 
                        SWAP(char, bezt1->h1, bezt1->h2);
-                       SWAP(short, bezt1->f1, bezt1->f3);
+                       SWAP(char, bezt1->f1, bezt1->f3);
 
                        if (bezt1 != bezt2) {
                                SWAP(char, bezt2->h1, bezt2->h2);
-                               SWAP(short, bezt2->f1, bezt2->f3);
+                               SWAP(char, bezt2->f1, bezt2->f3);
                                bezt1->alfa = -bezt1->alfa;
                                bezt2->alfa = -bezt2->alfa;
                        }
index 36c571a..a00bea3 100644 (file)
@@ -72,25 +72,29 @@ typedef struct LayerTypeInfo {
        const char *structname;  /* name of the struct used, for file writing */
        int structnum;     /* number of structs per element, for file writing */
 
-       /* default layer name.
+       /**
+        * default layer name.
         * note! when NULL this is a way to ensure there is only ever one item
         * see: CustomData_layertype_is_singleton() */
        const char *defaultname;
 
-       /* a function to copy count elements of this layer's data
+       /**
+        * a function to copy count elements of this layer's data
         * (deep copy if appropriate)
         * if NULL, memcpy is used
         */
        void (*copy)(const void *source, void *dest, int count);
 
-       /* a function to free any dynamically allocated components of this
+       /**
+        * a function to free any dynamically allocated components of this
         * layer's data (note the data pointer itself should not be freed)
         * size should be the size of one element of this layer's data (e.g.
         * LayerTypeInfo.size)
         */
        void (*free)(void *data, int count, int size);
 
-       /* a function to interpolate between count source elements of this
+       /**
+        * a function to interpolate between count source elements of this
         * layer's data and store the result in dest
         * if weights == NULL or sub_weights == NULL, they should default to 1
         *
@@ -98,18 +102,24 @@ typedef struct LayerTypeInfo {
         * sub_weights gives the sub-element weights for each element in sources
         *    (there should be (sub element count)^2 weights per element)
         * count gives the number of elements in sources
+        *
+        * \note in some cases \a dest pointer is in \a sources
+        *       so all functions have to take this into account and delay
+        *       applying changes while reading from sources.
+        *       See bug [#32395] - Campbell.
         */
        void (*interp)(void **sources, const float *weights, const float *sub_weights,
                       int count, void *dest);
 
-       /* a function to swap the data in corners of the element */
+       /** a function to swap the data in corners of the element */
        void (*swap)(void *data, const int *corner_indices);
 
-       /* a function to set a layer's data to default values. if NULL, the
+       /**
+        * a function to set a layer's data to default values. if NULL, the
         * default is assumed to be all zeros */
        void (*set_default)(void *data, int count);
 
-       /* functions necessary for geometry collapse*/
+       /** functions necessary for geometry collapse */
        int (*equal)(void *data1, void *data2);
        void (*multiply)(void *data, float fac);
        void (*initminmax)(void *min, void *max);
@@ -117,13 +127,13 @@ typedef struct LayerTypeInfo {
        void (*dominmax)(void *data1, void *min, void *max);
        void (*copyvalue)(void *source, void *dest);
 
-       /* a function to read data from a cdf file */
+       /** a function to read data from a cdf file */
        int (*read)(CDataFile *cdf, void *data, int count);
 
-       /* a function to write data to a cdf file */
+       /** a function to write data to a cdf file */
        int (*write)(CDataFile *cdf, void *data, int count);
 
-       /* a function to determine file size */
+       /** a function to determine file size */
        size_t (*filesize)(CDataFile *cdf, void *data, int count);
 } LayerTypeInfo;
 
@@ -243,6 +253,8 @@ static void layerInterp_mdeformvert(void **sources, const float *weights,
                }
        }
 
+       /* delay writing to the destination incase dest is in sources */
+
        /* now we know how many unique deform weights there are, so realloc */
        if (dvert->dw) MEM_freeN(dvert->dw);
 
@@ -276,6 +288,7 @@ static void layerInterp_msticky(void **sources, const float *weights,
                madd_v2_v2fl(co, mst->co, w);
        }
 
+       /* delay writing to the destination incase dest is in sources */
        mst = (MSticky *)dest;
        copy_v2_v2(mst->co, co);
 }
@@ -318,6 +331,7 @@ static void layerInterp_tface(void **sources, const float *weights,
                }
        }
 
+       /* delay writing to the destination incase dest is in sources */
        *tf = *(MTFace *)(*sources);
        memcpy(tf->uv, uv, sizeof(tf->uv));
 }
@@ -419,6 +433,8 @@ static void layerInterp_origspace_face(void **sources, const float *weights,
                }
        }
 
+       /* delay writing to the destination incase dest is in sources */
+
 #if 0 /* no need, this ONLY contains UV's */
        *osf = *(OrigSpaceFace *)(*sources);
 #endif
@@ -719,7 +735,8 @@ static void layerInterp_mloopcol(void **sources, const float *weights,
        CLAMP(col.r, 0.0f, 255.0f);
        CLAMP(col.g, 0.0f, 255.0f);
        CLAMP(col.b, 0.0f, 255.0f);
-       
+
+       /* delay writing to the destination incase dest is in sources */
        mc->r = (int)col.r;
        mc->g = (int)col.g;
        mc->b = (int)col.b;
@@ -771,8 +788,7 @@ static void layerAdd_mloopuv(void *data1, void *data2)
 static void layerInterp_mloopuv(void **sources, const float *weights,
                                 const float *sub_weights, int count, void *dest)
 {
-       MLoopUV *mluv = dest;
-       float *uv = mluv->uv;
+       float uv[2];
        int i;
 
        zero_v2(uv);
@@ -793,6 +809,9 @@ static void layerInterp_mloopuv(void **sources, const float *weights,
                        madd_v2_v2fl(uv, src->uv, weight);
                }
        }
+
+       /* delay writing to the destination incase dest is in sources */
+       copy_v2_v2(((MLoopUV *)dest)->uv, uv);
 }
 
 /* origspace is almost exact copy of mloopuv's, keep in sync */
@@ -841,8 +860,7 @@ static void layerAdd_mloop_origspace(void *data1, void *data2)
 static void layerInterp_mloop_origspace(void **sources, const float *weights,
                                         const float *sub_weights, int count, void *dest)
 {
-       OrigSpaceLoop *mluv = dest;
-       float *uv = mluv->uv;
+       float uv[2];
        int i;
 
        zero_v2(uv);
@@ -858,11 +876,14 @@ static void layerInterp_mloop_origspace(void **sources, const float *weights,
        }
        else {
                for (i = 0; i < count; i++) {
-                       float weight = weights ? weights[i] : 1;
+                       float weight = weights ? weights[i] : 1.0f;
                        OrigSpaceLoop *src = sources[i];
                        madd_v2_v2fl(uv, src->uv, weight);
                }
        }
+
+       /* delay writing to the destination incase dest is in sources */
+       copy_v2_v2(((OrigSpaceLoop *)dest)->uv, uv);
 }
 /* --- end copy */
 
@@ -907,6 +928,7 @@ static void layerInterp_mcol(void **sources, const float *weights,
                }
        }
 
+       /* delay writing to the destination incase dest is in sources */
        for (j = 0; j < 4; ++j) {
                
                /* Subdivide smooth or fractal can cause problems without clamping
@@ -949,30 +971,33 @@ static void layerDefault_mcol(void *data, int count)
 static void layerInterp_bweight(void **sources, const float *weights,
                                 const float *UNUSED(sub_weights), int count, void *dest)
 {
-       float *f = dest;
+       float f;
        float **in = (float **)sources;
        int i;
        
        if (count <= 0) return;
 
-       *f = 0.0f;
+       f = 0.0f;
 
        if (weights) {
                for (i = 0; i < count; ++i) {
-                       *f += *in[i] * weights[i];
+                       f += *in[i] * weights[i];
                }
        }
        else {
                for (i = 0; i < count; ++i) {
-                       *f += *in[i];
+                       f += *in[i];
                }
        }
+
+       /* delay writing to the destination incase dest is in sources */
+       *((float *)dest) = f;
 }
 
 static void layerInterp_shapekey(void **sources, const float *weights,
                                  const float *UNUSED(sub_weights), int count, void *dest)
 {
-       float *co = dest;
+       float co[3];
        float **in = (float **)sources;
        int i;
 
@@ -990,6 +1015,9 @@ static void layerInterp_shapekey(void **sources, const float *weights,
                        add_v3_v3(co, in[i]);
                }
        }
+
+       /* delay writing to the destination incase dest is in sources */
+       copy_v3_v3((float *)dest, co);
 }
 
 static void layerDefault_mvert_skin(void *data, int count)
@@ -1019,6 +1047,7 @@ static void layerInterp_mvert_skin(void **sources, const float *weights,
                madd_v3_v3fl(radius, vs->radius, w);
        }
 
+       /* delay writing to the destination incase dest is in sources */
        vs = dest;
        copy_v3_v3(vs->radius, radius);
        vs->flag &= ~MVERT_SKIN_ROOT;
@@ -1962,23 +1991,6 @@ void CustomData_free_elem(CustomData *data, int index, int count)
 
 #define SOURCE_BUF_SIZE 100
 
-/* This define makes it so when we are interpolating customdata,
- * the source is checked if it matches the destination.
- *
- * There are 2 ways to get around this,
- * - Each interp function could accumulate the final result in a local, stack variable,
- *   then apply the result at the end.
- *
- * - Or we can make a temp copy of the destinations custom data before applying it.
- *   This isn't so efficient but avoids having to consider feedback loop on each interp function.
- *   Since this is more of a corner case its also not worth worrying about speed too much.
- *
- * (opted for the second option for now), keeping as an ifdef since we may wan't to change how works.
- *
- * see bug [#32395] - Campbell.
- */
-#define USE_INTERP_OVERLAP_FIX
-
 void CustomData_interp(const CustomData *source, CustomData *dest,
                        int *src_indices, float *weights, float *sub_weights,
                        int count, int dest_index)
@@ -2017,9 +2029,6 @@ void CustomData_interp(const CustomData *source, CustomData *dest,
                        void *src_data = source->layers[src_i].data;
 
                        for (j = 0; j < count; ++j) {
-                               /* if this happens we need to do a temp copy, see: USE_INTERP_OVERLAP_FIX */
-                               BLI_assert(((source == dest) && (dest_index == src_indices[j])) == FALSE);
-
                                sources[j] = (char *)src_data + typeInfo->size * src_indices[j];
                        }
 
@@ -2599,11 +2608,6 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights
        void *source_buf[SOURCE_BUF_SIZE];
        void **sources = source_buf;
 
-#ifdef USE_INTERP_OVERLAP_FIX
-       /* incase there is overlap with the source */
-       void *dest_block_copy = NULL;
-#endif
-
        /* slow fallback in case we're interpolating a ridiculous number of
         * elements
         */
@@ -2617,21 +2621,7 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights
                const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
                if (typeInfo->interp) {
                        for (j = 0; j < count; ++j) {
-#ifdef USE_INTERP_OVERLAP_FIX
-                               void *src_block;
-                               if (UNLIKELY(src_blocks[j] == dest_block)) {
-                                       if (dest_block_copy == NULL) {
-                                               CustomData_bmesh_copy_data(data, data, dest_block, &dest_block_copy);
-                                       }
-                                       src_block = dest_block_copy;
-                               }
-                               else {
-                                       src_block = src_blocks[j];
-                               }
-                               sources[j] = (char *)src_block + layer->offset;
-#else
                                sources[j] = (char *)src_blocks[j] + layer->offset;
-#endif
                        }
 
                        typeInfo->interp(sources, weights, sub_weights, count,
@@ -2639,12 +2629,6 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights
                }
        }
 
-#ifdef USE_INTERP_OVERLAP_FIX
-       if (dest_block_copy) {
-               CustomData_bmesh_free_block(data, &dest_block_copy);
-       }
-#endif
-
        if (count > SOURCE_BUF_SIZE) MEM_freeN(sources);
 }
 
index 8db93f8..06807df 100644 (file)
@@ -3996,7 +3996,7 @@ void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, floa
                float force_intersect;
                float temp;
 
-               /* project force vector on the plane determined by these two neightbour points
+               /* project force vector on the plane determined by these two neighbor points
                 *  and calculate relative force angle from it*/
                cross_v3_v3v3(tangent, bNeighs[closest_id[0]].dir, bNeighs[closest_id[1]].dir);
                normalize_v3(tangent);
index 67e7743..53c12d3 100644 (file)
@@ -365,7 +365,7 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short
        /* initialize replace-flag first */
        *replace = 0;
        
-       /* sneaky optimisations (don't go through searching process if...):
+       /* sneaky optimizations (don't go through searching process if...):
         *      - keyframe to be added is to be added out of current bounds
         *      - keyframe to be added would replace one of the existing ones on bounds
         */
index a6ceba5..d7f6b6f 100644 (file)
@@ -19,7 +19,8 @@
  * All rights reserved.
  *
  * Contributor(s): Blender Foundation,
- *                 Sergey Sharybin
+ *                 Sergey Sharybin,
+ *                 Campbell Barton
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
 #include "DNA_mask_types.h"
 #include "DNA_node_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
-#include "DNA_movieclip_types.h"
-#include "DNA_tracking_types.h"
 #include "DNA_sequence_types.h"
 
 #include "BKE_curve.h"
@@ -58,7 +55,6 @@
 #include "BKE_sequencer.h"
 #include "BKE_tracking.h"
 #include "BKE_movieclip.h"
-#include "BKE_utildefines.h"
 
 static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point)
 {
@@ -90,7 +86,7 @@ static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline, MaskSplinePoi
        }
 }
 
-static BezTriple *mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point)
+BezTriple *BKE_mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point)
 {
        if (point == &points_array[spline->tot_point - 1]) {
                if (spline->flag & MASK_SPLINE_CYCLIC) {
@@ -269,588 +265,6 @@ MaskSpline *BKE_mask_spline_add(MaskLayer *masklay)
        return spline;
 }
 
-unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
-{
-       float max_segment = 0.01f;
-       unsigned int i, resol = 1;
-
-       if (width != 0 && height != 0) {
-               if (width >= height)
-                       max_segment = 1.0f / (float) width;
-               else
-                       max_segment = 1.0f / (float) height;
-       }
-
-       for (i = 0; i < spline->tot_point; i++) {
-               MaskSplinePoint *point = &spline->points[i];
-               BezTriple *bezt, *bezt_next;
-               float a, b, c, len;
-               unsigned int cur_resol;
-
-               bezt = &point->bezt;
-               bezt_next = mask_spline_point_next_bezt(spline, spline->points, point);
-
-               if (bezt_next == NULL) {
-                       break;
-               }
-
-               a = len_v3v3(bezt->vec[1], bezt->vec[2]);
-               b = len_v3v3(bezt->vec[2], bezt_next->vec[0]);
-               c = len_v3v3(bezt_next->vec[0], bezt_next->vec[1]);
-
-               len = a + b + c;
-               cur_resol = len / max_segment;
-
-               resol = MAX2(resol, cur_resol);
-
-               if (resol >= MASK_RESOL_MAX) {
-                       break;
-               }
-       }
-
-       return CLAMPIS(resol, 1, MASK_RESOL_MAX);
-}
-
-unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int height)
-{
-       const float max_segment = 0.005;
-       unsigned int resol = BKE_mask_spline_resolution(spline, width, height);
-       float max_jump = 0.0f;
-       int i;
-
-       /* avoid checking the featrher if we already hit the maximum value */
-       if (resol >= MASK_RESOL_MAX) {
-               return MASK_RESOL_MAX;
-       }
-
-       for (i = 0; i < spline->tot_point; i++) {
-               MaskSplinePoint *point = &spline->points[i];
-               float prev_u, prev_w;
-               int j;
-
-               prev_u = 0.0f;
-               prev_w = point->bezt.weight;
-
-               for (j = 0; j < point->tot_uw; j++) {
-                       const float w_diff = (point->uw[j].w - prev_w);
-                       const float u_diff = (point->uw[j].u - prev_u);
-
-                       /* avoid divide by zero and very high values,
-                        * though these get clamped eventually */
-                       if (u_diff > FLT_EPSILON) {
-                               float jump = fabsf(w_diff / u_diff);
-
-                               max_jump = MAX2(max_jump, jump);
-                       }
-
-                       prev_u = point->uw[j].u;
-                       prev_w = point->uw[j].w;
-               }
-       }
-
-       resol += max_jump / max_segment;
-
-       return CLAMPIS(resol, 1, MASK_RESOL_MAX);
-}
-
-int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const unsigned int resol)
-{
-       if (spline->flag & MASK_SPLINE_CYCLIC) {
-               return spline->tot_point * resol;
-       }
-       else {
-               return ((spline->tot_point - 1) * resol) + 1;
-       }
-}
-
-float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline,
-                                                         int *tot_diff_point,
-                                                         const unsigned int resol
-                                                         ))[2]
-{
-       MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
-
-       MaskSplinePoint *point, *prev;
-       float (*diff_points)[2], (*fp)[2];
-       const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol);
-       int a;
-
-       if (spline->tot_point <= 1) {
-               /* nothing to differentiate */
-               *tot_diff_point = 0;
-               return NULL;
-       }
-
-       /* len+1 because of 'forward_diff_bezier' function */
-       *tot_diff_point = tot;
-       diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets");
-
-       a = spline->tot_point - 1;
-       if (spline->flag & MASK_SPLINE_CYCLIC)
-               a++;
-
-       prev = points_array;
-       point = prev + 1;
-
-       while (a--) {
-               BezTriple *prevbezt;
-               BezTriple *bezt;
-               int j;
-
-               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
-                       point = points_array;
-
-               prevbezt = &prev->bezt;
-               bezt = &point->bezt;
-
-               for (j = 0; j < 2; j++) {
-                       BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j],
-                                                     bezt->vec[0][j], bezt->vec[1][j],
-                                                     &(*fp)[j], resol, 2 * sizeof(float));
-               }
-
-               fp += resol;
-
-               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) {
-                       copy_v2_v2(*fp, bezt->vec[1]);
-               }
-
-               prev = point;
-               point++;
-       }
-
-       return diff_points;
-}
-
-float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height,
-                                                      int *tot_diff_point
-                                                      ))[2]
-{
-       int unsigned resol = BKE_mask_spline_resolution(spline, width, height);
-
-       return BKE_mask_spline_differentiate_with_resolution_ex(spline, tot_diff_point, resol);
-}
-
-float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2]
-{
-       return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point);
-}
-
-/* ** feather points self-intersection collapse routine ** */
-
-typedef struct FeatherEdgesBucket {
-       int tot_segment;
-       int (*segments)[2];
-       int alloc_segment;
-} FeatherEdgesBucket;
-
-static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int end)
-{
-       const int alloc_delta = 256;
-
-       if (bucket->tot_segment >= bucket->alloc_segment) {
-               if (!bucket->segments) {
-                       bucket->segments = MEM_callocN(alloc_delta * sizeof(*bucket->segments), "feather bucket segments");
-               }
-               else {
-                       bucket->segments = MEM_reallocN(bucket->segments,
-                                       (alloc_delta + bucket->tot_segment) * sizeof(*bucket->segments));
-               }
-
-               bucket->alloc_segment += alloc_delta;
-       }
-
-       bucket->segments[bucket->tot_segment][0] = start;
-       bucket->segments[bucket->tot_segment][1] = end;
-
-       bucket->tot_segment++;
-}
-
-static void feather_bucket_check_intersect(float (*feather_points)[2], int tot_feather_point, FeatherEdgesBucket *bucket,
-                                           int cur_a, int cur_b)
-{
-       int i;
-
-       float *v1 = (float *) feather_points[cur_a];
-       float *v2 = (float *) feather_points[cur_b];
-
-       for (i = 0; i < bucket->tot_segment; i++) {
-               int check_a = bucket->segments[i][0];
-               int check_b = bucket->segments[i][1];
-
-               float *v3 = (float *) feather_points[check_a];
-               float *v4 = (float *) feather_points[check_b];
-
-               if (check_a >= cur_a - 1 || cur_b == check_a)
-                       continue;
-
-               if (isect_seg_seg_v2(v1, v2, v3, v4)) {
-                       int k;
-                       float p[2];
-                       float min_a[2], max_a[2];
-                       float min_b[2], max_b[2];
-
-                       isect_seg_seg_v2_point(v1, v2, v3, v4, p);
-
-                       INIT_MINMAX2(min_a, max_a);
-                       INIT_MINMAX2(min_b, max_b);
-
-                       /* collapse loop with smaller AABB */
-                       for (k = 0; k < tot_feather_point; k++) {
-                               if (k >= check_b && k <= cur_a) {
-                                       DO_MINMAX2(feather_points[k], min_a, max_a);
-                               }
-                               else {
-                                       DO_MINMAX2(feather_points[k], min_b, max_b);
-                               }
-                       }
-
-                       if (max_a[0] - min_a[0] < max_b[0] - min_b[0] ||
-                           max_a[1] - min_a[1] < max_b[1] - min_b[1])
-                       {
-                               for (k = check_b; k <= cur_a; k++) {
-                                       copy_v2_v2(feather_points[k], p);
-                               }
-                       }
-                       else {
-                               for (k = 0; k <= check_a; k++) {
-                                       copy_v2_v2(feather_points[k], p);
-                               }
-
-                               if (cur_b != 0) {
-                                       for (k = cur_b; k < tot_feather_point; k++) {
-                                               copy_v2_v2(feather_points[k], p);
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
-static int feather_bucket_index_from_coord(float co[2], const float min[2], const float bucket_scale[2],
-                                           const int buckets_per_side)
-{
-       int x = (int) ((co[0] - min[0]) * bucket_scale[0]);
-       int y = (int) ((co[1] - min[1]) * bucket_scale[1]);
-
-       if (x == buckets_per_side)
-               x--;
-
-       if (y == buckets_per_side)
-               y--;
-
-       return y * buckets_per_side + x;
-}
-
-static void feather_bucket_get_diagonal(FeatherEdgesBucket *buckets, int start_bucket_index, int end_bucket_index,
-                                        int buckets_per_side, FeatherEdgesBucket **diagonal_bucket_a_r,
-                                        FeatherEdgesBucket **diagonal_bucket_b_r)
-{
-       int start_bucket_x = start_bucket_index % buckets_per_side;
-       int start_bucket_y = start_bucket_index / buckets_per_side;
-
-       int end_bucket_x = end_bucket_index % buckets_per_side;
-       int end_bucket_y = end_bucket_index / buckets_per_side;
-
-       int diagonal_bucket_a_index = start_bucket_y * buckets_per_side + end_bucket_x;
-       int diagonal_bucket_b_index = end_bucket_y * buckets_per_side + start_bucket_x;
-
-       *diagonal_bucket_a_r = &buckets[diagonal_bucket_a_index];
-       *diagonal_bucket_b_r = &buckets[diagonal_bucket_b_index];
-}
-
-void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point)
-{
-#define BUCKET_INDEX(co) \
-       feather_bucket_index_from_coord(co, min, bucket_scale, buckets_per_side)
-
-       int buckets_per_side, tot_bucket;
-       float bucket_size, bucket_scale[2];
-
-       FeatherEdgesBucket *buckets;
-
-       int i;
-       float min[2], max[2];
-       float max_delta_x = -1.0f, max_delta_y = -1.0f, max_delta;
-
-       if (tot_feather_point < 4) {
-               /* self-intersection works only for quads at least,
-                * in other cases polygon can't be self-intersecting anyway
-                */
-
-               return;
-       }
-
-       /* find min/max corners of mask to build buckets in that space */
-       INIT_MINMAX2(min, max);
-
-       for (i = 0; i < tot_feather_point; i++) {
-               int next = i + 1;
-               float delta;
-
-               DO_MINMAX2(feather_points[i], min, max);
-
-               if (next == tot_feather_point) {
-                       if (spline->flag & MASK_SPLINE_CYCLIC)
-                               next = 0;
-                       else
-                               break;
-               }
-
-               delta = fabsf(feather_points[i][0] - feather_points[next][0]);
-               if (delta > max_delta_x)
-                       max_delta_x = delta;
-
-               delta = fabsf(feather_points[i][1] - feather_points[next][1]);
-               if (delta > max_delta_y)
-                       max_delta_y = delta;
-       }
-
-       /* prevent divisionsby zero by ensuring bounding box is not collapsed */
-       if (max[0] - min[0] < FLT_EPSILON) {
-               max[0] += 0.01f;
-               min[0] -= 0.01f;
-       }
-
-       if (max[1] - min[1] < FLT_EPSILON) {
-               max[1] += 0.01f;
-               min[1] -= 0.01f;
-       }
-
-       /* use dynamically calculated buckets per side, so we likely wouldn't
-        * run into a situation when segment doesn't fit two buckets which is
-        * pain collecting candidates for intersection
-        */
-
-       max_delta_x /= max[0] - min[0];
-       max_delta_y /= max[1] - min[1];
-
-       max_delta = MAX2(max_delta_x, max_delta_y);
-
-       buckets_per_side = MIN2(512, 0.9f / max_delta);
-
-       if (buckets_per_side == 0) {
-               /* happens when some segment fills the whole bounding box across some of dimension */
-
-               buckets_per_side = 1;
-       }
-
-       tot_bucket = buckets_per_side * buckets_per_side;
-       bucket_size = 1.0f / buckets_per_side;
-
-       /* pre-compute multipliers, to save mathematical operations in loops */
-       bucket_scale[0] = 1.0f / ((max[0] - min[0]) * bucket_size);
-       bucket_scale[1] = 1.0f / ((max[1] - min[1]) * bucket_size);
-
-       /* fill in buckets' edges */
-       buckets = MEM_callocN(sizeof(FeatherEdgesBucket) * tot_bucket, "feather buckets");
-
-       for (i = 0; i < tot_feather_point; i++) {
-               int start = i, end = i + 1;
-               int start_bucket_index, end_bucket_index;
-
-               if (end == tot_feather_point) {
-                       if (spline->flag & MASK_SPLINE_CYCLIC)
-                               end = 0;
-                       else
-                               break;
-               }
-
-               start_bucket_index = BUCKET_INDEX(feather_points[start]);
-               end_bucket_index = BUCKET_INDEX(feather_points[end]);
-
-               feather_bucket_add_edge(&buckets[start_bucket_index], start, end);
-
-               if (start_bucket_index != end_bucket_index) {
-                       FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index];
-                       FeatherEdgesBucket *diagonal_bucket_a, *diagonal_bucket_b;
-
-                       feather_bucket_get_diagonal(buckets, start_bucket_index, end_bucket_index, buckets_per_side,
-                                                   &diagonal_bucket_a, &diagonal_bucket_b);
-
-                       feather_bucket_add_edge(end_bucket, start, end);
-                       feather_bucket_add_edge(diagonal_bucket_a, start, end);
-                       feather_bucket_add_edge(diagonal_bucket_a, start, end);
-               }
-       }
-
-       /* check all edges for intersection with edges from their buckets */
-       for (i = 0; i < tot_feather_point; i++) {
-               int cur_a = i, cur_b = i + 1;
-               int start_bucket_index, end_bucket_index;
-
-               FeatherEdgesBucket *start_bucket;
-
-               if (cur_b == tot_feather_point)
-                       cur_b = 0;
-
-               start_bucket_index = BUCKET_INDEX(feather_points[cur_a]);
-               end_bucket_index = BUCKET_INDEX(feather_points[cur_b]);
-
-               start_bucket = &buckets[start_bucket_index];
-
-               feather_bucket_check_intersect(feather_points, tot_feather_point, start_bucket, cur_a, cur_b);
-
-               if (start_bucket_index != end_bucket_index) {
-                       FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index];
-                       FeatherEdgesBucket *diagonal_bucket_a, *diagonal_bucket_b;
-
-                       feather_bucket_get_diagonal(buckets, start_bucket_index, end_bucket_index, buckets_per_side,
-                                                   &diagonal_bucket_a, &diagonal_bucket_b);
-
-                       feather_bucket_check_intersect(feather_points, tot_feather_point, end_bucket, cur_a, cur_b);
-                       feather_bucket_check_intersect(feather_points, tot_feather_point, diagonal_bucket_a, cur_a, cur_b);
-                       feather_bucket_check_intersect(feather_points, tot_feather_point, diagonal_bucket_b, cur_a, cur_b);
-               }
-       }
-
-       /* free buckets */
-       for (i = 0; i < tot_bucket; i++) {
-               if (buckets[i].segments)
-                       MEM_freeN(buckets[i].segments);
-       }
-
-       MEM_freeN(buckets);
-
-#undef BUCKET_INDEX
-}
-
-/**
- * values align with #BKE_mask_spline_differentiate_with_resolution_ex
- * when \a resol arguments match.
- */
-float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline,
-                                                                         int *tot_feather_point,
-                                                                         const unsigned int resol,
-                                                                         const int do_feather_isect
-                                                                         ))[2]
-{
-       MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
-       MaskSplinePoint *point, *prev;
-       float (*feather)[2], (*fp)[2];
-
-       const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol);
-       int a;
-
-       /* tot+1 because of 'forward_diff_bezier' function */
-       feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points");
-
-       a = spline->tot_point - 1;
-       if (spline->flag & MASK_SPLINE_CYCLIC)
-               a++;
-
-       prev = points_array;
-       point = prev + 1;
-
-       while (a--) {
-               /* BezTriple *prevbezt; */  /* UNUSED */
-               /* BezTriple *bezt; */      /* UNUSED */
-               int j;
-
-               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
-                       point = points_array;
-
-
-               /* prevbezt = &prev->bezt; */
-               /* bezt = &point->bezt; */
-
-               for (j = 0; j < resol; j++, fp++) {
-                       float u = (float) j / resol, weight;
-                       float co[2], n[2];
-
-                       /* TODO - these calls all calculate similar things
-                        * could be unified for some speed */
-                       BKE_mask_point_segment_co(spline, prev, u, co);
-                       BKE_mask_point_normal(spline, prev, u, n);
-                       weight = BKE_mask_point_weight(spline, prev, u);
-
-                       madd_v2_v2v2fl(*fp, co, n, weight);
-               }
-
-               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) {
-                       float u = 1.0f, weight;
-                       float co[2], n[2];
-
-                       BKE_mask_point_segment_co(spline, prev, u, co);
-                       BKE_mask_point_normal(spline, prev, u, n);
-                       weight = BKE_mask_point_weight(spline, prev, u);
-
-                       madd_v2_v2v2fl(*fp, co, n, weight);
-               }
-
-               prev = point;
-               point++;
-       }
-
-       *tot_feather_point = tot;
-
-       if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) {
-               BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot);
-       }
-
-       return feather;
-}
-
-float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height,
-                                                                      int *tot_feather_point, const int do_feather_isect))[2]
-{
-       unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height);
-
-       return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, do_feather_isect);
-}
-
-float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2]
-{
-       return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point, TRUE);
-}
-
-float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2]
-{
-       MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
-
-       int i, tot = 0;
-       float (*feather)[2], (*fp)[2];
-
-       /* count */
-       for (i = 0; i < spline->tot_point; i++) {
-               MaskSplinePoint *point = &points_array[i];
-
-               tot += point->tot_uw + 1;
-       }
-
-       /* create data */
-       feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather points");
-
-       for (i = 0; i < spline->tot_point; i++) {
-               MaskSplinePoint *point = &points_array[i];
-               BezTriple *bezt = &point->bezt;
-               float weight, n[2];
-               int j;
-
-               BKE_mask_point_normal(spline, point, 0.0f, n);
-               weight = BKE_mask_point_weight(spline, point, 0.0f);
-
-               madd_v2_v2v2fl(*fp, bezt->vec[1], n, weight);
-               fp++;
-
-               for (j = 0; j < point->tot_uw; j++) {
-                       float u = point->uw[j].u;
-                       float co[2];
-
-                       BKE_mask_point_segment_co(spline, point, u, co);
-                       BKE_mask_point_normal(spline, point, u, n);
-                       weight = BKE_mask_point_weight(spline, point, u);
-
-                       madd_v2_v2v2fl(*fp, co, n, weight);
-                       fp++;
-               }
-       }
-
-       *tot_feather_point = tot;
-
-       return feather;
-}
-
 void BKE_mask_point_direction_switch(MaskSplinePoint *point)
 {
        const int tot_uw = point->tot_uw;
@@ -1111,7 +525,7 @@ float *BKE_mask_point_segment_diff_with_resolution(MaskSpline *spline, MaskSplin
        int j, resol = BKE_mask_spline_resolution(spline, width, height);
 
        bezt = &point->bezt;
-       bezt_next = mask_spline_point_next_bezt(spline, points_array, point);
+       bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
 
        if (!bezt_next)
                return NULL;
@@ -1143,7 +557,7 @@ void BKE_mask_point_segment_co(MaskSpline *spline, MaskSplinePoint *point, float
        BezTriple *bezt = &point->bezt, *bezt_next;
        float q0[2], q1[2], q2[2], r0[2], r1[2];
 
-       bezt_next = mask_spline_point_next_bezt(spline, points_array, point);
+       bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
 
        if (!bezt_next) {
                copy_v2_v2(co, bezt->vec[1]);
@@ -1167,7 +581,7 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u,
        BezTriple *bezt = &point->bezt, *bezt_next;
        float q0[2], q1[2], q2[2], r0[2], r1[2], vec[2];
 
-       bezt_next = mask_spline_point_next_bezt(spline, points_array, point);
+       bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
 
        if (!bezt_next) {
                BKE_mask_point_handle(point, vec);
@@ -1202,7 +616,7 @@ float BKE_mask_point_weight_scalar(MaskSpline *spline, MaskSplinePoint *point, c
        MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point);
        BezTriple *bezt = &point->bezt, *bezt_next;
 
-       bezt_next = mask_spline_point_next_bezt(spline, points_array, point);
+       bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
 
        if (!bezt_next) {
                return bezt->weight;
@@ -1223,7 +637,7 @@ float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const fl
        MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point);
        BezTriple *bezt = &point->bezt, *bezt_next;
 
-       bezt_next = mask_spline_point_next_bezt(spline, points_array, point);
+       bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
 
        if (!bezt_next) {
                return bezt->weight;
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
new file mode 100644 (file)
index 0000000..4480fbf
--- /dev/null
@@ -0,0 +1,647 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation,
+ *                 Sergey Sharybin,
+ *                 Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/mask_evaluate.c
+ *  \ingroup bke
+ *
+ * Functions for evaluating the mask beziers into points for the outline and feather.
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+#include "DNA_mask_types.h"
+#include "DNA_node_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_movieclip_types.h"
+#include "DNA_tracking_types.h"
+#include "DNA_sequence_types.h"
+
+#include "BKE_curve.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_mask.h"
+#include "BKE_node.h"
+#include "BKE_sequencer.h"
+#include "BKE_tracking.h"
+#include "BKE_movieclip.h"
+#include "BKE_utildefines.h"
+
+
+unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
+{
+       float max_segment = 0.01f;
+       unsigned int i, resol = 1;
+
+       if (width != 0 && height != 0) {
+               if (width >= height)
+                       max_segment = 1.0f / (float) width;
+               else
+                       max_segment = 1.0f / (float) height;
+       }
+
+       for (i = 0; i < spline->tot_point; i++) {
+               MaskSplinePoint *point = &spline->points[i];
+               BezTriple *bezt, *bezt_next;
+               float a, b, c, len;
+               unsigned int cur_resol;
+
+               bezt = &point->bezt;
+               bezt_next = BKE_mask_spline_point_next_bezt(spline, spline->points, point);
+
+               if (bezt_next == NULL) {
+                       break;
+               }
+
+               a = len_v3v3(bezt->vec[1], bezt->vec[2]);
+               b = len_v3v3(bezt->vec[2], bezt_next->vec[0]);
+               c = len_v3v3(bezt_next->vec[0], bezt_next->vec[1]);
+
+               len = a + b + c;
+               cur_resol = len / max_segment;
+
+               resol = MAX2(resol, cur_resol);
+
+               if (resol >= MASK_RESOL_MAX) {
+                       break;
+               }
+       }
+
+       return CLAMPIS(resol, 1, MASK_RESOL_MAX);
+}
+
+unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int height)
+{
+       const float max_segment = 0.005;
+       unsigned int resol = BKE_mask_spline_resolution(spline, width, height);
+       float max_jump = 0.0f;
+       int i;
+
+       /* avoid checking the featrher if we already hit the maximum value */
+       if (resol >= MASK_RESOL_MAX) {
+               return MASK_RESOL_MAX;
+       }
+
+       for (i = 0; i < spline->tot_point; i++) {
+               MaskSplinePoint *point = &spline->points[i];
+               float prev_u, prev_w;
+               int j;
+
+               prev_u = 0.0f;
+               prev_w = point->bezt.weight;
+
+               for (j = 0; j < point->tot_uw; j++) {
+                       const float w_diff = (point->uw[j].w - prev_w);
+                       const float u_diff = (point->uw[j].u - prev_u);
+
+                       /* avoid divide by zero and very high values,
+                        * though these get clamped eventually */
+                       if (u_diff > FLT_EPSILON) {
+                               float jump = fabsf(w_diff / u_diff);
+
+                               max_jump = MAX2(max_jump, jump);
+                       }
+
+                       prev_u = point->uw[j].u;
+                       prev_w = point->uw[j].w;
+               }
+       }
+
+       resol += max_jump / max_segment;
+
+       return CLAMPIS(resol, 1, MASK_RESOL_MAX);
+}
+
+int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const unsigned int resol)
+{
+       if (spline->flag & MASK_SPLINE_CYCLIC) {
+               return spline->tot_point * resol;
+       }
+       else {
+               return ((spline->tot_point - 1) * resol) + 1;
+       }
+}
+
+float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline,
+                                                         int *tot_diff_point,
+                                                         const unsigned int resol
+                                                         ))[2]
+{
+       MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
+
+       MaskSplinePoint *point, *prev;
+       float (*diff_points)[2], (*fp)[2];
+       const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol);
+       int a;
+
+       if (spline->tot_point <= 1) {
+               /* nothing to differentiate */
+               *tot_diff_point = 0;
+               return NULL;
+       }
+
+       /* len+1 because of 'forward_diff_bezier' function */
+       *tot_diff_point = tot;
+       diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets");
+
+       a = spline->tot_point - 1;
+       if (spline->flag & MASK_SPLINE_CYCLIC)
+               a++;
+
+       prev = points_array;
+       point = prev + 1;
+
+       while (a--) {
+               BezTriple *prevbezt;
+               BezTriple *bezt;
+               int j;
+
+               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
+                       point = points_array;
+
+               prevbezt = &prev->bezt;
+               bezt = &point->bezt;
+
+               for (j = 0; j < 2; j++) {
+                       BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j],
+                                                     bezt->vec[0][j], bezt->vec[1][j],
+                                                     &(*fp)[j], resol, 2 * sizeof(float));
+               }
+
+               fp += resol;
+
+               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) {
+                       copy_v2_v2(*fp, bezt->vec[1]);
+               }
+
+               prev = point;
+               point++;
+       }
+
+       return diff_points;
+}
+
+float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height,
+                                                      int *tot_diff_point
+                                                      ))[2]
+{
+       int unsigned resol = BKE_mask_spline_resolution(spline, width, height);
+
+       return BKE_mask_spline_differentiate_with_resolution_ex(spline, tot_diff_point, resol);
+}
+
+float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2]
+{
+       return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point);
+}
+
+/* ** feather points self-intersection collapse routine ** */
+
+typedef struct FeatherEdgesBucket {
+       int tot_segment;
+       int (*segments)[2];
+       int alloc_segment;
+} FeatherEdgesBucket;
+
+static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int end)
+{
+       const int alloc_delta = 256;
+
+       if (bucket->tot_segment >= bucket->alloc_segment) {
+               if (!bucket->segments) {
+                       bucket->segments = MEM_callocN(alloc_delta * sizeof(*bucket->segments), "feather bucket segments");
+               }
+               else {
+                       bucket->segments = MEM_reallocN(bucket->segments,
+                                       (alloc_delta + bucket->tot_segment) * sizeof(*bucket->segments));
+               }
+
+               bucket->alloc_segment += alloc_delta;
+       }
+
+       bucket->segments[bucket->tot_segment][0] = start;
+       bucket->segments[bucket->tot_segment][1] = end;
+
+       bucket->tot_segment++;
+}
+
+static void feather_bucket_check_intersect(float (*feather_points)[2], int tot_feather_point, FeatherEdgesBucket *bucket,
+                                           int cur_a, int cur_b)
+{
+       int i;
+
+       float *v1 = (float *) feather_points[cur_a];
+       float *v2 = (float *) feather_points[cur_b];
+
+       for (i = 0; i < bucket->tot_segment; i++) {
+               int check_a = bucket->segments[i][0];
+               int check_b = bucket->segments[i][1];
+
+               float *v3 = (float *) feather_points[check_a];
+               float *v4 = (float *) feather_points[check_b];
+
+               if (check_a >= cur_a - 1 || cur_b == check_a)
+                       continue;
+
+               if (isect_seg_seg_v2(v1, v2, v3, v4)) {
+                       int k;
+                       float p[2];
+                       float min_a[2], max_a[2];
+                       float min_b[2], max_b[2];
+
+                       isect_seg_seg_v2_point(v1, v2, v3, v4, p);
+
+                       INIT_MINMAX2(min_a, max_a);
+                       INIT_MINMAX2(min_b, max_b);
+
+                       /* collapse loop with smaller AABB */
+                       for (k = 0; k < tot_feather_point; k++) {
+                               if (k >= check_b && k <= cur_a) {
+                                       DO_MINMAX2(feather_points[k], min_a, max_a);
+                               }
+                               else {
+                                       DO_MINMAX2(feather_points[k], min_b, max_b);
+                               }
+                       }
+
+                       if (max_a[0] - min_a[0] < max_b[0] - min_b[0] ||
+                           max_a[1] - min_a[1] < max_b[1] - min_b[1])
+                       {
+                               for (k = check_b; k <= cur_a; k++) {
+                                       copy_v2_v2(feather_points[k], p);
+                               }
+                       }
+                       else {
+                               for (k = 0; k <= check_a; k++) {
+                                       copy_v2_v2(feather_points[k], p);
+                               }
+
+                               if (cur_b != 0) {
+                                       for (k = cur_b; k < tot_feather_point; k++) {
+                                               copy_v2_v2(feather_points[k], p);
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+static int feather_bucket_index_from_coord(float co[2], const float min[2], const float bucket_scale[2],
+                                           const int buckets_per_side)
+{
+       int x = (int) ((co[0] - min[0]) * bucket_scale[0]);
+       int y = (int) ((co[1] - min[1]) * bucket_scale[1]);
+
+       if (x == buckets_per_side)
+               x--;
+
+       if (y == buckets_per_side)
+               y--;
+
+       return y * buckets_per_side + x;
+}
+
+static void feather_bucket_get_diagonal(FeatherEdgesBucket *buckets, int start_bucket_index, int end_bucket_index,
+                                        int buckets_per_side, FeatherEdgesBucket **diagonal_bucket_a_r,
+                                        FeatherEdgesBucket **diagonal_bucket_b_r)
+{
+       int start_bucket_x = start_bucket_index % buckets_per_side;
+       int start_bucket_y = start_bucket_index / buckets_per_side;
+
+       int end_bucket_x = end_bucket_index % buckets_per_side;
+       int end_bucket_y = end_bucket_index / buckets_per_side;
+
+       int diagonal_bucket_a_index = start_bucket_y * buckets_per_side + end_bucket_x;
+       int diagonal_bucket_b_index = end_bucket_y * buckets_per_side + start_bucket_x;
+
+       *diagonal_bucket_a_r = &buckets[diagonal_bucket_a_index];
+       *diagonal_bucket_b_r = &buckets[diagonal_bucket_b_index];
+}
+
+void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point)
+{
+#define BUCKET_INDEX(co) \
+       feather_bucket_index_from_coord(co, min, bucket_scale, buckets_per_side)
+
+       int buckets_per_side, tot_bucket;
+       float bucket_size, bucket_scale[2];
+
+       FeatherEdgesBucket *buckets;
+
+       int i;
+       float min[2], max[2];
+       float max_delta_x = -1.0f, max_delta_y = -1.0f, max_delta;
+
+       if (tot_feather_point < 4) {
+               /* self-intersection works only for quads at least,
+                * in other cases polygon can't be self-intersecting anyway
+                */
+
+               return;
+       }
+
+       /* find min/max corners of mask to build buckets in that space */
+       INIT_MINMAX2(min, max);
+
+       for (i = 0; i < tot_feather_point; i++) {
+               int next = i + 1;
+               float delta;
+
+               DO_MINMAX2(feather_points[i], min, max);
+
+               if (next == tot_feather_point) {
+                       if (spline->flag & MASK_SPLINE_CYCLIC)
+                               next = 0;
+                       else
+                               break;
+               }
+
+               delta = fabsf(feather_points[i][0] - feather_points[next][0]);
+               if (delta > max_delta_x)
+                       max_delta_x = delta;
+
+               delta = fabsf(feather_points[i][1] - feather_points[next][1]);
+               if (delta > max_delta_y)
+                       max_delta_y = delta;
+       }
+
+       /* prevent divisionsby zero by ensuring bounding box is not collapsed */
+       if (max[0] - min[0] < FLT_EPSILON) {
+               max[0] += 0.01f;
+               min[0] -= 0.01f;
+       }
+
+       if (max[1] - min[1] < FLT_EPSILON) {
+               max[1] += 0.01f;
+               min[1] -= 0.01f;
+       }
+
+       /* use dynamically calculated buckets per side, so we likely wouldn't
+        * run into a situation when segment doesn't fit two buckets which is
+        * pain collecting candidates for intersection
+        */
+
+       max_delta_x /= max[0] - min[0];
+       max_delta_y /= max[1] - min[1];
+
+       max_delta = MAX2(max_delta_x, max_delta_y);
+
+       buckets_per_side = MIN2(512, 0.9f / max_delta);
+
+       if (buckets_per_side == 0) {
+               /* happens when some segment fills the whole bounding box across some of dimension */
+
+               buckets_per_side = 1;
+       }
+
+       tot_bucket = buckets_per_side * buckets_per_side;
+       bucket_size = 1.0f / buckets_per_side;
+
+       /* pre-compute multipliers, to save mathematical operations in loops */
+       bucket_scale[0] = 1.0f / ((max[0] - min[0]) * bucket_size);
+       bucket_scale[1] = 1.0f / ((max[1] - min[1]) * bucket_size);
+
+       /* fill in buckets' edges */
+       buckets = MEM_callocN(sizeof(FeatherEdgesBucket) * tot_bucket, "feather buckets");
+
+       for (i = 0; i < tot_feather_point; i++) {
+               int start = i, end = i + 1;
+               int start_bucket_index, end_bucket_index;
+
+               if (end == tot_feather_point) {
+                       if (spline->flag & MASK_SPLINE_CYCLIC)
+                               end = 0;
+                       else
+                               break;
+               }
+
+               start_bucket_index = BUCKET_INDEX(feather_points[start]);
+               end_bucket_index = BUCKET_INDEX(feather_points[end]);
+
+               feather_bucket_add_edge(&buckets[start_bucket_index], start, end);
+
+               if (start_bucket_index != end_bucket_index) {
+                       FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index];
+                       FeatherEdgesBucket *diagonal_bucket_a, *diagonal_bucket_b;
+
+                       feather_bucket_get_diagonal(buckets, start_bucket_index, end_bucket_index, buckets_per_side,
+                                                   &diagonal_bucket_a, &diagonal_bucket_b);
+
+                       feather_bucket_add_edge(end_bucket, start, end);
+                       feather_bucket_add_edge(diagonal_bucket_a, start, end);
+                       feather_bucket_add_edge(diagonal_bucket_a, start, end);
+               }
+       }
+
+       /* check all edges for intersection with edges from their buckets */
+       for (i = 0; i < tot_feather_point; i++) {
+               int cur_a = i, cur_b = i + 1;
+               int start_bucket_index, end_bucket_index;
+
+               FeatherEdgesBucket *start_bucket;
+
+               if (cur_b == tot_feather_point)
+                       cur_b = 0;
+
+               start_bucket_index = BUCKET_INDEX(feather_points[cur_a]);
+               end_bucket_index = BUCKET_INDEX(feather_points[cur_b]);
+
+               start_bucket = &buckets[start_bucket_index];
+
+               feather_bucket_check_intersect(feather_points, tot_feather_point, start_bucket, cur_a, cur_b);
+
+               if (start_bucket_index != end_bucket_index) {
+                       FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index];
+                       FeatherEdgesBucket *diagonal_bucket_a, *diagonal_bucket_b;
+
+                       feather_bucket_get_diagonal(buckets, start_bucket_index, end_bucket_index, buckets_per_side,
+                                                   &diagonal_bucket_a, &diagonal_bucket_b);
+
+                       feather_bucket_check_intersect(feather_points, tot_feather_point, end_bucket, cur_a, cur_b);
+                       feather_bucket_check_intersect(feather_points, tot_feather_point, diagonal_bucket_a, cur_a, cur_b);
+                       feather_bucket_check_intersect(feather_points, tot_feather_point, diagonal_bucket_b, cur_a, cur_b);
+               }
+       }
+
+       /* free buckets */
+       for (i = 0; i < tot_bucket; i++) {
+               if (buckets[i].segments)
+                       MEM_freeN(buckets[i].segments);
+       }
+
+       MEM_freeN(buckets);
+
+#undef BUCKET_INDEX
+}
+
+/**
+ * values align with #BKE_mask_spline_differentiate_with_resolution_ex
+ * when \a resol arguments match.
+ */
+float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline,
+                                                                         int *tot_feather_point,
+                                                                         const unsigned int resol,
+                                                                         const int do_feather_isect
+                                                                         ))[2]
+{
+       MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
+       MaskSplinePoint *point, *prev;
+       float (*feather)[2], (*fp)[2];
+
+       const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol);
+       int a;
+
+       /* tot+1 because of 'forward_diff_bezier' function */
+       feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points");
+
+       a = spline->tot_point - 1;
+       if (spline->flag & MASK_SPLINE_CYCLIC)
+               a++;
+
+       prev = points_array;
+       point = prev + 1;
+
+       while (a--) {
+               /* BezTriple *prevbezt; */  /* UNUSED */
+               /* BezTriple *bezt; */      /* UNUSED */
+               int j;
+
+               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
+                       point = points_array;
+
+
+               /* prevbezt = &prev->bezt; */
+               /* bezt = &point->bezt; */
+
+               for (j = 0; j < resol; j++, fp++) {
+                       float u = (float) j / resol, weight;
+                       float co[2], n[2];
+
+                       /* TODO - these calls all calculate similar things
+                        * could be unified for some speed */
+                       BKE_mask_point_segment_co(spline, prev, u, co);
+                       BKE_mask_point_normal(spline, prev, u, n);
+                       weight = BKE_mask_point_weight(spline, prev, u);
+
+                       madd_v2_v2v2fl(*fp, co, n, weight);
+               }
+
+               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) {
+                       float u = 1.0f, weight;
+                       float co[2], n[2];
+
+                       BKE_mask_point_segment_co(spline, prev, u, co);
+                       BKE_mask_point_normal(spline, prev, u, n);
+                       weight = BKE_mask_point_weight(spline, prev, u);
+
+                       madd_v2_v2v2fl(*fp, co, n, weight);
+               }
+
+               prev = point;
+               point++;
+       }
+
+       *tot_feather_point = tot;
+
+       if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) {
+               BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot);
+       }
+
+       return feather;
+}
+
+float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height,
+                                                                      int *tot_feather_point, const int do_feather_isect))[2]
+{
+       unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height);
+
+       return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, do_feather_isect);
+}
+
+float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2]
+{
+       return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point, TRUE);
+}
+
+float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2]
+{
+       MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
+
+       int i, tot = 0;
+       float (*feather)[2], (*fp)[2];
+
+       /* count */
+       for (i = 0; i < spline->tot_point; i++) {
+               MaskSplinePoint *point = &points_array[i];
+
+               tot += point->tot_uw + 1;
+       }
+
+       /* create data */
+       feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather points");
+
+       for (i = 0; i < spline->tot_point; i++) {
+               MaskSplinePoint *point = &points_array[i];
+               BezTriple *bezt = &point->bezt;
+               float weight, n[2];
+               int j;
+
+               BKE_mask_point_normal(spline, point, 0.0f, n);
+               weight = BKE_mask_point_weight(spline, point, 0.0f);
+
+               madd_v2_v2v2fl(*fp, bezt->vec[1], n, weight);
+               fp++;
+
+               for (j = 0; j < point->tot_uw; j++) {
+                       float u = point->uw[j].u;
+                       float co[2];
+
+                       BKE_mask_point_segment_co(spline, point, u, co);
+                       BKE_mask_point_normal(spline, point, u, n);
+                       weight = BKE_mask_point_weight(spline, point, u);
+
+                       madd_v2_v2v2fl(*fp, co, n, weight);
+                       fp++;
+               }
+       }
+
+       *tot_feather_point = tot;
+
+       return feather;
+}
index fd167c6..7523c59 100644 (file)
@@ -813,7 +813,7 @@ void assign_material(Object *ob, Material *ma, short act, int assign_type)
                *totcolp = act;
        }
 
-       // Determine the object/mesh linking
+       /* Determine the object/mesh linking */
        if (assign_type == BKE_MAT_ASSIGN_USERPREF && ob->totcol && ob->actcol) {
                /* copy from previous material */
                bit = ob->matbits[ob->actcol - 1];
@@ -1633,7 +1633,7 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall)
        /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */
        flag -= 1;
 
-       alphablend = flag >> 15; //encoded in the encode_tfaceflag function
+       alphablend = flag >> 15;  /* encoded in the encode_tfaceflag function */
        (*game).flag = 0;
        
        /* General Material Options */
@@ -2033,8 +2033,7 @@ int do_version_tface(Main *main, int fileload)
                                nowarning = 0;
                        }
                        else
-                               convert_tfacematerial(main, ma);
-                       continue;       
+                               convert_tfacematerial(main, ma);                        continue;       
                }
        
                /* no conflicts in this material - 90% of cases
index f5ae3c7..8c3ec7e 100644 (file)
@@ -2702,13 +2702,13 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
 #endif
                {
                        /* sort loop indices to ensure winding is correct */
-                       if (mf->v1 > mf->v2) SWAP(int, mf->v1, mf->v2);
-                       if (mf->v2 > mf->v3) SWAP(int, mf->v2, mf->v3);
-                       if (mf->v1 > mf->v2) SWAP(int, mf->v1, mf->v2);
+                       if (mf->v1 > mf->v2) SWAP(unsigned int, mf->v1, mf->v2);
+                       if (mf->v2 > mf->v3) SWAP(unsigned int, mf->v2, mf->v3);
+                       if (mf->v1 > mf->v2) SWAP(unsigned int, mf->v1, mf->v2);
 
-                       if (mf->v1 > mf->v2) SWAP(int, mf->v1, mf->v2);
-                       if (mf->v2 > mf->v3) SWAP(int, mf->v2, mf->v3);
-                       if (mf->v1 > mf->v2) SWAP(int, mf->v1, mf->v2);
+                       if (mf->v1 > mf->v2) SWAP(unsigned int, mf->v1, mf->v2);
+                       if (mf->v2 > mf->v3) SWAP(unsigned int, mf->v2, mf->v3);
+                       if (mf->v1 > mf->v2) SWAP(unsigned int, mf->v1, mf->v2);
                }
 
                /* end abusing the edcode */
index d62b03b..9590160 100644 (file)
@@ -764,7 +764,7 @@ void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp)
 }
 
 /* Add the given NLA-Strip to the given Meta-Strip, assuming that the
- * strip isn't attached to anyy list of strips 
+ * strip isn't attached to any list of strips
  */
 short BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
 {
index 3b860cf..52b1e1b 100644 (file)
@@ -1484,7 +1484,7 @@ void nodeSocketSetType(bNodeSocket *sock, int type)
  * otherwise we may reference missing data.
  *
  * Currently its only used for ID's, but nodes may one day
- * referene other pointers which need validation.
+ * reference other pointers which need validation.
  */
 typedef struct bNodeClipboardExtraInfo {
        struct bNodeClipboardExtraInfo *next, *prev;
index 914e19b..dfa3582 100644 (file)
@@ -1514,7 +1514,7 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
                        /* end drot correction */
 
                        if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
-                       else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
+                       else            mat3_to_eulO(ob->rot, ob->rotmode, tmat);
                }
        }
 }
index 9156deb..60b0b65 100644 (file)
@@ -3617,8 +3617,8 @@ int BKE_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
        SWAP(float, seq_a->blend_opacity, seq_b->blend_opacity);
 
 
-       SWAP(void *, seq_a->prev, seq_b->prev);
-       SWAP(void *, seq_a->next, seq_b->next);
+       SWAP(Sequence *, seq_a->prev, seq_b->prev);
+       SWAP(Sequence *, seq_a->next, seq_b->next);
        SWAP(int, seq_a->start, seq_b->start);
        SWAP(int, seq_a->startofs, seq_b->startofs);
        SWAP(int, seq_a->endofs, seq_b->endofs);
index 1436029..2462de0 100644 (file)
@@ -774,37 +774,37 @@ void sound_force_device(int UNUSED(device)) {}
 void sound_init_once(void) {}
 void sound_init(struct Main *UNUSED(bmain)) {}
 void sound_exit(void) {}
-void sound_cache(struct bSoundUNUSED(sound)) { }
-void sound_delete_cache(struct bSoundUNUSED(sound)) {}
-void sound_load(struct Main *UNUSED(bmain), struct bSoundUNUSED(sound)) {}
+void sound_cache(struct bSound *UNUSED(sound)) { }
+void sound_delete_cache(struct bSound *UNUSED(sound)) {}
+void sound_load(struct Main *UNUSED(bmain), struct bSound *UNUSED(sound)) {}
 void sound_create_scene(struct Scene *UNUSED(scene)) {}
 void sound_destroy_scene(struct Scene *UNUSED(scene)) {}
 void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {}
-void* sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
-void* sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence)) { return NULL; }
-void* sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
-void* sound_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence)) { return NULL; }
-void sound_remove_scene_sound(struct Scene *UNUSED(scene), voidUNUSED(handle)) {}
-void sound_mute_scene_sound(voidUNUSED(handle), char UNUSED(mute)) {}
-void sound_move_scene_sound(struct Scene *UNUSED(scene), voidUNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {}
+void *sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
+void *sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) { return NULL; }
+void *sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
+void *sound_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) { return NULL; }
+void sound_remove_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle)) {}
+void sound_mute_scene_sound(void *UNUSED(handle), char UNUSED(mute)) {}
+void sound_move_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {}
 void sound_move_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) {}
 void sound_play_scene(struct Scene *UNUSED(scene)) {}
 void sound_stop_scene(struct Scene *UNUSED(scene)) {}
 void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {}
 float sound_sync_scene(struct Scene *UNUSED(scene)) { return NAN_FLT; }
 int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
-int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; }
-void sound_read_waveform(struct bSoundsound) { (void)sound; }
+int sound_read_sound_buffer(struct bSound *UNUSED(sound), float *UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; }
+void sound_read_waveform(struct bSound *sound) { (void)sound; }
 void sound_init_main(struct Main *bmain) { (void)bmain; }
 void sound_set_cfra(int cfra) { (void)cfra; }
-void sound_update_sequencer(struct Main* main, struct bSound* sound) { (void)main; (void)sound; }
-void sound_update_scene(struct Scenescene) { (void)scene; }
-void sound_update_scene_sound(void* handle, struct bSound* sound) { (void)handle; (void)sound; }
+void sound_update_sequencer(struct Main *main, struct bSound *sound) { (void)main; (void)sound; }
+void sound_update_scene(struct Scene *scene) { (void)scene; }
+void sound_update_scene_sound(void *handle, struct bSound *sound) { (void)handle; (void)sound; }
 void sound_update_scene_listener(struct Scene *scene) { (void)scene; }
 void sound_update_fps(struct Scene *scene) { (void)scene; }
-void sound_set_scene_sound_volume(voidhandle, float volume, char animated) { (void)handle; (void)volume; (void)animated; }
-void sound_set_scene_sound_pan(voidhandle, float pan, char animated) { (void)handle; (void)pan; (void)animated; }
+void sound_set_scene_sound_volume(void *handle, float volume, char animated) { (void)handle; (void)volume; (void)animated; }
+void sound_set_scene_sound_pan(void *handle, float pan, char animated) { (void)handle; (void)pan; (void)animated; }
 void sound_set_scene_volume(struct Scene *scene, float volume) { (void)scene; (void)volume; }
-void sound_set_scene_sound_pitch(voidhandle, float pitch, char animated) { (void)handle; (void)pitch; (void)animated; }
-float sound_get_length(struct bSoundsound) { (void)sound; return 0; }
+void sound_set_scene_sound_pitch(void *handle, float pitch, char animated) { (void)handle; (void)pitch; (void)animated; }
+float sound_get_length(struct bSound *sound) { (void)sound; return 0; }
 #endif // WITH_AUDASPACE
index f22fd74..3526058 100644 (file)
@@ -69,8 +69,6 @@
 
 #include "ffmpeg_compat.h"
 
-extern void do_init_ffmpeg(void);
-
 static int ffmpeg_type = 0;
 static int ffmpeg_codec = CODEC_ID_MPEG4;
 static int ffmpeg_audio_codec = CODEC_ID_NONE;
@@ -101,6 +99,8 @@ static AUD_Device *audio_mixdown_device = 0;
 
 #define FFMPEG_AUTOSPLIT_SIZE 2000000000
 
+#define PRINT if (G.debug & G_DEBUG_FFMPEG) printf
+
 /* Delete a picture buffer */
 
 static void delete_picture(AVFrame *f)
@@ -125,9 +125,7 @@ static int write_audio_frame(void)
        AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_samples);
        audio_time += (double) audio_input_samples / (double) c->sample_rate;
 
-       pkt.size = avcodec_encode_audio(c, audio_output_buffer,
-                                       audio_outbuf_size,
-                                       (short *)audio_input_buffer);
+       pkt.size = avcodec_encode_audio(c, audio_output_buffer, audio_outbuf_size, (short *) audio_input_buffer);
 
        if (pkt.size < 0) {
                // XXX error("Error writing audio packet");
@@ -137,9 +135,8 @@ static int write_audio_frame(void)
        pkt.data = audio_output_buffer;
 
        if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) {
-               pkt.pts = av_rescale_q(c->coded_frame->pts,
-                                      c->time_base, audio_stream->time_base);
-               fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts);
+               pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_stream->time_base);
+               PRINT("Audio Frame PTS: %d\n", (int) pkt.pts);
        }
 
        pkt.stream_index = audio_stream->index;
@@ -189,8 +186,7 @@ static const char **get_file_extensions(int format)
                        return rv;
                }
                case FFMPEG_MPEG2: {
-                       static const char *rv[] = { ".dvd", ".vob", ".mpg", ".mpeg",
-                                                       NULL };
+                       static const char *rv[] = { ".dvd", ".vob", ".mpg", ".mpeg", NULL };
                        return rv;
                }
                case FFMPEG_MPEG4: {
@@ -254,21 +250,18 @@ static int write_video_frame(RenderData *rd, int cfra, AVFrame *frame, ReportLis
                frame->top_field_first = ((rd->mode & R_ODDFIELD) != 0);
        }
 
-       outsize = avcodec_encode_video(c, video_buffer, video_buffersize, 
-                                      frame);
+       outsize = avcodec_encode_video(c, video_buffer, video_buffersize,  frame);
 
        if (outsize > 0) {
                AVPacket packet;
                av_init_packet(&packet);
 
                if (c->coded_frame->pts != AV_NOPTS_VALUE) {
-                       packet.pts = av_rescale_q(c->coded_frame->pts,
-                                                 c->time_base,
-                                                 video_stream->time_base);
-                       fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
+                       packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base);
+                       PRINT("Video Frame PTS: %d\n", (int)packet.pts);
                }
                else {
-                       fprintf(stderr, "Video Frame PTS: not set\n");
+                       PRINT("Video Frame PTS: not set\n");
                }
                if (c->coded_frame->key_frame)
                        packet.flags |= AV_PKT_FLAG_KEY;
@@ -364,7 +357,7 @@ static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop)
        char *param;
        const AVOption *rv = NULL;
 
-       fprintf(stderr, "FFMPEG expert option: %s: ", prop->name);
+       PRINT("FFMPEG expert option: %s: ", prop->name);
 
        BLI_strncpy(name, prop->name, sizeof(name));
 
@@ -376,15 +369,15 @@ static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop)
 
        switch (prop->type) {
                case IDP_STRING:
-                       fprintf(stderr, "%s.\n", IDP_String(prop));
+                       PRINT("%s.\n", IDP_String(prop));
                        av_set_string3(c, prop->name, IDP_String(prop), 1, &rv);
                        break;
                case IDP_FLOAT:
-                       fprintf(stderr, "%g.\n", IDP_Float(prop));
+                       PRINT("%g.\n", IDP_Float(prop));
                        rv = av_set_double(c, prop->name, IDP_Float(prop));
                        break;
                case IDP_INT:
-                       fprintf(stderr, "%d.\n", IDP_Int(prop));
+                       PRINT("%d.\n", IDP_Int(prop));
 
                        if (param) {
                                if (IDP_Int(prop)) {
@@ -401,8 +394,7 @@ static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop)
        }
 
        if (!rv) {
-               fprintf(stderr, "ffmpeg-option not supported: %s! Skipping.\n",
-                       prop->name);
+               PRINT("ffmpeg-option not supported: %s! Skipping.\n", prop->name);
        }
 }
 
@@ -446,11 +438,14 @@ static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char
 /* prepare a video stream for the output file */
 
 static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContext *of,
-                                    int rectx, int recty)
+                                    int rectx, int recty, char *error, int error_size)
 {
        AVStream *st;
        AVCodecContext *c;
        AVCodec *codec;
+
+       error[0] = '\0';
+
        st = av_new_stream(of, 0);
        if (!st) return NULL;
 
@@ -460,7 +455,6 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
        c->codec_id = codec_id;
        c->codec_type = AVMEDIA_TYPE_VIDEO;
 
-
        /* Get some values from the current render settings */
        
        c->width = rectx;
@@ -492,7 +486,8 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
        c->me_method = ME_EPZS;
        
        codec = avcodec_find_encoder(c->codec_id);
-       if (!codec) return NULL;
+       if (!codec)
+               return NULL;
        
        /* Be sure to use the correct pixel format(e.g. RGB, YUV) */
 
@@ -547,27 +542,25 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
 //         || !strcmp(of->oformat->name, "3gp")
            )
        {
-               fprintf(stderr, "Using global header\n");
+               PRINT("Using global header\n");
                c->flags |= CODEC_FLAG_GLOBAL_HEADER;
        }
        
        /* Determine whether we are encoding interlaced material or not */
        if (rd->mode & R_FIELDS) {
-               fprintf(stderr, "Encoding interlaced video\n");
+               PRINT("Encoding interlaced video\n");
                c->flags |= CODEC_FLAG_INTERLACED_DCT;
                c->flags |= CODEC_FLAG_INTERLACED_ME;
        }
 
        /* xasp & yasp got float lately... */
 
-       st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q(
-                                     ((double) rd->xasp / (double) rd->yasp), 255);
+       st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q(((double) rd->xasp / (double) rd->yasp), 255);
 
        set_ffmpeg_properties(rd, c, "video");
        
        if (avcodec_open(c, codec) < 0) {
-               //
-               //XXX error("Couldn't initialize codec");
+               BLI_strncpy(error, IMB_ffmpeg_last_error(), error_size);
                return NULL;
        }
 
@@ -584,16 +577,11 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
        else
                video_buffersize = avpicture_get_size(c->pix_fmt, c->width, c->height);
 
-       video_buffer = (uint8_t *)MEM_mallocN(video_buffersize * sizeof(uint8_t),
-                                             "FFMPEG video buffer");
+       video_buffer = (uint8_t *)MEM_mallocN(video_buffersize * sizeof(uint8_t), "FFMPEG video buffer");
        
        current_frame = alloc_picture(c->pix_fmt, c->width, c->height);
 
-       img_convert_ctx = sws_getContext(c->width, c->height,
-                                        PIX_FMT_BGR32,
-                                        c->width, c->height,
-                                        c->pix_fmt,
-                                        SWS_BICUBIC,
+       img_convert_ctx = sws_getContext(c->width, c->height, PIX_FMT_BGR32, c->width, c->height, c->pix_fmt, SWS_BICUBIC,
                                         NULL, NULL, NULL);
        return st;
 }
@@ -645,11 +633,9 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
                        audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4;
        }
 
-       audio_output_buffer = (uint8_t *)av_malloc(
-           audio_outbuf_size);
+       audio_output_buffer = (uint8_t *) av_malloc(audio_outbuf_size);
 
-       audio_input_buffer = (uint8_t *)av_malloc(
-           audio_input_samples * c->channels * sizeof(int16_t));
+       audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(int16_t));
 
        audio_time = 0.0f;
 
@@ -672,7 +658,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
        AVFormatContext *of;
        AVOutputFormat *fmt;
        AVDictionary *opts = NULL;
-       char name[256];
+       char name[256], error[1024];
        const char **exts;
 
        ffmpeg_type = rd->ffcodecdata.type;
@@ -681,14 +667,11 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
        ffmpeg_video_bitrate = rd->ffcodecdata.video_bitrate;
        ffmpeg_audio_bitrate = rd->ffcodecdata.audio_bitrate;
        ffmpeg_gop_size = rd->ffcodecdata.gop_size;
-       ffmpeg_autosplit = rd->ffcodecdata.flags
-                          & FFMPEG_AUTOSPLIT_OUTPUT;
+       ffmpeg_autosplit = rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT;
        
-       do_init_ffmpeg();
-
        /* Determine the correct filename */
        BKE_ffmpeg_filepath_get(name, rd);
-       fprintf(stderr, "Starting output to %s(ffmpeg)...\n"
+       PRINT("Starting output to %s(ffmpeg)...\n"
                "  Using type=%d, codec=%d, audio_codec=%d,\n"
                "  video_bitrate=%d, audio_bitrate=%d,\n"
                "  gop_size=%d, autosplit=%d\n"
@@ -793,10 +776,14 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
        }
        
        if (fmt->video_codec != CODEC_ID_NONE) {
-               video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty);
-               printf("alloc video stream %p\n", video_stream);
+               video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty, error, sizeof(error));
+               PRINT("alloc video stream %p\n", video_stream);
                if (!video_stream) {
-                       BKE_report(reports, RPT_ERROR, "Error initializing video stream.");
+                       if (error[0])
+                               BKE_report(reports, RPT_ERROR, error);
+                       else
+                               BKE_report(reports, RPT_ERROR, "Error initializing video stream.");
+
                        av_dict_free(&opts);
                        return 0;
                }
@@ -867,13 +854,11 @@ void flush_ffmpeg(void)
                        break;
                }
                if (c->coded_frame->pts != AV_NOPTS_VALUE) {
-                       packet.pts = av_rescale_q(c->coded_frame->pts,
-                                                 c->time_base,
-                                                 video_stream->time_base);
-                       fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
+                       packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base);
+                       PRINT("Video Frame PTS: %d\n", (int) packet.pts);
                }
                else {
-                       fprintf(stderr, "Video Frame PTS: not set\n");
+                       PRINT("Video Frame PTS: not set\n");
                }
                if (c->coded_frame->key_frame) {
                        packet.flags |= AV_PKT_FLAG_KEY;
@@ -916,8 +901,7 @@ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd)
        }
 
        while (*fe) {
-               if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), 
-                                  *fe) == 0)
+               if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), *fe) == 0)
                {
                        break;
                }
@@ -983,9 +967,7 @@ int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, i
        AVFrame *avframe;
        int success = 1;
 
-       fprintf(stderr, "Writing frame %i, "
-               "render width=%d, render height=%d\n", frame,
-               rectx, recty);
+       PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, recty);
 
 // why is this done before writing the video frame and again at end_ffmpeg?
 //     write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
@@ -1013,7 +995,7 @@ void BKE_ffmpeg_end(void)
 {
        unsigned int i;
        
-       fprintf(stderr, "Closing ffmpeg...\n");
+       PRINT("Closing ffmpeg...\n");
 
 #if 0
        if (audio_stream) { /* SEE UPPER */
@@ -1029,7 +1011,7 @@ void BKE_ffmpeg_end(void)
 #endif
 
        if (video_stream && video_stream->codec) {
-               fprintf(stderr, "Flushing delayed frames...\n");
+               PRINT("Flushing delayed frames...\n");
                flush_ffmpeg();
        }
        
@@ -1041,7 +1023,7 @@ void BKE_ffmpeg_end(void)
 
        if (video_stream && video_stream->codec) {
                avcodec_close(video_stream->codec);
-               printf("zero video stream %p\n", video_stream);
+               PRINT("zero video stream %p\n", video_stream);
                video_stream = 0;
        }
 
@@ -1142,8 +1124,7 @@ IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_in
                BLI_strncpy(name, o->name, sizeof(name));
        }
 
-       fprintf(stderr, "ffmpeg_property_add: %s %d %d %s\n",
-               type, parent_index, opt_index, name);
+       PRINT("ffmpeg_property_add: %s %d %d %s\n", type, parent_index, opt_index, name);
 
        prop = IDP_GetPropertyFromGroup(group, name);
        if (prop) {
@@ -1181,8 +1162,7 @@ IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_in
 
 /* not all versions of ffmpeg include that, so here we go ... */
 
-static const AVOption *my_av_find_opt(void *v, const char *name,
-                                      const char *unit, int mask, int flags)
+static const AVOption *my_av_find_opt(void *v, const char *name, const char *unit, int mask, int flags)
 {
        AVClass *c = *(AVClass **)v;
        const AVOption *o = c->option;
@@ -1235,14 +1215,11 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char
        if (param && o->type != FF_OPT_TYPE_CONST && o->unit) {
                p = my_av_find_opt(&c, param, o->unit, 0, 0);   
                if (p) {
-                       prop = BKE_ffmpeg_property_add(rd,
-                                                      (char *) type, p - c.av_class->option,
-                                                      o - c.av_class->option);
+                       prop = BKE_ffmpeg_property_add(rd, (char *) type, p - c.av_class->option, o - c.av_class->option);
                }
        }
        else {
-               prop = BKE_ffmpeg_property_add(rd,
-                                              (char *) type, o - c.av_class->option, 0);
+               prop = BKE_ffmpeg_property_add(rd, (char *) type, o - c.av_class->option, 0);
        }
                
 
@@ -1316,12 +1293,10 @@ static void ffmpeg_set_expert_options(RenderData *rd)
                if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
                        BKE_ffmpeg_property_add_string(rd, "video", "cqp:0");
        }
-#if 0   /* disabled for after release */
        else if (codec_id == CODEC_ID_DNXHD) {
                if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
-                       ffmpeg_property_add_string(rd, "video", "mbd:rd");
+                       BKE_ffmpeg_property_add_string(rd, "video", "mbd:rd");
        }
-#endif
 }
 
 void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
index b0e0d3c..4a89776 100644 (file)
 #  endif
 #endif
 
+/* Causes warning:
+ * incompatible types when assigning to type 'Foo' from type 'Bar'
+ * ... the compiler optimizes away the temp var */
+#ifndef CHECK_TYPE
+#ifdef __GNUC__
+#define CHECK_TYPE(var, type)  {  \
+       __typeof(var) *__tmp;         \
+       __tmp = (type *)NULL;         \
+       (void)__tmp;                  \
+} (void)0
+#else
+#define CHECK_TYPE(var, type)
+#endif
+#endif
+
 #ifndef SWAP
-#  define SWAP(type, a, b)  { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } (void)0
+#  define SWAP(type, a, b)  {  \
+       type sw_ap;                \
+       CHECK_TYPE(a, type);       \
+       CHECK_TYPE(b, type);       \
+       sw_ap = (a);               \
+       (a) = (b);                 \
+       (b) = sw_ap;               \
+} (void)0
 #endif
 
 #ifndef CLAMP
index a40d4ca..8a439c7 100644 (file)
@@ -60,6 +60,7 @@ void sub_qt_qtqt(float q[4], const float a[4], const float b[4]);
 void invert_qt(float q[4]);
 void invert_qt_qt(float q1[4], const float q2[4]);
 void conjugate_qt(float q[4]);
+void conjugate_qt_qt(float q1[4], const float q2[4]);
 float dot_qtqt(const float a[4], const float b[4]);
 float normalize_qt(float q[4]);
 float normalize_qt_qt(float q1[4], const float q2[4]);
@@ -151,10 +152,10 @@ void mat3_to_eulO(float eul[3], const short order, float mat[3][3]);
 void mat4_to_eulO(float eul[3], const short order, float mat[4][4]);
 void axis_angle_to_eulO(float eul[3], const short order, const float axis[3], const float angle);
 
-void mat3_to_compatible_eulO(float eul[3], float old[3], short order, float mat[3][3]);
-void mat4_to_compatible_eulO(float eul[3], float old[3], short order, float mat[4][4]);
+void mat3_to_compatible_eulO(float eul[3], float old[3], const short order, float mat[3][3]);
+void mat4_to_compatible_eulO(float eul[3], float old[3], const short order, float mat[4][4]);
 
-void rotate_eulO(float eul[3], short order, char axis, float angle);
+void rotate_eulO(float eul[3], const short order, char axis, float angle);
 
 /******************************* Dual Quaternions ****************************/
 
index 6c0d547..20d04f7 100644 (file)
@@ -260,8 +260,8 @@ void BLI_pbvh_node_free_proxies(PBVHNode *node);
 PBVHProxyNode *BLI_pbvh_node_add_proxy(PBVH *bvh, PBVHNode *node);
 void BLI_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes,  int *totnode);
 
-//void BLI_pbvh_node_BB_reset(PBVHNodenode);
-//void BLI_pbvh_node_BB_expand(PBVHNodenode, float co[3]);
+//void BLI_pbvh_node_BB_reset(PBVHNode *node);
+//void BLI_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
 
 #endif /* __BLI_PBVH_H__ */
 
index a74629e..b3d0df0 100644 (file)
@@ -32,6 +32,8 @@
  *  \ingroup bli
  */
 
+#include <stdarg.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -139,6 +141,11 @@ __attribute__((nonnull))
 #endif
 ;
 
+/*
+ * Replacement for vsnprintf
+ */
+size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg);
+
 /*
  * Print formatted string into a newly mallocN'd string
  * and return it.
index 78d54de..8a459b9 100644 (file)
 
 /* some math and copy defines */
 
+/* Causes warning:
+ * incompatible types when assigning to type 'Foo' from type 'Bar'
+ * ... the compiler optimizes away the temp var */
+#ifndef CHECK_TYPE
+#ifdef __GNUC__
+#define CHECK_TYPE(var, type)  {  \
+       __typeof(var) *__tmp;         \
+       __tmp = (type *)NULL;         \
+       (void)__tmp;                  \
+} (void)0
+#else
+#define CHECK_TYPE(var, type)
+#endif
+#endif
+
 #ifndef SWAP
-#  define SWAP(type, a, b)       { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } (void)0
+#  define SWAP(type, a, b)  {  \
+       type sw_ap;                \
+       CHECK_TYPE(a, type);       \
+       CHECK_TYPE(b, type);       \
+       sw_ap = (a);               \
+       (a) = (b);                 \
+       (b) = sw_ap;               \
+} (void)0
 #endif
 
 #define ABS(a)          ( (a) < 0 ? (-(a)) : (a) )
index 1698733..f0ed23a 100644 (file)
@@ -34,7 +34,7 @@
 
 /******************************** Quaternions ********************************/
 
-/* used to test is a quat is not normalized */
+/* used to test is a quat is not normalized (only used for debug prints) */
 #define QUAT_EPSILON 0.0001
 
 /* convenience, avoids setting Y axis everywhere */
@@ -113,6 +113,14 @@ void mul_qt_v3(const float q[4], float v[3])
        v[1] = t2;
 }
 
+void conjugate_qt_qt(float q1[4], const float q2[4])
+{
+       q1[0] =  q2[0];
+       q1[1] = -q2[1];
+       q1[2] = -q2[2];
+       q1[3] = -q2[3];
+}
+
 void conjugate_qt(float q[4])
 {
        q[1] = -q[1];
@@ -370,7 +378,7 @@ float normalize_qt(float q[4])
 {
        float len;
 
-       len = (float)sqrt(dot_qtqt(q, q));
+       len = sqrtf(dot_qtqt(q, q));
        if (len != 0.0f) {
                mul_qt_fl(q, 1.0f / len);
        }
@@ -404,80 +412,75 @@ void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2
 void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q2[4])
 {
        float tquat[4];
-       double dot = 0.0f;
-       int x;
 
-       copy_qt_qt(tquat, q1);
-       conjugate_qt(tquat);
-       dot = 1.0f / dot_qtqt(tquat, tquat);
+       conjugate_qt_qt(tquat, q1);
 
-       for (x = 0; x < 4; x++)
-               tquat[x] *= dot;
+       mul_qt_fl(tquat, 1.0f / dot_qtqt(tquat, tquat));
 
        mul_qt_qtqt(q, tquat, q2);
 }
 
 void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
 {
-       float q2[4], nor[3], *fp, mat[3][3], angle, si, co, x2, y2, z2, len1;
+       float nor[3], tvec[3];
+       float angle, si, co, len;
 
        assert(axis >= 0 && axis <= 5);
        assert(upflag >= 0 && upflag <= 2);
 
-       /* first rotate to axis */
+       /* first set the quat to unit */
+       unit_qt(q);
+
+       len = len_v3(vec);
+
+       if (UNLIKELY(len == 0.0f)) {
+               return;
+       }
+
+       /* rotate to axis */
        if (axis > 2) {
-               x2 = vec[0];
-               y2 = vec[1];
-               z2 = vec[2];
+               copy_v3_v3(tvec, vec);
                axis -= 3;
        }
        else {
-               x2 = -vec[0];
-               y2 = -vec[1];
-               z2 = -vec[2];
+               negate_v3_v3(tvec, vec);
        }
 
-       q[0] = 1.0;
-       q[1] = q[2] = q[3] = 0.0;
-
-       len1 = (float)sqrt(x2 * x2 + y2 * y2 + z2 * z2);
-       if (len1 == 0.0f) return;
-
        /* nasty! I need a good routine for this...
         * problem is a rotation of an Y axis to the negative Y-axis for example.
         */
 
        if (axis == 0) { /* x-axis */
-               nor[0] = 0.0;
-               nor[1] = -z2;
-               nor[2] = y2;
+               nor[0] =  0.0;
+               nor[1] = -tvec[2];
+               nor[2] =  tvec[1];
 
-               if (fabsf(y2) + fabsf(z2) < 0.0001f)
-                       nor[1] = 1.0;
+               if (fabsf(tvec[1]) + fabsf(tvec[2]) < 0.0001f)
+                       nor[1] = 1.0f;
 
-               co = x2;
+               co = tvec[0];
        }
        else if (axis == 1) { /* y-axis */
-               nor[0] = z2;
-               nor[1] = 0.0;
-               nor[2] = -x2;
+               nor[0] =  tvec[2];
+               nor[1] =  0.0;
+               nor[2] = -tvec[0];
 
-               if (fabsf(x2) + fabsf(z2) < 0.0001f)
-                       nor[2] = 1.0;
+               if (fabsf(tvec[0]) + fabsf(tvec[2]) < 0.0001f)
+                       nor[2] = 1.0f;
 
-               co = y2;
+               co = tvec[1];
        }
        else { /* z-axis */
-               nor[0] = -y2;
-               nor[1] = x2;
-               nor[2] = 0.0;
+               nor[0] = -tvec[1];
+               nor[1] =  tvec[0];
+               nor[2] =  0.0;
 
-               if (fabsf(x2) + fabsf(y2) < 0.0001f)
-                       nor[0] = 1.0;
+               if (fabsf(tvec[0]) + fabsf(tvec[1]) < 0.0001f)
+                       nor[0] = 1.0f;
 
-               co = z2;
+               co = tvec[2];
        }
-       co /= len1;
+       co /= len;
 
        normalize_v3(nor);
 
@@ -489,28 +492,30 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
        q[3] = nor[2] * si;
 
        if (axis != upflag) {
+               float mat[3][3];
+               float q2[4];
+               const float *fp = mat[2];
                quat_to_mat3(mat, q);
 
-               fp = mat[2];
                if (axis == 0) {
-                       if (upflag == 1) angle = (float)(0.5 * atan2(fp[2], fp[1]));
-                       else angle = (float)(-0.5 * atan2(fp[1], fp[2]));
+                       if (upflag == 1) angle =  0.5f * atan2f(fp[2], fp[1]);
+                       else             angle = -0.5f * atan2f(fp[1], fp[2]);
                }
                else if (axis == 1) {
-                       if (upflag == 0) angle = (float)(-0.5 * atan2(fp[2], fp[0]));
-                       else angle = (float)(0.5 * atan2(fp[0], fp[2]));
+                       if (upflag == 0) angle = -0.5f * atan2f(fp[2], fp[0]);
+                       else             angle =  0.5f * atan2f(fp[0], fp[2]);
                }
                else {
-                       if (upflag == 0) angle = (float)(0.5 * atan2(-fp[1], -fp[0]));
-                       else angle = (float)(-0.5 * atan2(-fp[0], -fp[1]));
+                       if (upflag == 0) angle =  0.5f * atan2f(-fp[1], -fp[0]);
+                       else             angle = -0.5f * atan2f(-fp[0], -fp[1]);
                }
 
                co = cosf(angle);
-               si = sinf(angle) / len1;
+               si = sinf(angle) / len;
                q2[0] = co;
-               q2[1] = x2 * si;
-               q2[2] = y2 * si;
-               q2[3] = z2 * si;
+               q2[1] = tvec[0] * si;
+               q2[2] = tvec[1] * si;
+               q2[3] = tvec[2] * si;
 
                mul_qt_qtqt(q, q2, q);
        }
@@ -1040,84 +1045,46 @@ void rotate_eul(float *beul, const char axis, const float ang)
 
 }
 
-/* exported to transform.c */
-
 /* order independent! */
 void compatible_eul(float eul[3], const float oldrot[3])
 {
-       float dx, dy, dz;
+       /* we could use M_PI as pi_thresh: which is correct but 5.1 gives better results.
+        * Checked with baking actions to fcurves - campbell */
+       const float pi_thresh = (5.1f);
+       const float pi_x2     = (2.0f * (float)M_PI);
+
+       float deul[3];
+       unsigned int i;
 
        /* correct differences of about 360 degrees first */
-       dx = eul[0] - oldrot[0];
-       dy = eul[1] - oldrot[1];
-       dz = eul[2] - oldrot[2];
-
-       while (fabsf(dx) > 5.1f) {
-               if (dx > 0.0f) eul[0] -= 2.0f * (float)M_PI;
-               else eul[0] += 2.0f * (float)M_PI;
-               dx = eul[0] - oldrot[0];
-       }
-       while (fabsf(dy) > 5.1f) {
-               if (dy > 0.0f) eul[1] -= 2.0f * (float)M_PI;
-               else eul[1] += 2.0f * (float)M_PI;
-               dy = eul[1] - oldrot[1];
-       }
-       while (fabsf(dz) > 5.1f) {
-               if (dz > 0.0f) eul[2] -= 2.0f * (float)M_PI;
-               else eul[2] += 2.0f * (float)M_PI;
-               dz = eul[2] - oldrot[2];
+       for (i = 0; i < 3; i++) {
+               deul[i] = eul[i] - oldrot[i];
+               if (deul[i] > pi_thresh) {
+                       eul[i] -= floorf(( deul[i] / pi_x2) + 0.5) * pi_x2;
+                       deul[i] = eul[i] - oldrot[i];
+               }
+               else if (deul[i] < -pi_thresh) {
+                       eul[i] += floorf((-deul[i] / pi_x2) + 0.5) * pi_x2;
+                       deul[i] = eul[i] - oldrot[i];
+               }
        }
 
        /* is 1 of the axis rotations larger than 180 degrees and the other small? NO ELSE IF!! */
-       if (fabsf(dx) > 3.2f && fabsf(dy) < 1.6f && fabsf(dz) < 1.6f) {
-               if (dx > 0.0f) eul[0] -= 2.0f * (float)M_PI;
-               else eul[0] += 2.0f * (float)M_PI;
+       if (fabsf(deul[0]) > 3.2f && fabsf(deul[1]) < 1.6f && fabsf(deul[2]) < 1.6f) {
+               if (deul[0] > 0.0f) eul[0] -= pi_x2;
+               else                eul[0] += pi_x2;
        }
-       if (fabsf(dy) > 3.2f && fabsf(dz) < 1.6f && fabsf(dx) < 1.6f) {
-               if (dy > 0.0f) eul[1] -= 2.0f * (float)M_PI;
-               else eul[1] += 2.0f * (float)M_PI;
+       if (fabsf(deul[1]) > 3.2f && fabsf(deul[2]) < 1.6f && fabsf(deul[0]) < 1.6f) {
+               if (deul[1] > 0.0f) eul[1] -= pi_x2;
+               else                eul[1] += pi_x2;
        }
-       if (fabsf(dz) > 3.2f && fabsf(dx) < 1.6f && fabsf(dy) < 1.6f) {
-               if (dz > 0.0f) eul[2] -= 2.0f * (float)M_PI;
-               else eul[2] += 2.0f * (float)M_PI;
+       if (fabsf(deul[2]) > 3.2f && fabsf(deul[0]) < 1.6f && fabsf(deul[1]) < 1.6f) {
+               if (deul[2] > 0.0f) eul[2] -= pi_x2;
+               else                eul[2] += pi_x2;
        }
 
-       /* the method below was there from ancient days... but why! probably because the code sucks :)
-        */
-#if 0
-       /* calc again */
-       dx = eul[0] - oldrot[0];
-       dy = eul[1] - oldrot[1];
-       dz = eul[2] - oldrot[2];
-
-       /* special case, tested for x-z  */
-
-       if ((fabsf(dx) > 3.1f && fabsf(dz) > 1.5f) || (fabsf(dx) > 1.5f && fabsf(dz) > 3.1f)) {
-               if (dx > 0.0f) eul[0] -= M_PI;
-               else eul[0] += M_PI;
-               if (eul[1] > 0.0) eul[1] = M_PI - eul[1];
-               else eul[1] = -M_PI - eul[1];
-               if (dz > 0.0f) eul[2] -= M_PI;
-               else eul[2] += M_PI;
-
-       }
-       else if ((fabsf(dx) > 3.1f && fabsf(dy) > 1.5f) || (fabsf(dx) > 1.5f && fabsf(dy) > 3.1f)) {
-               if (dx > 0.0f) eul[0] -= M_PI;
-               else eul[0] += M_PI;
-               if (dy > 0.0f) eul[1] -= M_PI;
-               else eul[1] += M_PI;
-               if (eul[2] > 0.0f) eul[2] = M_PI - eul[2];
-               else eul[2] = -M_PI - eul[2];
-       }
-       else if ((fabsf(dy) > 3.1f && fabsf(dz) > 1.5f) || (fabsf(dy) > 1.5f && fabsf(dz) > 3.f1)) {
-               if (eul[0] > 0.0f) eul[0] = M_PI - eul[0];
-               else eul[0] = -M_PI - eul[0];
-               if (dy > 0.0f) eul[1] -= M_PI;
-               else eul[1] += M_PI;
-               if (dz > 0.0f) eul[2] -= M_PI;
-               else eul[2] += M_PI;
-       }
-#endif
+#undef PI_THRESH
+#undef PI_2F
 }
 
 /* uses 2 methods to retrieve eulers, and picks the closest */
@@ -1166,7 +1133,7 @@ typedef struct RotOrderInfo {
 /* Array of info for Rotation Order calculations
  * WARNING: must be kept in same order as eEulerRotationOrders
  */
-static RotOrderInfo rotOrders[] = {
+static const RotOrderInfo rotOrders[] = {
        /* i, j, k, n */
        {{0, 1, 2}, 0}, /* XYZ */
        {{0, 2, 1}, 1}, /* XZY */
@@ -1185,7 +1152,7 @@ static RotOrderInfo rotOrders[] = {
 /* Construct quaternion from Euler angles (in radians). */
 void eulO_to_quat(float q[4], const float e[3], const short order)
 {
-       RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
+       const RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
        short i = R->axis[0], j = R->axis[1], k = R->axis[2];
        double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
        double a[3];
@@ -1230,7 +1197,7 @@ void quat_to_eulO(float e[3], short const order, const float q[4])
 /* Construct 3x3 matrix from Euler angles (in radians). */
 void eulO_to_mat3(float M[3][3], const float e[3], const short order)
 {
-       RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
+       const RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
        short i = R->axis[0], j = R->axis[1], k = R->axis[2];
        double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
 
@@ -1269,9 +1236,9 @@ void eulO_to_mat3(float M[3][3], const float e[3], const short order)
 }
 
 /* returns two euler calculation methods, so we can pick the best */
-static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, short order)
+static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, const short order)
 {
-       RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
+       const RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
        short i = R->axis[0], j = R->axis[1], k = R->axis[2];
        float m[3][3];
        double cy;
@@ -1349,7 +1316,7 @@ void mat4_to_eulO(float e[3], const short order, float M[4][4])
 }
 
 /* uses 2 methods to retrieve eulers, and picks the closest */
-void mat3_to_compatible_eulO(float eul[3], float oldrot[3], short order, float mat[3][3])
+void mat3_to_compatible_eulO(float eul[3], float oldrot[3], const short order, float mat[3][3])
 {
        float eul1[3], eul2[3];
        float d1, d2;
@@ -1369,7 +1336,7 @@ void mat3_to_compatible_eulO(float eul[3], float oldrot[3], short order, float m
                copy_v3_v3(eul, eul1);
 }
 
-void mat4_to_compatible_eulO(float eul[3], float oldrot[3], short order, float M[4][4])
+void mat4_to_compatible_eulO(float eul[3], float oldrot[3], const short order, float M[4][4])
 {
        float m[3][3];
 
@@ -1381,7 +1348,7 @@ void mat4_to_compatible_eulO(float eul[3], float oldrot[3], short order, float M
 /* rotate the given euler by the given angle on the specified axis */
 // NOTE: is this safe to do with different axis orders?
 
-void rotate_eulO(float beul[3], short order, char axis, float ang)
+void rotate_eulO(float beul[3], const short order, char axis, float ang)
 {
        float eul[3], mat1[3][3], mat2[3][3], totmat[3][3];
 
@@ -1406,7 +1373,7 @@ void rotate_eulO(float beul[3], short order, char axis, float ang)
 /* the matrix is written to as 3 axis vectors */
 void eulO_to_gimbal_axis(float gmat[][3], const float eul[3], const short order)
 {
-       RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
+       const RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
 
        float mat[3][3];
        float teul[3];
@@ -1474,10 +1441,9 @@ void mat4_to_dquat(DualQuat *dq, float basemat[][4], float mat[][4])
        mult_m4_m4m4(baseRS, mat, basemat);
        mat4_to_size(scale, baseRS);
 
-       copy_v3_v3(dscale, scale);
-       dscale[0] -= 1.0f;
-       dscale[1] -= 1.0f;
-       dscale[2] -= 1.0f;
+       dscale[0] = scale[0] - 1.0f;
+       dscale[1] = scale[1] - 1.0f;
+       dscale[2] = scale[2] - 1.0f;
 
        if ((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4f) {
                /* extract R and S  */
@@ -1513,10 +1479,10 @@ void mat4_to_dquat(DualQuat *dq, float basemat[][4], float mat[][4])
        /* dual part */
        t = R[3];
        q = dq->quat;
-       dq->trans[0] = -0.5f * (t[0] * q[1] + t[1] * q[2] + t[2] * q[3]);
-       dq->trans[1] = 0.5f * (t[0] * q[0] + t[1] * q[3] - t[2] * q[2]);
-       dq->trans[2] = 0.5f * (-t[0] * q[3] + t[1] * q[0] + t[2] * q[1]);
-       dq->trans[3] = 0.5f * (t[0] * q[2] - t[1] * q[1] + t[2] * q[0]);
+       dq->trans[0] = -0.5f * ( t[0] * q[1] + t[1] * q[2] + t[2] * q[3]);
+       dq->trans[1] =  0.5f * ( t[0] * q[0] + t[1] * q[3] - t[2] * q[2]);
+       dq->trans[2] =  0.5f * (-t[0] * q[3] + t[1] * q[0] + t[2] * q[1]);
+       dq->trans[3] =  0.5f * ( t[0] * q[2] - t[1] * q[1] + t[2] * q[0]);
 }
 
 void dquat_to_mat4(float mat[][4], DualQuat *dq)
@@ -1527,7 +1493,7 @@ void dquat_to_mat4(float mat[][4], DualQuat *dq)
        copy_qt_qt(q0, dq->quat);
 
        /* normalize */
-       len = (float)sqrt(dot_qtqt(q0, q0));
+       len = sqrtf(dot_qtqt(q0, q0));
        if (len != 0.0f)
                mul_qt_fl(q0, 1.0f / len);
 
index b4b546d..22597c9 100644 (file)
@@ -260,12 +260,12 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node)
        node->vb = vb;
 }
 
-//void BLI_pbvh_node_BB_reset(PBVHNodenode)
+//void BLI_pbvh_node_BB_reset(PBVHNode *node)
 //{
 //     BB_reset(&node->vb);
 //}
 //
-//void BLI_pbvh_node_BB_expand(PBVHNodenode, float co[3])
+//void BLI_pbvh_node_BB_expand(PBVHNode *node, float co[3])
 //{
 //     BB_expand(&node->vb, co);
 //}
index 7a750a7..8501db7 100644 (file)
@@ -78,22 +78,31 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy)
        return dst;
 }
 
-size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...)
+size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg)
 {
        size_t n;
-       va_list arg;
 
-       va_start(arg, format);
        n = vsnprintf(buffer, count, format, arg);
-       
+
        if (n != -1 && n < count) {
                buffer[n] = '\0';
        }
        else {
                buffer[count - 1] = '\0';
        }
-       
+
+       return n;
+}
+
+size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...)
+{
+       size_t n;
+       va_list arg;
+
+       va_start(arg, format);
+       n = BLI_vsnprintf(buffer, count, format, arg);
        va_end(arg);
+
        return n;
 }
 
index 1956cfa..e6b97f1 100644 (file)
@@ -2617,7 +2617,7 @@ static void lib_link_armature(FileData *fd, Main *main)
        }
 }
 
-static void direct_link_bones(FileData *fd, Bonebone)
+static void direct_link_bones(FileData *fd, Bone *bone)
 {
        Bone *child;
        
index ed5ffbf..1bad1bd 100644 (file)
@@ -129,7 +129,7 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb)
        ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
 }
 
-static void sequencer_init_preview_region(ARegionar)
+static void sequencer_init_preview_region(ARegion *ar)
 {
        // XXX a bit ugly still, copied from space_sequencer
        /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */
@@ -1787,7 +1787,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
                                SpaceLink *sl;
                                for (sl = sa->spacedata.first; sl; sl = sl->next) {
                                        if (sl->spacetype == SPACE_VIEW3D) {
-                                               View3Dv3d = (View3D *)sl;
+                                               View3D *v3d = (View3D *)sl;
                                                v3d->flag2 &= ~V3D_RENDER_OVERRIDE;
                                        }
                                }
@@ -2206,7 +2206,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
                        bActuator *act;
                        for (act = ob->actuators.first; act; act = act->next) {
                                if (act->type == ACT_STEERING) {
-                                       bSteeringActuatorstact = act->data;
+                                       bSteeringActuator *stact = act->data;
                                        if (stact->facingaxis == 0) {
                                                stact->facingaxis = 1;
                                        }
index c31906c..8ace277 100644 (file)
@@ -1141,7 +1141,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
        }
 
        if (main->versionfile <= 212) {
-               bSoundsound;
+               bSound *sound;
                bProperty *prop;
                Object *ob;
                Mesh *me;
@@ -1307,7 +1307,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
        }
 
        if (main->versionfile <= 224) {
-               bSoundsound;
+               bSound *sound;
                Scene *sce;
                Mesh *me;
                bScreen *sc;
index 4ada0c5..252e815 100644 (file)
@@ -2525,7 +2525,7 @@ static void write_libraries(WriteData *wd, Main *main)
        }
 }
 
-static void write_bone(WriteData *wd, Bonebone)
+static void write_bone(WriteData *wd, Bone *bone)
 {
        Bone*   cbone;
 
index c3cedcb..2ef146c 100644 (file)
@@ -84,8 +84,8 @@ void BMO_error_clear(BMesh *bm);
        (void)((!(a)) ?  (                                                        \
                (                                                                     \
                fprintf(stderr,                                                       \
-                       "BMESH_ASSERT failed: %s, %s(), %d at \'%s\'\n",                  \
-                       __FILE__, __func__, __LINE__, STRINGIFY(a)),                      \
+                       "BMESH_ASSERT failed: %s, %s(), %d at \'%s\'\n",              \
+                       __FILE__, __func__, __LINE__, STRINGIFY(a)),                  \
                _BMESH_DUMMY_ABORT(),                                                 \
                NULL)) : NULL)
 
index fc270c6..73e2d83 100644 (file)
@@ -174,7 +174,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
                                        f = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e, TRUE);
                                        /* return if couldn't join faces in manifold
                                         * conditions */
-                                       //!disabled for testing why bad things happen
+                                       /* !disabled for testing why bad things happen */
                                        if (!f) {
                                                return FALSE;
                                        }
index 802c6cc..790f0cb 100644 (file)
@@ -47,9 +47,9 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f,
                         float cos[][3], int n,
                         BMLoop **r_l, BMEdge *example);
 
-BMEdgeBM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac,
+BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac,
                                const short join_faces, const short kill_degenerate_faces);
-BMEdgeBM_vert_collapse_edge(BMesh *bm, BMEdge *ke, BMVert *kv,
+BMEdge *BM_vert_collapse_edge(BMesh *bm, BMEdge *ke, BMVert *kv,
                               const short kill_degenerate_faces);
 
 
index 48d8583..362157a 100644 (file)
@@ -366,8 +366,8 @@ static BMOpDefine bmo_weld_verts_def = {
  */
 static BMOpDefine bmo_create_vert_def = {
        "create_vert",
-       {{BMO_OP_SLOT_VEC, "co"}, //the coordinate of the new vert
-        {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, //the new vert
+       {{BMO_OP_SLOT_VEC, "co"},  /* the coordinate of the new vert */
+        {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"},  /* the new vert */
         {0, /* null-terminating sentinel */}},
        bmo_create_vert_exec,
        0,
@@ -381,8 +381,8 @@ static BMOpDefine bmo_create_vert_def = {
  */
 static BMOpDefine bmo_join_triangles_def = {
        "join_triangles",
-       {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input geometry.
-        {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //joined faces
+       {{BMO_OP_SLOT_ELEMENT_BUF, "faces"},    /* input geometry. */
+        {BMO_OP_SLOT_ELEMENT_BUF, "faceout"},  /* joined faces */
         {BMO_OP_SLOT_BOOL, "cmp_sharp"},
         {BMO_OP_SLOT_BOOL, "cmp_uvs"},
         {BMO_OP_SLOT_BOOL, "cmp_vcols"},
@@ -406,7 +406,7 @@ static BMOpDefine bmo_join_triangles_def = {
  */
 static BMOpDefine bmo_contextual_create_def = {
        "contextual_create",
-       {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry.
+       {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry. */
         {BMO_OP_SLOT_ELEMENT_BUF, "faceout"},     /* newly-made face(s) */
        /* note, this is for stand-alone edges only, not edges which are apart of newly created faces */
         {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"},     /* newly-made edge(s) */
@@ -459,8 +459,8 @@ static BMOpDefine bmo_edgenet_fill_def = {
  */
 static BMOpDefine bmo_edgenet_prepare_def = {
        "edgenet_prepare",
-       {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges
-        {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //new edges
+       {{BMO_OP_SLOT_ELEMENT_BUF, "edges"},    /* input edges */
+        {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"},  /* new edges */
         {0, /* null-terminating sentinel */}},
        bmo_edgenet_prepare,
        0,
@@ -474,9 +474,9 @@ static BMOpDefine bmo_edgenet_prepare_def = {
  */
 static BMOpDefine bmo_rotate_def = {
        "rotate",
-       {{BMO_OP_SLOT_VEC, "cent"}, //center of rotation
-        {BMO_OP_SLOT_MAT, "mat"}, //matrix defining rotation
-        {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices
+       {{BMO_OP_SLOT_VEC, "cent"},  /* center of rotation */
+        {BMO_OP_SLOT_MAT, "mat"},   /* matrix defining rotation */
+        {BMO_OP_SLOT_ELEMENT_BUF, "verts"},  /* input vertices */
         {0, /* null-terminating sentinel */}},
        bmo_rotate_exec,
        0,
@@ -490,8 +490,8 @@ static BMOpDefine bmo_rotate_def = {
  */
 static BMOpDefine bmo_translate_def = {
        "translate",
-       {{BMO_OP_SLOT_VEC, "vec"}, //translation offset
-        {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices
+       {{BMO_OP_SLOT_VEC, "vec"},  /* translation offset */
+        {BMO_OP_SLOT_ELEMENT_BUF, "verts"},  /* input vertices */
         {0, /* null-terminating sentinel */}},
        bmo_translate_exec,
        0,
@@ -504,8 +504,8 @@ static BMOpDefine bmo_translate_def = {
  */
 static BMOpDefine bmo_scale_def = {
        "scale",
-       {{BMO_OP_SLOT_VEC, "vec"}, //scale factor
-        {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices
+       {{BMO_OP_SLOT_VEC, "vec"},  /* scale factor */
+        {BMO_OP_SLOT_ELEMENT_BUF, "verts"},  /* input vertices */
         {0, /* null-terminating sentinel */}},
        bmo_scale_exec,
        0,
@@ -520,8 +520,8 @@ static BMOpDefine bmo_scale_def = {
  */
 static BMOpDefine bmo_transform_def = {
        "transform",
-       {{BMO_OP_SLOT_MAT, "mat"}, //transform matrix
-        {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices
+       {{BMO_OP_SLOT_MAT, "mat"},  /* transform matrix */
+        {BMO_OP_SLOT_ELEMENT_BUF, "verts"},  /* input vertices */
         {0, /* null-terminating sentinel */}},
        bmo_transform_exec,
        0,
@@ -550,9 +550,9 @@ static BMOpDefine bmo_object_load_bmesh_def = {
  */
 static BMOpDefine bmo_bmesh_to_mesh_def = {
        "bmesh_to_mesh",
-       {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a mesh structure to fill in
-        {BMO_OP_SLOT_PTR, "object"}, //pointer to an object structure
-        {BMO_OP_SLOT_BOOL, "notessellation"}, //don't calculate mfaces
+       {{BMO_OP_SLOT_PTR, "mesh"},    /* pointer to a mesh structure to fill in */
+        {BMO_OP_SLOT_PTR, "object"},  /* pointer to an object structure */
+        {BMO_OP_SLOT_BOOL, "notessellation"},  /* don't calculate mfaces */
         {0, /* null-terminating sentinel */}},
        bmo_bmesh_to_mesh_exec,
        0,
@@ -566,9 +566,9 @@ static BMOpDefine bmo_bmesh_to_mesh_def = {
  */
 static BMOpDefine bmo_mesh_to_bmesh_def = {
        "mesh_to_bmesh",
-       {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a Mesh structure
-        {BMO_OP_SLOT_PTR, "object"}, //pointer to an Object structure
-        {BMO_OP_SLOT_BOOL, "set_shapekey"}, //load active shapekey coordinates into verts
+       {{BMO_OP_SLOT_PTR, "mesh"},    /* pointer to a Mesh structure */
+        {BMO_OP_SLOT_PTR, "object"},  /* pointer to an Object structure */
+        {BMO_OP_SLOT_BOOL, "set_shapekey"},  /* load active shapekey coordinates into verts */
         {0, /* null-terminating sentinel */}},
        bmo_mesh_to_bmesh_exec,
        0
@@ -581,9 +581,9 @@ static BMOpDefine bmo_mesh_to_bmesh_def = {
  */
 static BMOpDefine bmo_extrude_discrete_faces_def = {
        "extrude_discrete_faces",
-       {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces
-        {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //output faces
-        {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, //output skirt geometry, faces and edges
+       {{BMO_OP_SLOT_ELEMENT_BUF, "faces"},     /* input faces */
+        {BMO_OP_SLOT_ELEMENT_BUF, "faceout"},   /* output faces */
+        {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"},  /* output skirt geometry, faces and edges */
         {0} /* null-terminating sentinel */},
        bmo_extrude_discrete_faces_exec,
        0
@@ -597,8 +597,8 @@ static BMOpDefine bmo_extrude_discrete_faces_def = {
  */
 static BMOpDefine bmo_extrude_edge_only_def = {
        "extrude_edge_only",
-       {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input vertices
-        {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output geometry
+       {{BMO_OP_SLOT_ELEMENT_BUF, "edges"},    /* input vertices */
+        {BMO_OP_SLOT_ELEMENT_BUF, "geomout"},  /* output geometry */
         {0} /* null-terminating sentinel */},
        bmo_extrude_edge_only_exec,
        0
@@ -611,9 +611,9 @@ static BMOpDefine bmo_extrude_edge_only_def = {
  */
 static BMOpDefine bmo_extrude_vert_indiv_def = {
        "extrude_vert_indiv",
-       {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices
-        {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //output wire edges
-        {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output vertices
+       {{BMO_OP_SLOT_ELEMENT_BUF, "verts"},    /* input vertices */
+        {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"},  /* output wire edges */
+        {BMO_OP_SLOT_ELEMENT_BUF, "vertout"},  /* output vertices */
         {0} /* null-terminating sentinel */},
        bmo_extrude_vert_indiv_exec,
        0
@@ -651,7 +651,7 @@ static BMOpDefine bmo_dissolve_edges_def = {
        "dissolve_edges",
        {{BMO_OP_SLOT_ELEMENT_BUF, "edges"},
         {BMO_OP_SLOT_ELEMENT_BUF, "regionout"},
-        {BMO_OP_SLOT_BOOL, "use_verts"}, // dissolve verts left between only 2 edges.
+        {BMO_OP_SLOT_BOOL, "use_verts"},  /* dissolve verts left between only 2 edges. */
         {0} /* null-terminating sentinel */},
        bmo_dissolve_edges_exec,
        BMO_OP_FLAG_UNTAN_MULTIRES
@@ -670,7 +670,7 @@ static BMOpDefine bmo_dissolve_faces_def = {
        "dissolve_faces",
        {{BMO_OP_SLOT_ELEMENT_BUF, "faces"},
         {BMO_OP_SLOT_ELEMENT_BUF, "regionout"},
-        {BMO_OP_SLOT_BOOL, "use_verts"}, // dissolve verts left between only 2 edges.
+        {BMO_OP_SLOT_BOOL, "use_verts"},  /* dissolve verts left between only 2 edges. */
         {0} /* null-terminating sentinel */},
        bmo_dissolve_faces_exec,
        BMO_OP_FLAG_UNTAN_MULTIRES
index 91a48c7..0674103 100644 (file)
@@ -289,7 +289,7 @@ void  BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]);
 /* only supports square mats */
 /* size must be 3 or 4; this api is meant only for transformation matrices.
  * note that internally the matrix is stored in 4x4 form, and it's safe to
- * call whichever BMO_Get_Mat* function you want. */
+ * call whichever BMO_Get_MatXXX function you want. */
 void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size);
 void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]);
 void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]);
index c9a0d74..6943dcb 100644 (file)
@@ -39,6 +39,7 @@
 #define FACE_NEW       2
 #define EDGE_MARK      4
 #define EDGE_DONE      8
+#define FACE_OUT       16
 
 void bmo_connect_verts_exec(BMesh *bm, BMOperator *op)
 {
@@ -429,8 +430,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
                
                /* merge loops of bridge faces */
                if (use_merge) {
-                       /* at the moment these will be the same */
-                       const int vert_len = mini(BLI_array_count(vv1), BLI_array_count(vv2));
+                       const int vert_len = mini(BLI_array_count(vv1), BLI_array_count(vv2)) - ((cl1 || cl2) ? 1 : 0);
                        const int edge_len = mini(BLI_array_count(ee1), BLI_array_count(ee2));
 
                        if (merge_factor <= 0.0f) {
@@ -515,6 +515,8 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
                                        fprintf(stderr, "%s: in bridge! (bmesh internal error)\n", __func__);
                                }
                                else {
+                                       BMO_elem_flag_enable(bm, f, FACE_OUT);
+
                                        l_iter = BM_FACE_FIRST_LOOP(f);
 
                                        if (l_1)      BM_elem_attrs_copy(bm, bm, l_1,      l_iter); l_iter = l_iter->next;
@@ -526,6 +528,8 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
                }
        }
 
+       BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_OUT);
+
 cleanup:
        BLI_array_free(ee1);
        BLI_array_free(ee2);
index 0a7832e..7fd3976 100644 (file)
@@ -96,7 +96,7 @@ public:
 protected:
        const ExportSettings *export_settings;
 
-       void dae_animation(Object* ob, FCurve *fcu, char* transformName, bool is_param, Material *ma = NULL);
+       void dae_animation(Object *ob, FCurve *fcu, char *transformName, bool is_param, Material *ma = NULL);
 
        void write_bone_animation_matrix(Object *ob_arm, Bone *bone);
 
@@ -161,7 +161,7 @@ protected:
        
        bool hasAnimations(Scene *sce);
        
-       charextract_transform_name(char *rna_path);
+       char *extract_transform_name(char *rna_path);
 
        std::string getObjectBoneName(Object *ob, const FCurve * fcu);
 };
index a237222..d241926 100644 (file)
@@ -561,7 +561,7 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
 
                case COLLADAFW::Transformation::MATRIX:
                        /*{
-                          COLLADAFW::Matrixmat = (COLLADAFW::Matrix*)transform;
+                          COLLADAFW::Matrix *mat = (COLLADAFW::Matrix*)transform;
                           COLLADABU::Math::Matrix4 mat4 = mat->getMatrix();
                           switch (binding->animationClass) {
                           case COLLADAFW::AnimationList::TRANSFORM:
index a08f443..47e59a1 100644 (file)
@@ -56,7 +56,7 @@ public:
                COLLADAFW::Transformation *tm; // which transform is animated by an AnimationList->id
        };
 
-       TransformReader(UnitConverterconv);
+       TransformReader(UnitConverter *conv);
 
        void get_node_mat(float mat[][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob);
        
index b64c75e..c1f75f9 100644 (file)
@@ -59,7 +59,7 @@ public:
        // Initialize with Z_UP, since Blender uses right-handed, z-up
        UnitConverter();
 
-       void read_asset(const COLLADAFW::FileInfoasset);
+       void read_asset(const COLLADAFW::FileInfo *asset);
 
        void convertVector3(COLLADABU::Math::Vector3 &vec, float *v);
        
index 83cb0db..e254fb7 100644 (file)
@@ -336,7 +336,7 @@ static int binarysearch_fcm_envelopedata_index(FCM_EnvelopeData array[], float f
        /* initialize exists-flag first */
        *exists = 0;
        
-       /* sneaky optimisations (don't go through searching process if...):
+       /* sneaky optimizations (don't go through searching process if...):
         *      - keyframe to be added is to be added out of current bounds
         *      - keyframe to be added would replace one of the existing ones on bounds
         */
index bc154de..e2d1589 100644 (file)
@@ -1938,7 +1938,7 @@ static void adduplicateflagNurb(Object *obedit, short flag)
                                }
                                else {
 
-                                       if (newu == 1) SWAP(short, newu, newv);
+                                       if (newu == 1) SWAP(int, newu, newv);
 
                                        newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN5");
                                        memcpy(newnu, nu, sizeof(Nurb));
index 6f2952a..e4bfbea 100644 (file)
@@ -1480,7 +1480,7 @@ static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event)
        float mousef[2];
        int tablet = 0;
 
-       /* convert from window-space to area-space mouse coordintes 
+       /* convert from window-space to area-space mouse coordinates
         * NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... 
         */
        p->mval[0] = event->mval[0] + 1;
index 37a110b..afbabaa 100644 (file)
@@ -510,18 +510,18 @@ static void ui_draw_links(uiBlock *block)
 
        /* Draw the inactive lines (lines with neither button being hovered over).
         * As we go, remember if we see any active or selected lines. */
-       int foundselectline = 0;
-       int foundactiveline = 0;
+       int foundselectline = FALSE;
+       int foundactiveline = FALSE;
        for (but = block->buttons.first; but; but = but->next) {
                if (but->type == LINK && but->link) {
                        for (line = but->link->lines.first; line; line = line->next) {
                                if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE))
                                        ui_draw_linkline(line, 0);
                                else
-                                       foundactiveline = 1;
+                                       foundactiveline = TRUE;
 
                                if ((line->from->flag & UI_SELECT) || (line->to->flag & UI_SELECT))
-                                       foundselectline = 1;
+                                       foundselectline = TRUE;
                        }
                }
        }       
@@ -680,28 +680,27 @@ int uiButActiveOnly(const bContext *C, uiBlock *block, uiBut *but)
 {
        uiBlock *oldblock;
        uiBut *oldbut;
-       int activate = 0, found = 0, isactive = 0;
+       int activate = FALSE, found = FALSE, isactive = FALSE;
        
        oldblock = block->oldblock;
        if (!oldblock)
-               activate = 1;
+               activate = TRUE;
        else {
                for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) {
                        if (ui_but_equals_old(oldbut, but)) {
-                               found = 1;
+                               found = TRUE;
                                
                                if (oldbut->active)
-                                       isactive = 1;
+                                       isactive = TRUE;
                                
                                break;
                        }
                }
        }
-       if (activate || found == 0) {
+       if ((activate == TRUE) || (found == FALSE)) {
                ui_button_activate_do((bContext *)C, CTX_wm_region(C), but);
        }
-       else if (found && isactive == 0) {
-               
+       else if ((found == TRUE) && (isactive == FALSE)) {
                BLI_remlink(&block->buttons, but);
                ui_free_but(C, but);
                return 0;
@@ -911,7 +910,7 @@ void uiEndBlock(const bContext *C, uiBlock *block)
 
                        if (ot == NULL || WM_operator_poll_context((bContext *)C, ot, but->opcontext) == 0) {
                                but->flag |= UI_BUT_DISABLED;
-                               but->lock = 1;
+                               but->lock = TRUE;
                        }
 
                        if (but->context)
@@ -1067,9 +1066,12 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
 
 static void ui_is_but_sel(uiBut *but, double *value)
 {
-       short is_push = 0, is_true = 1;
+       short is_push = 0;  /* (0 == UNSELECT), (1 == SELECT), (2 == DO-NOHING) */
+       short is_true = TRUE;
 
-       if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true = 0;
+       if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) {
+               is_true = FALSE;
+       }
 
        if (but->bit) {
                int lvalue;
@@ -1198,14 +1200,14 @@ void uiComposeLinks(uiBlock *block)
 void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr)
 {
        if (val) {
-               block->lock = val ? 1 : 0;
+               block->lock = val ? TRUE : FALSE;
                block->lockstr = lockstr;
        }
 }
 
 void uiBlockClearButLock(uiBlock *block)
 {
-       block->lock = 0;
+       block->lock = FALSE;
        block->lockstr = NULL;
 }
 
@@ -1515,10 +1517,15 @@ void ui_set_but_val(uiBut *but, double value)
                if (but->pointype == CHA)
                        value = (char)floor(value + 0.5);
                else if (but->pointype == SHO) {
-                       /* gcc 3.2.1 seems to have problems 
+                       /* gcc 3.2.1 seems to have problems
                         * casting a double like 32772.0 to
-                        * a short so we cast to an int, then 
-                        * to a short */
+                        * a short so we cast to an int, then
+                        * to a short.
+                        *
+                        * Update: even in gcc.4.6 using intermediate int cast gives -32764,
+                        * where as a direct cast from double to short gives -32768,
+                        * if this difference isn't important we could remove this hack,
+                        * since we dont support gcc3 anymore - Campbell */
                        int gcckludge;
                        gcckludge = (int) floor(value + 0.5);
                        value = (short)gcckludge;
@@ -2625,7 +2632,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
 
        but->flag |= (block->flag & UI_BUT_ALIGN);
 
-       if (but->lock) {
+       if (but->lock == TRUE) {
                if (but->lockstr) {
                        but->flag |= UI_BUT_DISABLED;
                }
@@ -2855,7 +2862,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *
 
        if (!ot) {
                but->flag |= UI_BUT_DISABLED;
-               but->lock = 1;
+               but->lock = TRUE;
                but->lockstr = "";
        }
 
@@ -2894,7 +2901,7 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn
 
        if (!ot) {
                but->flag |= UI_BUT_DISABLED;
-               but->lock = 1;
+               but->lock = TRUE;
                but->lockstr = "";
        }
 
index 33a5a07..ca52daa 100644 (file)
@@ -1140,8 +1140,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
        static ColorBand but_copypaste_coba = {0};
        char buf[UI_MAX_DRAW_STR + 1] = {0};
 
-       if (mode == 'v' && but->lock)
+       if (mode == 'v' && but->lock  == TRUE) {
                return;
+       }
 
        if (mode == 'v') {
                /* extract first line from clipboard in case of multi-line copies */
@@ -2969,7 +2970,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
                                 * Alt+MouseWheel over the render slots, without this,
                                 * the slot menu fails to switch a second time.
                                 *
-                                * Theactive state of the button could be maintained some other way
+                                * The active state of the button could be maintained some other way
                                 * and remove this mousemove event.
                                 */
                                WM_event_add_mousemove(C);
@@ -4793,7 +4794,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
        /* verify if we can edit this button */
        if (ELEM(event->type, LEFTMOUSE, RETKEY)) {
                /* this should become disabled button .. */
-               if (but->lock) {
+               if (but->lock == TRUE) {
                        if (but->lockstr) {
                                BKE_report(NULL, RPT_WARNING, but->lockstr);
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
index 13d05ca..567109e 100644 (file)
@@ -303,27 +303,27 @@ struct uiBlock {
        const char *lockstr;
 
        char lock;
-       char active;                // to keep blocks while drawing and free them afterwards
-       char tooltipdisabled;       // to avoid tooltip after click
-       char endblock;              // uiEndBlock done?
-       
-       float xofs, yofs;           // offset to parent button
-       int dobounds, mx, my;       // for doing delayed
-       int bounds, minbounds;      // for doing delayed
+       char active;                /* to keep blocks while drawing and free them afterwards */
+       char tooltipdisabled;       /* to avoid tooltip after click */
+       char endblock;              /* uiEndBlock done? */
+
+       float xofs, yofs;           /* offset to parent button */
+       int dobounds, mx, my;       /* for doing delayed */
+       int bounds, minbounds;      /* for doing delayed */
 
-       rctf safety;                // pulldowns, to detect outside, can differ per case how it is created
-       ListBase saferct;           // uiSafetyRct list
+       rctf safety;                /* pulldowns, to detect outside, can differ per case how it is created */
+       ListBase saferct;           /* uiSafetyRct list */
 
-       uiPopupBlockHandle *handle; // handle
+       uiPopupBlockHandle *handle; /* handle */
 
-       struct wmOperator *ui_operator; // use so presets can find the operator,
-                                      // across menus and from nested popups which fail for operator context.
+       struct wmOperator *ui_operator; /* use so presets can find the operator, */
+                                       /* across menus and from nested popups which fail for operator context. */
 
-       void *evil_C;               // XXX hack for dynamic operator enums
+       void *evil_C;               /* XXX hack for dynamic operator enums */
 
-       struct UnitSettings *unit;  // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time.
-       float _hsv[3];              // XXX, only access via ui_block_hsv_get()
-       char color_profile;         // color profile for correcting linear colors for display
+       struct UnitSettings *unit;  /* unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. */
+       float _hsv[3];              /* XXX, only access via ui_block_hsv_get() */
+       char color_profile;         /* color profile for correcting linear colors for display */
 };
 
 typedef struct uiSafetyRct {
index deef36d..b68e148 100644 (file)
@@ -630,7 +630,7 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
 
        but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
        but->flag |= UI_BUT_DISABLED;
-       but->lock = 1;
+       but->lock = TRUE;
        but->lockstr = "";
 }
 
index ebfc052..d0ce3f0 100644 (file)
@@ -269,15 +269,15 @@ void WM_OT_collada_export(wmOperatorType *ot)
 
 
        RNA_def_boolean(ot->srna, "active_uv_only", 0, "Only Active UV layer",
-                                       "Export textures assigned to the object UV maps");
+                       "Export textures assigned to the object UV maps");
 
        RNA_def_boolean(ot->srna, "include_uv_textures", 0, "Include UV Textures",
-                                       "Export textures assigned to the object UV maps");
+                       "Export textures assigned to the object UV maps");
 
        RNA_def_boolean(ot->srna, "include_material_textures", 0, "Include Material Textures",
-                                       "Export textures assigned to the object Materials");
+                       "Export textures assigned to the object Materials");
 
-       RNA_def_boolean(ot->srna, "use_texture_copies", 1, "Copy", 
+       RNA_def_boolean(ot->srna, "use_texture_copies", 1, "Copy",
                        "Copy textures to same folder where the .dae file is exported");
 
 
index d2a5e80..b37f758 100644 (file)
@@ -180,25 +180,20 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
 
 /******************** add vertex *********************/
 
-static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point,
+static void setup_vertex_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point,
                                const float point_co[2], const float tangent[2], const float u,
                                MaskSplinePoint *reference_point, const short reference_adjacent,
                                const float view_zoom)
 {
-       ScrArea *sa = CTX_wm_area(C);
-
        MaskSplinePoint *prev_point = NULL;
        MaskSplinePoint *next_point = NULL;
        BezTriple *bezt;
-       int width, height;
        float co[3];
-       const float len = 20.0; /* default length of handle in pixel space */
+       const float len = 10.0; /* default length of handle in pixel space */
 
        copy_v2_v2(co, point_co);
        co[2] = 0.0f;
 
-       ED_mask_get_size(sa, &width, &height);
-
        /* point coordinate */
        bezt = &new_point->bezt;
 
@@ -226,21 +221,15 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline
        /* initial offset for handles */
        if (spline->tot_point == 1) {
                /* first point of splien is aligned horizontally */
-               bezt->vec[0][0] -= len / maxi(width, height) * view_zoom;
-               bezt->vec[2][0] += len / maxi(width, height) * view_zoom;
+               bezt->vec[0][0] -= len * view_zoom;
+               bezt->vec[2][0] += len * view_zoom;
        }
        else if (tangent) {
                float vec[2];
 
                copy_v2_v2(vec, tangent);
 
-               vec[0] *= width;
-               vec[1] *= height;
-
-               mul_v2_fl(vec, len / len_v2(vec));
-
-               vec[0] /= width;
-               vec[1] /= height;
+               mul_v2_fl(vec, len);
 
                sub_v2_v2(bezt->vec[0], vec);
                add_v2_v2(bezt->vec[2], vec);
@@ -392,7 +381,7 @@ static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2]
 
                new_point = &spline->points[point_index + 1];
 
-               setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f);
+               setup_vertex_point(mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f);
 
                /* TODO - we could pass the spline! */
                BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, TRUE);
@@ -491,7 +480,7 @@ static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay,
 
        masklay->act_point = new_point;
 
-       setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, 1.0f);
+       setup_vertex_point(mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, 1.0f);
 
        if (masklay->splines_shapes.first) {
                point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
@@ -542,22 +531,18 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con
                ScrArea *sa = CTX_wm_area(C);
                ARegion *ar = CTX_wm_region(C);
 
+               float zoom_x, zoom_y;
                /* calc view zoom in a simplistic way */
-               float co_a[2];
-               float co_b[2];
-               int mval_a[2] = {0, 0};
-               int mval_b[2] = {1, 1};
-
-               ED_mask_mouse_pos(sa, ar, mval_a, co_a);
-               ED_mask_mouse_pos(sa, ar, mval_b, co_b);
+               ED_mask_zoom(sa, ar, &zoom_x, &zoom_y);
 
-               view_zoom = ((co_b[0] - co_a[0]) + (co_b[1] - co_a[1])) / 2.0f;
+               view_zoom = zoom_x + zoom_y / 2.0f;
+               view_zoom = 1.0f / view_zoom;
 
-               /* scale up - arbitrarty but works well in the view */
-               view_zoom *= 200.0f;
+               /* arbitrary but gives good results */
+               view_zoom /= 500.0f;
        }
 
-       setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, view_zoom);
+       setup_vertex_point(mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, view_zoom);
 
        {
                int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
index 843a36c..92cc336 100644 (file)
@@ -4802,19 +4802,32 @@ void MESH_OT_bevel(wmOperatorType *ot)
 
 static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
 {
+       BMOperator bmop;
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BMEdit_FromObject(obedit);
+       const int use_merge = RNA_boolean_get(op->ptr, "use_merge");
+       const float merge_factor = RNA_float_get(op->ptr, "merge_factor");
        
-       if (!EDBM_op_callf(em, op,
-                          "bridge_loops edges=%he use_merge=%b merge_factor=%f",
-                          BM_ELEM_SELECT, RNA_boolean_get(op->ptr, "use_merge"), RNA_float_get(op->ptr, "merge_factor")))
-       {
-               return OPERATOR_CANCELLED;
+       EDBM_op_init(em, &bmop, op,
+                    "bridge_loops edges=%he use_merge=%b merge_factor=%f",
+                    BM_ELEM_SELECT, use_merge, merge_factor);
+
+       BMO_op_exec(em->bm, &bmop);
+
+       /* when merge is used the edges are joined and remain selected */
+       if (use_merge == FALSE) {
+               EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+               BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE);
        }
-       
-       EDBM_update_generic(C, em, TRUE);
 
-       return OPERATOR_FINISHED;
+       if (!EDBM_op_finish(em, &bmop, op, TRUE)) {
+               return OPERATOR_CANCELLED;
+
+       }
+       else {
+               EDBM_update_generic(C, em, TRUE);
+               return OPERATOR_FINISHED;
+       }
 }
 
 void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
index 53bfdde..cca37cf 100644 (file)
@@ -370,6 +370,7 @@ void OBJECT_OT_group_add(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec = group_add_exec;
+       ot->poll = ED_operator_objectmode;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -403,6 +404,7 @@ void OBJECT_OT_group_link(wmOperatorType *ot)
        /* api callbacks */
        ot->exec = group_link_exec;
        ot->invoke = WM_enum_search_invoke;
+       ot->poll = ED_operator_objectmode;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -438,6 +440,7 @@ void OBJECT_OT_group_remove(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec = group_remove_exec;
+       ot->poll = ED_operator_objectmode;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
index 2f91652..f95b07b 100644 (file)
@@ -1113,7 +1113,7 @@ void fluidsimSettingsFree(FluidsimSettings *UNUSED(fss))
 {
 }
 
-FluidsimSettingsfluidsimSettingsCopy(FluidsimSettings *UNUSED(fss))
+FluidsimSettings *fluidsimSettingsCopy(FluidsimSettings *UNUSED(fss))
 {
        return NULL;
 }
index 96e2b3f..04a43c4 100644 (file)
@@ -592,7 +592,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        /* store actual owner of job, so modal operator could check for it,
         * the reason of this is that active scene could change when rendering
-        * several layers from composistor [#31800]
+        * several layers from compositor [#31800]
         */
        op->customdata = scene;
 
index 66b78f2..35db965 100644 (file)
@@ -390,7 +390,11 @@ typedef struct UndoImageTile {
        char idname[MAX_ID_NAME];  /* name instead of pointer*/
        char ibufname[IB_FILENAME_SIZE];
 
-       void *rect;
+       union {
+               float        *fp;
+               unsigned int *uint;
+               void         *pt;
+       } rect;
        int x, y;
 
        short source, use_float;
@@ -408,10 +412,10 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, int
                    tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
 
        if (ibuf->rect_float) {
-               SWAP(void *, tmpibuf->rect_float, tile->rect);
+               SWAP(float *, tmpibuf->rect_float, tile->rect.fp);
        }
        else {
-               SWAP(void *, tmpibuf->rect, tile->rect);
+               SWAP(unsigned int *, tmpibuf->rect, tile->rect.uint);
        }
        
        if (restore)
@@ -430,7 +434,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int
                if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source)
                        if (tile->use_float == use_float)
                                if (strcmp(tile->idname, ima->id.name) == 0 && strcmp(tile->ibufname, ibuf->name) == 0)
-                                       return tile->rect;
+                                       return tile->rect.pt;
        
        if (*tmpibuf == NULL)
                *tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat | IB_rect);
@@ -442,7 +446,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int
 
        allocsize = IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE * 4;
        allocsize *= (ibuf->rect_float) ? sizeof(float) : sizeof(char);
-       tile->rect = MEM_mapallocN(allocsize, "UndeImageTile.rect");
+       tile->rect.pt = MEM_mapallocN(allocsize, "UndeImageTile.rect");
 
        BLI_strncpy(tile->ibufname, ibuf->name, sizeof(tile->ibufname));
 
@@ -455,7 +459,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int
 
        BLI_addtail(lb, tile);
        
-       return tile->rect;
+       return tile->rect.pt;
 }
 
 static void image_undo_restore(bContext *C, ListBase *lb)
@@ -519,7 +523,7 @@ static void image_undo_free(ListBase *lb)
        UndoImageTile *tile;
 
        for (tile = lb->first; tile; tile = tile->next)
-               MEM_freeN(tile->rect);
+               MEM_freeN(tile->rect.pt);
 }
 
 /* get active image for face depending on old/new shading system */
@@ -4550,15 +4554,15 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
 
                /* temporarily add float rect for cloning */
                if (s->canvas->rect_float && !s->clonecanvas->rect_float) {
-                       int profile = IB_PROFILE_NONE;
+                       short profile = IB_PROFILE_NONE;
                        
                        /* Don't want to color manage, but don't disturb existing profiles */
-                       SWAP(int, s->clonecanvas->profile, profile);
+                       SWAP(short, s->clonecanvas->profile, profile);
 
                        IMB_float_from_rect(s->clonecanvas);
                        s->clonefreefloat = 1;
                        
-                       SWAP(int, s->clonecanvas->profile, profile);
+                       SWAP(short, s->clonecanvas->profile, profile);
                }
                else if (!s->canvas->rect_float && !s->clonecanvas->rect)
                        IMB_rect_from_float(s->clonecanvas);
index 6d1610f..09f6271 100644 (file)
@@ -157,7 +157,7 @@ void CLIP_OT_dopesheet_select_channel(wmOperatorType *ot)
 
        /* properties */
        RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
-               "Location", "Mouse location to select channel", -100.0f, 100.0f);
+                            "Location", "Mouse location to select channel", -100.0f, 100.0f);
        RNA_def_boolean(ot->srna, "extend", 0,
-               "Extend", "Extend selection rather than clearing the existing selection");
+                       "Extend", "Extend selection rather than clearing the existing selection");
 }
index 20b0ad5..aa2cadb 100644 (file)
@@ -456,7 +456,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot)
 
        /* properties */
        RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX,
-               "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX);
+                            "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX);
 }
 
 /********************** view zoom operator *********************/
@@ -580,7 +580,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot)
 
        /* properties */
        RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX,
-               "Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX);
+                     "Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX);
 }
 
 /********************** view zoom in/out operator *********************/
@@ -701,7 +701,7 @@ void CLIP_OT_view_zoom_ratio(wmOperatorType *ot)
 
        /* properties */
        RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX,
-               "Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
+                     "Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
 }
 
 /********************** view all operator *********************/
index 8c5ecb4..fcf6f28 100644 (file)
@@ -252,7 +252,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa))
 
 static void file_listener(ScrArea *sa, wmNotifier *wmn)
 {
-       /* SpaceFilesfile = (SpaceFile*)sa->spacedata.first; */
+       /* SpaceFile *sfile = (SpaceFile*)sa->spacedata.first; */
 
        /* context changes */
        switch (wmn->category) {
index a8bd0a4..08e0934 100644 (file)
@@ -724,25 +724,25 @@ static const char *actuator_name(int type)
 static const char *actuator_pup(Object *owner)
 {
        switch (owner->type) {
-       case OB_ARMATURE:
-               return "Actuators  %t|Action %x15|Armature %x23|Motion %x0|Constraint %x9|Ipo %x1"
-                       "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
-                                               "|Scene %x11|Random %x13|Message %x14|Game %x17"
-                       "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22";
-               break;
+               case OB_ARMATURE:
+                       return ("Actuators  %t|Action %x15|Armature %x23|Motion %x0|Constraint %x9|Ipo %x1"
+                               "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
+                               "|Scene %x11|Random %x13|Message %x14|Game %x17"
+                               "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
+                       break;
 
-       case OB_MESH:
-               return "Actuators  %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1"
-                       "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
-                                               "|Scene %x11|Random %x13|Message %x14|Game %x17"
-                       "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22";
-               break;
+               case OB_MESH:
+                       return ("Actuators  %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1"
+                               "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
+                               "|Scene %x11|Random %x13|Message %x14|Game %x17"
+                               "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
+                       break;
 
-       default:
-               return "Actuators  %t|Motion %x0|Constraint %x9|Ipo %x1"
-                       "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
-                                               "|Scene %x11|Random %x13|Message %x14|Game %x17"
-                       "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22";
+               default:
+                       return ("Actuators  %t|Motion %x0|Constraint %x9|Ipo %x1"
+                               "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
+                               "|Scene %x11|Random %x13|Message %x14|Game %x17"
+                               "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
        }
 }
 
index 81ee992..f5c3a4c 100644 (file)
@@ -52,7 +52,7 @@ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa);
 
 /* sequencer_draw.c */
 void draw_timeline_seq(const struct bContext *C, struct ARegion *ar);
-void draw_image_seq(const struct bContextC, struct Scene *scene, struct  ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay);
+void draw_image_seq(const struct bContext *C, struct Scene *scene, struct  ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay);
 
 void seq_reset_imageofs(struct SpaceSeq *sseq);
 
index db47f88..e74bda8 100644 (file)
@@ -662,8 +662,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y)
 
                if (vod->use_dyn_ofs) {
                        /* compute the post multiplication quat, to rotate the offset correctly */
-                       copy_qt_qt(q1, vod->oldquat);
-                       conjugate_qt(q1);
+                       conjugate_qt_qt(q1, vod->oldquat);
                        mul_qt_qtqt(q1, q1, vod->viewquat);
 
                        conjugate_qt(q1); /* conj == inv for unit quat */
index 561e97a..855771b 100644 (file)
@@ -489,7 +489,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event)
        else if (event->type == NDOF_MOTION) {
                /* do these automagically get delivered? yes. */
                // puts("ndof motion detected in fly mode!");
-               // static const chartag_name = "3D mouse position";
+               // static const char *tag_name = "3D mouse position";
 
                wmNDOFMotionData *incoming_ndof = (wmNDOFMotionData *)event->customdata;
                switch (incoming_ndof->progress) {
index 72c38be..f017394 100644 (file)
@@ -45,7 +45,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "BLO_sys_types.h" // for intptr_t support
+#include "BLO_sys_types.h"  /* for intptr_t support */
 
 /* Utils */
 
@@ -1040,7 +1040,7 @@ static PFace *p_face_add(PHandle *handle)
 
        /* allocate */
        f = (PFace *)BLI_memarena_alloc(handle->arena, sizeof *f);
-       f->flag = 0; // init !
+       f->flag = 0;  /* init ! */
 
        e1 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e1);
        e2 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e2);
@@ -1139,7 +1139,7 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys
         * that in symmetric models we choose the same split direction instead of
         * depending on floating point errors to decide */
        float bias = 1.0f + 1e-6f;
-       float fac = len_v3v3(co[0], co[2])*bias - len_v3v3(co[1], co[3]);
+       float fac = len_v3v3(co[0], co[2]) * bias - len_v3v3(co[1], co[3]);
        PBool dir = (fac <= 0.0f);
 
        /* the face exists check is there because of a special case: when
index f6dc673..439f52e 100644 (file)
@@ -515,5 +515,9 @@ void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_
                                                       void *customdata),
                                   void *(do_thread) (void *));
 
+/* ffmpeg */
+void IMB_ffmpeg_init(void);
+const char *IMB_ffmpeg_last_error(void);
+
 #endif
 
index e206541..a6f3851 100644 (file)
@@ -63,16 +63,16 @@ typedef enum ThumbSource {
 // IB_metadata
 
 /* create thumbnail for file and returns new imbuf for thumbnail */
-ImBuf *IMB_thumb_create(const charpath, ThumbSize size, ThumbSource source, ImBuf *ibuf);
+ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, ImBuf *ibuf);
 
 /* read thumbnail for file and returns new imbuf for thumbnail */
-ImBuf *IMB_thumb_read(const charpath, ThumbSize size);
+ImBuf *IMB_thumb_read(const char *path, ThumbSize size);
 
 /* delete all thumbs for the file */
-void IMB_thumb_delete(const charpath, ThumbSize size);
+void IMB_thumb_delete(const char *path, ThumbSize size);
 
 /* return the state of the thumb, needed to determine how to manage the thumb */
-ImBuf *IMB_thumb_manage(const charpath, ThumbSize size, ThumbSource source);
+ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source);
 
 /* create the necessary dirs to store the thumbnails */
 void IMB_thumb_makedirs(void);
index f07a18c..9092d59 100644 (file)
@@ -439,8 +439,6 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
 
 #ifdef WITH_FFMPEG
 
-extern void do_init_ffmpeg(void);
-
 static int startffmpeg(struct anim *anim)
 {
        int i, videoStream;
@@ -463,8 +461,6 @@ static int startffmpeg(struct anim *anim)
 
        streamcount = anim->streamindex;
 
-       do_init_ffmpeg();
-
        if (avformat_open_input(&pFormatCtx, anim->name, NULL, NULL) != 0) {
                return -1;
        }
index ebfee7a..10381e9 100644 (file)
@@ -92,9 +92,8 @@ struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags)
        /* allocate the image buffer */
        ibuf = IMB_allocImBuf(bitmapSize.width, bitmapSize.height, 32/*RGBA*/, 0);
        if (!ibuf) {
-               fprintf(stderr, 
-                       "imb_cocoaLoadImage: could not allocate memory for the " \
-                       "image.\n");
+               fprintf(stderr,
+                       "imb_cocoaLoadImage: could not allocate memory for the image.\n");
                [bitmapImage release];
                [pool drain];
                return NULL;
@@ -243,8 +242,8 @@ short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags)
                        break;
                default:
                        fprintf(stderr,
-                                       "imb_cocoaSaveImage: unsupported number of bytes per " 
-                                       "pixel: %d\n", samplesperpixel);
+                               "imb_cocoaSaveImage: unsupported number of bytes per "
+                               "pixel: %d\n", samplesperpixel);
                        return (0);
        }
 
@@ -257,16 +256,16 @@ short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags)
        
        /* Create bitmap image rep in blender format */
        blBitmapFormatImage = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
-                                                                                                                                 pixelsWide:ibuf->x 
-                                                                                                                                 pixelsHigh:ibuf->y
-                                                                                                                          bitsPerSample:bitspersample samplesPerPixel:samplesperpixel hasAlpha:hasAlpha isPlanar:NO
-                                                                                                                         colorSpaceName:colorSpace 
-                                                                                                                               bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
-                                                                                                                                bytesPerRow:(ibuf->x*bitspersample*samplesperpixel/8)
-                                                                                                                               bitsPerPixel:(bitspersample*samplesperpixel)];
+                                                                     pixelsWide:ibuf->x
+                                                                     pixelsHigh:ibuf->y
+                                                                  bitsPerSample:bitspersample samplesPerPixel:samplesperpixel hasAlpha:hasAlpha isPlanar:NO
+                                                                 colorSpaceName:colorSpace
+                                                                   bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
+                                                                    bytesPerRow:(ibuf->x*bitspersample*samplesperpixel/8)
+                                                                   bitsPerPixel:(bitspersample*samplesperpixel)];
        if (!blBitmapFormatImage) {
-               [pool drain];
-               return FALSE;
+           [pool drain];
+           return FALSE;
        }
        
        /* setup pointers */
index 34afdda..26aab29 100644 (file)
@@ -153,7 +153,7 @@ void Mem_IStream::clear()
 
 /* File Input Stream */
 
-class IFileStream : public IStream
+class IFileStream : public Imf::IStream
 {
 public:
        IFileStream(const char *filename)
index 2b0597d..9ec22f0 100644 (file)
@@ -43,6 +43,8 @@
 
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
 
 #include "DNA_userdef_types.h"
 #include "BKE_global.h"
@@ -220,6 +222,8 @@ static int isqtime(const char *name)
 
 #ifdef WITH_FFMPEG
 
+static char ffmpeg_last_error[1024];
+
 void silence_log_ffmpeg(int quiet)
 {
        if (quiet) {
@@ -230,21 +234,40 @@ void silence_log_ffmpeg(int quiet)
        }
 }
 
-extern void do_init_ffmpeg(void);
-void do_init_ffmpeg(void)
+void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg)
 {
-       static int ffmpeg_init = 0;
-       if (!ffmpeg_init) {
-               ffmpeg_init = 1;
-               av_register_all();
-               avdevice_register_all();
-               if ((G.debug & G_DEBUG_FFMPEG) == 0) {
-                       silence_log_ffmpeg(1);
-               }
-               else {
-                       silence_log_ffmpeg(0);
-               }
+       if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) {
+               size_t n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, arg);
+
+               /* strip trailing \n */
+               ffmpeg_last_error[n - 1] = '\0';
        }
+
+       /* call default logger to print all message to console */
+       av_log_default_callback(ptr, level, format, arg);
+}
+
+void IMB_ffmpeg_init(void)
+{
+       av_register_all();
+       avdevice_register_all();
+
+       if ((G.debug & G_DEBUG_FFMPEG) == 0) {
+               silence_log_ffmpeg(1);
+       }
+       else {
+               silence_log_ffmpeg(0);
+       }
+
+       ffmpeg_last_error[0] = '\0';
+
+       /* set own callback which could store last error to report to UI */
+       av_log_set_callback(ffmpeg_log_callback);
+}
+
+const char *IMB_ffmpeg_last_error(void)
+{
+       return ffmpeg_last_error;
 }
 
 static int isffmpeg(const char *filename)
@@ -255,8 +278,6 @@ static int isffmpeg(const char *filename)
        AVCodec *pCodec;
        AVCodecContext *pCodecCtx;
 
-       do_init_ffmpeg();
-
        if (BLI_testextensie(filename, ".swf") ||
            BLI_testextensie(filename, ".jpg") ||
            BLI_testextensie(filename, ".png") ||
index 6dd75e9..e69d313 100644 (file)
@@ -313,7 +313,7 @@ static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
        if (!base)
                return;
        
-       SWAP(int, base->lay, ob->lay);
+       SWAP(unsigned int, base->lay, ob->lay);
 
        rna_Object_layer_update__internal(bmain, scene, base, ob);
        ob->lay = base->lay;
index aca1b3d..90fe092 100644 (file)
@@ -3006,7 +3006,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
                {CODEC_ID_FLV1, "FLASH", 0, "Flash Video", ""},
                {CODEC_ID_FFV1, "FFV1", 0, "FFmpeg video codec #1", ""},
                {CODEC_ID_QTRLE, "QTRLE", 0, "QTRLE", ""},
-               /* {CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""}, */ /* disabled for after release */
+               {CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""},
                {0, NULL, 0, NULL, NULL}
        };
 
index 0898ba5..172a799 100644 (file)
@@ -910,7 +910,7 @@ static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop)
                           "Frame number to find marker for", MINFRAME, MAXFRAME);
        RNA_def_property_flag(parm, PROP_REQUIRED);
        parm = RNA_def_boolean(func, "exact", TRUE, "Exact",
-                       "Get marker at exact frame number rather than get estimated marker");
+                              "Get marker at exact frame number rather than get estimated marker");
        parm = RNA_def_pointer(func, "marker", "MovieTrackingMarker", "", "Marker for specified frame");
        RNA_def_function_return(func, parm);
 
index 4a6d5ce..988d15e 100644 (file)
@@ -185,7 +185,7 @@ static void displaceModifier_do(
 
        if (dmd->texture) {
                tex_co = MEM_callocN(sizeof(*tex_co) * numVerts,
-                                                        "displaceModifier_do tex_co");
+                                    "displaceModifier_do tex_co");
                get_texture_coords((MappingInfoModifierData *)dmd, ob, dm, vertexCos, tex_co, numVerts);
 
                modifier_init_texture(dmd->modifier.scene, dmd->texture);
index f3e5b30..e02efc7 100644 (file)
@@ -97,9 +97,9 @@ static PyObject *bpy_bm_from_edit_mesh(PyObject *UNUSED(self), PyObject *value)
 }
 
 static struct PyMethodDef BPy_BM_methods[] = {
-    {"new",            (PyCFunction)bpy_bm_new,            METH_NOARGS,  bpy_bm_new_doc},
-    {"from_edit_mesh", (PyCFunction)bpy_bm_from_edit_mesh, METH_O,       bpy_bm_from_edit_mesh_doc},
-    {NULL, NULL, 0, NULL}
+       {"new",            (PyCFunction)bpy_bm_new,            METH_NOARGS,  bpy_bm_new_doc},
+       {"from_edit_mesh", (PyCFunction)bpy_bm_from_edit_mesh, METH_O,       bpy_bm_from_edit_mesh_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 PyDoc_STRVAR(BPy_BM_doc,
index 8e7c481..c16b1fb 100644 (file)
@@ -420,7 +420,7 @@ static PyObject *bpy_bmesh_fmod_getattro(PyObject *UNUSED(self), PyObject *pynam
        }
 
        PyErr_Format(PyExc_AttributeError,
-                                "BMeshOpsModule: operator \"%.200s\" doesn't exist",
+                    "BMeshOpsModule: operator \"%.200s\" doesn't exist",
                     name);
        return NULL;
 }
index 24e7cd5..d7d9baf 100644 (file)
 
 /* scene does not use BM_* flags. */
 PyC_FlagSet bpy_bm_scene_vert_edge_face_flags[] = {
-    {1, "VERT"},
-    {2, "EDGE"},
-    {4, "FACE"},
-    {0, NULL}
+       {1, "VERT"},
+       {2, "EDGE"},
+       {4, "FACE"},
+       {0, NULL}
 };
 
 PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[] = {
-    {BM_VERT, "VERT"},
-    {BM_EDGE, "EDGE"},
-    {BM_FACE, "FACE"},
-    {0, NULL}
+       {BM_VERT, "VERT"},
+       {BM_EDGE, "EDGE"},
+       {BM_FACE, "FACE"},
+               {0, NULL}
 };
 
 PyC_FlagSet bpy_bm_htype_all_flags[] = {
-    {BM_VERT, "VERT"},
-    {BM_LOOP, "EDGE"},
-    {BM_FACE, "FACE"},
-    {BM_LOOP, "LOOP"},
-    {0, NULL}
+       {BM_VERT, "VERT"},
+       {BM_LOOP, "EDGE"},
+       {BM_FACE, "FACE"},
+       {BM_LOOP, "LOOP"},
+       {0, NULL}
 };
 
 PyC_FlagSet bpy_bm_hflag_all_flags[] = {
-    {BM_ELEM_SELECT,  "SELECT"},
-    {BM_ELEM_HIDDEN,  "HIDE"},
-    {BM_ELEM_SEAM,    "SEAM"},
-    {BM_ELEM_SMOOTH,  "SMOOTH"},
-    {BM_ELEM_TAG,     "TAG"},
-    {0, NULL}
+       {BM_ELEM_SELECT,  "SELECT"},
+       {BM_ELEM_HIDDEN,  "HIDE"},
+       {BM_ELEM_SEAM,    "SEAM"},
+       {BM_ELEM_SMOOTH,  "SMOOTH"},
+       {BM_ELEM_TAG,     "TAG"},
+       {0, NULL}
 };
 
 /* py-type definitions
@@ -556,131 +556,131 @@ static PyObject *bpy_bmelemseq_layers_get(BPy_BMElemSeq *self, void *htype)
 }
 
 static PyGetSetDef bpy_bmesh_getseters[] = {
-    {(char *)"verts", (getter)bpy_bmvertseq_get, (setter)NULL, (char *)bpy_bmvertseq_doc, NULL},
-    {(char *)"edges", (getter)bpy_bmedgeseq_get, (setter)NULL, (char *)bpy_bmedgeseq_doc, NULL},
-    {(char *)"faces", (getter)bpy_bmfaceseq_get, (setter)NULL, (char *)bpy_bmfaceseq_doc, NULL},
-    {(char *)"loops", (getter)bpy_bmloopseq_get, (setter)NULL, (char *)bpy_bmloopseq_doc, NULL},
-    {(char *)"select_mode", (getter)bpy_bmesh_select_mode_get, (setter)bpy_bmesh_select_mode_set, (char *)bpy_bmesh_select_mode_doc, NULL},
+       {(char *)"verts", (getter)bpy_bmvertseq_get, (setter)NULL, (char *)bpy_bmvertseq_doc, NULL},
+       {(char *)"edges", (getter)bpy_bmedgeseq_get, (setter)NULL, (char *)bpy_bmedgeseq_doc, NULL},
+       {(char *)"faces", (getter)bpy_bmfaceseq_get, (setter)NULL, (char *)bpy_bmfaceseq_doc, NULL},
+       {(char *)"loops", (getter)bpy_bmloopseq_get, (setter)NULL, (char *)bpy_bmloopseq_doc, NULL},
+       {(char *)"select_mode", (getter)bpy_bmesh_select_mode_get, (setter)bpy_bmesh_select_mode_set, (char *)bpy_bmesh_select_mode_doc, NULL},
 
-    {(char *)"select_history", (getter)bpy_bmesh_select_history_get, (setter)bpy_bmesh_select_history_set, (char *)bpy_bmesh_select_history_doc, NULL},
+       {(char *)"select_history", (getter)bpy_bmesh_select_history_get, (setter)bpy_bmesh_select_history_set, (char *)bpy_bmesh_select_history_doc, NULL},
 
-    /* readonly checks */
-    {(char *)"is_wrapped", (getter)bpy_bmesh_is_wrapped_get, (setter)NULL, (char *)bpy_bmesh_is_wrapped_doc, NULL}, /* as with mathutils */
-    {(char *)"is_valid",   (getter)bpy_bm_is_valid_get,   (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
+       /* readonly checks */
+       {(char *)"is_wrapped", (getter)bpy_bmesh_is_wrapped_get, (setter)NULL, (char *)bpy_bmesh_is_wrapped_doc, NULL}, /* as with mathutils */
+       {(char *)"is_valid",   (getter)bpy_bm_is_valid_get,   (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmvert_getseters[] = {
-    /* generic */
-    {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
-    {(char *)"hide",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc,   (void *)BM_ELEM_HIDDEN},
-    {(char *)"tag",    (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc,    (void *)BM_ELEM_TAG},
-    {(char *)"index",  (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc,  NULL},
-
-    {(char *)"co",     (getter)bpy_bmvert_co_get,     (setter)bpy_bmvert_co_set,     (char *)bpy_bmvert_co_doc, NULL},
-    {(char *)"normal", (getter)bpy_bmvert_normal_get, (setter)bpy_bmvert_normal_set, (char *)bpy_bmvert_normal_doc, NULL},
-
-    /* connectivity data */
-    {(char *)"link_edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_edges_doc, (void *)BM_EDGES_OF_VERT},
-    {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_faces_doc, (void *)BM_FACES_OF_VERT},
-    {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_loops_doc, (void *)BM_LOOPS_OF_VERT},
-
-    /* readonly checks */
-    {(char *)"is_manifold",  (getter)bpy_bmvert_is_manifold_get,  (setter)NULL, (char *)bpy_bmvert_is_manifold_doc, NULL},
-    {(char *)"is_wire",      (getter)bpy_bmvert_is_wire_get,      (setter)NULL, (char *)bpy_bmvert_is_wire_doc, NULL},
-    {(char *)"is_valid",     (getter)bpy_bm_is_valid_get,         (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
-
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       /* generic */
+       {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
+       {(char *)"hide",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc,   (void *)BM_ELEM_HIDDEN},
+       {(char *)"tag",    (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc,    (void *)BM_ELEM_TAG},
+       {(char *)"index",  (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc,  NULL},
+
+       {(char *)"co",     (getter)bpy_bmvert_co_get,     (setter)bpy_bmvert_co_set,     (char *)bpy_bmvert_co_doc, NULL},
+       {(char *)"normal", (getter)bpy_bmvert_normal_get, (setter)bpy_bmvert_normal_set, (char *)bpy_bmvert_normal_doc, NULL},
+
+       /* connectivity data */
+       {(char *)"link_edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_edges_doc, (void *)BM_EDGES_OF_VERT},
+       {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_faces_doc, (void *)BM_FACES_OF_VERT},
+       {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_loops_doc, (void *)BM_LOOPS_OF_VERT},
+
+       /* readonly checks */
+       {(char *)"is_manifold",  (getter)bpy_bmvert_is_manifold_get,  (setter)NULL, (char *)bpy_bmvert_is_manifold_doc, NULL},
+       {(char *)"is_wire",      (getter)bpy_bmvert_is_wire_get,      (setter)NULL, (char *)bpy_bmvert_is_wire_doc, NULL},
+       {(char *)"is_valid",     (getter)bpy_bm_is_valid_get,         (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
+
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmedge_getseters[] = {
-    /* generic */
-    {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
-    {(char *)"hide",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc,   (void *)BM_ELEM_HIDDEN},
-    {(char *)"tag",    (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc,    (void *)BM_ELEM_TAG},
-    {(char *)"index",  (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc,  NULL},
+       /* generic */
+       {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
+       {(char *)"hide",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc,   (void *)BM_ELEM_HIDDEN},
+       {(char *)"tag",    (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc,    (void *)BM_ELEM_TAG},
+       {(char *)"index",  (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc,  NULL},
 
-    {(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH},
-    {(char *)"seam",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_seam_doc, (void *)BM_ELEM_SEAM},
+       {(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH},
+       {(char *)"seam",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_seam_doc, (void *)BM_ELEM_SEAM},
 
-    /* connectivity data */
-    {(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_verts_doc, (void *)BM_VERTS_OF_EDGE},
+       /* connectivity data */
+       {(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_verts_doc, (void *)BM_VERTS_OF_EDGE},
 
-    {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_faces_doc, (void *)BM_FACES_OF_EDGE},
-    {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_loops_doc, (void *)BM_LOOPS_OF_EDGE},
+       {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_faces_doc, (void *)BM_FACES_OF_EDGE},
+       {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_loops_doc, (void *)BM_LOOPS_OF_EDGE},
 
-    /* readonly checks */
-    {(char *)"is_manifold",  (getter)bpy_bmedge_is_manifold_get,  (setter)NULL, (char *)bpy_bmedge_is_manifold_doc, NULL},
-    {(char *)"is_wire",      (getter)bpy_bmedge_is_wire_get,      (setter)NULL, (char *)bpy_bmedge_is_wire_doc, NULL},
-    {(char *)"is_boundary",   (getter)bpy_bmedge_is_boundary_get,   (setter)NULL, (char *)bpy_bmedge_is_boundary_doc, NULL},
-    {(char *)"is_valid",     (getter)bpy_bm_is_valid_get,         (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
+       /* readonly checks */
+       {(char *)"is_manifold",  (getter)bpy_bmedge_is_manifold_get,  (setter)NULL, (char *)bpy_bmedge_is_manifold_doc, NULL},
+       {(char *)"is_wire",      (getter)bpy_bmedge_is_wire_get,      (setter)NULL, (char *)bpy_bmedge_is_wire_doc, NULL},
+       {(char *)"is_boundary",   (getter)bpy_bmedge_is_boundary_get,   (setter)NULL, (char *)bpy_bmedge_is_boundary_doc, NULL},
+       {(char *)"is_valid",     (getter)bpy_bm_is_valid_get,         (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmface_getseters[] = {
-    /* generic */
-    {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
-    {(char *)"hide",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc,   (void *)BM_ELEM_HIDDEN},
-    {(char *)"tag",    (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc,    (void *)BM_ELEM_TAG},
-    {(char *)"index",  (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc,  NULL},
+       /* generic */
+       {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
+       {(char *)"hide",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc,   (void *)BM_ELEM_HIDDEN},
+       {(char *)"tag",    (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc,    (void *)BM_ELEM_TAG},
+       {(char *)"index",  (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc,  NULL},
 
-    {(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH},
+       {(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH},
 
-    {(char *)"normal", (getter)bpy_bmface_normal_get, (setter)bpy_bmface_normal_set, (char *)bpy_bmface_normal_doc, NULL},
+       {(char *)"normal", (getter)bpy_bmface_normal_get, (setter)bpy_bmface_normal_set, (char *)bpy_bmface_normal_doc, NULL},
 
-    {(char *)"material_index",  (getter)bpy_bmface_material_index_get, (setter)bpy_bmface_material_index_set, (char *)bpy_bmface_material_index_doc,  NULL},
+       {(char *)"material_index",  (getter)bpy_bmface_material_index_get, (setter)bpy_bmface_material_index_set, (char *)bpy_bmface_material_index_doc,  NULL},
 
-    /* connectivity data */
-    {(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_verts_doc, (void *)BM_VERTS_OF_FACE},
-    {(char *)"edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_edges_doc, (void *)BM_EDGES_OF_FACE},
-    {(char *)"loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_loops_doc, (void *)BM_LOOPS_OF_FACE},
+       /* connectivity data */
+       {(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_verts_doc, (void *)BM_VERTS_OF_FACE},
+       {(char *)"edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_edges_doc, (void *)BM_EDGES_OF_FACE},
+       {(char *)"loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_loops_doc, (void *)BM_LOOPS_OF_FACE},
 
-    /* readonly checks */
-    {(char *)"is_valid",   (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
+       /* readonly checks */
+       {(char *)"is_valid",   (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmloop_getseters[] = {
-    /* generic */
-    // flags are available but not used for loops.
-    // {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
-    // {(char *)"hide",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc,   (void *)BM_ELEM_HIDDEN},
-    {(char *)"tag",    (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc,    (void *)BM_ELEM_TAG},
-    {(char *)"index",  (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc,  NULL},
-
-    {(char *)"vert", (getter)bpy_bmloop_vert_get, (setter)NULL, (char *)bpy_bmloop_vert_doc, NULL},
-    {(char *)"edge", (getter)bpy_bmloop_edge_get, (setter)NULL, (char *)bpy_bmloop_edge_doc, NULL},
-    {(char *)"face", (getter)bpy_bmloop_face_get, (setter)NULL, (char *)bpy_bmloop_face_doc, NULL},
-
-    /* connectivity data */
-    {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmloops_link_loops_doc, (void *)BM_LOOPS_OF_LOOP},
-    {(char *)"link_loop_next", (getter)bpy_bmloop_link_loop_next_get, (setter)NULL, (char *)bpy_bmloop_link_loop_next_doc, NULL},
-    {(char *)"link_loop_prev", (getter)bpy_bmloop_link_loop_prev_get, (setter)NULL, (char *)bpy_bmloop_link_loop_prev_doc, NULL},
-
-    /* readonly checks */
-    {(char *)"is_valid",   (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
-
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       /* generic */
+       // flags are available but not used for loops.
+       // {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
+       // {(char *)"hide",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc,   (void *)BM_ELEM_HIDDEN},
+       {(char *)"tag",    (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc,    (void *)BM_ELEM_TAG},
+       {(char *)"index",  (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc,  NULL},
+
+       {(char *)"vert", (getter)bpy_bmloop_vert_get, (setter)NULL, (char *)bpy_bmloop_vert_doc, NULL},
+       {(char *)"edge", (getter)bpy_bmloop_edge_get, (setter)NULL, (char *)bpy_bmloop_edge_doc, NULL},
+       {(char *)"face", (getter)bpy_bmloop_face_get, (setter)NULL, (char *)bpy_bmloop_face_doc, NULL},
+
+       /* connectivity data */
+       {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmloops_link_loops_doc, (void *)BM_LOOPS_OF_LOOP},
+       {(char *)"link_loop_next", (getter)bpy_bmloop_link_loop_next_get, (setter)NULL, (char *)bpy_bmloop_link_loop_next_doc, NULL},
+       {(char *)"link_loop_prev", (getter)bpy_bmloop_link_loop_prev_get, (setter)NULL, (char *)bpy_bmloop_link_loop_prev_doc, NULL},
+
+       /* readonly checks */
+       {(char *)"is_valid",   (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
+
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmvertseq_getseters[] = {
-    {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_VERT},
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_VERT},
+               {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 static PyGetSetDef bpy_bmedgeseq_getseters[] = {
-    {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_EDGE},
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_EDGE},
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 static PyGetSetDef bpy_bmfaceseq_getseters[] = {
-    {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_FACE},
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_FACE},
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 static PyGetSetDef bpy_bmloopseq_getseters[] = {
-    {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_LOOP},
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_LOOP},
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 
@@ -2166,7 +2166,7 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
 
        if (keyfunc != NULL && !PyCallable_Check(keyfunc)) {
                PyErr_SetString(PyExc_TypeError,
-                               "the 'key' argument is not a callable object");
+                               "the 'key' argument is not a callable object");
                return NULL;
        }
 
@@ -2280,129 +2280,129 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
 }
 
 static struct PyMethodDef bpy_bmesh_methods[] = {
-    /* utility */
-    {"copy",  (PyCFunction)bpy_bmesh_copy,  METH_NOARGS, bpy_bmesh_copy_doc},
-    {"clear", (PyCFunction)bpy_bmesh_clear, METH_NOARGS, bpy_bmesh_clear_doc},
-    {"free",  (PyCFunction)bpy_bmesh_free,  METH_NOARGS, bpy_bmesh_free_doc},
-
-    /* conversion */
-    {"from_object", (PyCFunction)bpy_bmesh_from_object, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_from_object_doc},
-    {"from_mesh",   (PyCFunction)bpy_bmesh_from_mesh,   METH_VARARGS | METH_KEYWORDS, bpy_bmesh_from_mesh_doc},
-    {"to_mesh",     (PyCFunction)bpy_bmesh_to_mesh,     METH_VARARGS,                 bpy_bmesh_to_mesh_doc},
-
-    /* meshdata */
-    {"select_flush_mode", (PyCFunction)bpy_bmesh_select_flush_mode, METH_NOARGS, bpy_bmesh_select_flush_mode_doc},
-    {"select_flush", (PyCFunction)bpy_bmesh_select_flush, METH_O, bpy_bmesh_select_flush_doc},
-    {"normal_update", (PyCFunction)bpy_bmesh_normal_update, METH_VARARGS, bpy_bmesh_normal_update_doc},
-    {"transform", (PyCFunction)bpy_bmesh_transform, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_transform_doc},
-    {NULL, NULL, 0, NULL}
+       /* utility */
+       {"copy",  (PyCFunction)bpy_bmesh_copy,  METH_NOARGS, bpy_bmesh_copy_doc},
+       {"clear", (PyCFunction)bpy_bmesh_clear, METH_NOARGS, bpy_bmesh_clear_doc},
+       {"free",  (PyCFunction)bpy_bmesh_free,  METH_NOARGS, bpy_bmesh_free_doc},
+
+       /* conversion */
+       {"from_object", (PyCFunction)bpy_bmesh_from_object, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_from_object_doc},
+       {"from_mesh",   (PyCFunction)bpy_bmesh_from_mesh,   METH_VARARGS | METH_KEYWORDS, bpy_bmesh_from_mesh_doc},
+       {"to_mesh",     (PyCFunction)bpy_bmesh_to_mesh,     METH_VARARGS,                 bpy_bmesh_to_mesh_doc},
+
+       /* meshdata */
+       {"select_flush_mode", (PyCFunction)bpy_bmesh_select_flush_mode, METH_NOARGS, bpy_bmesh_select_flush_mode_doc},
+       {"select_flush", (PyCFunction)bpy_bmesh_select_flush, METH_O, bpy_bmesh_select_flush_doc},
+       {"normal_update", (PyCFunction)bpy_bmesh_normal_update, METH_VARARGS, bpy_bmesh_normal_update_doc},
+       {"transform", (PyCFunction)bpy_bmesh_transform, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_transform_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmvert_methods[] = {
-    {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc},
-    {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc},
-    {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
-    {"copy_from_face_interp", (PyCFunction)bpy_bmvert_copy_from_face_interp, METH_VARARGS, bpy_bmvert_copy_from_face_interp_doc},
-    {"copy_from_vert_interp", (PyCFunction)bpy_bmvert_copy_from_vert_interp, METH_VARARGS, bpy_bmvert_copy_from_vert_interp_doc},
+       {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc},
+       {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc},
+       {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
+       {"copy_from_face_interp", (PyCFunction)bpy_bmvert_copy_from_face_interp, METH_VARARGS, bpy_bmvert_copy_from_face_interp_doc},
+       {"copy_from_vert_interp", (PyCFunction)bpy_bmvert_copy_from_vert_interp, METH_VARARGS, bpy_bmvert_copy_from_vert_interp_doc},
 
-    {"calc_vert_angle",   (PyCFunction)bpy_bmvert_calc_edge_angle,   METH_NOARGS, bpy_bmvert_calc_edge_angle_doc},
-    {"calc_shell_factor", (PyCFunction)bpy_bmvert_calc_shell_factor, METH_NOARGS, bpy_bmvert_calc_shell_factor_doc},
+       {"calc_vert_angle",   (PyCFunction)bpy_bmvert_calc_edge_angle,   METH_NOARGS, bpy_bmvert_calc_edge_angle_doc},
+       {"calc_shell_factor", (PyCFunction)bpy_bmvert_calc_shell_factor, METH_NOARGS, bpy_bmvert_calc_shell_factor_doc},
 
-    {"normal_update",  (PyCFunction)bpy_bmvert_normal_update,  METH_NOARGS,  bpy_bmvert_normal_update_doc},
+       {"normal_update",  (PyCFunction)bpy_bmvert_normal_update,  METH_NOARGS,  bpy_bmvert_normal_update_doc},
 
-    {NULL, NULL, 0, NULL}
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmedge_methods[] = {
-    {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc},
-    {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc},
-    {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
+       {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc},
+       {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc},
+       {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
 
-    {"other_vert", (PyCFunction)bpy_bmedge_other_vert, METH_O, bpy_bmedge_other_vert_doc},
+       {"other_vert", (PyCFunction)bpy_bmedge_other_vert, METH_O, bpy_bmedge_other_vert_doc},
 
-    {"calc_length",     (PyCFunction)bpy_bmedge_calc_length,     METH_NOARGS,  bpy_bmedge_calc_length_doc},
-    {"calc_face_angle", (PyCFunction)bpy_bmedge_calc_face_angle, METH_NOARGS,  bpy_bmedge_calc_face_angle_doc},
-    {"calc_tangent",    (PyCFunction)bpy_bmedge_calc_tangent,    METH_VARARGS, bpy_bmedge_calc_tangent_doc},
+       {"calc_length",     (PyCFunction)bpy_bmedge_calc_length,     METH_NOARGS,  bpy_bmedge_calc_length_doc},
+       {"calc_face_angle", (PyCFunction)bpy_bmedge_calc_face_angle, METH_NOARGS,  bpy_bmedge_calc_face_angle_doc},
+       {"calc_tangent",    (PyCFunction)bpy_bmedge_calc_tangent,    METH_VARARGS, bpy_bmedge_calc_tangent_doc},
 
-    {"normal_update",  (PyCFunction)bpy_bmedge_normal_update,  METH_NOARGS,  bpy_bmedge_normal_update_doc},
+       {"normal_update",  (PyCFunction)bpy_bmedge_normal_update,  METH_NOARGS,  bpy_bmedge_normal_update_doc},
 
-    {NULL, NULL, 0, NULL}
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmface_methods[] = {
-    {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc},
-    {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc},
+       {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc},
+       {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc},
 
-    {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
-    {"copy_from_face_interp", (PyCFunction)bpy_bmface_copy_from_face_interp, METH_O, bpy_bmface_copy_from_face_interp_doc},
+       {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
+       {"copy_from_face_interp", (PyCFunction)bpy_bmface_copy_from_face_interp, METH_O, bpy_bmface_copy_from_face_interp_doc},
 
-    {"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS | METH_KEYWORDS, bpy_bmface_copy_doc},
+       {"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS | METH_KEYWORDS, bpy_bmface_copy_doc},
 
-    {"calc_area",          (PyCFunction)bpy_bmface_calc_area,          METH_NOARGS, bpy_bmface_calc_area_doc},
-    {"calc_perimeter",     (PyCFunction)bpy_bmface_calc_perimeter,     METH_NOARGS, bpy_bmface_calc_perimeter_doc},
-    {"calc_center_median", (PyCFunction)bpy_bmface_calc_center_mean,   METH_NOARGS, bpy_bmface_calc_center_mean_doc},
-    {"calc_center_bounds", (PyCFunction)bpy_bmface_calc_center_bounds, METH_NOARGS, bpy_bmface_calc_center_bounds_doc},
+       {"calc_area",          (PyCFunction)bpy_bmface_calc_area,          METH_NOARGS, bpy_bmface_calc_area_doc},
+       {"calc_perimeter",     (PyCFunction)bpy_bmface_calc_perimeter,     METH_NOARGS, bpy_bmface_calc_perimeter_doc},
+       {"calc_center_median", (PyCFunction)bpy_bmface_calc_center_mean,   METH_NOARGS, bpy_bmface_calc_center_mean_doc},
+       {"calc_center_bounds", (PyCFunction)bpy_bmface_calc_center_bounds, METH_NOARGS, bpy_bmface_calc_center_bounds_doc},
 
-    {"normal_update",  (PyCFunction)bpy_bmface_normal_update,  METH_NOARGS,  bpy_bmface_normal_update_doc},
+       {"normal_update",  (PyCFunction)bpy_bmface_normal_update,  METH_NOARGS,  bpy_bmface_normal_update_doc},
 
-    {NULL, NULL, 0, NULL}
+               {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmloop_methods[] = {
-    {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
-    {"copy_from_face_interp", (PyCFunction)bpy_bmloop_copy_from_face_interp, METH_O, bpy_bmloop_copy_from_face_interp_doc},
+       {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
+       {"copy_from_face_interp", (PyCFunction)bpy_bmloop_copy_from_face_interp, METH_O, bpy_bmloop_copy_from_face_interp_doc},
 
-    {"calc_angle",   (PyCFunction)bpy_bmloop_calc_angle,   METH_NOARGS, bpy_bmloop_calc_angle_doc},
-    {"calc_normal",  (PyCFunction)bpy_bmloop_calc_normal,  METH_NOARGS, bpy_bmloop_calc_normal_doc},
-    {"calc_tangent", (PyCFunction)bpy_bmloop_calc_tangent, METH_NOARGS, bpy_bmloop_calc_tangent_doc},
-    {NULL, NULL, 0, NULL}
+       {"calc_angle",   (PyCFunction)bpy_bmloop_calc_angle,   METH_NOARGS, bpy_bmloop_calc_angle_doc},
+       {"calc_normal",  (PyCFunction)bpy_bmloop_calc_normal,  METH_NOARGS, bpy_bmloop_calc_normal_doc},
+       {"calc_tangent", (PyCFunction)bpy_bmloop_calc_tangent, METH_NOARGS, bpy_bmloop_calc_tangent_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmelemseq_methods[] = {
-    /* odd function, initializes index values */
-    {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
-    {NULL, NULL, 0, NULL}
+       /* odd function, initializes index values */
+       {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmvertseq_methods[] = {
-    {"new",     (PyCFunction)bpy_bmvertseq_new,         METH_VARARGS, bpy_bmvertseq_new_doc},
-    {"remove",  (PyCFunction)bpy_bmvertseq_remove,      METH_O,       bpy_bmvertseq_remove_doc},
+       {"new",     (PyCFunction)bpy_bmvertseq_new,         METH_VARARGS, bpy_bmvertseq_new_doc},
+       {"remove",  (PyCFunction)bpy_bmvertseq_remove,      METH_O,       bpy_bmvertseq_remove_doc},
 
-    /* odd function, initializes index values */
-    {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
-    {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
-    {NULL, NULL, 0, NULL}
+       /* odd function, initializes index values */
+       {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
+       {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmedgeseq_methods[] = {
-    {"new",     (PyCFunction)bpy_bmedgeseq_new,         METH_VARARGS, bpy_bmedgeseq_new_doc},
-    {"remove",  (PyCFunction)bpy_bmedgeseq_remove,      METH_O,       bpy_bmedgeseq_remove_doc},
-    /* 'bpy_bmelemseq_get' for different purpose */
-    {"get",     (PyCFunction)bpy_bmedgeseq_get__method, METH_VARARGS, bpy_bmedgeseq_get__method_doc},
-
-    /* odd function, initializes index values */
-    {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
-    {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
-    {NULL, NULL, 0, NULL}
+       {"new",     (PyCFunction)bpy_bmedgeseq_new,         METH_VARARGS, bpy_bmedgeseq_new_doc},
+       {"remove",  (PyCFunction)bpy_bmedgeseq_remove,      METH_O,       bpy_bmedgeseq_remove_doc},
+       /* 'bpy_bmelemseq_get' for different purpose */
+       {"get",     (PyCFunction)bpy_bmedgeseq_get__method, METH_VARARGS, bpy_bmedgeseq_get__method_doc},
+
+       /* odd function, initializes index values */
+       {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
+       {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmfaceseq_methods[] = {
-    {"new",     (PyCFunction)bpy_bmfaceseq_new,         METH_VARARGS, bpy_bmfaceseq_new_doc},
-    {"remove",  (PyCFunction)bpy_bmfaceseq_remove,      METH_O,       bpy_bmfaceseq_remove_doc},
-    /* 'bpy_bmelemseq_get' for different purpose */
-    {"get",     (PyCFunction)bpy_bmfaceseq_get__method, METH_VARARGS, bpy_bmfaceseq_get__method_doc},
-
-    /* odd function, initializes index values */
-    {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
-    {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
-    {NULL, NULL, 0, NULL}
+       {"new",     (PyCFunction)bpy_bmfaceseq_new,         METH_VARARGS, bpy_bmfaceseq_new_doc},
+       {"remove",  (PyCFunction)bpy_bmfaceseq_remove,      METH_O,       bpy_bmfaceseq_remove_doc},
+       /* 'bpy_bmelemseq_get' for different purpose */
+       {"get",     (PyCFunction)bpy_bmfaceseq_get__method, METH_VARARGS, bpy_bmfaceseq_get__method_doc},
+
+       /* odd function, initializes index values */
+       {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
+       {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmloopseq_methods[] = {
-    /* odd function, initializes index values */
-    /* no: index_update() function since we cant iterate over loops */
-    /* no: sort() function since we cant iterate over loops */
-    {NULL, NULL, 0, NULL}
+       /* odd function, initializes index values */
+       /* no: index_update() function since we cant iterate over loops */
+       /* no: sort() function since we cant iterate over loops */
+       {NULL, NULL, 0, NULL}
 };
 
 /* Sequences
@@ -2637,29 +2637,29 @@ static int bpy_bmelem_ass_subscript(BPy_BMElem *self, BPy_BMLayerItem *key, PyOb
 }
 
 static PySequenceMethods bpy_bmelemseq_as_sequence = {
-    (lenfunc)bpy_bmelemseq_length,               /* sq_length */
-    NULL,                                        /* sq_concat */
-    NULL,                                        /* sq_repeat */
-    (ssizeargfunc)bpy_bmelemseq_subscript_int,   /* sq_item */ /* Only set this so PySequence_Check() returns True */
-    NULL,                                        /* sq_slice */
-    (ssizeobjargproc)NULL,                       /* sq_ass_item */
-    NULL,                                        /* *was* sq_ass_slice */
-    (objobjproc)bpy_bmelemseq_contains,          /* sq_contains */
-    (binaryfunc) NULL,                           /* sq_inplace_concat */
-    (ssizeargfunc) NULL,                         /* sq_inplace_repeat */
+       (lenfunc)bpy_bmelemseq_length,               /* sq_length */
+       NULL,                                        /* sq_concat */
+       NULL,                                        /* sq_repeat */
+       (ssizeargfunc)bpy_bmelemseq_subscript_int,   /* sq_item */ /* Only set this so PySequence_Check() returns True */
+       NULL,                                        /* sq_slice */
+       (ssizeobjargproc)NULL,                       /* sq_ass_item */
+       NULL,                                        /* *was* sq_ass_slice */
+       (objobjproc)bpy_bmelemseq_contains,          /* sq_contains */
+       (binaryfunc) NULL,                           /* sq_inplace_concat */
+       (ssizeargfunc) NULL,                         /* sq_inplace_repeat */
 };
 
 static PyMappingMethods bpy_bmelemseq_as_mapping = {
-    (lenfunc)bpy_bmelemseq_length,               /* mp_length */
-    (binaryfunc)bpy_bmelemseq_subscript,         /* mp_subscript */
-    (objobjargproc)NULL,                         /* mp_ass_subscript */
+       (lenfunc)bpy_bmelemseq_length,               /* mp_length */
+       (binaryfunc)bpy_bmelemseq_subscript,         /* mp_subscript */
+       (objobjargproc)NULL,                         /* mp_ass_subscript */
 };
 
 /* for customdata access */
 static PyMappingMethods bpy_bm_elem_as_mapping = {
-    (lenfunc)NULL,                           /* mp_length */ /* keep this empty, messes up 'if elem: ...' test */
-    (binaryfunc)bpy_bmelem_subscript,        /* mp_subscript */
-    (objobjargproc)bpy_bmelem_ass_subscript, /* mp_ass_subscript */
+       (lenfunc)NULL,                           /* mp_length */ /* keep this empty, messes up 'if elem: ...' test */
+       (binaryfunc)bpy_bmelem_subscript,        /* mp_subscript */
+       (objobjargproc)bpy_bmelem_ass_subscript, /* mp_ass_subscript */
 };
 
 /* Iterator
@@ -3055,15 +3055,15 @@ void BPy_BM_init_types(void)
  * ********************* */
 
 static struct PyModuleDef BPy_BM_types_module_def = {
-    PyModuleDef_HEAD_INIT,
-    "bmesh.types",  /* m_name */
-    NULL,  /* m_doc */
-    0,     /* m_size */
-    NULL,  /* m_methods */
-    NULL,  /* m_reload */
-    NULL,  /* m_traverse */
-    NULL,  /* m_clear */
-    NULL,  /* m_free */
+       PyModuleDef_HEAD_INIT,
+       "bmesh.types",  /* m_name */
+       NULL,  /* m_doc */
+       0,     /* m_size */
+       NULL,  /* m_methods */
+       NULL,  /* m_reload */
+       NULL,  /* m_traverse */
+       NULL,  /* m_clear */
+       NULL,  /* m_free */
 };
 
 PyObject *BPyInit_bmesh_types(void)
index d484ad5..e45a39a 100644 (file)
@@ -175,64 +175,64 @@ static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void *UNUSED(fl
 }
 
 static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
-    {(char *)"deform", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__deform_doc, (void *)CD_MDEFORMVERT},
+       {(char *)"deform", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__deform_doc, (void *)CD_MDEFORMVERT},
 
-    {(char *)"float",  (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
-    {(char *)"int",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
-    {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
+       {(char *)"float",  (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
+       {(char *)"int",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
+       {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
 
-    {(char *)"shape",        (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__shape_doc, (void *)CD_SHAPEKEY},
-    {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT},
+       {(char *)"shape",        (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__shape_doc, (void *)CD_SHAPEKEY},
+       {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmlayeraccess_edge_getseters[] = {
-    {(char *)"float",  (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
-    {(char *)"int",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
-    {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
+       {(char *)"float",  (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
+       {(char *)"int",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
+       {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
 
-    {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT},
-    {(char *)"crease",       (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__crease_doc, (void *)CD_CREASE},
+       {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT},
+       {(char *)"crease",       (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__crease_doc, (void *)CD_CREASE},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmlayeraccess_face_getseters[] = {
-    {(char *)"float",  (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
-    {(char *)"int",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
-    {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
+       {(char *)"float",  (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
+       {(char *)"int",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
+       {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
 
-    {(char *)"tex",   (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__tex_doc, (void *)CD_MTEXPOLY},
+       {(char *)"tex",   (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__tex_doc, (void *)CD_MTEXPOLY},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmlayeraccess_loop_getseters[] = {
-    {(char *)"float",  (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
-    {(char *)"int",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
-    {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
+       {(char *)"float",  (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
+       {(char *)"int",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
+       {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
 
-    {(char *)"uv",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__uv_doc, (void *)CD_MLOOPUV},
-    {(char *)"color", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__color_doc, (void *)CD_MLOOPCOL},
+       {(char *)"uv",    (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__uv_doc, (void *)CD_MLOOPUV},
+       {(char *)"color", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__color_doc, (void *)CD_MLOOPCOL},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 
 static PyGetSetDef bpy_bmlayercollection_getseters[] = {
-    /* BMESH_TODO, make writeable */
-    {(char *)"active",       (getter)bpy_bmlayercollection_active_get,       (setter)NULL, (char *)bpy_bmlayercollection_active_doc, NULL},
-    {(char *)"is_singleton", (getter)bpy_bmlayercollection_is_singleton_get, (setter)NULL, (char *)bpy_bmlayercollection_is_singleton_doc, NULL},
+       /* BMESH_TODO, make writeable */
+       {(char *)"active",       (getter)bpy_bmlayercollection_active_get,       (setter)NULL, (char *)bpy_bmlayercollection_active_doc, NULL},
+       {(char *)"is_singleton", (getter)bpy_bmlayercollection_is_singleton_get, (setter)NULL, (char *)bpy_bmlayercollection_is_singleton_doc, NULL},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 static PyGetSetDef bpy_bmlayeritem_getseters[] = {
-    /* BMESH_TODO, make writeable */
-    {(char *)"name", (getter)bpy_bmlayeritem_name_get, (setter)NULL, (char *)bpy_bmlayercollection_name_doc, NULL},
+       /* BMESH_TODO, make writeable */
+       {(char *)"name", (getter)bpy_bmlayeritem_name_get, (setter)NULL, (char *)bpy_bmlayercollection_name_doc, NULL},
 
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
 
@@ -556,20 +556,20 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject
 }
 
 static struct PyMethodDef bpy_bmlayeritem_methods[] = {
-    {"copy_from", (PyCFunction)bpy_bmlayeritem_copy_from,    METH_O,       bpy_bmlayeritem_copy_from_doc},
-    {NULL, NULL, 0, NULL}
+       {"copy_from", (PyCFunction)bpy_bmlayeritem_copy_from,    METH_O,       bpy_bmlayeritem_copy_from_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 static struct PyMethodDef bpy_bmelemseq_methods[] = {
-    {"verify",  (PyCFunction)bpy_bmlayercollection_verify,   METH_NOARGS,  bpy_bmlayercollection_verify_doc},
-    {"new",     (PyCFunction)bpy_bmlayercollection_new,      METH_VARARGS, bpy_bmlayercollection_new_doc},
-    {"remove",  (PyCFunction)bpy_bmlayercollection_remove,   METH_O,       bpy_bmlayercollection_remove_doc},
-
-    {"keys",    (PyCFunction)bpy_bmlayercollection_keys,     METH_NOARGS,  bpy_bmlayercollection_keys_doc},
-    {"values",  (PyCFunction)bpy_bmlayercollection_values,   METH_NOARGS,  bpy_bmlayercollection_values_doc},
-    {"items",   (PyCFunction)bpy_bmlayercollection_items,    METH_NOARGS,  bpy_bmlayercollection_items_doc},
-    {"get",     (PyCFunction)bpy_bmlayercollection_get,      METH_VARARGS, bpy_bmlayercollection_get_doc},
-    {NULL, NULL, 0, NULL}
+       {"verify",  (PyCFunction)bpy_bmlayercollection_verify,   METH_NOARGS,  bpy_bmlayercollection_verify_doc},
+       {"new",     (PyCFunction)bpy_bmlayercollection_new,      METH_VARARGS, bpy_bmlayercollection_new_doc},
+       {"remove",  (PyCFunction)bpy_bmlayercollection_remove,   METH_O,       bpy_bmlayercollection_remove_doc},
+
+       {"keys",    (PyCFunction)bpy_bmlayercollection_keys,     METH_NOARGS,  bpy_bmlayercollection_keys_doc},
+       {"values",  (PyCFunction)bpy_bmlayercollection_values,   METH_NOARGS,  bpy_bmlayercollection_values_doc},
+       {"items",   (PyCFunction)bpy_bmlayercollection_items,    METH_NOARGS,  bpy_bmlayercollection_items_doc},
+       {"get",     (PyCFunction)bpy_bmlayercollection_get,      METH_VARARGS, bpy_bmlayercollection_get_doc},
+       {NULL, NULL, 0, NULL}
 };
 
 /* Sequences
@@ -724,22 +724,22 @@ static int bpy_bmlayercollection_contains(BPy_BMLayerCollection *self, PyObject
 }
 
 static PySequenceMethods bpy_bmlayercollection_as_sequence = {
-    (lenfunc)bpy_bmlayercollection_length,       /* sq_length */
-    NULL,                                        /* sq_concat */
-    NULL,                                        /* sq_repeat */
-    (ssizeargfunc)bpy_bmlayercollection_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */
-    NULL,                                        /* sq_slice */
-    (ssizeobjargproc)NULL,                       /* sq_ass_item */
-    NULL,                                        /* *was* sq_ass_slice */
-    (objobjproc)bpy_bmlayercollection_contains,  /* sq_contains */
-    (binaryfunc) NULL,                           /* sq_inplace_concat */
-    (ssizeargfunc) NULL,                         /* sq_inplace_repeat */
+       (lenfunc)bpy_bmlayercollection_length,       /* sq