Merged revision(s) 58682-58770 from trunk/blender into soc-2013-dingto.
authorThomas Dinges <blender@dingto.org>
Wed, 31 Jul 2013 18:14:18 +0000 (18:14 +0000)
committerThomas Dinges <blender@dingto.org>
Wed, 31 Jul 2013 18:14:18 +0000 (18:14 +0000)
147 files changed:
doc/python_api/rst/bge.render.rst
extern/libmv/libmv-capi.cc
extern/libmv/libmv-capi.h
extern/libmv/libmv-capi_stub.cc
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_session.cpp
intern/cycles/bvh/bvh.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_types.h
intern/ghost/GHOST_C-api.h
intern/ghost/GHOST_IWindow.h
intern/ghost/intern/GHOST_C-api.cpp
intern/ghost/intern/GHOST_Window.h
intern/ghost/intern/GHOST_WindowWin32.cpp
intern/ghost/intern/GHOST_WindowWin32.h
intern/ghost/intern/GHOST_WindowX11.cpp
intern/ghost/intern/GHOST_WindowX11.h
release/scripts/startup/bl_ui/properties_game.py
release/scripts/startup/bl_ui/properties_object.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/templates_py/custom_nodes.py
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/modifiers_bmesh.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/BLI_alloca.h [new file with mode: 0644]
source/blender/blenlib/BLI_array.h
source/blender/blenlib/BLI_math_matrix.h
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/math_vector_inline.c
source/blender/blenlib/intern/string.c
source/blender/bmesh/CMakeLists.txt
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_core.c
source/blender/bmesh/intern/bmesh_interp.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mods.c
source/blender/bmesh/intern/bmesh_opdefines.c
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/intern/bmesh_operators_private.h
source/blender/bmesh/intern/bmesh_polygon.c
source/blender/bmesh/intern/bmesh_queries.c
source/blender/bmesh/intern/bmesh_queries.h
source/blender/bmesh/operators/bmo_connect.c
source/blender/bmesh/operators/bmo_connect_nonplanar.c [new file with mode: 0644]
source/blender/bmesh/operators/bmo_connect_pair.c
source/blender/bmesh/operators/bmo_dissolve.c
source/blender/bmesh/operators/bmo_dupe.c
source/blender/bmesh/operators/bmo_fill_holes.c
source/blender/bmesh/operators/bmo_inset.c
source/blender/bmesh/operators/bmo_subdivide_edgering.c
source/blender/bmesh/operators/bmo_utils.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/bmesh/tools/bmesh_triangulate.c
source/blender/collada/ArmatureImporter.cpp
source/blender/collada/DocumentImporter.cpp
source/blender/collada/SkinInfo.cpp
source/blender/collada/TransformReader.cpp
source/blender/collada/collada_internal.cpp
source/blender/collada/collada_internal.h
source/blender/collada/collada_utils.cpp
source/blender/collada/collada_utils.h
source/blender/editors/animation/anim_markers.c
source/blender/editors/armature/armature_select.c
source/blender/editors/armature/pose_select.c
source/blender/editors/armature/pose_utils.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_ops.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/object/object_bake.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_relations.c
source/blender/editors/render/render_opengl.c
source/blender/editors/render/render_preview.c
source/blender/editors/render/render_shading.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_logic/logic_buttons.c
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_node/node_buttons.c
source/blender/editors/space_node/node_relationships.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_node/node_toolbar.c
source/blender/editors/space_node/node_view.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_sequencer/sequencer_buttons.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/space_view3d/view3d_toolbar.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/editors/uvedit/uvedit_parametrizer.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/modifiers/intern/MOD_mirror.c
source/blender/nodes/intern/node_common.c
source/blender/nodes/intern/node_exec.c
source/blender/nodes/shader/nodes/node_shader_math.c
source/blender/nodes/texture/nodes/node_texture_output.c
source/blender/quicktime/apple/quicktime_export.c
source/blender/render/intern/source/convertblender.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm_window.h
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
source/gameengine/BlenderRoutines/KX_BlenderGL.h
source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
source/gameengine/GamePlayer/ghost/GPG_Canvas.h
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Rasterizer/RAS_ICanvas.h

index c3bcf19c01b2a9e4b5bf0aa5d4cefd7125d35145..5a80b7fa5c1c55c231916a98db75b5210660f7df 100644 (file)
@@ -62,6 +62,18 @@ Constants
 .. data:: KX_BLENDER_GLSL_MATERIAL
 
    Materials approximating blender materials with GLSL.
+   
+.. DATA:: VSYNC_OFF
+
+   Disables vsync
+
+.. DATA:: VSYNC_ON
+
+   Enables vsync
+
+.. DATA:: VSYNC_ADAPTIVE
+
+   Enables adaptive vsync if supported. Adaptive vsync enables vsync if the framerate is above the monitors refresh rate. Otherwise, vsync is diabled if the framerate is too low.
 
 *********
 Functions
@@ -289,3 +301,15 @@ Functions
 
    Disable the motion blur effect.
 
+.. function:: setVsync(value)
+
+   Set the vsync value
+
+   :arg value: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE
+   :type value: integer
+
+.. function:: getVsync()
+
+   Get the current vsync value
+
+   :rtype: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE
index 563919e1d7b9cc677357c2ae44e2b7e1f57c07c1..990b40df90a47ded14054863afe810306eefedf8 100644 (file)
@@ -62,7 +62,7 @@
 #  define snprintf _snprintf
 #endif
 
-typedef struct libmv_Reconstruction {
+struct libmv_Reconstruction {
        libmv::EuclideanReconstruction reconstruction;
 
        /* used for per-track average error calculation after reconstruction */
@@ -70,12 +70,12 @@ typedef struct libmv_Reconstruction {
        libmv::CameraIntrinsics intrinsics;
 
        double error;
-} libmv_Reconstruction;
+};
 
-typedef struct libmv_Features {
+struct libmv_Features {
        int count, margin;
        libmv::Feature *features;
-} libmv_Features;
+};
 
 /* ************ Logging ************ */
 
@@ -197,30 +197,30 @@ static void saveImage(const char *prefix, libmv::FloatImage image, int x0, int y
        int x, y;
        png_bytep *row_pointers;
 
-       row_pointers= (png_bytep*)malloc(sizeof(png_bytep)*image.Height());
+       row_pointers = (png_bytep *) malloc(sizeof(png_bytep) * image.Height());
 
        for (y = 0; y < image.Height(); y++) {
-               row_pointers[y]= (png_bytep)malloc(sizeof(png_byte)*4*image.Width());
+               row_pointers[y] = (png_bytep) malloc(sizeof(png_byte) * 4 * image.Width());
 
                for (x = 0; x < image.Width(); x++) {
                        if (x0 == x && image.Height() - y0 - 1 == y) {
-                               row_pointers[y][x*4+0]= 255;
-                               row_pointers[y][x*4+1]= 0;
-                               row_pointers[y][x*4+2]= 0;
-                               row_pointers[y][x*4+3]= 255;
+                               row_pointers[y][x * 4 + 0] = 255;
+                               row_pointers[y][x * 4 + 1] = 0;
+                               row_pointers[y][x * 4 + 2] = 0;
+                               row_pointers[y][x * 4 + 3] = 255;
                        }
                        else {
                                float pixel = image(image.Height() - y - 1, x, 0);
-                               row_pointers[y][x*4+0]= pixel*255;
-                               row_pointers[y][x*4+1]= pixel*255;
-                               row_pointers[y][x*4+2]= pixel*255;
-                               row_pointers[y][x*4+3]= 255;
+                               row_pointers[y][x * 4 + 0] = pixel * 255;
+                               row_pointers[y][x * 4 + 1] = pixel * 255;
+                               row_pointers[y][x * 4 + 2] = pixel * 255;
+                               row_pointers[y][x * 4 + 3] = 255;
                        }
                }
        }
 
        {
-               static int a= 0;
+               static int a = 0;
                char buf[128];
                snprintf(buf, sizeof(buf), "%s_%02d.png", prefix, ++a);
                savePNGImage(row_pointers, image.Width(), image.Height(), 8, PNG_COLOR_TYPE_RGBA, buf);
@@ -237,17 +237,17 @@ static void saveBytesImage(const char *prefix, unsigned char *data, int width, i
        int x, y;
        png_bytep *row_pointers;
 
-       row_pointers= (png_bytep*)malloc(sizeof(png_bytep)*height);
+       row_pointers = (png_bytep *) malloc(sizeof(png_bytep) * height);
 
        for (y = 0; y < height; y++) {
-               row_pointers[y]= (png_bytep)malloc(sizeof(png_byte)*4*width);
+               row_pointers[y] = (png_bytep) malloc(sizeof(png_byte) * 4 * width);
 
                for (x = 0; x < width; x++) {
-                       char pixel = data[width*y+x];
-                       row_pointers[y][x*4+0]= pixel;
-                       row_pointers[y][x*4+1]= pixel;
-                       row_pointers[y][x*4+2]= pixel;
-                       row_pointers[y][x*4+3]= 255;
+                       char pixel = data[width * y + x];
+                       row_pointers[y][x * 4 + 0] = pixel;
+                       row_pointers[y][x * 4 + 1] = pixel;
+                       row_pointers[y][x * 4 + 2] = pixel;
+                       row_pointers[y][x * 4 + 3] = 255;
                }
        }
 
@@ -267,12 +267,12 @@ static void saveBytesImage(const char *prefix, unsigned char *data, int width, i
 
 /* ************ Planar tracker ************ */
 
-/* TrackRegion (new planar tracker) */
-int libmv_trackRegion(const struct libmv_trackRegionOptions *options,
+/* TrackRegion */
+int libmv_trackRegion(const libmv_TrackRegionOptions *options,
                       const float *image1, int image1_width, int image1_height,
                       const float *image2, int image2_width, int image2_height,
                       const double *x1, const double *y1,
-                      struct libmv_trackRegionResult *result,
+                      libmv_TrackRegionResult *result,
                       double *x2, double *y2)
 {
        double xx1[5], yy1[5];
@@ -292,7 +292,7 @@ int libmv_trackRegion(const struct libmv_trackRegionOptions *options,
 
        switch (options->motion_model) {
 #define LIBMV_CONVERT(the_model) \
-    case libmv::TrackRegionOptions::the_model: \
+       case libmv::TrackRegionOptions::the_model: \
                track_region_options.mode = libmv::TrackRegionOptions::the_model; \
                break;
                LIBMV_CONVERT(TRANSLATION)
@@ -384,29 +384,28 @@ void libmv_samplePlanarPatch(const float *image, int width, int height,
 
 /* ************ Tracks ************ */
 
-libmv_Tracks *libmv_tracksNew(void)
+struct libmv_Tracks *libmv_tracksNew(void)
 {
        libmv::Tracks *libmv_tracks = new libmv::Tracks();
 
-       return (libmv_Tracks *)libmv_tracks;
+       return (struct libmv_Tracks *)libmv_tracks;
 }
 
-void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y)
+void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks)
 {
-       ((libmv::Tracks*)libmv_tracks)->Insert(image, track, x, y);
+       delete (libmv::Tracks*) libmv_tracks;
 }
 
-void libmv_tracksDestroy(libmv_Tracks *libmv_tracks)
+void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y)
 {
-       delete (libmv::Tracks*)libmv_tracks;
+       ((libmv::Tracks*) libmv_tracks)->Insert(image, track, x, y);
 }
 
-/* ************ Reconstruction solver ************ */
+/* ************ Reconstruction ************ */
 
 class ReconstructUpdateCallback : public libmv::ProgressUpdateCallback {
 public:
-       ReconstructUpdateCallback(reconstruct_progress_update_cb progress_update_callback,
-                       void *callback_customdata)
+       ReconstructUpdateCallback(reconstruct_progress_update_cb progress_update_callback, void *callback_customdata)
        {
                progress_update_callback_ = progress_update_callback;
                callback_customdata_ = callback_customdata;
@@ -414,7 +413,7 @@ public:
 
        void invoke(double progress, const char *message)
        {
-               if(progress_update_callback_) {
+               if (progress_update_callback_) {
                        progress_update_callback_(callback_customdata_, progress, message);
                }
        }
@@ -456,7 +455,7 @@ static void libmv_solveRefineIntrinsics(const libmv::Tracks &tracks,
                                               intrinsics);
 }
 
-static void cameraIntrinsicsFromOptions(const libmv_cameraIntrinsicsOptions *camera_intrinsics_options,
+static void cameraIntrinsicsFromOptions(const libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
                                         libmv::CameraIntrinsics *camera_intrinsics)
 {
        camera_intrinsics->SetFocalLength(camera_intrinsics_options->focal_length,
@@ -486,7 +485,7 @@ static libmv::Tracks getNormalizedTracks(const libmv::Tracks &tracks, const libm
 }
 
 static void finishReconstruction(const libmv::Tracks &tracks, const libmv::CameraIntrinsics &camera_intrinsics,
-                                 libmv_Reconstruction *libmv_reconstruction,
+                                 struct libmv_Reconstruction *libmv_reconstruction,
                                  reconstruct_progress_update_cb progress_update_callback,
                                  void *callback_customdata)
 {
@@ -571,13 +570,13 @@ static bool selectTwoKeyframesBasedOnGRICAndVariance(
        return true;
 }
 
-libmv_Reconstruction *libmv_solveReconstruction(const libmv_Tracks *libmv_tracks,
-                       const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-                       libmv_reconstructionOptions *libmv_reconstruction_options,
-                       reconstruct_progress_update_cb progress_update_callback,
-                       void *callback_customdata)
+struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks *libmv_tracks,
+               const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+               libmv_ReconstructionOptions *libmv_reconstruction_options,
+               reconstruct_progress_update_cb progress_update_callback,
+               void *callback_customdata)
 {
-       libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
+       struct libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
 
        libmv::Tracks &tracks = *((libmv::Tracks *) libmv_tracks);
        libmv::EuclideanReconstruction &reconstruction = libmv_reconstruction->reconstruction;
@@ -650,16 +649,16 @@ libmv_Reconstruction *libmv_solveReconstruction(const libmv_Tracks *libmv_tracks
        finishReconstruction(tracks, camera_intrinsics, libmv_reconstruction,
                             progress_update_callback, callback_customdata);
 
-       return (libmv_Reconstruction *)libmv_reconstruction;
+       return (struct libmv_Reconstruction *)libmv_reconstruction;
 }
 
-struct libmv_Reconstruction *libmv_solveModal(const libmv_Tracks *libmv_tracks,
-                       const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-                       const libmv_reconstructionOptions *libmv_reconstruction_options,
-                       reconstruct_progress_update_cb progress_update_callback,
-                       void *callback_customdata)
+struct libmv_Reconstruction *libmv_solveModal(const struct libmv_Tracks *libmv_tracks,
+               const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+               const libmv_ReconstructionOptions *libmv_reconstruction_options,
+               reconstruct_progress_update_cb progress_update_callback,
+               void *callback_customdata)
 {
-       libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
+       struct libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
 
        libmv::Tracks &tracks = *((libmv::Tracks *) libmv_tracks);
        libmv::EuclideanReconstruction &reconstruction = libmv_reconstruction->reconstruction;
@@ -697,15 +696,20 @@ struct libmv_Reconstruction *libmv_solveModal(const libmv_Tracks *libmv_tracks,
        finishReconstruction(tracks, camera_intrinsics, libmv_reconstruction,
                             progress_update_callback, callback_customdata);
 
-       return (libmv_Reconstruction *)libmv_reconstruction;
+       return (struct libmv_Reconstruction *)libmv_reconstruction;
+}
+
+void libmv_reconstructionDestroy(struct libmv_Reconstruction *libmv_reconstruction)
+{
+       delete libmv_reconstruction;
 }
 
-int libmv_reporojectionPointForTrack(const libmv_Reconstruction *libmv_reconstruction, int track, double pos[3])
+int libmv_reprojectionPointForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3])
 {
        const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
        const libmv::EuclideanPoint *point = reconstruction->PointForTrack(track);
 
-       if(point) {
+       if (point) {
                pos[0] = point->X[0];
                pos[1] = point->X[2];
                pos[2] = point->X[1];
@@ -732,7 +736,7 @@ static libmv::Marker ProjectMarker(const libmv::EuclideanPoint &point,
        return reprojected_marker;
 }
 
-double libmv_reporojectionErrorForTrack(const libmv_Reconstruction *libmv_reconstruction, int track)
+double libmv_reprojectionErrorForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track)
 {
        const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
        const libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
@@ -755,13 +759,13 @@ double libmv_reporojectionErrorForTrack(const libmv_Reconstruction *libmv_recons
                double ex = reprojected_marker.x - markers[i].x;
                double ey = reprojected_marker.y - markers[i].y;
 
-               total_error += sqrt(ex*ex + ey*ey);
+               total_error += sqrt(ex * ex + ey * ey);
        }
 
        return total_error / num_reprojected;
 }
 
-double libmv_reporojectionErrorForImage(const libmv_Reconstruction *libmv_reconstruction, int image)
+double libmv_reprojectionErrorForImage(const struct libmv_Reconstruction *libmv_reconstruction, int image)
 {
        const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
        const libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
@@ -786,19 +790,19 @@ double libmv_reporojectionErrorForImage(const libmv_Reconstruction *libmv_recons
                double ex = reprojected_marker.x - markers[i].x;
                double ey = reprojected_marker.y - markers[i].y;
 
-               total_error += sqrt(ex*ex + ey*ey);
+               total_error += sqrt(ex * ex + ey * ey);
        }
 
        return total_error / num_reprojected;
 }
 
-int libmv_reporojectionCameraForImage(const libmv_Reconstruction *libmv_reconstruction,
+int libmv_reprojectionCameraForImage(const struct libmv_Reconstruction *libmv_reconstruction,
                                       int image, double mat[4][4])
 {
        const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
        const libmv::EuclideanCamera *camera = reconstruction->CameraForImage(image);
 
-       if(camera) {
+       if (camera) {
                for (int j = 0; j < 3; ++j) {
                        for (int k = 0; k < 3; ++k) {
                                int l = k;
@@ -809,7 +813,7 @@ int libmv_reporojectionCameraForImage(const libmv_Reconstruction *libmv_reconstr
                                if (j == 2) mat[j][l] = -camera->R(j,k);
                                else mat[j][l] = camera->R(j,k);
                        }
-                       mat[j][3]= 0.0;
+                       mat[j][3] = 0.0;
                }
 
                libmv::Vec3 optical_center = -camera->R.transpose() * camera->t;
@@ -818,7 +822,7 @@ int libmv_reporojectionCameraForImage(const libmv_Reconstruction *libmv_reconstr
                mat[3][1] = optical_center(2);
                mat[3][2] = optical_center(1);
 
-               mat[3][3]= 1.0;
+               mat[3][3] = 1.0;
 
                return 1;
        }
@@ -826,17 +830,17 @@ int libmv_reporojectionCameraForImage(const libmv_Reconstruction *libmv_reconstr
        return 0;
 }
 
-double libmv_reprojectionError(const libmv_Reconstruction *libmv_reconstruction)
+double libmv_reprojectionError(const struct libmv_Reconstruction *libmv_reconstruction)
 {
        return libmv_reconstruction->error;
 }
 
-void libmv_destroyReconstruction(libmv_Reconstruction *libmv_reconstruction)
+struct libmv_CameraIntrinsics *libmv_reconstructionExtractIntrinsics(struct libmv_Reconstruction *libmv_reconstruction)
 {
-       delete libmv_reconstruction;
+       return (struct libmv_CameraIntrinsics *)&libmv_reconstruction->intrinsics;
 }
 
-/* ************ feature detector ************ */
+/* ************ Feature detector ************ */
 
 struct libmv_Features *libmv_detectFeaturesFAST(const unsigned char *data,
                                                 int width, int height, int stride,
@@ -844,24 +848,24 @@ struct libmv_Features *libmv_detectFeaturesFAST(const unsigned char *data,
 {
        libmv::Feature *features = NULL;
        std::vector<libmv::Feature> v;
-       libmv_Features *libmv_features = new libmv_Features();
-       int i= 0, count;
+       struct libmv_Features *libmv_features = new libmv_Features();
+       int i = 0, count;
 
-       if(margin) {
-               data += margin*stride+margin;
-               width -= 2*margin;
-               height -= 2*margin;
+       if (margin) {
+               data += margin * stride+margin;
+               width -= 2 * margin;
+               height -= 2 * margin;
        }
 
        v = libmv::DetectFAST(data, width, height, stride, min_trackness, min_distance);
 
        count = v.size();
 
-       if(count) {
-               features= new libmv::Feature[count];
+       if (count) {
+               features = new libmv::Feature[count];
 
                for(std::vector<libmv::Feature>::iterator it = v.begin(); it != v.end(); it++) {
-                       features[i++]= *it;
+                       features[i++] = *it;
                }
        }
 
@@ -869,7 +873,7 @@ struct libmv_Features *libmv_detectFeaturesFAST(const unsigned char *data,
        libmv_features->count = count;
        libmv_features->margin = margin;
 
-       return (libmv_Features *)libmv_features;
+       return (struct libmv_Features *)libmv_features;
 }
 
 struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char *data,
@@ -877,13 +881,13 @@ struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char *data,
                                                    int margin, int count, int min_distance)
 {
        libmv::Feature *features = NULL;
-       libmv_Features *libmv_features = new libmv_Features;
+       struct libmv_Features *libmv_features = new libmv_Features;
 
-       if(count) {
-               if(margin) {
-                       data += margin*stride+margin;
-                       width -= 2*margin;
-                       height -= 2*margin;
+       if (count) {
+               if (margin) {
+                       data += margin * stride+margin;
+                       width -= 2 * margin;
+                       height -= 2 * margin;
                }
 
                features = new libmv::Feature[count];
@@ -897,14 +901,22 @@ struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char *data,
        return libmv_features;
 }
 
-int libmv_countFeatures(const libmv_Features *libmv_features)
+void libmv_featuresDestroy(struct libmv_Features *libmv_features)
+{
+       if (libmv_features->features)
+               delete [] libmv_features->features;
+
+       delete libmv_features;
+}
+
+int libmv_countFeatures(const struct libmv_Features *libmv_features)
 {
        return libmv_features->count;
 }
 
-void libmv_getFeature(const libmv_Features *libmv_features, int number, double *x, double *y, double *score, double *size)
+void libmv_getFeature(const struct libmv_Features *libmv_features, int number, double *x, double *y, double *score, double *size)
 {
-       libmv::Feature feature= libmv_features->features[number];
+       libmv::Feature feature = libmv_features->features[number];
 
        *x = feature.x + libmv_features->margin;
        *y = feature.y + libmv_features->margin;
@@ -912,29 +924,16 @@ void libmv_getFeature(const libmv_Features *libmv_features, int number, double *
        *size = feature.size;
 }
 
-void libmv_destroyFeatures(libmv_Features *libmv_features)
-{
-       if(libmv_features->features)
-               delete [] libmv_features->features;
+/* ************ Camera intrinsics ************ */
 
-       delete libmv_features;
-}
-
-/* ************ camera intrinsics ************ */
-
-struct libmv_CameraIntrinsics *libmv_ReconstructionExtractIntrinsics(libmv_Reconstruction *libmv_Reconstruction)
-{
-       return (struct libmv_CameraIntrinsics *)&libmv_Reconstruction->intrinsics;
-}
-
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNewEmpty(void)
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNewEmpty(void)
 {
        libmv::CameraIntrinsics *camera_intrinsics = new libmv::CameraIntrinsics();
 
        return (struct libmv_CameraIntrinsics *) camera_intrinsics;
 }
 
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNew(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options)
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNew(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options)
 {
        libmv::CameraIntrinsics *camera_intrinsics = new libmv::CameraIntrinsics();
 
@@ -943,23 +942,23 @@ struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNew(const libmv_cameraIntri
        return (struct libmv_CameraIntrinsics *) camera_intrinsics;
 }
 
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsCopy(const libmv_CameraIntrinsics *libmvIntrinsics)
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsCopy(const libmv_CameraIntrinsics *libmvIntrinsics)
 {
        libmv::CameraIntrinsics *orig_intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
-       libmv::CameraIntrinsics *new_intrinsics= new libmv::CameraIntrinsics(*orig_intrinsics);
+       libmv::CameraIntrinsics *new_intrinsics = new libmv::CameraIntrinsics(*orig_intrinsics);
 
        return (struct libmv_CameraIntrinsics *) new_intrinsics;
 }
 
-void libmv_CameraIntrinsicsDestroy(struct libmv_CameraIntrinsics *libmvIntrinsics)
+void libmv_cameraIntrinsicsDestroy(struct libmv_CameraIntrinsics *libmvIntrinsics)
 {
        libmv::CameraIntrinsics *intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
 
        delete intrinsics;
 }
 
-void libmv_CameraIntrinsicsUpdate(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-                                  libmv_CameraIntrinsics *libmv_intrinsics)
+void libmv_cameraIntrinsicsUpdate(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+                                  struct libmv_CameraIntrinsics *libmv_intrinsics)
 {
        libmv::CameraIntrinsics *camera_intrinsics = (libmv::CameraIntrinsics *) libmv_intrinsics;
 
@@ -997,15 +996,16 @@ void libmv_CameraIntrinsicsUpdate(const libmv_cameraIntrinsicsOptions *libmv_cam
        }
 }
 
-void libmv_CameraIntrinsicsSetThreads(libmv_CameraIntrinsics *libmv_intrinsics, int threads)
+void libmv_cameraIntrinsicsSetThreads(struct libmv_CameraIntrinsics *libmv_intrinsics, int threads)
 {
        libmv::CameraIntrinsics *camera_intrinsics = (libmv::CameraIntrinsics *) libmv_intrinsics;
 
        camera_intrinsics->SetThreads(threads);
 }
 
-void libmv_CameraIntrinsicsExtract(const libmv_CameraIntrinsics *libmv_intrinsics, double *focal_length,
-                       double *principal_x, double *principal_y, double *k1, double *k2, double *k3, int *width, int *height)
+void libmv_cameraIntrinsicsExtract(const struct libmv_CameraIntrinsics *libmv_intrinsics, double *focal_length,
+                                   double *principal_x, double *principal_y, double *k1, double *k2, double *k3,
+                                   int *width, int *height)
 {
        libmv::CameraIntrinsics *camera_intrinsics = (libmv::CameraIntrinsics *) libmv_intrinsics;
 
@@ -1016,40 +1016,42 @@ void libmv_CameraIntrinsicsExtract(const libmv_CameraIntrinsics *libmv_intrinsic
        *k2 = camera_intrinsics->k2();
 }
 
-void libmv_CameraIntrinsicsUndistortByte(const libmv_CameraIntrinsics *libmv_intrinsics,
-                       unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels)
+void libmv_cameraIntrinsicsUndistortByte(const struct libmv_CameraIntrinsics *libmv_intrinsics,
+                                         unsigned char *src, unsigned char *dst, int width, int height,
+                                         float overscan, int channels)
 {
        libmv::CameraIntrinsics *camera_intrinsics = (libmv::CameraIntrinsics *) libmv_intrinsics;
 
        camera_intrinsics->Undistort(src, dst, width, height, overscan, channels);
 }
 
-void libmv_CameraIntrinsicsUndistortFloat(const libmv_CameraIntrinsics *libmvIntrinsics,
-                       float *src, float *dst, int width, int height, float overscan, int channels)
+void libmv_cameraIntrinsicsUndistortFloat(const struct libmv_CameraIntrinsics *libmvIntrinsics,
+                                          float *src, float *dst, int width, int height,
+                                          float overscan, int channels)
 {
        libmv::CameraIntrinsics *intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
 
        intrinsics->Undistort(src, dst, width, height, overscan, channels);
 }
 
-void libmv_CameraIntrinsicsDistortByte(const libmv_CameraIntrinsics *libmvIntrinsics,
-                       unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels)
+void libmv_cameraIntrinsicsDistortByte(const struct libmv_CameraIntrinsics *libmvIntrinsics,
+                                       unsigned char *src, unsigned char *dst, int width, int height,
+                                       float overscan, int channels)
 {
        libmv::CameraIntrinsics *intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
        intrinsics->Distort(src, dst, width, height, overscan, channels);
 }
 
-void libmv_CameraIntrinsicsDistortFloat(const libmv_CameraIntrinsics *libmvIntrinsics,
-                       float *src, float *dst, int width, int height, float overscan, int channels)
+void libmv_cameraIntrinsicsDistortFloat(const struct libmv_CameraIntrinsics *libmvIntrinsics,
+                                        float *src, float *dst, int width, int height,
+                                        float overscan, int channels)
 {
        libmv::CameraIntrinsics *intrinsics = (libmv::CameraIntrinsics *) libmvIntrinsics;
 
        intrinsics->Distort(src, dst, width, height, overscan, channels);
 }
 
-/* ************ utils ************ */
-
-void libmv_ApplyCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+void libmv_cameraIntrinsicsApply(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
                                  double x, double y, double *x1, double *y1)
 {
        libmv::CameraIntrinsics camera_intrinsics;
@@ -1063,7 +1065,7 @@ void libmv_ApplyCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_came
        }
 }
 
-void libmv_InvertCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+void libmv_cameraIntrinsicsInvert(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
                                   double x, double y, double *x1, double *y1)
 {
        libmv::CameraIntrinsics camera_intrinsics;
index beac3e85468206c8863b19c971ee190bd5ad3254..7c91881fe71638c0fc539ca12d7ddaedc9f4ace7 100644 (file)
@@ -41,8 +41,8 @@ void libmv_initLogging(const char *argv0);
 void libmv_startDebugLogging(void);
 void libmv_setLoggingVerbosity(int verbosity);
 
-/* TrackRegion (new planar tracker) */
-struct libmv_trackRegionOptions {
+/* Planar tracker */
+typedef struct libmv_TrackRegionOptions {
        int motion_model;
        int num_iterations;
        int use_brute;
@@ -50,21 +50,20 @@ struct libmv_trackRegionOptions {
        double minimum_correlation;
        double sigma;
        float *image1_mask;
-};
+} libmv_TrackRegionOptions;
 
-struct libmv_trackRegionResult {
+typedef struct libmv_TrackRegionResult {
        int termination;
        const char *termination_reason;
        double correlation;
-};
+} libmv_TrackRegionResult;
 
-int libmv_trackRegion(const struct libmv_trackRegionOptions *options,
+int libmv_trackRegion(const libmv_TrackRegionOptions *options,
                       const float *image1, int image1_width, int image1_height,
                       const float *image2, int image2_width, int image2_height,
                       const double *x1, const double *y1,
-                      struct libmv_trackRegionResult *result,
+                      libmv_TrackRegionResult *result,
                       double *x2, double *y2);
-
 void libmv_samplePlanarPatch(const float *image, int width, int height,
                              int channels, const double *xs, const double *ys,
                              int num_samples_x, int num_samples_y,
@@ -73,25 +72,24 @@ void libmv_samplePlanarPatch(const float *image, int width, int height,
 
 /* Tracks */
 struct libmv_Tracks *libmv_tracksNew(void);
-void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y);
 void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks);
+void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y);
 
-/* Reconstruction solver */
-
+/* Reconstruction */
 #define LIBMV_REFINE_FOCAL_LENGTH          (1 << 0)
 #define LIBMV_REFINE_PRINCIPAL_POINT       (1 << 1)
 #define LIBMV_REFINE_RADIAL_DISTORTION_K1  (1 << 2)
 #define LIBMV_REFINE_RADIAL_DISTORTION_K2  (1 << 4)
 
-typedef struct libmv_cameraIntrinsicsOptions {
+typedef struct libmv_CameraIntrinsicsOptions {
        double focal_length;
        double principal_point_x, principal_point_y;
        double k1, k2, k3;
        double p1, p2;
        int image_width, image_height;
-} libmv_cameraIntrinsicsOptions;
+} libmv_CameraIntrinsicsOptions;
 
-typedef struct libmv_reconstructionOptions {
+typedef struct libmv_ReconstructionOptions {
        int select_keyframes;
        int keyframe1, keyframe2;
 
@@ -99,72 +97,67 @@ typedef struct libmv_reconstructionOptions {
 
        double success_threshold;
        int use_fallback_reconstruction;
-} libmv_reconstructionOptions;
+} libmv_ReconstructionOptions;
 
 typedef void (*reconstruct_progress_update_cb) (void *customdata, double progress, const char *message);
 
 struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks *libmv_tracks,
-                       const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-                       libmv_reconstructionOptions *libmv_reconstruction_options,
-                       reconstruct_progress_update_cb progress_update_callback,
-                       void *callback_customdata);
+               const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+               libmv_ReconstructionOptions *libmv_reconstruction_options,
+               reconstruct_progress_update_cb progress_update_callback,
+               void *callback_customdata);
 struct libmv_Reconstruction *libmv_solveModal(const struct libmv_Tracks *libmv_tracks,
-                       const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-                       const libmv_reconstructionOptions *libmv_reconstruction_options,
-                       reconstruct_progress_update_cb progress_update_callback,
-                       void *callback_customdata);
-int libmv_reporojectionPointForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]);
-double libmv_reporojectionErrorForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track);
-double libmv_reporojectionErrorForImage(const struct libmv_Reconstruction *libmv_reconstruction, int image);
-int libmv_reporojectionCameraForImage(const struct libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4]);
+               const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+               const libmv_ReconstructionOptions *libmv_reconstruction_options,
+               reconstruct_progress_update_cb progress_update_callback,
+               void *callback_customdata);
+void libmv_reconstructionDestroy(struct libmv_Reconstruction *libmv_reconstruction);
+int libmv_reprojectionPointForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]);
+double libmv_reprojectionErrorForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track);
+double libmv_reprojectionErrorForImage(const struct libmv_Reconstruction *libmv_reconstruction, int image);
+int libmv_reprojectionCameraForImage(const struct libmv_Reconstruction *libmv_reconstruction,
+                                     int image, double mat[4][4]);
 double libmv_reprojectionError(const struct libmv_Reconstruction *libmv_reconstruction);
-void libmv_destroyReconstruction(struct libmv_Reconstruction *libmv_reconstruction);
+struct libmv_CameraIntrinsics *libmv_reconstructionExtractIntrinsics(struct libmv_Reconstruction *libmv_Reconstruction);
 
-/* feature detector */
+/* Feature detector */
 struct libmv_Features *libmv_detectFeaturesFAST(const unsigned char *data, int width, int height, int stride,
-                       int margin, int min_trackness, int min_distance);
+                                                int margin, int min_trackness, int min_distance);
 struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char *data, int width, int height, int stride,
-                       int margin, int count, int min_distance);
+                                                   int margin, int count, int min_distance);
+void libmv_featuresDestroy(struct libmv_Features *libmv_features);
 int libmv_countFeatures(const struct libmv_Features *libmv_features);
-void libmv_getFeature(const struct libmv_Features *libmv_features, int number, double *x, double *y, double *score, double *size);
-void libmv_destroyFeatures(struct libmv_Features *libmv_features);
-
-/* camera intrinsics */
-struct libmv_CameraIntrinsics *libmv_ReconstructionExtractIntrinsics(struct libmv_Reconstruction *libmv_Reconstruction);
-
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNewEmpty(void);
-
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNew(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options);
-
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsCopy(const struct libmv_CameraIntrinsics *libmv_intrinsics);
-
-void libmv_CameraIntrinsicsDestroy(struct libmv_CameraIntrinsics *libmv_intrinsics);
-
-void libmv_CameraIntrinsicsUpdate(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+void libmv_getFeature(const struct libmv_Features *libmv_features, int number, double *x, double *y, double *score,
+                      double *size);
+
+/* Camera intrinsics */
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNewEmpty(void);
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNew(
+               const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options);
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsCopy(const struct libmv_CameraIntrinsics *libmv_intrinsics);
+void libmv_cameraIntrinsicsDestroy(struct libmv_CameraIntrinsics *libmv_intrinsics);
+void libmv_cameraIntrinsicsUpdate(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
                                   struct libmv_CameraIntrinsics *libmv_intrinsics);
-
-void libmv_CameraIntrinsicsSetThreads(struct libmv_CameraIntrinsics *libmv_intrinsics, int threads);
-
-void libmv_CameraIntrinsicsExtract(const struct libmv_CameraIntrinsics *libmv_intrinsics, double *focal_length,
-                       double *principal_x, double *principal_y, double *k1, double *k2, double *k3, int *width, int *height);
-
-void libmv_CameraIntrinsicsUndistortByte(const struct libmv_CameraIntrinsics *libmv_intrinsics,
-                       unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels);
-
-void libmv_CameraIntrinsicsUndistortFloat(const struct libmv_CameraIntrinsics *libmv_intrinsics,
-                       float *src, float *dst, int width, int height, float overscan, int channels);
-
-void libmv_CameraIntrinsicsDistortByte(const struct libmv_CameraIntrinsics *libmv_intrinsics,
-                       unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels);
-
-void libmv_CameraIntrinsicsDistortFloat(const struct libmv_CameraIntrinsics *libmv_intrinsics,
-                       float *src, float *dst, int width, int height, float overscan, int channels);
-
-/* utils */
-void libmv_ApplyCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-                       double x, double y, double *x1, double *y1);
-void libmv_InvertCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-                       double x, double y, double *x1, double *y1);
+void libmv_cameraIntrinsicsSetThreads(struct libmv_CameraIntrinsics *libmv_intrinsics, int threads);
+void libmv_cameraIntrinsicsExtract(const struct libmv_CameraIntrinsics *libmv_intrinsics, double *focal_length,
+                                   double *principal_x, double *principal_y, double *k1, double *k2, double *k3,
+                                   int *width, int *height);
+void libmv_cameraIntrinsicsUndistortByte(const struct libmv_CameraIntrinsics *libmv_intrinsics,
+                                         unsigned char *src, unsigned char *dst, int width, int height,
+                                         float overscan, int channels);
+void libmv_cameraIntrinsicsUndistortFloat(const struct libmv_CameraIntrinsics *libmv_intrinsics,
+                                          float *src, float *dst, int width, int height,
+                                          float overscan, int channels);
+void libmv_cameraIntrinsicsDistortByte(const struct libmv_CameraIntrinsics *libmv_intrinsics,
+                                       unsigned char *src, unsigned char *dst, int width, int height,
+                                       float overscan, int channels);
+void libmv_cameraIntrinsicsDistortFloat(const struct libmv_CameraIntrinsics *libmv_intrinsics,
+                                        float *src, float *dst, int width, int height,
+                                        float overscan, int channels);
+void libmv_cameraIntrinsicsApply(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+                                 double x, double y, double *x1, double *y1);
+void libmv_cameraIntrinsicsInvert(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+                                  double x, double y, double *x1, double *y1);
 
 #ifdef __cplusplus
 }
index 4bc2b18081a1fe400483d0b95be20cfe60bf6972..36977eb58bab11f64b21260448ce41bc9b1da60c 100644 (file)
@@ -48,11 +48,11 @@ void libmv_setLoggingVerbosity(int /*verbosity*/)
 /* ************ Planar tracker ************ */
 
 /* TrackRegion (new planar tracker) */
-int libmv_trackRegion(const struct libmv_trackRegionOptions * /*options*/,
+int libmv_trackRegion(const libmv_TrackRegionOptions * /*options*/,
                       const float * /*image1*/, int /*image1_width*/, int /*image1_height*/,
                       const float * /*image2*/, int /*image2_width*/, int /*image2_height*/,
                       const double *x1, const double *y1,
-                      struct libmv_trackRegionResult *result,
+                      libmv_TrackRegionResult *result,
                       double *x2, double *y2)
 {
        /* Convert to doubles for the libmv api. The four corners and the center. */
@@ -79,7 +79,8 @@ void libmv_samplePlanarPatch(const float *image, int width, int height,
 
 /* ************ Tracks ************ */
 
-libmv_Tracks *libmv_tracksNew(void) {
+struct libmv_Tracks *libmv_tracksNew(void)
+{
        return NULL;
 }
 
@@ -88,73 +89,72 @@ void libmv_tracksInsert(struct libmv_Tracks * /*libmv_tracks*/, int /*image*/,
 {
 }
 
-void libmv_tracksDestroy(libmv_Tracks * /*libmv_tracks*/)
+void libmv_tracksDestroy(struct libmv_Tracks * /*libmv_tracks*/)
 {
 }
 
 /* ************ Reconstruction solver ************ */
 
-libmv_Reconstruction *libmv_solveReconstruction(const libmv_Tracks * /*libmv_tracks*/,
-                       const libmv_cameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/,
-                       libmv_reconstructionOptions * /*libmv_reconstruction_options*/,
-                       reconstruct_progress_update_cb /*progress_update_callback*/,
-                       void * /*callback_customdata*/)
+struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks * /*libmv_tracks*/,
+               const libmv_CameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/,
+               libmv_ReconstructionOptions * /*libmv_reconstruction_options*/,
+               reconstruct_progress_update_cb /*progress_update_callback*/,
+               void * /*callback_customdata*/)
 {
        return NULL;
 }
 
 struct libmv_Reconstruction *libmv_solveModal(const struct libmv_Tracks * /*libmv_tracks*/,
-                       const libmv_cameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/,
-                       const libmv_reconstructionOptions * /*libmv_reconstruction_options*/,
-                       reconstruct_progress_update_cb /*progress_update_callback*/,
-                       void * /*callback_customdata*/)
+               const libmv_CameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/,
+               const libmv_ReconstructionOptions * /*libmv_reconstruction_options*/,
+               reconstruct_progress_update_cb /*progress_update_callback*/,
+               void * /*callback_customdata*/)
 {
        return NULL;
 }
 
-int libmv_reporojectionPointForTrack(const libmv_Reconstruction * /*libmv_reconstruction*/,
+int libmv_reprojectionPointForTrack(const struct libmv_Reconstruction * /*libmv_reconstruction*/,
                                      int /*track*/, double /*pos*/[3])
 {
        return 0;
 }
 
-double libmv_reporojectionErrorForTrack(const libmv_Reconstruction * /*libmv_reconstruction*/, int /*track*/)
+double libmv_reprojectionErrorForTrack(const struct libmv_Reconstruction * /*libmv_reconstruction*/, int /*track*/)
 {
        return 0.0;
 }
 
-double libmv_reporojectionErrorForImage(const libmv_Reconstruction * /*libmv_reconstruction*/, int /*image*/)
+double libmv_reprojectionErrorForImage(const struct libmv_Reconstruction * /*libmv_reconstruction*/, int /*image*/)
 {
        return 0.0;
 }
 
-int libmv_reporojectionCameraForImage(const libmv_Reconstruction * /*libmv_reconstruction*/, int /*image*/,
+int libmv_reprojectionCameraForImage(const struct libmv_Reconstruction * /*libmv_reconstruction*/, int /*image*/,
                                       double /*mat*/[4][4])
 {
        return 0;
 }
 
-double libmv_reprojectionError(const libmv_Reconstruction * /*libmv_reconstruction*/)
+double libmv_reprojectionError(const struct libmv_Reconstruction * /*libmv_reconstruction*/)
 {
        return 0.0;
 }
 
-void libmv_destroyReconstruction(libmv_Reconstruction * /*libmv_reconstruction*/)
+void libmv_reconstructionDestroy(struct libmv_Reconstruction * /*libmv_reconstruction*/)
 {
 }
 
 /* ************ feature detector ************ */
 
-struct libmv_Features *libmv_detectFeaturesFAST(const unsigned char * /*data*/,
-                       int /*width*/, int /*height*/, int /*stride*/,
-                       int /*margin*/, int /*min_trackness*/, int /*min_distance*/)
+struct libmv_Features *libmv_detectFeaturesFAST(const unsigned char * /*data*/, int /*width*/, int /*height*/,
+                                                int /*stride*/, int /*margin*/, int /*min_trackness*/,
+                                                int /*min_distance*/)
 {
        return NULL;
 }
 
-struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char * /*data*/,
-                       int /*width*/, int /*height*/, int /*stride*/,
-                       int /*margin*/, int /*count*/, int /*min_distance*/)
+struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char * /*data*/, int /*width*/, int /*height*/,
+                                                   int /*stride*/, int /*margin*/, int /*count*/, int /*min_distance*/)
 {
        return NULL;
 }
@@ -173,49 +173,50 @@ void libmv_getFeature(const struct libmv_Features * /*libmv_features*/, int /*nu
        *size = 0.0;
 }
 
-void libmv_destroyFeatures(struct libmv_Features * /*libmv_features*/)
+void libmv_featuresDestroy(struct libmv_Features * /*libmv_features*/)
 {
 }
 
 /* ************ camera intrinsics ************ */
 
-struct libmv_CameraIntrinsics *libmv_ReconstructionExtractIntrinsics(
-                       struct libmv_Reconstruction * /*libmv_Reconstruction*/)
+struct libmv_CameraIntrinsics *libmv_reconstructionExtractIntrinsics(
+               struct libmv_Reconstruction * /*libmv_reconstruction*/)
 {
        return NULL;
 }
 
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNewEmpty(void)
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNewEmpty(void)
 {
        return NULL;
 }
 
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNew(const libmv_cameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/)
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsNew(
+               const libmv_CameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/)
 {
        return NULL;
 }
 
-struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsCopy(const struct libmv_CameraIntrinsics * /*libmvIntrinsics*/)
+struct libmv_CameraIntrinsics *libmv_cameraIntrinsicsCopy(const libmv_CameraIntrinsics * /*libmvIntrinsics*/)
 {
        return NULL;
 }
 
-void libmv_CameraIntrinsicsDestroy(struct libmv_CameraIntrinsics * /*libmvIntrinsics*/)
+void libmv_cameraIntrinsicsDestroy(struct libmv_CameraIntrinsics * /*libmvIntrinsics*/)
 {
 }
 
-void libmv_CameraIntrinsicsUpdate(const libmv_cameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/,
-                                  libmv_CameraIntrinsics * /*libmv_intrinsics*/)
+void libmv_cameraIntrinsicsUpdate(const libmv_CameraIntrinsicsOptions * /*libmv_camera_intrinsics_options*/,
+                                  struct libmv_CameraIntrinsics * /*libmv_intrinsics*/)
 {
 }
 
-void libmv_CameraIntrinsicsSetThreads(struct libmv_CameraIntrinsics * /*libmv_intrinsics*/, int /*threads*/)
+void libmv_cameraIntrinsicsSetThreads(struct libmv_CameraIntrinsics * /*libmv_intrinsics*/, int /*threads*/)
 {
 }
 
-void libmv_CameraIntrinsicsExtract(const struct libmv_CameraIntrinsics * /*libmv_intrinsics*/, double * focal_length,
-                       double * principal_x, double *principal_y, double *k1, double *k2, double *k3,
-                       int *width, int *height)
+void libmv_cameraIntrinsicsExtract(const struct libmv_CameraIntrinsics * /*libmv_intrinsics*/, double * focal_length,
+                                   double * principal_x, double *principal_y, double *k1, double *k2, double *k3,
+                                   int *width, int *height)
 {
        *focal_length = 1.0;
        *principal_x = 0.0;
@@ -226,33 +227,35 @@ void libmv_CameraIntrinsicsExtract(const struct libmv_CameraIntrinsics * /*libmv
        *height = 0.0;
 }
 
-void libmv_CameraIntrinsicsUndistortByte(const struct libmv_CameraIntrinsics * /*libmv_intrinsics*/,
-                       unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels)
+void libmv_cameraIntrinsicsUndistortByte(const struct libmv_CameraIntrinsics * /*libmv_intrinsics*/,
+                                         unsigned char *src, unsigned char *dst, int width, int height,
+                                         float overscan, int channels)
 {
        memcpy(dst, src, channels * width * height * sizeof(unsigned char));
 }
 
-void libmv_CameraIntrinsicsUndistortFloat(const struct libmv_CameraIntrinsics * /*libmvIntrinsics*/,
-                       float *src, float *dst, int width, int height, float overscan, int channels)
+void libmv_cameraIntrinsicsUndistortFloat(const struct libmv_CameraIntrinsics * /*libmvIntrinsics*/,
+                                          float *src, float *dst, int width, int height, float overscan, int channels)
 {
        memcpy(dst, src, channels * width * height * sizeof(float));
 }
 
-void libmv_CameraIntrinsicsDistortByte(const struct libmv_CameraIntrinsics *libmvIntrinsics,
-                       unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels)
+void libmv_cameraIntrinsicsDistortByte(const struct libmv_CameraIntrinsics *libmvIntrinsics,
+                                       unsigned char *src, unsigned char *dst, int width, int height,
+                                       float overscan, int channels)
 {
        memcpy(dst, src, channels * width * height * sizeof(unsigned char));
 }
 
-void libmv_CameraIntrinsicsDistortFloat(const struct libmv_CameraIntrinsics *libmvIntrinsics,
-                       float *src, float *dst, int width, int height, float overscan, int channels)
+void libmv_cameraIntrinsicsDistortFloat(const struct libmv_CameraIntrinsics *libmvIntrinsics,
+                                        float *src, float *dst, int width, int height, float overscan, int channels)
 {
        memcpy(dst, src, channels * width * height * sizeof(float));
 }
 
 /* ************ utils ************ */
 
-void libmv_ApplyCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+void libmv_cameraIntrinsicsApply(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
                                  double x, double y, double *x1, double *y1)
 {
        double focal_length = libmv_camera_intrinsics_options->focal_length;
@@ -263,7 +266,7 @@ void libmv_ApplyCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_came
        *y1 = y * focal_length + principal_y;
 }
 
-void libmv_InvertCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+void libmv_cameraIntrinsicsInvert(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
                                   double x, double y, double *x1, double *y1)
 {
        double focal_length = libmv_camera_intrinsics_options->focal_length;
index 9fa9e1267565a910be0462022003b8e0b1be1357..55282a1ec00b36705085d52eb7adced8d066a0dd 100644 (file)
@@ -462,7 +462,6 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
        mesh_synced.insert(mesh);
 
        /* create derived mesh */
-       bool need_undeformed = mesh->need_attribute(scene, ATTR_STD_GENERATED);
        PointerRNA cmesh = RNA_pointer_get(&b_ob_data.ptr, "cycles");
 
        vector<Mesh::Triangle> oldtriangle = mesh->triangles;
@@ -479,6 +478,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
                if(preview)
                        b_ob.update_from_editmode();
 
+               bool need_undeformed = mesh->need_attribute(scene, ATTR_STD_GENERATED);
                BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, need_undeformed);
 
                if(b_mesh) {
index 6e535e82886be7a9bed9e749731c157c926da779..fb743acf29af3c34643b532418a5c65dfdf9af2e 100644 (file)
@@ -285,6 +285,11 @@ void BlenderSession::do_write_update_render_tile(RenderTile& rtile, bool do_upda
 
        BL::RenderResult::layers_iterator b_single_rlay;
        b_rr.layers.begin(b_single_rlay);
+
+       /* layer will be missing if it was disabled in the UI */
+       if(b_single_rlay == b_rr.layers.end())
+               return;
+
        BL::RenderLayer b_rlay = *b_single_rlay;
 
        if (do_update_only) {
index 00c146143b84b8acd64ee827520441a0031e9256..f2c96638b8454d817beb80b26a336080f304bef6 100644 (file)
@@ -46,7 +46,7 @@ class Progress;
 
 struct PackedBVH {
        /* BVH nodes storage, one node is 4x int4, and contains two bounding boxes,
-        * and child, triangle or object indexes dependening on the node type */
+        * and child, triangle or object indexes depending on the node type */
        array<int4> nodes; 
        /* object index to BVH node index mapping for instances */
        array<int> object_node; 
index 091582093c6276743ada6ca20d7400a748db24bf..7d0b9a0afb810e47cc6e915cbd21069a55132e4a 100644 (file)
@@ -925,10 +925,7 @@ __device_noinline void kernel_path_non_progressive_lighting(KernelGlobals *kg, R
                        path_radiance_bsdf_bounce(L, &tp, &bsdf_eval, bsdf_pdf, state.bounce, label);
 
                        /* set labels */
-                       float min_ray_pdf = FLT_MAX;
-
-                       if(!(label & LABEL_TRANSPARENT))
-                               min_ray_pdf = fminf(bsdf_pdf, min_ray_pdf);
+                       float min_ray_pdf = fminf(bsdf_pdf, FLT_MAX);
 
                        /* modify path state */
                        PathState ps = state;
index 12a4506af13c178b2498379b5b8c050a8e5f3860..c6a7e1a9c2fb8a2cff37f0e50c8d800e998524c7 100644 (file)
@@ -449,7 +449,7 @@ typedef enum AttributeStandard {
 
 /* Closure data */
 
-#define MAX_CLOSURE 16
+#define MAX_CLOSURE 64
 
 typedef struct ShaderClosure {
        ClosureType type;
index a92d0d33b652ede9c4b0a017bc7d7f9fed4091fc..aae90179be5cd74365ddb8500316d6e760b139cd 100644 (file)
@@ -665,6 +665,19 @@ extern GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
  */
 extern GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle);
 
+/**
+ * Sets the swap interval for swapBuffers.
+ * \param interval The swap interval to use.
+ * \return A boolean success indicator.
+ */
+extern GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interval);
+
+/**
+ * Gets the current swap interval for swapBuffers.
+ * \return An integer.
+ */
+extern int GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle);
+
 /**
  * Activates the drawing context of this window.
  * \param windowhandle The handle to the window
index a2d3e9b91fbb884822450548a0a888c605d865b8..355770752634dd00a7317886825c9ff8973327d4 100644 (file)
@@ -204,6 +204,19 @@ public:
         */
        virtual GHOST_TSuccess swapBuffers() = 0;
 
+       /**
+        * Sets the swap interval for swapBuffers.
+        * \param interval The swap interval to use.
+        * \return A boolean success indicator.
+        */
+       virtual GHOST_TSuccess setSwapInterval(int interval) = 0;
+
+       /**
+        * Gets the current swap interval for swapBuffers.
+        * \return An integer.
+        */
+       virtual int getSwapInterval() = 0;
+
        /**
         * Activates the drawing context of this window.
         * \return  A boolean success indicator.
index b73ff26c259918cacec4e31ba31fd4e46259aa67..8d4498ed759b11951bed50a4790f611857b7f665 100644 (file)
@@ -691,6 +691,19 @@ GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
        return window->swapBuffers();
 }
 
+GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interval)
+{
+       GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
+
+       return window->setSwapInterval(interval);
+}
+
+int GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
+
+       return window->getSwapInterval();
+}
 
 
 GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
index 588de0911e302576c7d616d3cc06ec162e175146..77ee4db8543e487e26ff672c9ce4f840ee8362ac 100644 (file)
@@ -67,6 +67,8 @@ public:
         * virtual GHOST_TWindowOrder getOrder(void) = 0;
         * virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
         * virtual GHOST_TSuccess swapBuffers() = 0;
+        * virtual GHOST_TSuccess setSwapInterval() = 0;
+        * virtual int getSwapInterval() = 0;
         * virtual GHOST_TSuccess activateDrawingContext() = 0;
         * virtual GHOST_TSuccess invalidate() = 0;
         */
@@ -110,6 +112,8 @@ public:
         * virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
         * virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
         * virtual GHOST_TSuccess swapBuffers() = 0;
+        * virtual GHOST_TSuccess setSwapInterval() = 0;
+        * virtual int getSwapInterval() = 0;
         * virtual GHOST_TSuccess activateDrawingContext() = 0;
         * virtual GHOST_TSuccess invalidate() = 0;
         */
@@ -204,6 +208,23 @@ public:
                return GHOST_kFailure;
        }
        
+       /**
+        * Sets the swap interval for swapBuffers.
+        * \param interval The swap interval to use.
+        * \return A boolean success indicator.
+        */
+       virtual GHOST_TSuccess setSwapInterval(int interval) {
+               return GHOST_kFailure;
+       }
+       
+       /**
+        * Gets the current swap interval for swapBuffers.
+        * \return An integer.
+        */
+       virtual int getSwapInterval() {
+               return 0;
+       }
+       
        /**
         * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
         */
index b0d0b1a5b5dbed78e68a17d5cef4cf38eea4e437..c264686fbb152a96ada6fd8cee5c82c29bfd86d5 100644 (file)
@@ -648,6 +648,20 @@ GHOST_TSuccess GHOST_WindowWin32::swapBuffers()
        return ::SwapBuffers(hDC) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
 }
 
+GHOST_TSuccess GHOST_WindowWin32::setSwapInterval(int interval)
+{
+       if (!WGL_EXT_swap_control)
+               return GHOST_kFailure;
+       return wglSwapIntervalEXT(interval) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
+}
+
+int GHOST_WindowWin32::getSwapInterval()
+{
+       if (WGL_EXT_swap_control)
+               return wglGetSwapIntervalEXT();
+
+       return 0;
+}
 
 GHOST_TSuccess GHOST_WindowWin32::activateDrawingContext()
 {
index 2fd1f5b37f4eb845f943a9b15415aed3a2449fd4..6fdc963f30ae8a1c1328b5f506ce661cc17ba0f1 100644 (file)
@@ -211,6 +211,19 @@ public:
         */
        virtual GHOST_TSuccess swapBuffers();
 
+       /**
+        * Sets the swap interval for swapBuffers.
+        * \param interval The swap interval to use.
+        * \return A boolean success indicator.
+        */
+       virtual GHOST_TSuccess setSwapInterval(int interval);
+
+       /**
+        * Gets the current swap interval for swapBuffers.
+        * \return An integer.
+        */
+       virtual int getSwapInterval();
+
        /**
         * Activates the drawing context of this window.
         * \return Indication of success.
index 25d7c181b68b0e0152914cbc4a27f061030c6e72..3173736c2a5b4410a1b6493a720a12c90d7788dc 100644 (file)
@@ -30,6 +30,8 @@
  */
 
 
+#include <GL/glxew.h>
+
 #include "GHOST_WindowX11.h"
 #include "GHOST_SystemX11.h"
 #include "STR_String.h"
@@ -1513,3 +1515,23 @@ endFullScreen() const
 
        return GHOST_kSuccess;
 }
+
+GHOST_TSuccess
+GHOST_WindowX11::
+setSwapInterval(int interval) {
+       if (!GLX_EXT_swap_control)
+               return GHOST_kFailure;
+       glXSwapIntervalEXT(m_display, m_window, interval);
+       return GHOST_kSuccess;
+}
+
+int
+GHOST_WindowX11::
+getSwapInterval() {
+       if (GLX_EXT_swap_control) {
+               unsigned int value;
+               glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &value);
+               return (int)value;
+       }
+       return 0;
+}
index b8471b41a111601dcb8b9cf54837be7cf31d8586..7cbdcdeec2188a1201784535ffe6e7b25e5eda7b 100644 (file)
@@ -235,6 +235,19 @@ public:
 
        GHOST_TSuccess endFullScreen() const;
 
+       /**
+        * Sets the swap interval for swapBuffers.
+        * \param interval The swap interval to use.
+        * \return A boolean success indicator.
+        */
+       virtual GHOST_TSuccess setSwapInterval(int interval);
+
+       /**
+        * Gets the current swap interval for swapBuffers.
+        * \return An integer.
+        */
+       virtual int getSwapInterval();
+
 protected:
        /**
         * Tries to install a rendering context in this window.
index 38e49853454abcd7cec178fc3e2e0727b59ef857..025d86204f21d3d30d272a2fdfca8f6aae9ad75f 100644 (file)
@@ -413,6 +413,9 @@ class RENDER_PT_game_system(RenderButtonsPanel, Panel):
         col.prop(gs, "use_display_lists")
         col.active = gs.raster_storage != 'VERTEX_BUFFER_OBJECT'
 
+        row = layout.row()
+        row.prop(gs, "vsync")
+
         row = layout.row()
         row.prop(gs, "raster_storage")
 
index 31023d49340fd7dd8124360b36be88bea226b7c8..ec2492f73651cdb5d71de78e952c7e00e23145e0 100644 (file)
@@ -205,10 +205,20 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
         layout = self.layout
 
         obj = context.object
+        obj_type = obj.type
+        is_geometry = (obj_type in {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'})
+        is_empty_image = (obj_type == 'EMPTY' and obj.empty_draw_type == 'IMAGE')
 
         split = layout.split()
+
         col = split.column()
-        col.prop(obj, "draw_type", text="Type")
+        col.prop(obj, "show_name", text="Name")
+        col.prop(obj, "show_axis", text="Axis")
+        if is_geometry:
+            # Makes no sense for cameras, armatures, etc.!
+            col.prop(obj, "show_wire", text="Wire")
+        if obj_type == 'MESH':
+            col.prop(obj, "show_all_edges")
 
         col = split.column()
         row = col.row()
@@ -217,27 +227,24 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
         sub.active = obj.show_bounds
         sub.prop(obj, "draw_bounds_type", text="")
 
+        if is_geometry:
+            col.prop(obj, "show_texture_space", text="Texture Space")
+        col.prop(obj, "show_x_ray", text="X-Ray")
+        if obj_type == 'MESH' or is_empty_image:
+            col.prop(obj, "show_transparent", text="Transparency")
+
         split = layout.split()
 
         col = split.column()
-        col.prop(obj, "show_name", text="Name")
-        col.prop(obj, "show_axis", text="Axis")
-
-        obj_type = obj.type
-
-        if obj_type in {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'}:
-            # Makes no sense for cameras, armtures, etc.!
-            col.prop(obj, "show_wire", text="Wire")
-            # Only useful with object having faces/materials...
-            col.prop(obj, "color", text="Object Color")
+        if obj_type not in {'CAMERA', 'EMPTY'}:
+            col.label(text="Maximum draw type:")
+            col.prop(obj, "draw_type", text="")
 
         col = split.column()
-        col.prop(obj, "show_texture_space", text="Texture Space")
-        col.prop(obj, "show_x_ray", text="X-Ray")
-        if obj_type == 'MESH' or (obj_type == 'EMPTY' and obj.empty_draw_type == 'IMAGE'):
-            col.prop(obj, "show_transparent", text="Transparency")
-        if obj_type == 'MESH':
-            col.prop(obj, "show_all_edges")
+        if is_geometry or is_empty_image:
+            # Only useful with object having faces/materials...
+            col.label(text="Object Color:")
+            col.prop(obj, "color", text="")
 
 
 class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
index 18008553368c4c223cc495270aeb5adcb8bad7f0..58eecc2641dd3a481f1b981cb9bff9c011e495bc 100644 (file)
@@ -1973,7 +1973,9 @@ class VIEW3D_MT_edit_mesh_edges(Menu):
 
     def draw(self, context):
         layout = self.layout
+
         with_freestyle = bpy.app.build_options.freestyle
+        scene = context.scene
 
         layout.operator_context = 'INVOKE_REGION_WIN'
 
@@ -1998,11 +2000,10 @@ class VIEW3D_MT_edit_mesh_edges(Menu):
 
         layout.separator()
 
-        if with_freestyle:
+        if with_freestyle and not scene.render.use_shading_nodes:
             layout.operator("mesh.mark_freestyle_edge").clear = False
             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
-
-        layout.separator()
+            layout.separator()
 
         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
@@ -2028,7 +2029,9 @@ class VIEW3D_MT_edit_mesh_faces(Menu):
 
     def draw(self, context):
         layout = self.layout
+
         with_freestyle = bpy.app.build_options.freestyle
+        scene = context.scene
 
         layout.operator_context = 'INVOKE_REGION_WIN'
 
@@ -2044,11 +2047,10 @@ class VIEW3D_MT_edit_mesh_faces(Menu):
 
         layout.separator()
 
-        if with_freestyle:
+        if with_freestyle and not scene.render.use_shading_nodes:
             layout.operator("mesh.mark_freestyle_face").clear = False
             layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
-
-        layout.separator()
+            layout.separator()
 
         layout.operator("mesh.poke")
         layout.operator("mesh.quads_convert_to_tris")
@@ -2092,6 +2094,7 @@ class VIEW3D_MT_edit_mesh_clean(Menu):
         layout = self.layout
 
         layout.operator("mesh.fill_holes")
+        layout.operator("mesh.vert_connect_nonplanar")
 
 
 class VIEW3D_MT_edit_mesh_delete(Menu):
@@ -2660,6 +2663,7 @@ class VIEW3D_PT_view3d_meshdisplay(Panel):
         with_freestyle = bpy.app.build_options.freestyle
 
         mesh = context.active_object.data
+        scene = context.scene
 
         split = layout.split()
 
@@ -2679,7 +2683,7 @@ class VIEW3D_PT_view3d_meshdisplay(Panel):
             col.prop(mesh, "show_edge_seams", text="Seams")
         col.prop(mesh, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
         col.prop(mesh, "show_edge_bevel_weight", text="Bevel")
-        if with_freestyle:
+        if with_freestyle and not scene.render.use_shading_nodes:
             col.prop(mesh, "show_freestyle_edge_marks", text="Edge Marks")
             col.prop(mesh, "show_freestyle_face_marks", text="Face Marks")
 
index d5bb71416c9fd00409908409a82bbef7d9bbe2be..5f002f3716176dcb355dbe532d67d5884ec9769d 100644 (file)
@@ -1,5 +1,5 @@
 import bpy
-from bpy_types import NodeTree, Node, NodeSocket
+from bpy.types import NodeTree, Node, NodeSocket
 
 # Implementation of custom nodes from Python
 
index 7a7d4c7d24ac4a940985654ab30d21f90edb2cba..3422f783eeb017d14e25ab5050692cefcabc6ee8 100644 (file)
@@ -46,7 +46,6 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_memarena.h"
-#include "BLI_array.h"
 #include "BLI_utildefines.h"
 #include "BLI_linklist.h"
 
index 001964087b8ba12a0581b8f38993fd07b6fac79b..4b05b0800a50c4ec6b3446d0a6101f72514d83bf 100644 (file)
@@ -39,8 +39,8 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_utildefines.h"
-#include "BLI_array.h"
 #include "BLI_blenlib.h"
+#include "BLI_alloca.h"
 #include "BLI_dynstr.h"
 
 #include "BLF_translation.h"
index 0e294f388386891b08e697558303dfc6bc412894..60f6bb0a7360a74cad179daeaf404d62e3bbc46c 100644 (file)
@@ -40,7 +40,6 @@
 #include "BLI_blenlib.h"
 #include "BLI_edgehash.h"
 #include "BLI_math.h"
-#include "BLI_array.h"
 #include "BLI_smallhash.h"
 #include "BLI_utildefines.h"
 #include "BLI_scanfill.h"
index a79fa3873f517dfbf0db92dfe62932e57e7b8c8b..5b8929e49fe7f77dd8770acb7be7baaef92f01ab 100644 (file)
@@ -533,7 +533,7 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char **
 
                        if (me->edit_btmesh && me->edit_btmesh->bm->totvert == kb->totelem) {
                                a = 0;
-                               co = MEM_callocN(sizeof(float) * 3 * me->edit_btmesh->bm->totvert, "key_block_get_data");
+                               co = MEM_mallocN(sizeof(float) * 3 * me->edit_btmesh->bm->totvert, "key_block_get_data");
 
                                BM_ITER_MESH (eve, &iter, me->edit_btmesh->bm, BM_VERTS_OF_MESH) {
                                        copy_v3_v3(co[a], eve->co);
@@ -1091,7 +1091,7 @@ static float *get_weights_array(Object *ob, char *vgroup)
                float *weights;
                int i;
                
-               weights = MEM_callocN(totvert * sizeof(float), "weights");
+               weights = MEM_mallocN(totvert * sizeof(float), "weights");
 
                if (em) {
                        const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
@@ -1622,7 +1622,7 @@ void BKE_key_convert_from_lattice(Lattice *lt, KeyBlock *kb)
 
        if (kb->data) MEM_freeN(kb->data);
 
-       kb->data = MEM_callocN(lt->key->elemsize * tot, "kb->data");
+       kb->data = MEM_mallocN(lt->key->elemsize * tot, "kb->data");
        kb->totelem = tot;
 
        bp = lt->def;
@@ -1664,7 +1664,7 @@ void BKE_key_convert_from_curve(Curve *cu, KeyBlock *kb, ListBase *nurb)
 
        if (kb->data) MEM_freeN(kb->data);
 
-       kb->data = MEM_callocN(cu->key->elemsize * tot, "kb->data");
+       kb->data = MEM_mallocN(cu->key->elemsize * tot, "kb->data");
        kb->totelem = tot;
 
        nu = nurb->first;
@@ -1762,7 +1762,7 @@ void BKE_key_convert_from_mesh(Mesh *me, KeyBlock *kb)
 
        if (kb->data) MEM_freeN(kb->data);
 
-       kb->data = MEM_callocN(me->key->elemsize * me->totvert, "kb->data");
+       kb->data = MEM_mallocN(me->key->elemsize * me->totvert, "kb->data");
        kb->totelem = me->totvert;
 
        mvert = me->mvert;
@@ -1812,7 +1812,7 @@ float (*BKE_key_convert_to_vertcos(Object *ob, KeyBlock *kb))[3]
 
        if (tot == 0) return NULL;
 
-       vertCos = MEM_callocN(tot * sizeof(*vertCos), "BKE_key_convert_to_vertcos vertCos");
+       vertCos = MEM_mallocN(tot * sizeof(*vertCos), "BKE_key_convert_to_vertcos vertCos");
 
        /* Copy coords to array */
        co = (float *)vertCos;
@@ -1895,7 +1895,7 @@ void BKE_key_convert_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos)[3])
                return;
        }
 
-       fp = kb->data = MEM_callocN(tot * elemsize, "BKE_key_convert_to_vertcos vertCos");
+       fp = kb->data = MEM_mallocN(tot * elemsize, "BKE_key_convert_to_vertcos vertCos");
 
        /* Copy coords to keyblock */
 
index 300beae1078ea0462b95c565bcd23635206946e8..6dc3c6d7bc63c83930c2d7a2bce5611a9654f0e9 100644 (file)
@@ -1176,7 +1176,9 @@ int object_remove_material_slot(Object *ob)
        totcolp = give_totcolp(ob);
        matarar = give_matarar(ob);
 
-       if (*matarar == NULL) return FALSE;
+       if (ELEM(NULL, matarar, *matarar)) {
+               return false;
+       }
 
        /* can happen on face selection in editmode */
        if (ob->actcol > ob->totcol) {
index 439965420f7352bbde6c21c840eeef4ab4285faa..095957b40d5a83788f08544922ffda35674c1823 100644 (file)
@@ -51,6 +51,7 @@
 #include "BLI_bitmap.h"
 #include "BLI_scanfill.h"
 #include "BLI_array.h"
+#include "BLI_alloca.h"
 
 #include "BKE_animsys.h"
 #include "BKE_main.h"
index a94daed11e3fbc190f3290f32160c52cff983d0b..290b0684e4047ea0656df99b7782e05399ea13ed 100644 (file)
  *  \ingroup bke
  */
 
-#include "BLI_math.h"
-
 #include "MEM_guardedalloc.h"
 
+#include "BLI_math.h"
+#include "BLI_alloca.h"
+
 #include "DNA_object_types.h"
 
-#include "BLI_array.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_editmesh.h"
index 2c561dd447264ae9a9a7a4e581493b1b9cacc1ee..12c2967afcfa4fde1121c78d31e59c8ffdc35f17 100644 (file)
@@ -1534,7 +1534,7 @@ void BKE_tracking_camera_get_reconstructed_interpolate(MovieTracking *tracking,
 
 /*********************** Distortion/Undistortion *************************/
 
-static void cameraIntrinscisOptionsFromTracking(libmv_cameraIntrinsicsOptions *camera_intrinsics_options,
+static void cameraIntrinscisOptionsFromTracking(libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
                                                 MovieTracking *tracking, int calibration_width, int calibration_height)
 {
        MovieTrackingCamera *camera = &tracking->camera;
@@ -1559,7 +1559,7 @@ MovieDistortion *BKE_tracking_distortion_new(void)
 
        distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
 
-       distortion->intrinsics = libmv_CameraIntrinsicsNewEmpty();
+       distortion->intrinsics = libmv_cameraIntrinsicsNewEmpty();
 
        return distortion;
 }
@@ -1567,17 +1567,17 @@ MovieDistortion *BKE_tracking_distortion_new(void)
 void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking *tracking,
                                     int calibration_width, int calibration_height)
 {
-       libmv_cameraIntrinsicsOptions camera_intrinsics_options;
+       libmv_CameraIntrinsicsOptions camera_intrinsics_options;
 
        cameraIntrinscisOptionsFromTracking(&camera_intrinsics_options, tracking,
                                            calibration_width, calibration_height);
 
-       libmv_CameraIntrinsicsUpdate(&camera_intrinsics_options, distortion->intrinsics);
+       libmv_cameraIntrinsicsUpdate(&camera_intrinsics_options, distortion->intrinsics);
 }
 
 void BKE_tracking_distortion_set_threads(MovieDistortion *distortion, int threads)
 {
-       libmv_CameraIntrinsicsSetThreads(distortion->intrinsics, threads);
+       libmv_cameraIntrinsicsSetThreads(distortion->intrinsics, threads);
 }
 
 MovieDistortion *BKE_tracking_distortion_copy(MovieDistortion *distortion)
@@ -1586,7 +1586,7 @@ MovieDistortion *BKE_tracking_distortion_copy(MovieDistortion *distortion)
 
        new_distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
 
-       new_distortion->intrinsics = libmv_CameraIntrinsicsCopy(distortion->intrinsics);
+       new_distortion->intrinsics = libmv_cameraIntrinsicsCopy(distortion->intrinsics);
 
        return new_distortion;
 }
@@ -1602,12 +1602,12 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
 
        if (ibuf->rect_float) {
                if (undistort) {
-                       libmv_CameraIntrinsicsUndistortFloat(distortion->intrinsics,
+                       libmv_cameraIntrinsicsUndistortFloat(distortion->intrinsics,
                                                             ibuf->rect_float, resibuf->rect_float,
                                                             ibuf->x, ibuf->y, overscan, ibuf->channels);
                }
                else {
-                       libmv_CameraIntrinsicsDistortFloat(distortion->intrinsics,
+                       libmv_cameraIntrinsicsDistortFloat(distortion->intrinsics,
                                                           ibuf->rect_float, resibuf->rect_float,
                                                           ibuf->x, ibuf->y, overscan, ibuf->channels);
                }
@@ -1617,12 +1617,12 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
        }
        else {
                if (undistort) {
-                       libmv_CameraIntrinsicsUndistortByte(distortion->intrinsics,
+                       libmv_cameraIntrinsicsUndistortByte(distortion->intrinsics,
                                                            (unsigned char *)ibuf->rect, (unsigned char *)resibuf->rect,
                                                            ibuf->x, ibuf->y, overscan, ibuf->channels);
                }
                else {
-                       libmv_CameraIntrinsicsDistortByte(distortion->intrinsics,
+                       libmv_cameraIntrinsicsDistortByte(distortion->intrinsics,
                                                          (unsigned char *)ibuf->rect, (unsigned char *)resibuf->rect,
                                                          ibuf->x, ibuf->y, overscan, ibuf->channels);
                }
@@ -1633,7 +1633,7 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
 
 void BKE_tracking_distortion_free(MovieDistortion *distortion)
 {
-       libmv_CameraIntrinsicsDestroy(distortion->intrinsics);
+       libmv_cameraIntrinsicsDestroy(distortion->intrinsics);
 
        MEM_freeN(distortion);
 }
@@ -1642,7 +1642,7 @@ void BKE_tracking_distort_v2(MovieTracking *tracking, const float co[2], float r
 {
        MovieTrackingCamera *camera = &tracking->camera;
 
-       libmv_cameraIntrinsicsOptions camera_intrinsics_options;
+       libmv_CameraIntrinsicsOptions camera_intrinsics_options;
        double x, y;
        float aspy = 1.0f / tracking->camera.pixel_aspect;
 
@@ -1652,7 +1652,7 @@ void BKE_tracking_distort_v2(MovieTracking *tracking, const float co[2], float r
        x = (co[0] - camera->principal[0]) / camera->focal;
        y = (co[1] - camera->principal[1] * aspy) / camera->focal;
 
-       libmv_ApplyCameraIntrinsics(&camera_intrinsics_options, x, y, &x, &y);
+       libmv_cameraIntrinsicsApply(&camera_intrinsics_options, x, y, &x, &y);
 
        /* result is in image coords already */
        r_co[0] = x;
@@ -1663,13 +1663,13 @@ void BKE_tracking_undistort_v2(MovieTracking *tracking, const float co[2], float
 {
        MovieTrackingCamera *camera = &tracking->camera;
 
-       libmv_cameraIntrinsicsOptions camera_intrinsics_options;
+       libmv_CameraIntrinsicsOptions camera_intrinsics_options;
        double x = co[0], y = co[1];
        float aspy = 1.0f / tracking->camera.pixel_aspect;
 
        cameraIntrinscisOptionsFromTracking(&camera_intrinsics_options, tracking, 0, 0);
 
-       libmv_InvertCameraIntrinsics(&camera_intrinsics_options, x, y, &x, &y);
+       libmv_cameraIntrinsicsInvert(&camera_intrinsics_options, x, y, &x, &y);
 
        r_co[0] = (float)x * camera->focal + camera->principal[0];
        r_co[1] = (float)y * camera->focal + camera->principal[1] * aspy;
@@ -2529,7 +2529,7 @@ static bool track_context_update_reference(MovieTrackingContext *context, TrackC
 
 /* Fill in libmv tracker options structure with settings need to be used to perform track. */
 static void tracking_configure_tracker(MovieTrackingTrack *track, float *mask,
-                                       struct libmv_trackRegionOptions *options)
+                                       libmv_TrackRegionOptions *options)
 {
        options->motion_model = track->motion_model;
 
@@ -2654,8 +2654,8 @@ static bool configure_and_run_tracker(ImBuf *destination_ibuf, MovieTrackingTrac
        double src_pixel_x[5], src_pixel_y[5];
 
        /* Settings for the tracker */
-       struct libmv_trackRegionOptions options = {0};
-       struct libmv_trackRegionResult result;
+       libmv_TrackRegionOptions options = {0};
+       libmv_TrackRegionResult result;
 
        float *patch_new;
 
@@ -2930,17 +2930,17 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in
 }
 
 /* Retrieve refined camera intrinsics from libmv to blender. */
-static void reconstruct_retrieve_libmv_intrinscis(MovieReconstructContext *context, MovieTracking *tracking)
+static void reconstruct_retrieve_libmv_intrinsics(MovieReconstructContext *context, MovieTracking *tracking)
 {
        struct libmv_Reconstruction *libmv_reconstruction = context->reconstruction;
-       struct libmv_CameraIntrinsics *libmv_intrinsics = libmv_ReconstructionExtractIntrinsics(libmv_reconstruction);
+       struct libmv_CameraIntrinsics *libmv_intrinsics = libmv_reconstructionExtractIntrinsics(libmv_reconstruction);
 
        float aspy = 1.0f / tracking->camera.pixel_aspect;
 
        double focal_length, principal_x, principal_y, k1, k2, k3;
        int width, height;
 
-       libmv_CameraIntrinsicsExtract(libmv_intrinsics, &focal_length, &principal_x, &principal_y,
+       libmv_cameraIntrinsicsExtract(libmv_intrinsics, &focal_length, &principal_x, &principal_y,
                                      &k1, &k2, &k3, &width, &height);
 
        tracking->camera.focal = focal_length;
@@ -2987,13 +2987,13 @@ static int reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, M
        while (track) {
                double pos[3];
 
-               if (libmv_reporojectionPointForTrack(libmv_reconstruction, tracknr, pos)) {
+               if (libmv_reprojectionPointForTrack(libmv_reconstruction, tracknr, pos)) {
                        track->bundle_pos[0] = pos[0];
                        track->bundle_pos[1] = pos[1];
                        track->bundle_pos[2] = pos[2];
 
                        track->flag |= TRACK_HAS_BUNDLE;
-                       track->error = libmv_reporojectionErrorForTrack(libmv_reconstruction, tracknr);
+                       track->error = libmv_reprojectionErrorForTrack(libmv_reconstruction, tracknr);
                }
                else {
                        track->flag &= ~TRACK_HAS_BUNDLE;
@@ -3017,10 +3017,10 @@ static int reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, M
        for (a = sfra; a <= efra; a++) {
                double matd[4][4];
 
-               if (libmv_reporojectionCameraForImage(libmv_reconstruction, a, matd)) {
+               if (libmv_reprojectionCameraForImage(libmv_reconstruction, a, matd)) {
                        int i, j;
                        float mat[4][4];
-                       float error = libmv_reporojectionErrorForImage(libmv_reconstruction, a);
+                       float error = libmv_reprojectionErrorForImage(libmv_reconstruction, a);
 
                        for (i = 0; i < 4; i++) {
                                for (j = 0; j < 4; j++)
@@ -3081,8 +3081,8 @@ static int reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, M
 /* Retrieve all the libmv data from context to blender's side data blocks. */
 static int reconstruct_retrieve_libmv(MovieReconstructContext *context, MovieTracking *tracking)
 {
-       /* take the intrinscis back from libmv */
-       reconstruct_retrieve_libmv_intrinscis(context, tracking);
+       /* take the intrinsics back from libmv */
+       reconstruct_retrieve_libmv_intrinsics(context, tracking);
 
        return reconstruct_retrieve_libmv_tracks(context, tracking);
 }
@@ -3243,7 +3243,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
 void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context)
 {
        if (context->reconstruction)
-               libmv_destroyReconstruction(context->reconstruction);
+               libmv_reconstructionDestroy(context->reconstruction);
 
        libmv_tracksDestroy(context->tracks);
 
@@ -3266,7 +3266,7 @@ static void reconstruct_update_solve_cb(void *customdata, double progress, const
 }
 
 /* FIll in camera intrinsics structure from reconstruction context. */
-static void camraIntrincicsOptionsFromContext(libmv_cameraIntrinsicsOptions *camera_intrinsics_options,
+static void camraIntrincicsOptionsFromContext(libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
                                               MovieReconstructContext *context)
 {
        camera_intrinsics_options->focal_length = context->focal_length;
@@ -3283,7 +3283,7 @@ static void camraIntrincicsOptionsFromContext(libmv_cameraIntrinsicsOptions *cam
 }
 
 /* Fill in reconstruction options structure from reconstruction context. */
-static void reconstructionOptionsFromContext(libmv_reconstructionOptions *reconstruction_options,
+static void reconstructionOptionsFromContext(libmv_ReconstructionOptions *reconstruction_options,
                                              MovieReconstructContext *context)
 {
        reconstruction_options->select_keyframes = context->select_keyframes;
@@ -3313,8 +3313,8 @@ void BKE_tracking_reconstruction_solve(MovieReconstructContext *context, short *
 
        ReconstructProgressData progressdata;
 
-       libmv_cameraIntrinsicsOptions camera_intrinsics_options;
-       libmv_reconstructionOptions reconstruction_options;
+       libmv_CameraIntrinsicsOptions camera_intrinsics_options;
+       libmv_ReconstructionOptions reconstruction_options;
 
        progressdata.stop = stop;
        progressdata.do_update = do_update;
@@ -3558,7 +3558,7 @@ void BKE_tracking_detect_fast(MovieTracking *tracking, ListBase *tracksbase, ImB
                                       framenr, ibuf->x, ibuf->y, layer,
                                       place_outside_layer ? true : false);
 
-       libmv_destroyFeatures(features);
+       libmv_featuresDestroy(features);
 }
 
 /*********************** 2D stabilization *************************/
diff --git a/source/blender/blenlib/BLI_alloca.h b/source/blender/blenlib/BLI_alloca.h
new file mode 100644 (file)
index 0000000..b93f5b7
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_ALLOCA_H__
+
+/** \file BLI_alloca.h
+ *  \ingroup bli
+ *
+ * Defines alloca and utility macro BLI_array_alloca
+ */
+
+/* BLI_array_alloca / alloca */
+#ifdef _MSC_VER
+#  define alloca _alloca
+#endif
+
+#if defined(__MINGW32__)
+#  include <malloc.h>  /* mingw needs for alloca() */
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+#define BLI_array_alloca(arr, realsize) \
+       (typeof(arr))alloca(sizeof(*arr) * (realsize))
+#else
+#define BLI_array_alloca(arr, realsize) \
+       alloca(sizeof(*arr) * (realsize))
+#endif
+
+#endif /* __BLI_ALLOCA_H__ */
index 3fb50afdeac396dddd01fb7831d102cd929806ba..ef5cb8bde04f7660cba0d7374836feee1956eaf2 100644 (file)
 #define _bli_array_totalsize_dynamic(arr)  (                                  \
        ((arr) == NULL) ?                                                         \
            0 :                                                                   \
-           MEM_allocN_len(arr) / sizeof(*arr)                                    \
+           MEM_allocN_len(arr) / sizeof(*(arr))                                  \
 )
 
 #define _bli_array_totalsize_static(arr)  \
-       (sizeof(_##arr##_static) / sizeof(*arr))
+       (sizeof(_##arr##_static) / sizeof(*(arr)))
 
 #define _bli_array_totalsize(arr)  (                                          \
        (size_t)                                                                  \
@@ -66,8 +66,9 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
 /* -------------------------------------------------------------------- */
 /* public defines */
 
+/* use sizeof(*(arr)) to ensure the array exists and is an array */
 #define BLI_array_declare(arr)                                                \
-       int   _##arr##_count = 0;                                                 \
+       int   _##arr##_count = ((void)(sizeof(*(arr))), 0);                       \
        void *_##arr##_static = NULL
 
 /* this will use stack space, up to maxstatic array elements, before
@@ -95,7 +96,7 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
        (LIKELY(_bli_array_totalsize(arr) >= _##arr##_count + num) ?              \
         (void)0 /* do nothing */ :                                               \
         _bli_array_grow_func((void **)&(arr), _##arr##_static,                   \
-                              sizeof(*arr), _##arr##_count, num,                 \
+                              sizeof(*(arr)), _##arr##_count, num,               \
                               "BLI_array." #arr),                                \
         (void)0)  /* msvc2008 needs this */                                      \
        ),                                                                        \
@@ -148,8 +149,8 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
 
 /* only to prevent unused warnings */
 #define BLI_array_fake_user(arr)                                              \
-       (void)_##arr##_count,                                                     \
-       (void)_##arr##_static
+       ((void)_##arr##_count,                                                    \
+        (void)_##arr##_static)
 
 
 /* -------------------------------------------------------------------- */
@@ -161,7 +162,7 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
  * but use when the max size is known ahead of time */
 #define BLI_array_fixedstack_declare(arr, maxstatic, realsize, allocstr)      \
        char _##arr##_static[maxstatic * sizeof(*(arr))];                         \
-       const int _##arr##_is_static = ((void *)_##arr##_static) != (             \
+       const bool _##arr##_is_static = ((void *)_##arr##_static) != (            \
            arr = ((realsize) <= maxstatic) ?                                     \
                (void *)_##arr##_static :                                         \
                MEM_mallocN(sizeof(*(arr)) * (realsize), allocstr)                \
@@ -172,31 +173,4 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
                MEM_freeN(arr);                                                       \
        } (void)0
 
-
-/* alloca */
-#ifdef _MSC_VER
-#  define alloca _alloca
-#endif
-
-#if defined(__MINGW32__)
-#  include <malloc.h>  /* mingw needs for alloca() */
-#endif
-
-#if defined(__GNUC__) || defined(__clang__)
-#define BLI_array_alloca(arr, realsize) \
-       (typeof(arr))alloca(sizeof(*arr) * (realsize))
-
-#define BLI_array_alloca_and_count(arr, realsize) \
-       (typeof(arr))alloca(sizeof(*arr) * (realsize));  \
-       const int _##arr##_count = (realsize)
-
-#else
-#define BLI_array_alloca(arr, realsize) \
-       alloca(sizeof(*arr) * (realsize))
-
-#define BLI_array_alloca_and_count(arr, realsize) \
-       alloca(sizeof(*arr) * (realsize));  \
-       const int _##arr##_count = (realsize)
-#endif
-
 #endif  /* __BLI_ARRAY_H__ */
index a4b0f449dc3242a62e2298d5d8ecee33c37b3102..c305cc9a0300a5f74308de0433afaf5aa8723f1d 100644 (file)
@@ -175,7 +175,7 @@ void mat4_to_size(float r[3], float M[4][4]);
 void translate_m4(float mat[4][4], float tx, float ty, float tz);
 void rotate_m4(float mat[4][4], const char axis, const float angle);
 void rotate_m2(float mat[2][2], const float angle);
-void pivot_m4(float mat[4][4], const float pivot[3]);
+void transform_pivot_set_m4(float mat[4][4], const float pivot[3]);
 
 void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3]);
 void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[4][4]);
index 304e2ea7fde62f2f572d6f2bb9188f81d347efae..38b377c640e3e600de39cce8eae220e85a431af3 100644 (file)
@@ -116,6 +116,9 @@ MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void mul_v4_fl(float r[4], float f);
 MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f);
 MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]);
+MINLINE float dot_m3_v3_row_x(float M[3][3], const float a[3]);
+MINLINE float dot_m3_v3_row_y(float M[3][3], const float a[3]);
+MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3]);
 
 MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
 MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
index 1d94ca9afbca3a7cbfc9b5deaaa6476efd662266..b6b69116e67778b21880bcb10a5acebbb262151b 100644 (file)
@@ -99,6 +99,7 @@ set(SRC
        intern/winstuff.c
 
        BLI_args.h
+       BLI_alloca.h
        BLI_array.h
        BLI_bitmap.h
        BLI_blenlib.h
index 8565698110e26fc6fe396431465ba9f9ab354d4e..99342c4d6dcb1a00ff971f5cb374aa3397758159 100644 (file)
@@ -1374,8 +1374,15 @@ void rotate_m2(float mat[2][2], const float angle)
        mat[1][0] = -mat[0][1];
 }
 
-/* scale or rotate around a non zero pivot */
-void pivot_m4(float mat[4][4], const float pivot[3])
+/**
+ * Scale or rotate around a pivot point,
+ * a convenience function to avoid having to do inline.
+ *
+ * Since its common to make a scale/rotation matrix that pivots around an arbitrary point.
+ *
+ * Typical use case is to make 3x3 matrix, copy to 4x4, then pass to this function.
+ */
+void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
 {
        float tmat[4][4];
 
index d77b1ecf0175e90c4b66417038c1ef8481704436..8e5040d983b4fd84d4375c81f30ea352f54ea9cd 100644 (file)
@@ -418,6 +418,21 @@ MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3])
               (mat[2][3] * co[2]) + mat[3][3];
 }
 
+/**
+ * Has the effect of mul_m3_v3(), on a single axis.
+ */
+MINLINE float dot_m3_v3_row_x(float M[3][3], const float a[3])
+{
+       return M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
+}
+MINLINE float dot_m3_v3_row_y(float M[3][3], const float a[3])
+{
+       return M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
+}
+MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3])
+{
+       return M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
+}
 
 MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
 {
index 5bd07ac877895caf2c1e0ad4cc77d43165b22686..572b142d04468570ce500c344ce0ec71ca767ffe 100644 (file)
@@ -357,10 +357,9 @@ char *BLI_replacestrN(const char *__restrict str, const char *__restrict substr_
                char *str_new;
                
                /* add what's left of the string to the assembly buffer 
-                *      - we've been adjusting str to point at the end of the replaced segments
+                * - we've been adjusting str to point at the end of the replaced segments
                 */
-               if (str != NULL)
-                       BLI_dynstr_append(ds, str);
+               BLI_dynstr_append(ds, str);
                
                /* convert to new c-string (MEM_malloc'd), and free the buffer */
                str_new = BLI_dynstr_get_cstring(ds);
index c49c290e81e6cebff62d410acbe8822f045417b2..228ebcb96c46398e583d3ae8efd46b1e69cc946a 100644 (file)
@@ -43,6 +43,7 @@ set(SRC
        operators/bmo_bevel.c
        operators/bmo_bridge.c
        operators/bmo_connect.c
+       operators/bmo_connect_nonplanar.c
        operators/bmo_connect_pair.c
        operators/bmo_create.c
        operators/bmo_dissolve.c
index 4d3653b1a82edd44170e3142aca157b5db7aa553..1f7ace1ba6dbf9aa20ae46e25f0241f200bb0f19 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_array.h"
+#include "BLI_alloca.h"
 #include "BLI_math.h"
 
 #include "BKE_customdata.h"
index 05c462ac672df3bac91a9663e7fb319ba8eb9005..f9e711a0dc3bf13f0fa3220e3d170111203878e3 100644 (file)
@@ -30,6 +30,7 @@
 #include "BLI_math_vector.h"
 #include "BLI_listbase.h"
 #include "BLI_array.h"
+#include "BLI_alloca.h"
 #include "BLI_smallhash.h"
 
 #include "BLF_translation.h"
@@ -594,7 +595,7 @@ static void bm_kill_only_loop(BMesh *bm, BMLoop *l)
  */
 void BM_face_edges_kill(BMesh *bm, BMFace *f)
 {
-       BMEdge **edges = BLI_array_alloca_and_count(edges, f->len);
+       BMEdge **edges = BLI_array_alloca(edges, f->len);
        BMLoop *l_iter;
        BMLoop *l_first;
        int i = 0;
@@ -604,7 +605,7 @@ void BM_face_edges_kill(BMesh *bm, BMFace *f)
                edges[i++] = l_iter->e;
        } while ((l_iter = l_iter->next) != l_first);
        
-       for (i = 0; i < BLI_array_count(edges); i++) {
+       for (i = 0; i < f->len; i++) {
                BM_edge_kill(bm, edges[i]);
        }
 }
@@ -615,7 +616,7 @@ void BM_face_edges_kill(BMesh *bm, BMFace *f)
  */
 void BM_face_verts_kill(BMesh *bm, BMFace *f)
 {
-       BMVert **verts = BLI_array_alloca_and_count(verts, f->len);
+       BMVert **verts = BLI_array_alloca(verts, f->len);
        BMLoop *l_iter;
        BMLoop *l_first;
        int i = 0;
@@ -625,7 +626,7 @@ void BM_face_verts_kill(BMesh *bm, BMFace *f)
                verts[i++] = l_iter->v;
        } while ((l_iter = l_iter->next) != l_first);
        
-       for (i = 0; i < BLI_array_count(verts); i++) {
+       for (i = 0; i < f->len; i++) {
                BM_vert_kill(bm, verts[i]);
        }
 }
@@ -1368,16 +1369,20 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
        BMLoop *l_next;
        BMEdge *e_new;
        BMVert *v_new, *v_old;
-       int i, valence1 = 0, valence2 = 0;
+#ifndef NDEBUG
+       int valence1, valence2;
        bool edok;
+       int i;
+#endif
 
        BLI_assert(bmesh_vert_in_edge(e, tv) != false);
 
        v_old = bmesh_edge_other_vert_get(e, tv);
 
+#ifndef NDEBUG
        valence1 = bmesh_disk_count(v_old);
-
        valence2 = bmesh_disk_count(tv);
+#endif
 
        v_new = BM_vert_create(bm, tv->co, tv, 0);
        e_new = BM_edge_create(bm, v_new, tv, e, 0);
@@ -1400,6 +1405,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
        /* add e_new to tv's disk cycle */
        bmesh_disk_edge_append(e_new, tv);
 
+#ifndef NDEBUG
        /* verify disk cycles */
        edok = bmesh_disk_validate(valence1, v_old->e, v_old);
        BMESH_ASSERT(edok != false);
@@ -1407,6 +1413,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
        BMESH_ASSERT(edok != false);
        edok = bmesh_disk_validate(2, v_new->e, v_new);
        BMESH_ASSERT(edok != false);
+#endif
 
        /* Split the radial cycle if present */
        l_next = e->l;
@@ -1470,6 +1477,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
 
                }
 
+#ifndef NDEBUG
                /* verify length of radial cycle */
                edok = bmesh_radial_validate(radlen, e->l);
                BMESH_ASSERT(edok != false);
@@ -1508,6 +1516,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
                        BM_CHECK_ELEMENT(l->e);
                        BM_CHECK_ELEMENT(l->f);
                }
+#endif
        }
 
        BM_CHECK_ELEMENT(e_new);
@@ -1555,8 +1564,8 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool check_e
 {
        BMEdge *e_old;
        BMVert *v_old, *tv;
-       BMLoop *l_kill, *l;
-       int len, radlen = 0, i, valence1, valence2;
+       BMLoop *l_kill;
+       int len, radlen = 0, i;
        bool edok, halt = false;
 
        if (bmesh_vert_in_edge(e_kill, v_kill) == 0) {
@@ -1566,6 +1575,11 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool check_e
        len = bmesh_disk_count(v_kill);
        
        if (len == 2) {
+#ifndef NDEBUG
+               int valence1, valence2;
+               BMLoop *l;
+#endif
+
                e_old = bmesh_disk_edge_next(e_kill, v_kill);
                tv = bmesh_edge_other_vert_get(e_kill, v_kill);
                v_old = bmesh_edge_other_vert_get(e_old, v_kill);
@@ -1577,9 +1591,11 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool check_e
                else {
                        BMEdge *e_splice;
 
+#ifndef NDEBUG
                        /* For verification later, count valence of v_old and tv */
                        valence1 = bmesh_disk_count(v_old);
                        valence2 = bmesh_disk_count(tv);
+#endif
 
                        if (check_edge_double) {
                                e_splice = BM_edge_exists(tv, v_old);
@@ -1645,6 +1661,7 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool check_e
                        /* deallocate vertex */
                        bm_kill_only_vert(bm, v_kill);
 
+#ifndef NDEBUG
                        /* Validate disk cycle lengths of v_old, tv are unchanged */
                        edok = bmesh_disk_validate(valence1, v_old->e, v_old);
                        BMESH_ASSERT(edok != false);
@@ -1664,6 +1681,7 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool check_e
                                BM_CHECK_ELEMENT(l->e);
                                BM_CHECK_ELEMENT(l->f);
                        }
+#endif
 
                        if (check_edge_double) {
                                if (e_splice) {
index 446d32de5d2805cafff575ab50691651456dc8d4..70d1d4c81dff8750c2fff09e323106922dcf9a5a 100644 (file)
@@ -36,7 +36,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 
-#include "BLI_array.h"
+#include "BLI_alloca.h"
 #include "BLI_math.h"
 
 #include "BKE_customdata.h"
@@ -205,6 +205,7 @@ void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source, const b
        int i;
 
        /* convert the 3d coords into 2d for projection */
+       BLI_assert(BM_face_is_normal_valid(source));
        axis_dominant_v3_to_m3(axis_mat, source->no);
 
        i = 0;
@@ -638,6 +639,7 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
        int i;
 
        /* convert the 3d coords into 2d for projection */
+       BLI_assert(BM_face_is_normal_valid(source));
        axis_dominant_v3_to_m3(axis_mat, source->no);
 
        i = 0;
@@ -678,6 +680,7 @@ void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source)
        int i;
 
        /* convert the 3d coords into 2d for projection */
+       BLI_assert(BM_face_is_normal_valid(source));
        axis_dominant_v3_to_m3(axis_mat, source->no);
 
        i = 0;
index 184fed59f011204e14f7854c537ae637b9018416..81d4aad0fdfd58c5f2515fff14c8be3e7b610db4 100644 (file)
@@ -84,7 +84,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_listbase.h"
-#include "BLI_array.h"
+#include "BLI_alloca.h"
 #include "BLI_math_vector.h"
 
 #include "BKE_mesh.h"
index 77cb2717f8419201f57d97eeba10dfa6197b8bb0..418fc16ea558cc9f8395a4a524b0fb3254838f97 100644 (file)
@@ -490,26 +490,22 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, float
        BMEdge *e2;
        BMVert *tv2;
 
-       BMIter iter;
-       BMLoop *l_iter = NULL, *kvloop = NULL, *tvloop = NULL;
-
-       void *src[2];
-       float w[2];
-
        /* Only intended to be called for 2-valence vertices */
        BLI_assert(bmesh_disk_count(v_kill) <= 2);
 
 
-       /* first modify the face loop data  */
-       w[0] = 1.0f - fac;
-       w[1] = fac;
+       /* first modify the face loop data */
 
        if (e_kill->l) {
+               BMLoop *l_iter;
+               const float w[2] = {1.0f - fac, fac};
+
                l_iter = e_kill->l;
                do {
                        if (l_iter->v == tv && l_iter->next->v == v_kill) {
-                               tvloop = l_iter;
-                               kvloop = l_iter->next;
+                               void *src[2];
+                               BMLoop *tvloop = l_iter;
+                               BMLoop *kvloop = l_iter->next;
 
                                src[0] = kvloop->head.data;
                                src[1] = tvloop->head.data;
@@ -525,11 +521,12 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, float
        tv2 = BM_edge_other_vert(e2, v_kill);
 
        if (join_faces) {
+               BMIter fiter;
                BMFace **faces = NULL;
                BMFace *f;
-               BLI_array_staticdeclare(faces, 8);
+               BLI_array_staticdeclare(faces, BM_DEFAULT_ITER_STACK_SIZE);
 
-               BM_ITER_ELEM (f, &iter, v_kill, BM_FACES_OF_VERT) {
+               BM_ITER_ELEM (f, &fiter, v_kill, BM_FACES_OF_VERT) {
                        BLI_array_append(faces, f);
                }
 
@@ -543,6 +540,8 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, float
                        }
                }
 
+               BLI_assert(BLI_array_count(faces) < 8);
+
                BLI_array_free(faces);
        }
        else {
@@ -553,8 +552,8 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, float
                /* e_new = BM_edge_exists(tv, tv2); */ /* same as return above */
 
                if (e_new && kill_degenerate_faces) {
-                       BLI_array_declare(bad_faces);
                        BMFace **bad_faces = NULL;
+                       BLI_array_staticdeclare(bad_faces, BM_DEFAULT_ITER_STACK_SIZE);
 
                        BMIter fiter;
                        BMFace *f;
index b56ed15b901d58026d0947d23bf208695ffb5f1e..4f8a851c7802aea7f2f75c9e7a61caa86d47a378 100644 (file)
@@ -867,6 +867,27 @@ static BMOpDefine bmo_connect_verts_def = {
        BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
 };
 
+/*
+ * Connect Verts Across non Planer Faces.
+ *
+ * Split faces by connecting edges along non planer **faces**.
+ */
+static BMOpDefine bmo_connect_verts_nonplanar_def = {
+       "connect_verts_nonplanar",
+       /* slots_in */
+       {{"angle_limit", BMO_OP_SLOT_FLT}, /* total rotation angle (radians) */
+        {"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},
+        {{'\0'}},
+       },
+       /* slots_out */
+       {{"edges.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}},
+        {"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},
+        {{'\0'}},
+       },
+       bmo_connect_verts_nonplanar_exec,
+       BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
+};
+
 /*
  * Connect Verts.
  *
@@ -1734,6 +1755,7 @@ const BMOpDefine *bmo_opdefines[] = {
        &bmo_collapse_def,
        &bmo_collapse_uvs_def,
        &bmo_connect_verts_def,
+       &bmo_connect_verts_nonplanar_def,
        &bmo_connect_vert_pair_def,
        &bmo_contextual_create_def,
 #ifdef WITH_BULLET
index e0268d6b504fc3c05a94cb404461dd0ef810f0fa..269501e1f02182cea052a7db80e4bccf87b46338 100644 (file)
@@ -34,7 +34,6 @@
 #include "BLI_memarena.h"
 #include "BLI_mempool.h"
 #include "BLI_listbase.h"
-#include "BLI_array.h"
 
 #include "BLF_translation.h"
 
index e029ad0d12420526d2744781e6a3cada115a2bb5..33c10411c0f49684924663d36b611439f752bb33 100644 (file)
@@ -40,6 +40,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op);
 void bmo_collapse_exec(BMesh *bm, BMOperator *op);
 void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op);
 void bmo_connect_verts_exec(BMesh *bm, BMOperator *op);
+void bmo_connect_verts_nonplanar_exec(BMesh *bm, BMOperator *op);
 void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op);
 void bmo_contextual_create_exec(BMesh *bm, BMOperator *op);
 void bmo_convex_hull_exec(BMesh *bm, BMOperator *op);
index 1ecb3c2b9acfcf10a044b78c05261ede491dc931..eea5ec596746c8dd493328290096f674e32ab0e4 100644 (file)
@@ -32,8 +32,8 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "BLI_alloca.h"
 #include "BLI_math.h"
-#include "BLI_array.h"
 #include "BLI_scanfill.h"
 #include "BLI_listbase.h"
 
@@ -1006,6 +1006,8 @@ void BM_face_triangulate(BMesh *bm, BMFace *f,
        float *abscoss = BLI_array_alloca(abscoss, f_len_orig);
        float mat[3][3];
 
+       BLI_assert(BM_face_is_normal_valid(f));
+
        axis_dominant_v3_to_m3(mat, f->no);
 
        /* copy vertex coordinates to vertspace area */
@@ -1061,7 +1063,7 @@ void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len)
 {
        const int len2 = len * 2;
        BMLoop *l;
-       float v1[2], v2[2], v3[2] /*, v4[3 */, no[3], mid[2], *p1, *p2, *p3, *p4;
+       float v1[2], v2[2], v3[2], mid[2], *p1, *p2, *p3, *p4;
        float out[2] = {-FLT_MAX, -FLT_MAX};
        float axis_mat[3][3];
        float (*projverts)[2] = BLI_array_alloca(projverts, f->len);
@@ -1069,10 +1071,9 @@ void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len)
        float fac1 = 1.0000001f, fac2 = 0.9f; //9999f; //0.999f;
        int i, j, a = 0, clen;
 
-       /* TODO, the face normal may already be correct */
-       BM_face_calc_normal(f, no);
+       BLI_assert(BM_face_is_normal_valid(f));
 
-       axis_dominant_v3_to_m3(axis_mat, no);
+       axis_dominant_v3_to_m3(axis_mat, f->no);
 
        for (i = 0, l = BM_FACE_FIRST_LOOP(f); i < f->len; i++, l = l->next) {
                BM_elem_index_set(l, i); /* set_loop */
index 9dc5ae61d6136b1c251135167d00a938c3f60989..0e2984c53cccd18d320c5b96a680dd1b5c5efa53 100644 (file)
@@ -33,8 +33,8 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_array.h"
 #include "BLI_math.h"
+#include "BLI_alloca.h"
 
 #include "bmesh.h"
 #include "intern/bmesh_private.h"
@@ -1719,6 +1719,18 @@ bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag)
        return false;
 }
 
+/**
+ * Use within assert's to check normals are valid.
+ */
+bool BM_face_is_normal_valid(BMFace *f)
+{
+       const float eps = 0.0001f;
+       float no[3];
+
+       BM_face_calc_normal(f, no);
+       return len_squared_v3v3(no, f->no) < (eps * eps);
+}
+
 static void bm_mesh_calc_volume_face(BMFace *f, float *r_vol)
 {
        int tottri = f->len - 2;
index 23d89cf92faf41fa0f4cb33004e135aae2e8449c..151d1de9b5b5f3e68754f62eb3601b965cf83ef7 100644 (file)
@@ -116,6 +116,8 @@ bool BM_edge_is_any_vert_flag_test(BMEdge *e, const char hflag);
 bool BM_face_is_any_vert_flag_test(BMFace *f, const char hflag);
 bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag);
 
+bool BM_face_is_normal_valid(BMFace *f);
+
 float BM_mesh_calc_volume(BMesh *bm, bool is_signed);
 
 int   BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
index 50588ad70a921659ee7a3a38fd7f4d1444cb9e4a..c718cac4bd6f8edaa799be29c200ae6b19c1360c 100644 (file)
@@ -29,8 +29,8 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_math.h"
-#include "BLI_array.h"
 #include "BLI_utildefines.h"
+#include "BLI_alloca.h"
 
 #include "bmesh.h"
 
diff --git a/source/blender/bmesh/operators/bmo_connect_nonplanar.c b/source/blender/bmesh/operators/bmo_connect_nonplanar.c
new file mode 100644 (file)
index 0000000..6d30b32
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * ***** 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.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/operators/bmo_connect_nonplanar.c
+ *  \ingroup bmesh
+ *
+ * Connect verts non-planer faces iteratively (splits faces).
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "BLI_alloca.h"
+
+#include "bmesh.h"
+
+#include "intern/bmesh_operators_private.h" /* own include */
+
+#define EDGE_OUT       (1 << 0)
+#define FACE_OUT       (1 << 1)
+
+/**
+ * Calculates the face subset normal.
+ */
+static bool bm_face_subset_calc_normal(BMLoop *l_first, BMLoop *l_last, float r_no[3])
+{
+       float const *v_prev, *v_curr;
+
+       /* Newell's Method */
+       BMLoop *l_iter = l_first;
+       BMLoop *l_term = l_last->next;
+
+       zero_v3(r_no);
+
+       v_prev = l_last->v->co;
+       do {
+               v_curr = l_iter->v->co;
+               add_newell_cross_v3_v3v3(r_no, v_prev, v_curr);
+               v_prev = v_curr;
+       } while ((l_iter = l_iter->next) != l_term);
+
+       return (normalize_v3(r_no) != 0.0f);
+}
+
+/**
+ * Calculates how non-planar the face subset is.
+ */
+static float bm_face_subset_calc_planar(BMLoop *l_first, BMLoop *l_last, const float no[3])
+{
+       float axis_mat[3][3];
+       float z_prev, z_curr;
+       float delta_z = 0.0f;
+
+       /* Newell's Method */
+       BMLoop *l_iter = l_first;
+       BMLoop *l_term = l_last->next;
+
+       axis_dominant_v3_to_m3(axis_mat, no);
+
+       z_prev = dot_m3_v3_row_z(axis_mat, l_last->v->co);
+       do {
+               z_curr = dot_m3_v3_row_z(axis_mat, l_iter->v->co);
+               delta_z += fabsf(z_curr - z_prev);
+               z_prev = z_curr;
+       } while ((l_iter = l_iter->next) != l_term);
+
+       return delta_z;
+}
+
+static bool bm_face_split_find(BMFace *f, BMVert *v_pair[2], float *r_angle)
+{
+       BMLoop *l_iter, *l_first;
+       BMLoop **l_arr = BLI_array_alloca(l_arr, f->len);
+       const unsigned int f_len = f->len;
+       unsigned int i_a, i_b;
+       bool found = false;
+
+       /* angle finding */
+       float err_best = FLT_MAX;
+       float angle_best = FLT_MAX;
+
+       l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+       i_a = 0;
+       do {
+               l_arr[i_a++] = l_iter;
+       } while ((l_iter = l_iter->next) != l_first);
+
+       /* now for the big search, O(N^2), however faces normally aren't so large */
+       for (i_a = 0; i_a < f_len; i_a++) {
+               BMLoop *l_a = l_arr[i_a];
+               for (i_b = i_a + 2; i_b < f_len; i_b++) {
+                       BMLoop *l_b = l_arr[i_b];
+                       /* check these are not touching
+                        * (we could be smarter here) */
+                       if ((l_a->next != l_b) &&
+                           (l_a->prev != l_b))
+                       {
+                               /* first calculate normals */
+                               float no_a[3], no_b[3];
+
+                               if (bm_face_subset_calc_normal(l_a, l_b, no_a) &&
+                                   bm_face_subset_calc_normal(l_b, l_a, no_b))
+                               {
+                                       const float err_a = bm_face_subset_calc_planar(l_a, l_b, no_a);
+                                       const float err_b = bm_face_subset_calc_planar(l_b, l_a, no_b);
+                                       const float err_test = err_a + err_b;
+
+                                       if (err_test < err_best) {
+                                               /* check we're legal (we could batch this) */
+                                               BMLoop *l_split[2] = {l_a, l_b};
+                                               BM_face_legal_splits(f, &l_split, 1);
+                                               if (l_split[0]) {
+                                                       err_best = err_test;
+                                                       v_pair[0] = l_a->v;
+                                                       v_pair[1] = l_b->v;
+
+                                                       angle_best = angle_normalized_v3v3(no_a, no_b);
+                                                       found = true;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       *r_angle = angle_best;
+
+       return found;
+
+
+}
+
+static bool bm_face_split_by_angle(BMesh *bm, BMFace *f, BMFace *r_f_pair[2], const float angle_limit)
+{
+       BMVert *v_pair[2];
+       float angle;
+
+       if (bm_face_split_find(f, v_pair, &angle) && (angle > angle_limit)) {
+               BMFace *f_new;
+               BMLoop *l_new;
+               f_new = BM_face_split(bm, f, v_pair[0], v_pair[1], &l_new, NULL, false);
+               if (f_new) {
+                       r_f_pair[0] = f;
+                       r_f_pair[1] = f_new;
+
+                       BMO_elem_flag_enable(bm, f, FACE_OUT);
+                       BMO_elem_flag_enable(bm, f_new, FACE_OUT);
+                       BMO_elem_flag_enable(bm, l_new->e, EDGE_OUT);
+                       return true;
+               }
+       }
+
+       return false;
+
+}
+
+void bmo_connect_verts_nonplanar_exec(BMesh *bm, BMOperator *op)
+{
+       BMOIter siter;
+       BMFace *f;
+       int totface = 0, totloop = 0;
+       int tottris;
+       BMFace **fstack;
+       STACK_DECLARE(fstack);
+
+       const float angle_limit = BMO_slot_float_get(op->slots_in, "angle_limit");
+
+
+       BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
+               if (f->len > 3) {
+                       totface += 1;
+                       totloop += f->len;
+               }
+       }
+
+       if (totface == 0) {
+               return;
+       }
+
+       /* over alloc, if we split every face */
+       tottris = poly_to_tri_count(totface, totloop);
+       fstack = MEM_mallocN(sizeof(BMFace *) * tottris, __func__);
+
+       STACK_INIT(fstack);
+
+       BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
+               if (f->len > 3) {
+                       STACK_PUSH(fstack, f);
+               }
+       }
+
+       while ((f = STACK_POP(fstack))) {
+               BMFace *f_pair[2];
+               if (bm_face_split_by_angle(bm, f, f_pair, angle_limit)) {
+                       int j;
+                       for (j = 0; j < 2; j++) {
+                               BM_face_normal_update(f_pair[j]);
+                               if (f_pair[j]->len > 3) {
+                                       STACK_PUSH(fstack, f_pair[j]);
+                               }
+                       }
+               }
+       }
+
+       MEM_freeN(fstack);
+
+       BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_OUT);
+       BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_OUT);
+}
index 872f1cea2c7a4ece0ff5cd67b1c8e28eaf3ff23e..0bc29c5625685db05111bcf4c0c327b3a8f78a56 100644 (file)
@@ -84,17 +84,11 @@ typedef struct PathLinkState {
        float co_prev[3];
 } PathLinkState;
 
-/* only the x axis */
-static float mul_v1_m3v3(float M[3][3], const float a[3])
-{
-       return M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
-}
-
 static int state_isect_co_pair(const PathContext *pc,
                                const float co_a[3], const float co_b[3])
 {
-       const float diff_a = mul_v1_m3v3((float (*)[3])pc->matrix, co_a) - pc->axis_sep;
-       const float diff_b = mul_v1_m3v3((float (*)[3])pc->matrix, co_b) - pc->axis_sep;
+       const float diff_a = dot_m3_v3_row_x((float (*)[3])pc->matrix, co_a) - pc->axis_sep;
+       const float diff_b = dot_m3_v3_row_x((float (*)[3])pc->matrix, co_b) - pc->axis_sep;
 
        const int test_a = (fabsf(diff_a) < CONNECT_EPS) ? 0 : (diff_a < 0.0f) ? -1 : 1;
        const int test_b = (fabsf(diff_b) < CONNECT_EPS) ? 0 : (diff_b < 0.0f) ? -1 : 1;
@@ -110,7 +104,7 @@ static int state_isect_co_pair(const PathContext *pc,
 static int state_isect_co_exact(const PathContext *pc,
                                 const float co[3])
 {
-       const float diff = mul_v1_m3v3((float (*)[3])pc->matrix, co) - pc->axis_sep;
+       const float diff = dot_m3_v3_row_x((float (*)[3])pc->matrix, co) - pc->axis_sep;
        return (fabsf(diff) <= CONNECT_EPS);
 }
 
@@ -119,8 +113,8 @@ static float state_calc_co_pair_fac(const PathContext *pc,
 {
        float diff_a, diff_b, diff_tot;
 
-       diff_a = fabsf(mul_v1_m3v3((float (*)[3])pc->matrix, co_a) - pc->axis_sep);
-       diff_b = fabsf(mul_v1_m3v3((float (*)[3])pc->matrix, co_b) - pc->axis_sep);
+       diff_a = fabsf(dot_m3_v3_row_x((float (*)[3])pc->matrix, co_a) - pc->axis_sep);
+       diff_b = fabsf(dot_m3_v3_row_x((float (*)[3])pc->matrix, co_b) - pc->axis_sep);
        diff_tot = (diff_a + diff_b);
        return (diff_tot > FLT_EPSILON) ? (diff_a / diff_tot) : 0.5f;
 }
@@ -443,7 +437,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
                normalize_v3_v3(pc.matrix[2], basis_nor);
                invert_m3(pc.matrix);
 
-               pc.axis_sep = mul_v1_m3v3(pc.matrix, pc.v_a->co);
+               pc.axis_sep = dot_m3_v3_row_x(pc.matrix, pc.v_a->co);
        }
 
        /* add first vertex */
index a3f674503806e87d95045a75b3ad454b99926d18..d633182de425f9dda62ad18a2ed624d752578970 100644 (file)
@@ -103,10 +103,10 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
 {
        BMOIter oiter;
        BMFace *f;
-       BLI_array_declare(faces);
-       BLI_array_declare(regions);
        BMFace ***regions = NULL;
        BMFace **faces = NULL;
+       BLI_array_declare(regions);
+       BLI_array_declare(faces);
        BMFace *act_face = bm->act_face;
        BMWalker regwalker;
        int i;
index 59e018eccf136c22a7fd086fe79eae5649b50920..f9ff308b706d6ac3204c0b24879a3e96a6eb8975 100644 (file)
@@ -28,8 +28,8 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_array.h"
 #include "BLI_math.h"
+#include "BLI_alloca.h"
 
 #include "bmesh.h"
 
index dca864452196de58a3093a23395a9c09c8a688ea..40a682e790d7c14d85b174888142e4f21031b34b 100644 (file)
@@ -29,7 +29,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_listbase.h"
-#include "BLI_array.h"
+#include "BLI_alloca.h"
 #include "BLI_math.h"
 
 #include "bmesh.h"
index 97444a504388ae862d7f2e5d31ab44236df80fe3..60fdf075d18abda1baad802c6de05927c0f41525 100644 (file)
@@ -277,6 +277,8 @@ static void bm_interp_face_store(InterpFace *iface, BMesh *bm, BMFace *f, MemAre
        void *axis_mat     = iface->axis_mat;
        int i;
 
+       BLI_assert(BM_face_is_normal_valid(f));
+
        axis_dominant_v3_to_m3(axis_mat, f->no);
 
        iface->f = f;
index f69d2f27346ea8b2261588921cf7051d87a0d22a..9cc418d61ede6d3d1539b3fccd031aebdeb20e5b 100644 (file)
@@ -40,7 +40,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_utildefines.h"
-#include "BLI_array.h"
+#include "BLI_alloca.h"
 #include "BLI_math.h"
 #include "BLI_listbase.h"
 
index 85bd8a853765e900b8438bbcf8cb2d3d88b1bdbc..8b8cab9d8815657758306622ae24555deba3aee5 100644 (file)
@@ -32,8 +32,8 @@
 #include "DNA_meshdata_types.h"
 
 #include "BLI_math.h"
-#include "BLI_array.h"
 #include "BLI_heap.h"
+#include "BLI_alloca.h"
 
 #include "BKE_customdata.h"
 
@@ -103,7 +103,7 @@ void bmo_rotate_exec(BMesh *bm, BMOperator *op)
 
        BMO_slot_vec_get(op->slots_in, "cent", center);
        BMO_slot_mat4_get(op->slots_in, "matrix", mat);
-       pivot_m4(mat, center);
+       transform_pivot_set_m4(mat, center);
 
        BMO_op_callf(bm, op->flag, "transform matrix=%m4 space=%s verts=%s", mat, op, "space", op, "verts");
 }
index 6431b6b7cf5f64b89bec70e21f1198791d8ae8d7..02f0251bff23fe0757367b9bdf5ff021c7b00e68 100644 (file)
@@ -34,6 +34,7 @@
 #include "DNA_meshdata_types.h"
 
 #include "BLI_array.h"
+#include "BLI_alloca.h"
 #include "BLI_math.h"
 #include "BLI_memarena.h"
 
index 79f6c76afc70337594d985aeab1e3eb2ee14cc47..2eacf62d68ab5bf563b590d4721dde4382131cf2 100644 (file)
@@ -30,7 +30,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_utildefines.h"
-#include "BLI_array.h"
+#include "BLI_alloca.h"
 
 #include "bmesh.h"
 
index c1ba40d95f92b1a84f8bc54764e769d0660b8627..5d47ce155c8fa07650221e830bd56013541c8056 100644 (file)
@@ -50,7 +50,11 @@ static const char *bc_get_joint_name(T *node)
 }
 
 ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, Scene *sce) :
-       TransformReader(conv), scene(sce), empty(NULL), mesh_importer(mesh) {
+       unit_converter(conv),
+       TransformReader(conv), 
+       scene(sce), 
+       empty(NULL), 
+       mesh_importer(mesh) {
 }
 
 ArmatureImporter::~ArmatureImporter()
@@ -82,17 +86,15 @@ JointData *ArmatureImporter::get_joint_data(COLLADAFW::Node *node);
 void ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBone *parent, int totchild,
                                    float parent_mat[4][4], bArmature *arm)
 {
+       float mat[4][4];
+       float joint_inv_bind_mat[4][4];
+
        //Checking if bone is already made.
        std::vector<COLLADAFW::Node *>::iterator it;
        it = std::find(finished_joints.begin(), finished_joints.end(), node);
        if (it != finished_joints.end()) return;
 
-       float joint_inv_bind_mat[4][4];
-
        // JointData* jd = get_joint_data(node);
-
-       float mat[4][4];
-       float obmat[4][4];
        
        // TODO rename from Node "name" attrs later
        EditBone *bone = ED_armature_edit_bone_add(arm, (char *)bc_get_joint_name(node));
@@ -101,9 +103,18 @@ void ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBo
        if (skin && skin->get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
                // get original world-space matrix
                invert_m4_m4(mat, joint_inv_bind_mat);
+
+               // And make local to armature
+               Object *ob_arm = skin->BKE_armature_from_object();
+               if (ob_arm) {
+                       float invmat[4][4];
+                       invert_m4_m4(invmat, ob_arm->obmat);
+                       mul_m4_m4m4(mat, invmat, mat);
+               }
        }
        // create a bone even if there's no joint data for it (i.e. it has no influence)
        else {
+               float obmat[4][4];
                // bone-space
                get_node_mat(obmat, node, NULL, NULL);
 
index 80bde1842dd93780ba0b6f0cb9095b04831c3aa7..c6337e27218102c706de10b225ba17ac616139e6 100644 (file)
@@ -185,6 +185,9 @@ void DocumentImporter::finish()
        Main *bmain = CTX_data_main(mContext);
        // TODO: create a new scene except the selected <visual_scene> - use current blender scene for it
        Scene *sce = CTX_data_scene(mContext);
+       unit_converter.calculate_scale(*sce);
+
+       std::vector<Object *> *objects_to_scale = new std::vector<Object *>();
 
        /** TODO Break up and put into 2-pass parsing of DAE */
        std::vector<const COLLADAFW::VisualScene *>::iterator it;
@@ -221,13 +224,8 @@ void DocumentImporter::finish()
                // Write nodes to scene
                const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes();
                for (unsigned int i = 0; i < roots.getCount(); i++) {
-                       std::vector<Object *> *objects_done;
-                       objects_done = write_node(roots[i], NULL, sce, NULL, false);
-                       
-                       if (!this->import_settings->import_units) {
-                               // Match incoming scene with current unit settings
-                               bc_match_scale(objects_done, *sce, unit_converter);
-                       }
+                       std::vector<Object *> *objects_done = write_node(roots[i], NULL, sce, NULL, false);
+                       objects_to_scale->insert(objects_to_scale->end(), objects_done->begin(), objects_done->end());
                }
 
                // update scene
@@ -278,6 +276,8 @@ void DocumentImporter::finish()
 
                DAG_relations_tag_update(bmain);
        }
+       
+       bc_match_scale(objects_to_scale, unit_converter, !this->import_settings->import_units);
 }
 
 
@@ -461,6 +461,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
        std::string name = node->getName();
 
        std::vector<Object *> *objects_done = new std::vector<Object *>();
+       std::vector<Object *> *root_objects = new std::vector<Object *>();
 
        fprintf(stderr,
                        "Writing node id='%s', name='%s'\n",
@@ -473,6 +474,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                        // Here we add the armature "on the fly":
                        par = bc_add_object(sce, OB_ARMATURE, std::string("Armature").c_str());
                        objects_done->push_back(par);
+                       root_objects->push_back(par);
                        object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), par));
                        node_map[node->getUniqueId()] = node;
                }
@@ -483,7 +485,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                if (parent_node == NULL) {
                        // for skeletons without root node all has been done above.
                        // Skeletons with root node are handled further down.
-                       return objects_done;
+                       return root_objects;
                }
        }
        else {
@@ -512,6 +514,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                        }
                        else {
                                objects_done->push_back(ob);
+                               if (parent_node == NULL) {
+                                       root_objects->push_back(ob);
+                               }
                        }
                        ++geom_done;
                }
@@ -522,19 +527,29 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                                std::string name = node->getName();
                                fprintf(stderr, "<node id=\"%s\", name=\"%s\" >...contains a reference to an unknown instance_camera.\n", id.c_str(), name.c_str());
                        }
-                       else
+                       else {
                                objects_done->push_back(ob);
+                               if (parent_node == NULL) {
+                                       root_objects->push_back(ob);
+                               }
+                       }
                        ++camera_done;
                }
                while (lamp_done < lamp.getCount()) {
                        ob = create_lamp_object(lamp[lamp_done], sce);
                        objects_done->push_back(ob);
+                       if (parent_node == NULL) {
+                               root_objects->push_back(ob);
+                       }
                        ++lamp_done;
                }
                while (controller_done < controller.getCount()) {
                        COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry *)controller[controller_done];
                        ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map);
                        objects_done->push_back(ob);
+                       if (parent_node == NULL) {
+                               root_objects->push_back(ob);
+                       }
                        ++controller_done;
                }
                // XXX instance_node is not supported yet
@@ -550,9 +565,12 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                                        Object *source_ob = (Object *)it2->second;
                                        COLLADAFW::Node *source_node = node_map[node_id];
                                        ob = create_instance_node(source_ob, source_node, node, sce, is_library_node);
+                                       objects_done->push_back(ob);
+                                       if (parent_node == NULL) {
+                                               root_objects->push_back(ob);
+                                       }
                                }
                        }
-                       if (ob != NULL) objects_done->push_back(ob);
                        ++inst_done;
 
                        read_transform = false;
@@ -569,12 +587,14 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                                ob = bc_add_object(sce, OB_EMPTY, NULL);
                        }
                        objects_done->push_back(ob);
-
+                       if (parent_node == NULL) {
+                               root_objects->push_back(ob);
+                       }
                }
                
                // XXX: if there're multiple instances, only one is stored
 
-               if (!ob) return objects_done;
+               if (!ob) return root_objects;
 
                for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
                        ob = *it;
@@ -623,7 +643,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                write_node(child_nodes[i], node, sce, ob, is_library_node);
        }
 
-       return objects_done;
+       return root_objects;
 }
 
 /** When this method is called, the writer must write the entire visual scene.
index c2770dc3dc56378f9d9f00201d6808c2f7a60a52..7ae1750d2cadd12e9c78e9d056b5255ca584318f 100644 (file)
@@ -226,8 +226,6 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
        ArmatureModifierData *amd = (ArmatureModifierData *)md;
        amd->object = ob_arm;
 
-       copy_m4_m4(ob->obmat, bind_shape_matrix);
-       BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
 #if 1
        bc_set_parent(ob, ob_arm, C);
 #else
@@ -243,6 +241,8 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
        DAG_relations_tag_update(bmain);
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
 #endif
+       copy_m4_m4(ob->obmat, bind_shape_matrix);
+       BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
 
        amd->deformflag = ARM_DEF_VGROUP;
 
index 43faa15b4bb69c0ceef6b8cdccbf54b9a0b1288c..f8f31304d28bfa1b1e8c96091980afe18b24ea45 100644 (file)
@@ -48,7 +48,9 @@ void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::
 
                switch (type) {
                        case COLLADAFW::Transformation::MATRIX:
-                               // XXX why does this return and discard all following transformations?
+                               // When matrix AND Trans/Rot/Scale are defined for a node,
+                               // then this is considered as redundant information.
+                               // So if we find a Matrix we use that and return.
                                dae_matrix_to_mat4(tm, mat);
                                return;
                        case COLLADAFW::Transformation::TRANSLATE:
index 069419f938b72eb67e0c537bfe7d1f560237e7e8..567ee22b3d62cf5c8d34644e67f7ba6bafd94bb7 100644 (file)
@@ -27,7 +27,7 @@
 
 /* COLLADABU_ASSERT, may be able to remove later */
 #include "COLLADABUPlatform.h"
-#include "collada_internal.h"
+#include "collada_utils.h"
 
 #include "BLI_linklist.h"
 
@@ -40,7 +40,7 @@ UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP)
        rotate_m4(y_up_mat4, 'X', 0.5 * M_PI);
 
        unit_m4(z_up_mat4);
-
+       unit_m4(scale_mat4);
 }
 
 void UnitConverter::read_asset(const COLLADAFW::FileInfo *asset)
@@ -124,6 +124,48 @@ float(&UnitConverter::get_rotation())[4][4]
        }
 }
 
+
+float(&UnitConverter::get_scale())[4][4]
+{
+       return scale_mat4;
+}
+
+void UnitConverter::calculate_scale(Scene &sce)
+{
+       PointerRNA scene_ptr, unit_settings;
+       PropertyRNA *system_ptr, *scale_ptr;
+       RNA_id_pointer_create(&sce.id, &scene_ptr);
+
+       unit_settings = RNA_pointer_get(&scene_ptr, "unit_settings");
+       system_ptr    = RNA_struct_find_property(&unit_settings, "system");
+       scale_ptr     = RNA_struct_find_property(&unit_settings, "scale_length");
+
+       int   type    = RNA_property_enum_get(&unit_settings, system_ptr);
+
+       float bl_scale;
+
+       switch (type) {
+               case USER_UNIT_NONE:
+                       bl_scale = 1.0; // map 1 Blender unit to 1 Meter
+                       break;
+
+               case USER_UNIT_METRIC:
+                       bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
+                       break;
+
+               default :
+                       bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
+                       // it looks like the conversion to Imperial is done implicitly.
+                       // So nothing to do here.
+                       break;
+       }
+
+       float rescale[3];
+       rescale[0] = rescale[1] = rescale[2] = getLinearMeter() / bl_scale;
+
+       size_to_mat4(scale_mat4, rescale);
+}
+
 void TransformBase::decompose(float mat[4][4], float *loc, float eul[3], float quat[4], float *size)
 {
        mat4_to_size(size, mat);
index 2e855764f4ba1d4718fb2d36fda000179be3b0e3..4aa637a687639a8d796e514fbbe4b581311d3352 100644 (file)
@@ -50,7 +50,8 @@ private:
        float x_up_mat4[4][4];
        float y_up_mat4[4][4];
        float z_up_mat4[4][4];
-
+       float scale_mat4[4][4];
+       
 public:
 
        enum UnitSystem {
@@ -79,7 +80,8 @@ public:
        void mat4_to_dae_double(double out[4][4], float in[4][4]);
 
        float(&get_rotation())[4][4];
-
+       float(&get_scale())[4][4];
+       void calculate_scale(Scene &sce);
 
 };
 
index d4196bacf0d1487320d73fb1f7ed57592d693f16..3e17472e9c2c603ff9dfb2c241f6eb89fc0f97c9 100644 (file)
@@ -324,65 +324,30 @@ std::string bc_replace_string(std::string data, const std::string& pattern,
  * Calculate a rescale factor such that the imported scene's scale
  * is preserved. I.e. 1 meter in the import will also be
  * 1 meter in the current scene.
- * XXX : I am not sure if it is correct to map 1 Blender Unit
- * to 1 Meter for unit type NONE. But it looks reasonable to me.
  */
-void bc_match_scale(std::vector<Object *> *objects_done, 
-                    Scene &sce,
-                    UnitConverter &bc_unit)
-{
-       Object *ob = NULL;
-
-       PointerRNA scene_ptr, unit_settings;
-       PropertyRNA *system_ptr, *scale_ptr;
-       RNA_id_pointer_create(&sce.id, &scene_ptr);
-
-       unit_settings = RNA_pointer_get(&scene_ptr, "unit_settings");
-       system_ptr = RNA_struct_find_property(&unit_settings, "system");
-       scale_ptr = RNA_struct_find_property(&unit_settings, "scale_length");
-
-       int   type  = RNA_property_enum_get(&unit_settings, system_ptr);
 
-       float bl_scale;
-       
-       switch (type) {
-               case USER_UNIT_NONE:
-                       bl_scale = 1.0; // map 1 Blender unit to 1 Meter
-                       break;
-
-               case USER_UNIT_METRIC:
-                       bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
-                       break;
-
-               default :
-                       bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
-                       // it looks like the conversion to Imperial is done implicitly.
-                       // So nothing to do here.
-                       break;
+void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene)
+{
+       if (scale_to_scene) {
+               mul_m4_m4m4(ob->obmat, bc_unit.get_scale(), ob->obmat);
        }
-       
-       float scale_conv = bc_unit.getLinearMeter() / bl_scale;
-
-       float rescale[3];
-       rescale[0] = rescale[1] = rescale[2] = scale_conv;
-
-       float size_mat4[4][4];
-
-       float axis_mat4[4][4];
-       unit_m4(axis_mat4);
-
-       size_to_mat4(size_mat4, rescale);
+       mul_m4_m4m4(ob->obmat, bc_unit.get_rotation(), ob->obmat);
+       BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
+}
 
+void bc_match_scale(std::vector<Object *> *objects_done, 
+                       UnitConverter &bc_unit,
+                       bool scale_to_scene)
+{
        for (std::vector<Object *>::iterator it = objects_done->begin();
                        it != objects_done->end();
                        ++it) 
        {
-               ob = *it;
-               mul_m4_m4m4(ob->obmat, size_mat4, ob->obmat);
-               mul_m4_m4m4(ob->obmat, bc_unit.get_rotation(), ob->obmat);
-               BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
+               Object *ob = *it;
+               if (ob -> parent == NULL) {
+                       bc_match_scale(*it, bc_unit, scale_to_scene);
+               }
        }
-
 }
 
 void bc_triangulate_mesh(Mesh *me)
index f8e6f09e4983420525e3a986621579532ad1ffe7..4bc2f55cf333e27ea794be16f93adb3eaef5ed7b 100644 (file)
@@ -83,7 +83,8 @@ extern int  bc_get_active_UVLayer(Object *ob);
 
 extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement); 
 extern std::string bc_url_encode(std::string data); 
-extern void bc_match_scale(std::vector<Object *> *objects_done, Scene &sce, UnitConverter &unit_converter);
+extern void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene);
+extern void bc_match_scale(std::vector<Object *> *objects_done, UnitConverter &unit_converter, bool scale_to_scene);
 
 extern void bc_triangulate_mesh(Mesh *me);
 
index fe41a037fcb765a597fd1464a7e8cf9e71dfbf09..3c8576be312626dfce1f58e4cb5d2aff869cbb1b 100644 (file)
@@ -553,7 +553,7 @@ static int ed_markers_opwrap_invoke(bContext *C, wmOperator *op, const wmEvent *
 /* ************************** add markers *************************** */
 
 /* add TimeMarker at curent frame */
-static int ed_marker_add(bContext *C, wmOperator *UNUSED(op))
+static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ListBase *markers = ED_context_get_markers(C);
        TimeMarker *marker;
@@ -593,7 +593,7 @@ static void MARKER_OT_add(wmOperatorType *ot)
        ot->idname = "MARKER_OT_add";
        
        /* api callbacks */
-       ot->exec = ed_marker_add;
+       ot->exec = ed_marker_add_exec;
        ot->invoke = ed_markers_opwrap_invoke;
        ot->poll = ED_operator_animview_active;
        
index d05d309b20146ed95e26e7206744142367af9d63..f2b3ce206f1d5f4c978d25042d3d16b7f05c6fef 100644 (file)
@@ -244,7 +244,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
        ot->description = "Select bones related to selected ones by parent/child relationships";
        
        /* api callbacks */
-       ot->exec = NULL;
+       /* leave 'exec' unset */
        ot->invoke = armature_select_linked_invoke;
        ot->poll = armature_select_linked_poll;
        
index c599e978e584872ec06c6c144d371bbb4bf37241..9449b5a49bf7ac62b8a38125acc54b0e3c5bbc04 100644 (file)
@@ -271,7 +271,7 @@ void POSE_OT_select_linked(wmOperatorType *ot)
        ot->description = "Select bones related to selected ones by parent/child relationships";
        
        /* api callbacks */
-       ot->exec = NULL;
+       /* leave 'exec' unset */
        ot->invoke = pose_select_connected_invoke;
        ot->poll = pose_select_linked_poll;
        
index a5e51ccf32ae5359f65e8a9e17407019e13d8355..014a64170db1dba46dd1ce3dcf12360b0335e359 100644 (file)
@@ -239,7 +239,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
                 *      - only do this if keyframes should have been added
                 *      - do not calculate unless there are paths already to update...
                 */
-               if (C && (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
+               if (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) {
                        //ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
                        ED_pose_recalculate_paths(scene, ob);
                }
index 6504c198b21a3aa470fa2ad8383f17b8282eba1c..21a63183c1a27e5ec42c50ee73f0c08de929c757 100644 (file)
@@ -3964,7 +3964,8 @@ void uiButSetFocusOnEnter(wmWindow *win, uiBut *but)
 {
        wmEvent event;
        
-       event = *(win->eventstate);
+       wm_event_init_from_window(win, &event);
+
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
index 8efad17133f904e0e91387da2010ace51d484fde..b3df719d95abe016c9c65ccb3e0522c893dbd01e 100644 (file)
@@ -6193,7 +6193,7 @@ void ui_button_activate_do(bContext *C, ARegion *ar, uiBut *but)
        
        button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
index ec6e9bbbfb3f53550d6aa864a72b89b6b81abdc4..5910909142c48673e01b27831ab514f3150dc355 100644 (file)
@@ -148,7 +148,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int
                if (BLI_rcti_isect_pt(&sa->totrct, mx, my)) {
                        if (sa->spacetype == SPACE_IMAGE) {
                                ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-                               if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) {
+                               if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) {
                                        SpaceImage *sima = sa->spacedata.first;
                                        int mval[2] = {mx - ar->winrct.xmin,
                                                       my - ar->winrct.ymin};
@@ -160,7 +160,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int
                        }
                        else if (sa->spacetype == SPACE_NODE) {
                                ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-                               if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) {
+                               if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) {
                                        SpaceNode *snode = sa->spacedata.first;
                                        int mval[2] = {mx - ar->winrct.xmin,
                                                       my - ar->winrct.ymin};
@@ -172,7 +172,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int
                        }
                        else if (sa->spacetype == SPACE_CLIP) {
                                ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-                               if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) {
+                               if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) {
                                        SpaceClip *sc = sa->spacedata.first;
                                        int mval[2] = {mx - ar->winrct.xmin,
                                                       my - ar->winrct.ymin};
index 3405d81e04abc567b449a216b77016a35201ac3f..95f47be0b70c3dff091381f9abee7da738340750 100644 (file)
@@ -590,7 +590,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                        /* never fails */
                        id_path = RNA_path_full_ID_py(id);
 
-                       if (ptr->id.data && ptr->data && prop) {
+                       if (ptr->data && prop) {
                                data_path = RNA_path_from_ID_to_property(ptr, prop);
                        }
 
@@ -2268,10 +2268,8 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_
        
        block = uiBeginBlock(C, handle->region, __func__, UI_EMBOSS);
        
-       if (but->rnaprop) {
-               if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
-                       block->color_profile = FALSE;
-               }
+       if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
+               block->color_profile = false;
        }
 
        if (but->block) {
index 772bd6fe671a2a5c4edf9f566334c8675a2755d6..929b7ae2a5d6ff86ffff9beffafb0b4671194ce1 100644 (file)
@@ -1288,7 +1288,7 @@ void UI_view2d_smooth_view(bContext *C, ARegion *ar,
                fac = smooth_view_rect_to_fac(&v2d->cur, cur);
        }
 
-       if (C && U.smooth_viewtx && fac > FLT_EPSILON) {
+       if (U.smooth_viewtx && fac > FLT_EPSILON) {
                int changed = FALSE;
 
                if (BLI_rctf_compare(&sms.new_cur, &v2d->cur, FLT_EPSILON) == FALSE)
index 9440a67c7f4aadee9e12aa752e2d0353dbe5aac9..d61f6712a8f6a06d3c6d85b9064142139bdb6cde 100644 (file)
@@ -38,6 +38,7 @@
 #include "BLI_listbase.h"
 #include "BLI_string.h"
 #include "BLI_array.h"
+#include "BLI_alloca.h"
 #include "BLI_linklist.h"
 #include "BLI_math.h"
 #include "BLI_smallhash.h"
index 4ccb2a59b45e6c52b36e2d4aee7652aeaea15f3a..a1f1f6bd83fde871ed1eaaff41c8471c37d88a2e 100644 (file)
@@ -3074,10 +3074,10 @@ void MESH_OT_region_to_loop(wmOperatorType *ot)
 static int loop_find_region(BMLoop *l, int flag,
                             SmallHash *fhash, BMFace ***region_out)
 {
-       BLI_array_declare(region);
-       BLI_array_declare(stack);
        BMFace **region = NULL;
        BMFace **stack = NULL;
+       BLI_array_declare(region);
+       BLI_array_declare(stack);
        BMFace *f;
        
        BLI_array_append(stack, l->f);
index 99638696ccd9b4d29625b4f1d10fc839be559cf3..868db4fa7466299007b13bb58606bf46e2110ccf 100644 (file)
@@ -635,7 +635,7 @@ void MESH_OT_edge_face_add(wmOperatorType *ot)
 
 /* ************************* SEAMS AND EDGES **************** */
 
-static int edbm_mark_seam(bContext *C, wmOperator *op)
+static int edbm_mark_seam_exec(bContext *C, wmOperator *op)
 {
        Scene *scene = CTX_data_scene(C);
        Object *obedit = CTX_data_edit_object(C);
@@ -681,7 +681,7 @@ void MESH_OT_mark_seam(wmOperatorType *ot)
        ot->description = "(Un)mark selected edges as a seam";
        
        /* api callbacks */
-       ot->exec = edbm_mark_seam;
+       ot->exec = edbm_mark_seam_exec;
        ot->poll = ED_operator_editmesh;
        
        /* flags */
@@ -690,7 +690,7 @@ void MESH_OT_mark_seam(wmOperatorType *ot)
        RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
 }
 
-static int edbm_mark_sharp(bContext *C, wmOperator *op)
+static int edbm_mark_sharp_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
        Mesh *me = ((Mesh *)obedit->data);
@@ -735,7 +735,7 @@ void MESH_OT_mark_sharp(wmOperatorType *ot)
        ot->description = "(Un)mark selected edges as sharp";
        
        /* api callbacks */
-       ot->exec = edbm_mark_sharp;
+       ot->exec = edbm_mark_sharp_exec;
        ot->poll = ED_operator_editmesh;
        
        /* flags */
@@ -745,7 +745,7 @@ void MESH_OT_mark_sharp(wmOperatorType *ot)
 }
 
 
-static int edbm_vert_connect(bContext *C, wmOperator *op)
+static int edbm_vert_connect_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -795,13 +795,58 @@ void MESH_OT_vert_connect(wmOperatorType *ot)
        ot->description = "Connect 2 vertices of a face by an edge, splitting the face in two";
        
        /* api callbacks */
-       ot->exec = edbm_vert_connect;
+       ot->exec = edbm_vert_connect_exec;
        ot->poll = ED_operator_editmesh;
        
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+
+static int edbm_vert_connect_nonplaner_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit = CTX_data_edit_object(C);
+       BMEditMesh *em = BKE_editmesh_from_object(obedit);
+
+       const float angle_limit = RNA_float_get(op->ptr, "angle_limit");
+
+       if (!EDBM_op_call_and_selectf(
+                    em, op,
+                    "faces.out", true,
+                    "connect_verts_nonplanar faces=%hf angle_limit=%f",
+                    BM_ELEM_SELECT, angle_limit))
+       {
+               return OPERATOR_CANCELLED;
+       }
+
+
+       EDBM_update_generic(em, true, true);
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_vert_connect_nonplanar(wmOperatorType *ot)
+{
+       PropertyRNA *prop;
+
+       /* identifiers */
+       ot->name = "Split Non-Planar Faces";
+       ot->idname = "MESH_OT_vert_connect_nonplanar";
+       ot->description = "Split non-planar faces that exceed the angle threshold";
+
+       /* api callbacks */
+       ot->exec = edbm_vert_connect_nonplaner_exec;
+       ot->poll = ED_operator_editmesh;
+
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+       /* props */
+       prop = RNA_def_float_rotation(ot->srna, "angle_limit", 0, NULL, 0.0f, DEG2RADF(180.0f),
+                                     "Max Angle", "Angle limit", 0.0f, DEG2RADF(180.0f));
+       RNA_def_property_float_default(prop, DEG2RADF(5.0f));
+}
+
+
 static int edbm_edge_split_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
@@ -4437,7 +4482,7 @@ void MESH_OT_symmetry_snap(struct wmOperatorType *ot)
 
 #ifdef WITH_FREESTYLE
 
-static int edbm_mark_freestyle_edge(bContext *C, wmOperator *op)
+static int edbm_mark_freestyle_edge_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
        Mesh *me = (Mesh *)obedit->data;
@@ -4490,7 +4535,7 @@ void MESH_OT_mark_freestyle_edge(wmOperatorType *ot)
        ot->idname = "MESH_OT_mark_freestyle_edge";
 
        /* api callbacks */
-       ot->exec = edbm_mark_freestyle_edge;
+       ot->exec = edbm_mark_freestyle_edge_exec;
        ot->poll = ED_operator_editmesh;
 
        /* flags */
index 3a3a734eef03201c169ce9907234a2d0016016e9..44cc89cb23cf62948cd083d10ab30e3b0d8eb03a 100644 (file)
@@ -35,7 +35,7 @@
 #include "DNA_object_types.h"
 
 #include "BLI_math.h"
-#include "BLI_array.h"
+#include "BLI_alloca.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_context.h"
index 52a8ccc4aabc9607fd7134519d499d47d32d66b2..e8cbf0926d4da902b95793ae48917b0b42df6c5c 100644 (file)
@@ -37,8 +37,8 @@
 #include "DNA_view3d_types.h"
 
 #include "BLI_utildefines.h"
+#include "BLI_alloca.h"
 #include "BLI_path_util.h"
-#include "BLI_array.h"
 #include "BLI_math.h"
 
 #include "BKE_context.h"
index c76b9819f753989b27eab3082edbfdd1a584e15d..b2d6e87220669e556d227cc3799d51d990b922ed 100644 (file)
@@ -166,6 +166,7 @@ void MESH_OT_normals_make_consistent(struct wmOperatorType *ot);
 void MESH_OT_vertices_smooth(struct wmOperatorType *ot);
 void MESH_OT_vertices_smooth_laplacian(struct wmOperatorType *ot);
 void MESH_OT_vert_connect(struct wmOperatorType *ot);
+void MESH_OT_vert_connect_nonplanar(struct wmOperatorType *ot);
 void MESH_OT_edge_split(struct wmOperatorType *ot);
 void MESH_OT_bridge_edge_loops(struct wmOperatorType *ot);
 void MESH_OT_wireframe(struct wmOperatorType *ot);
index 74aaa58d32db9de7dac921aef62c4b5527db6116..90dc803ea50b0a1f1bbf09fbe0db148ea05d2859 100644 (file)
@@ -156,6 +156,7 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_solidify);
        WM_operatortype_append(MESH_OT_select_nth);
        WM_operatortype_append(MESH_OT_vert_connect);
+       WM_operatortype_append(MESH_OT_vert_connect_nonplanar);
        WM_operatortype_append(MESH_OT_knife_tool);
        WM_operatortype_append(MESH_OT_knife_project);
 
index 3f1ceb7327c9c7b7611d7e02ede22d2d417cab08..8b674cf1e50f54c47145244a31c7103f4e221dd5 100644 (file)
@@ -107,13 +107,14 @@ typedef struct {
        int threads;
 } MultiresBakeJob;
 
-static int multiresbake_check(bContext *C, wmOperator *op)
+static bool multiresbake_check(bContext *C, wmOperator *op)
 {
        Scene *scene = CTX_data_scene(C);
        Object *ob;
        Mesh *me;
        MultiresModifierData *mmd;
-       int ok = 1, a;
+       bool ok = true;
+       int a;
 
        CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
        {
@@ -122,7 +123,7 @@ static int multiresbake_check(bContext *C, wmOperator *op)
                if (ob->type != OB_MESH) {
                        BKE_report(op->reports, RPT_ERROR, "Baking of multires data only works with an active mesh object");
 
-                       ok = 0;
+                       ok = false;
                        break;
                }
 
@@ -137,12 +138,12 @@ static int multiresbake_check(bContext *C, wmOperator *op)
 
                        for (md = (ModifierData *)mmd->modifier.next; md && ok; md = md->next) {
                                if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
-                                       ok = 0;
+                                       ok = false;
                                }
                        }
                }
                else {
-                       ok = 0;
+                       ok = false;
                }
 
                if (!ok) {
@@ -153,14 +154,14 @@ static int multiresbake_check(bContext *C, wmOperator *op)
 
                if (mmd->lvl == 0) {
                        BKE_report(op->reports, RPT_ERROR, "Multires data baking is not supported for preview subdivision level 0");
-
+                       ok = false;
                        break;
                }
 
                if (!me->mtpoly) {
                        BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking");
 
-                       ok = 0;
+                       ok = false;
                }
                else {
                        a = me->totpoly;
@@ -170,7 +171,7 @@ static int multiresbake_check(bContext *C, wmOperator *op)
                                if (!ima) {
                                        BKE_report(op->reports, RPT_ERROR, "You should have active texture to use multires baker");
 
-                                       ok = 0;
+                                       ok = false;
                                }
                                else {
                                        ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
@@ -178,14 +179,14 @@ static int multiresbake_check(bContext *C, wmOperator *op)
                                        if (!ibuf) {
                                                BKE_report(op->reports, RPT_ERROR, "Baking should happen to image with image buffer");
 
-                                               ok = 0;
+                                               ok = false;
                                        }
                                        else {
                                                if (ibuf->rect == NULL && ibuf->rect_float == NULL)
-                                                       ok = 0;
+                                                       ok = false;
 
                                                if (ibuf->rect_float && !(ibuf->channels == 0 || ibuf->channels == 4))
-                                                       ok = 0;
+                                                       ok = false;
 
                                                if (!ok)
                                                        BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type");
index 9eaaf8fe1db7e328a68e9a897534cfe1463e2aed..aed1d9a1a6cefb34b8f0f15da7cc68cb58890c93 100644 (file)
@@ -1610,7 +1610,7 @@ void ED_object_toggle_modes(bContext *C, int mode)
 
 /************************ Game Properties ***********************/
 
-static int game_property_new(bContext *C, wmOperator *op)
+static int game_property_new_exec(bContext *C, wmOperator *op)
 {
        Object *ob = CTX_data_active_object(C);
        bProperty *prop;
@@ -1640,7 +1640,7 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot)
        ot->idname = "OBJECT_OT_game_property_new";
 
        /* api callbacks */
-       ot->exec = game_property_new;
+       ot->exec = game_property_new_exec;
        ot->poll = ED_operator_object_active_editable;
 
        /* flags */
@@ -1650,7 +1650,7 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot)
        RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the game property to add");
 }
 
-static int game_property_remove(bContext *C, wmOperator *op)
+static int game_property_remove_exec(bContext *C, wmOperator *op)
 {
        Object *ob = CTX_data_active_object(C);
        bProperty *prop;
@@ -1681,7 +1681,7 @@ void OBJECT_OT_game_property_remove(wmOperatorType *ot)
        ot->idname = "OBJECT_OT_game_property_remove";
 
        /* api callbacks */
-       ot->exec = game_property_remove;
+       ot->exec = game_property_remove_exec;
        ot->poll = ED_operator_object_active_editable;
 
        /* flags */
index 13fb46e35de9dcb7f46378fada4792d1d8b3c37b..52f51cfcf486cfa4e594280f43593cb30fef9bbd 100644 (file)
@@ -2049,7 +2049,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
                        if (adt) BKE_animdata_make_local(adt);
                        
                        /* tag indirect data direct */
-                       matarar = (Material ***)give_matarar(ob);
+                       matarar = give_matarar(ob);
                        if (matarar) {
                                for (a = 0; a < ob->totcol; a++) {
                                        ma = (*matarar)[a];
index 6b55518552ae7837ad068fb14691e220fb55571b..b4532e0571c19deda268c64bc899dc9000331d97 100644 (file)
@@ -469,9 +469,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
                WM_event_remove_timer(oglrender->wm, oglrender->win, oglrender->timer);
        }
 
-       if (oglrender->win) {
-               WM_cursor_restore(oglrender->win);
-       }
+       WM_cursor_restore(oglrender->win);
 
        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene);
 
@@ -560,9 +558,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
                }
        }
 
-       if (oglrender->win) {
-               WM_cursor_time(oglrender->win, scene->r.cfra);
-       }
+       WM_cursor_time(oglrender->win, scene->r.cfra);
 
        BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender));
 
index 8da66c114d5e4b7b99505f82ef565dd7aaa91dbe..4bd8a7d426a87476e8a99ac549208c93bd24bbb6 100644 (file)
@@ -964,7 +964,7 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
 
                br->icon_imbuf = get_brush_icon(br);
 
-               memset(sp->pr_rect, 0x888888, sp->sizex * sp->sizey * sizeof(unsigned int));
+               memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(unsigned int));
 
                if (!(br->icon_imbuf) || !(br->icon_imbuf->rect))
                        return;
index 49ecfe2940e9792fd9e6cb6e7414726de33e2968..58c244228ed9a18da0a99758afebfea5a573b910 100644 (file)
@@ -1214,7 +1214,7 @@ void SCENE_OT_freestyle_modifier_move(wmOperatorType *ot)
 
 #endif /* WITH_FREESTYLE */
 
-static int texture_slot_move(bContext *C, wmOperator *op)
+static int texture_slot_move_exec(bContext *C, wmOperator *op)
 {
        ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
 
@@ -1292,7 +1292,7 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
        ot->description = "Move texture slots up and down";
 
        /* api callbacks */
-       ot->exec = texture_slot_move;
+       ot->exec = texture_slot_move_exec;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
index 93ccc4f6a09fab77c95011097d40ac8740a190c2..3066b733fc52a333bfee0048c55daa6db284df51 100644 (file)
@@ -649,7 +649,8 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
        
        sad->modifier = RNA_int_get(op->ptr, "modifier");
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
+
        if (type == AZONE_AREA)
                event.type = EVT_ACTIONZONE_AREA;
        else
@@ -2564,7 +2565,7 @@ static void SCREEN_OT_area_options(wmOperatorType *ot)
 /* ******************************* */
 
 
-static int spacedata_cleanup(bContext *C, wmOperator *op)
+static int spacedata_cleanup_exec(bContext *C, wmOperator *op)
 {
        Main *bmain = CTX_data_main(C);
        bScreen *screen;
@@ -2596,7 +2597,7 @@ static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot)
        ot->idname = "SCREEN_OT_spacedata_cleanup";
        
        /* api callbacks */
-       ot->exec = spacedata_cleanup;
+       ot->exec = spacedata_cleanup_exec;
        ot->poll = WM_operator_winactive;
        
 }
@@ -3369,7 +3370,7 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot)
  * poll()      has to be filled in by user for context
  */
 #if 0
-static int border_select_do(bContext *C, wmOperator *op)
+static int border_select_exec(bContext *C, wmOperator *op)
 {
        int event_type = RNA_int_get(op->ptr, "event_type");
        
@@ -3390,7 +3391,7 @@ static void SCREEN_OT_border_select(wmOperatorType *ot)
        ot->idname = "SCREEN_OT_border_select";
        
        /* api callbacks */
-       ot->exec = border_select_do;
+       ot->exec = border_select_exec;
        ot->invoke = WM_border_select_invoke;
        ot->modal = WM_border_select_modal;
        ot->cancel = WM_border_select_cancel;
index cef624463c25f84bed17408a2e3e3c9f7ee46846..bdf542526eed05ce71895b75bc36bebdd471a4a1 100644 (file)
@@ -847,7 +847,7 @@ static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot)
 }
 
 
-static int stencil_reset_transform(bContext *C, wmOperator *op)
+static int stencil_reset_transform_exec(bContext *C, wmOperator *op)
 {
        Paint *paint = BKE_paint_get_active_from_context(C);
        Brush *br = BKE_paint_brush(paint);
@@ -889,7 +889,7 @@ static void BRUSH_OT_stencil_reset_transform(wmOperatorType *ot)
        ot->idname = "BRUSH_OT_stencil_reset_transform";
 
        /* api callbacks */
-       ot->exec = stencil_reset_transform;
+       ot->exec = stencil_reset_transform_exec;
        ot->poll = stencil_control_poll;
 
        /* flags */
index e145065daab1209ef2f8f61d7d9e0914291273f3..3ac3564ed45c9b06505f1426ef8bfc03a02c2185 100644 (file)
@@ -2025,7 +2025,7 @@ static void do_weight_paint_vertex(
 
 /* *************** set wpaint operator ****************** */
 
-static int set_wpaint(bContext *C, wmOperator *UNUSED(op))  /* toggle */
+static int wpaint_mode_toggle_exec(bContext *C, wmOperator *UNUSED(op))  /* toggle */
 {              
        Object *ob = CTX_data_active_object(C);
        Scene *scene = CTX_data_scene(C);
@@ -2096,7 +2096,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
        ot->description = "Toggle weight paint mode in 3D view";
        
        /* api callbacks */
-       ot->exec = set_wpaint;
+       ot->exec = wpaint_mode_toggle_exec;
        ot->poll = paint_poll_test;
        
        /* flags */
@@ -2642,7 +2642,7 @@ void PAINT_OT_weight_set(wmOperatorType *ot)
 /* ************ set / clear vertex paint mode ********** */
 
 
-static int set_vpaint(bContext *C, wmOperator *op)  /* toggle */
+static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)  /* toggle */
 {      
        Object *ob = CTX_data_active_object(C);
        Scene *scene = CTX_data_scene(C);
@@ -2673,7 +2673,7 @@ static int set_vpaint(bContext *C, wmOperator *op)  /* toggle */
                ob->mode |= OB_MODE_VERTEX_PAINT;
                /* Turn off weight painting */
                if (ob->mode & OB_MODE_WEIGHT_PAINT)
-                       set_wpaint(C, op);
+                       wpaint_mode_toggle_exec(C, op);
                
                if (vp == NULL)
                        vp = scene->toolsettings->vpaint = new_vpaint(0);
@@ -2700,7 +2700,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
        ot->description = "Toggle the vertex paint mode in 3D view";
        
        /* api callbacks */
-       ot->exec = set_vpaint;
+       ot->exec = vpaint_mode_toggle_exec;
        ot->poll = paint_poll_test;
        
        /* flags */
index 283cd0b3ee86572402e5c70b303e13ef22db32fb..4b7c2995ea708e34773492844f5226a7359daadb 100644 (file)
@@ -4523,7 +4523,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
 
 /**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/
 
-static int sculpt_set_persistent_base(bContext *C, wmOperator *UNUSED(op))
+static int sculpt_set_persistent_base_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SculptSession *ss = CTX_data_active_object(C)->sculpt;
 
@@ -4544,7 +4544,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
        ot->description = "Reset the copy of the mesh that is being sculpted on";
        
        /* api callbacks */
-       ot->exec = sculpt_set_persistent_base;
+       ot->exec = sculpt_set_persistent_base_exec;
        ot->poll = sculpt_mode_poll;
        
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -4588,14 +4588,21 @@ void sculpt_dynamic_topology_enable(bContext *C)
        Object *ob = CTX_data_active_object(C);
        SculptSession *ss = ob->sculpt;
        Mesh *me = ob->data;
+       const BMAllocTemplate allocsize = {me->totvert,
+                                          me->totedge,
+                                          me->totloop,
+                                          me->totpoly};
 
        sculpt_pbvh_clear(ob);
 
        ss->bm_smooth_shading = (scene->toolsettings->sculpt->flags &
                                 SCULPT_DYNTOPO_SMOOTH_SHADING);
 
+       /* Dynamic topology doesn't ensure selection state is valid, so remove [#36280] */
+       BKE_mesh_mselect_clear(me);
+
        /* Create triangles-only BMesh */
-       ss->bm = BM_mesh_create(&bm_mesh_allocsize_default);
+       ss->bm = BM_mesh_create(&allocsize);
 
        BM_mesh_bm_from_me(ss->bm, me, true, true, ob->shapenr);
        sculpt_dynamic_topology_triangulate(ss->bm);
@@ -4893,7 +4900,7 @@ int ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
        return ret;
 }
 
-static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op))
+static int sculpt_mode_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
        ToolSettings *ts = CTX_data_tool_settings(C);
@@ -4981,7 +4988,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
        ot->description = "Toggle sculpt mode in 3D view";
        
        /* api callbacks */
-       ot->exec = sculpt_toggle_mode;
+       ot->exec = sculpt_mode_toggle_exec;
        ot->poll = ED_operator_object_active_editable_mesh;
        
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
index 49b87a6160ac1fcb586f2537903bc61928dd2ded..f3d070452a5f8bd77418bb949c87f8a518731e00 100644 (file)
@@ -3478,6 +3478,8 @@ static int clean_tracks_exec(bContext *C, wmOperator *op)
                track = next;
        }
 
+       BKE_tracking_dopesheet_tag_update(tracking);
+
        WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip);
 
        return OPERATOR_FINISHED;
index c4315c56376eed5ebb48682c79a7623f90cdc6e7..93a68be164a464e5895cc9d83375917e5900aa2b 100644 (file)
@@ -148,15 +148,16 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
        PointerRNA fcu_ptr;
        uiLayout *layout = pa->layout;
        uiLayout *col, *row, *sub;
-       uiBlock *block;
+       // uiBlock *block;  // UNUSED
        char name[256];
        int icon = 0;
 
        if (!graph_panel_context(C, &ale, &fcu))
                return;
        
-       block = uiLayoutGetBlock(layout);
-       /* uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); */
+       // UNUSED
+       // block = uiLayoutGetBlock(layout);
+       // uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
        
        /* F-Curve pointer */
        RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
@@ -827,7 +828,7 @@ void graph_buttons_register(ARegionType *art)
        BLI_addtail(&art->paneltypes, pt);
 }
 
-static int graph_properties(bContext *C, wmOperator *UNUSED(op))
+static int graph_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = graph_has_buttons_region(sa);
@@ -844,7 +845,7 @@ void GRAPH_OT_properties(wmOperatorType *ot)
        ot->idname = "GRAPH_OT_properties";
        ot->description = "Toggle display properties panel";
        
-       ot->exec = graph_properties;
+       ot->exec = graph_properties_toggle_exec;
        ot->poll = ED_operator_graphedit_active;
 
        /* flags */
index 4b1975bc058c6167f2cad21ccad8cea970ee13b3..144d2c14e9f4af5e3cce2287b209d40938065a6c 100644 (file)
@@ -886,7 +886,7 @@ void image_buttons_register(ARegionType *art)
        BLI_addtail(&art->paneltypes, pt);
 }
 
-static int image_properties(bContext *C, wmOperator *UNUSED(op))
+static int image_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = image_has_buttons_region(sa);
@@ -903,14 +903,14 @@ void IMAGE_OT_properties(wmOperatorType *ot)
        ot->idname = "IMAGE_OT_properties";
        ot->description = "Toggle display properties panel";
        
-       ot->exec = image_properties;
+       ot->exec = image_properties_toggle_exec;
        ot->poll = ED_operator_image_active;
        
        /* flags */
        ot->flag = 0;
 }
 
-static int image_scopes(bContext *C, wmOperator *UNUSED(op))
+static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = image_has_scope_region(sa);
@@ -927,7 +927,7 @@ void IMAGE_OT_scopes(wmOperatorType *ot)
        ot->idname = "IMAGE_OT_scopes";
        ot->description = "Toggle display scopes panel";
        
-       ot->exec = image_scopes;
+       ot->exec = image_scopes_toggle_exec;
        ot->poll = ED_operator_image_active;
        
        /* flags */
index a55da0e3b2cf7bfb38a2a6f6eef0733e3a49e24f..2c521532484c67a30105415d9b3aa6af940b0343 100644 (file)
@@ -50,7 +50,7 @@
 #include "interface_intern.h"
 #include "logic_intern.h"
 
-static int logic_properties(bContext *C, wmOperator *UNUSED(op))
+static int logic_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = logic_has_buttons_region(sa);
@@ -67,7 +67,7 @@ void LOGIC_OT_properties(wmOperatorType *ot)
        ot->description = "Toggle display properties panel";
        ot->idname = "LOGIC_OT_properties";
        
-       ot->exec = logic_properties;
+       ot->exec = logic_properties_toggle_exec;
        ot->poll = ED_operator_logic_active;
        
        /* flags */
index 4cda92fbe07f50f2523dd55057a5d06debc62650..d3bef34670509cdf9c0342040e6a03da4ef42af6 100644 (file)
@@ -552,7 +552,7 @@ void nla_buttons_register(ARegionType *art)
        BLI_addtail(&art->paneltypes, pt);
 }
 
-static int nla_properties(bContext *C, wmOperator *UNUSED(op))
+static int nla_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = nla_has_buttons_region(sa);
@@ -569,7 +569,7 @@ void NLA_OT_properties(wmOperatorType *ot)
        ot->idname = "NLA_OT_properties";
        ot->description = "Toggle display properties panel";
        
-       ot->exec = nla_properties;
+       ot->exec = nla_properties_toggle_exec;
        ot->poll = ED_operator_nla_active;
 
        /* flags */
index 7068973b2bfafecbb6fc9df9071653bf6e6846a2..f95e895bef2d5eadb7c50037c808ab584fe06b99 100644 (file)
@@ -206,7 +206,7 @@ void node_buttons_register(ARegionType *art)
        BLI_addtail(&art->paneltypes, pt);
 }
 
-static int node_properties(bContext *C, wmOperator *UNUSED(op))
+static int node_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = node_has_buttons_region(sa);
@@ -230,7 +230,7 @@ void NODE_OT_properties(wmOperatorType *ot)
        ot->description = "Toggles the properties panel display";
        ot->idname = "NODE_OT_properties";
        
-       ot->exec = node_properties;
+       ot->exec = node_properties_toggle_exec;
        ot->poll = node_properties_poll;
        
        /* flags */
index beea4dc3183935259c5dc834b413e8444c846197..244b222811ec81ab17e8670af2d97a7c1466a346 100644 (file)
@@ -356,7 +356,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
 }
 
 
-static int node_active_link_viewer(bContext *C, wmOperator *UNUSED(op))
+static int node_active_link_viewer_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceNode *snode = CTX_wm_space_node(C);
        bNode *node;
@@ -385,7 +385,7 @@ void NODE_OT_link_viewer(wmOperatorType *ot)
        ot->idname = "NODE_OT_link_viewer";
 
        /* api callbacks */
-       ot->exec = node_active_link_viewer;
+       ot->exec = node_active_link_viewer_exec;
        ot->poll = composite_node_editable;
 
        /* flags */
index bd0c9848b239d83abdadfc34c6a3a2ca0e7e3bf0..e17699309ef9bf127f63557776a2427862c1c266 100644 (file)
@@ -926,7 +926,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
        uiEndBlock(C, block);
        
        //      uiButActiveOnly(C, ar, block, but); XXX using this here makes Blender hang - investigate
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
index 86da4009b178128adf7043afeb5be9d7a2d207b8..dd5bad3f8adf776be223f1e3202801a0cf513110 100644 (file)
@@ -60,7 +60,7 @@ void node_toolbar_register(ARegionType *UNUSED(art))
 
 /* ********** operator to open/close toolshelf region */
 
-static int node_toolbar(bContext *C, wmOperator *UNUSED(op))
+static int node_toolbar_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = node_has_tools_region(sa);
@@ -84,7 +84,7 @@ void NODE_OT_toolbar(wmOperatorType *ot)
        ot->description = "Toggles tool shelf display";
        ot->idname = "NODE_OT_toolbar";
        
-       ot->exec = node_toolbar;
+       ot->exec = node_toolbar_toggle_exec;
        ot->poll = node_toolbar_poll;
        
        /* flags */
index eed8a10a1dbbd9efc2d70ce4232022e5fb1ba877..9e6e1e628f6ce92271d53610a5c63fddb61ce384 100644 (file)
@@ -295,7 +295,7 @@ void NODE_OT_backimage_move(wmOperatorType *ot)
        ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER;
 }
 
-static int backimage_zoom(bContext *C, wmOperator *op)
+static int backimage_zoom_exec(bContext *C, wmOperator *op)
 {
        SpaceNode *snode = CTX_wm_space_node(C);
        ARegion *ar = CTX_wm_region(C);
@@ -317,7 +317,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot)
        ot->description = "Zoom in/out the background image";
 
        /* api callbacks */
-       ot->exec = backimage_zoom;
+       ot->exec = backimage_zoom_exec;
        ot->poll = composite_node_active;
 
        /* flags */
index 81207deea0172d0c58188baca97254ed2b59197b..b308bd09026f68fd63a09c0d08520adcc44cfae0 100644 (file)
@@ -263,7 +263,7 @@ static void restrictbutton_bone_visibility_cb(bContext *C, void *poin, void *poi
 {
        bArmature *arm = (bArmature *)poin;
        Bone *bone = (Bone *)poin2;
-       if (bone && (bone->flag & BONE_HIDDEN_P))
+       if (bone->flag & BONE_HIDDEN_P)
                bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
 
        if (CTX_wm_window(C)->eventstate->ctrl) {
@@ -277,7 +277,7 @@ static void restrictbutton_bone_select_cb(bContext *C, void *poin, void *poin2)
 {
        bArmature *arm = (bArmature *)poin;
        Bone *bone = (Bone *)poin2;
-       if (bone && (bone->flag & BONE_UNSELECTABLE))
+       if (bone->flag & BONE_UNSELECTABLE)
                bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
 
        if (CTX_wm_window(C)->eventstate->ctrl) {
@@ -539,21 +539,21 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF,
-                                                  (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
+                                                  (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y,
                                                   &ptr, "hide", -1, 0, 0, -1, -1,
                                                   TIP_("Restrict viewport visibility (Ctrl - Recursive)"));
                                uiButSetFunc(bt, restrictbutton_view_cb, scene, ob);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF,
-                                                  (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
+                                                  (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y,
                                                   &ptr, "hide_select", -1, 0, 0, -1, -1,
                                                   TIP_("Restrict viewport selection (Ctrl - Recursive)"));
                                uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF,
-                                                  (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
+                                                  (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y,
                                                   &ptr, "hide_render", -1, 0, 0, -1, -1,
                                                   TIP_("Restrict rendering (Ctrl - Recursive)"));
                                uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob);
@@ -570,21 +570,21 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
 
                                restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW);
                                bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF,
-                                                 (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
+                                                 (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y,
                                                  NULL, 0, 0, 0, 0, TIP_("Restrict/Allow visibility in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
 
                                restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT);
                                bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF,
-                                                 (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
+                                                 (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y,
                                                  NULL, 0, 0, 0, 0, TIP_("Restrict/Allow selection in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
 
                                restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER);
                                bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF,
-                                                 (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
+                                                 (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y,
                                                  NULL, 0, 0, 0, 0, TIP_("Restrict/Allow renderability"));
                                uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
@@ -596,7 +596,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                
                                bt = uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT - 1,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, te->directdata, 0, 0, 0, 0, TIP_("Render this RenderLayer"));
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
@@ -611,7 +611,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                
                                bt = uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT - 1,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, layflag, 0, 0, 0, 0, TIP_("Render this Pass"));
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
@@ -621,7 +621,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                          SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT))
                                {
                                        bt = uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag) ? ICON_DOT : ICON_BLANK1,
-                                                             (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X,
+                                                             (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
                                                              UI_UNIT_Y, layflag, 0, 0, 0, 0, TIP_("Exclude this Pass from Combined"));
                                        uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
                                        uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
@@ -635,14 +635,14 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, &(md->mode), 0, 0, 0, 0,
                                                      TIP_("Restrict/Allow visibility in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)te->ys, UI_UNIT_X,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, &(md->mode), 0, 0, 0, 0, TIP_("Restrict/Allow renderability"));
                                uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
@@ -656,14 +656,14 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0,
                                                      TIP_("Restrict/Allow visibility in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_bone_visibility_cb, ob->data, bone);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0,
                                                      TIP_("Restrict/Allow selection in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_bone_select_cb, ob->data, bone);
@@ -676,14 +676,14 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, &(ebone->flag), 0, 0, 0, 0,
                                                      TIP_("Restrict/Allow visibility in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_ebone_visibility_cb, NULL, ebone);
                                uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, &(ebone->flag), 0, 0, 0, 0,
                                                      TIP_("Restrict/Allow selection in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_ebone_select_cb, NULL, ebone);
@@ -735,7 +735,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
                                prop = te->directdata;
                                
                                if (!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem, soops)))) {
-                                       uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX,
+                                       uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, te->ys, OL_RNA_COL_SIZEX,
                                                      UI_UNIT_Y - 1);
                                }
                        }
@@ -743,7 +743,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
                                ptr = &te->rnaptr;
                                prop = te->directdata;
                                
-                               uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX,
+                               uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, te->ys, OL_RNA_COL_SIZEX,
                                              UI_UNIT_Y - 1);
                        }
                }
@@ -811,7 +811,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi)
        uiBlockSetDirection(block, UI_DOWN);
        uiEndBlock(C, block);
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
@@ -960,7 +960,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
                                        /* pass */
                                }
                                else {
-                                       uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys + 1, butw1, UI_UNIT_Y - 1,
+                                       uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, te->ys + 1, butw1, UI_UNIT_Y - 1,
                                                      TIP_("Assign new Operator"));
                                }
                                xstart += butw1 + 10;
@@ -969,7 +969,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
                                kmi->maptype = keymap_menu_type(kmi->type);
                                
                                str = keymap_type_menu();
-                               but = uiDefButS(block, MENU, 0, str,    xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype,
+                               but = uiDefButS(block, MENU, 0, str,    xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype,
                                                0, 0, 0, 0, TIP_("Event type"));
                                uiButSetFunc(but, keymap_type_cb, kmi, NULL);
                                xstart += butw2 + 5;
@@ -977,48 +977,48 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
                                /* edit actual event */
                                switch (kmi->maptype) {
                                        case OL_KM_KEYBOARD:
-                                               uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
+                                               uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
                                                                TIP_("Key code"));
                                                xstart += butw2 + 5;
                                                break;
                                        case OL_KM_MOUSE:
                                                str = keymap_mouse_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
+                                               uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
                                                          0, 0, 0, 0, TIP_("Mouse button"));
                                                xstart += butw2 + 5;
                                                break;
                                        case OL_KM_TWEAK:
                                                str = keymap_tweak_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
+                                               uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
                                                          0, 0, 0, 0, TIP_("Tweak gesture"));
                                                xstart += butw2 + 5;
                                                str = keymap_tweak_dir_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val,
+                                               uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val,
                                                          0, 0, 0, 0, TIP_("Tweak gesture direction"));
                                                xstart += butw2 + 5;
                                                break;
                                }
                                
                                /* modifiers */
-                               uiDefButS(block, OPTION, 0, IFACE_("Shift"), xstart, (int)te->ys + 1, butw3 + 5, UI_UNIT_Y - 1,
+                               uiDefButS(block, OPTION, 0, IFACE_("Shift"), xstart, te->ys + 1, butw3 + 5, UI_UNIT_Y - 1,
                                          &kmi->shift, 0, 0, 0, 0, TIP_("Modifier"));
                                xstart += butw3 + 5;
-                               uiDefButS(block, OPTION, 0, IFACE_("Ctrl"), xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl,
+                               uiDefButS(block, OPTION, 0, IFACE_("Ctrl"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl,
                                          0, 0, 0, 0, TIP_("Modifier"));
                                xstart += butw3;
-                               uiDefButS(block, OPTION, 0, IFACE_("Alt"), xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt,
+                               uiDefButS(block, OPTION, 0, IFACE_("Alt"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt,
                                          0, 0, 0, 0, TIP_("Modifier"));
                                xstart += butw3;
-                               uiDefButS(block, OPTION, 0, IFACE_("OS"), xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey,
+                               uiDefButS(block, OPTION, 0, IFACE_("OS"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey,
                                          0, 0, 0, 0, TIP_("Modifier"));
                                xstart += butw3 + 5;
-                               uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier,
+                               uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier,
                                                TIP_("Key Modifier code"));
                                xstart += butw3 + 5;
                                
                                /* rna property */
                                if (kmi->ptr && kmi->ptr->data) {
-                                       uiDefBut(block, LABEL, 0, IFACE_("(RNA property)"), xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1,
+                                       uiDefBut(block, LABEL, 0, IFACE_("(RNA property)"), xstart, te->ys + 1, butw2, UI_UNIT_Y - 1,
                                                 NULL, 0, 0, 0, 0, "");
                                        xstart += butw2;
                                }
@@ -1064,7 +1064,7 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa
                                spx = te->xs + 1.8f * UI_UNIT_X;
                                if (spx + dx + 0.5f * UI_UNIT_X > ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax - spx - 0.5f * UI_UNIT_X;
 
-                               bt = uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx + UI_UNIT_X, UI_UNIT_Y - 1, (void *)te->name,
+                               bt = uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, te->ys, dx + UI_UNIT_X, UI_UNIT_Y - 1, (void *)te->name,
                                              1.0, (float)len, 0, 0, "");
                                uiButSetRenameFunc(bt, namebutton_cb, tselem);
                                
@@ -1440,8 +1440,8 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
                        }
                        
                        tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f);
-                       te->xs = (float)*offsx;
-                       te->ys = (float)ys;
+                       te->xs = *offsx;
+                       te->ys = ys;
                        te->xend = (short)*offsx + UI_UNIT_X;
                        te->flag |= TE_ICONROW; // for click
                        
@@ -1456,13 +1456,13 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
 }
 
 /* closed tree element */
-static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, int startx, int *starty)
+static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, int startx, int starty)
 {
        TreeElement *ten;
        
        /* store coord and continue, we need coordinates for elements outside view too */
-       te->xs = (float)startx;
-       te->ys = (float)(*starty);
+       te->xs = startx;
+       te->ys = starty;
        
        for (ten = te->subtree.first; ten; ten = ten->next) {
                outliner_set_coord_tree_element(soops, ten, startx + UI_UNIT_X, starty);
@@ -1656,8 +1656,8 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                }
        }
        /* store coord and continue, we need coordinates for elements outside view too */
-       te->xs = (float)startx;
-       te->ys = (float)*starty;
+       te->xs = startx;
+       te->ys = *starty;
        te->xend = startx + offsx;
                
        if (TSELEM_OPEN(tselem, soops)) {
@@ -1668,7 +1668,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
        }
        else {
                for (ten = te->subtree.first; ten; ten = ten->next)
-                       outliner_set_coord_tree_element(soops, te, startx, starty);
+                       outliner_set_coord_tree_element(soops, ten, startx, *starty);
                
                *starty -= UI_UNIT_Y;
        }
index 0161f53e6905925cce37b35f8c07569005592bcf..cef5fe53407efe52d95d9a9927dbcaa6bbf26194 100644 (file)
@@ -618,7 +618,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
        te = outliner_find_id(so, &so->tree, (ID *)OBACT);
        if (te) {
                /* make te->ys center of view */
-               ytop = (int)(te->ys + BLI_rcti_size_y(&v2d->mask) / 2);
+               ytop = te->ys + BLI_rcti_size_y(&v2d->mask) / 2;
                if (ytop > 0) ytop = 0;
                
                v2d->cur.ymax = (float)ytop;
index fe07a7dae9f8829ac1a89efb18fc5637d26bcf77..2310ca9b4b5cb90cd6a09d417d27aa6c180a9265 100644 (file)
@@ -48,7 +48,7 @@ struct Object;
 typedef struct TreeElement {
        struct TreeElement *next, *prev, *parent;
        ListBase subtree;
-       float xs, ys;       // do selection
+       int xs, ys;         // do selection
        int store_index;    // offset in tree store
        short flag;         // flag for non-saved stuff
        short index;        // index for data arrays
index eb33d799dff1dade2a104cf4487207f3ad23abfc..17734f00997b3c6a4e19d0c7cf0ae13853031bd8 100644 (file)
@@ -804,7 +804,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
        TreeElement *te;
        TreeStoreElem *tselem;
        ID *id = idv;
-       int a = 0;
        
        if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
                id = ((PointerRNA *)idv)->id.data;
@@ -1084,7 +1083,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                te->name = km->idname;
                
                if (TSELEM_OPEN(tselem, soops)) {
-                       a = 0;
+                       int a = 0;
                        
                        for (kmi = km->items.first; kmi; kmi = kmi->next, a++) {
                                const char *key = WM_key_event_string(kmi->type);
@@ -1131,7 +1130,7 @@ static int need_add_seq_dup(Sequence *seq)
 {
        Sequence *p;
 
-       if ((!seq->strip) || (!seq->strip->stripdata) || (!seq->strip->stripdata->name))
+       if ((!seq->strip) || (!seq->strip->stripdata))
                return(1);
 
        /*
index 197cc64dea47edc2e584b79ad6309541684ce555..36589984c785bdb827c0c94248fa13252dcb90c2 100644 (file)
@@ -76,7 +76,7 @@ void sequencer_buttons_register(ARegionType *art)
 
 /* **************** operator to open/close properties view ************* */
 
-static int sequencer_properties(bContext *C, wmOperator *UNUSED(op))
+static int sequencer_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = sequencer_has_buttons_region(sa);
@@ -93,7 +93,7 @@ void SEQUENCER_OT_properties(wmOperatorType *ot)
        ot->idname = "SEQUENCER_OT_properties";
        ot->description = "Open sequencer properties panel";
        
-       ot->exec = sequencer_properties;
+       ot->exec = sequencer_properties_toggle_exec;
        ot->poll = ED_operator_sequencer_active;
        
        /* flags */
index 1d98906a6fbaa149b95c378fa2bf68feaf22e1ca..6383440893dffc72ae91d9dce9e7e81c9a5adee2 100644 (file)
@@ -3852,8 +3852,8 @@ static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag,
                                        glEnd();
 
                                        glEnable(GL_LIGHTING);
-                                       break;
                                }
+                               break;
                        case DL_SURF:
 
                                if (dl->index) {
index dab20651537f045cef2ba6c1e22e447d2b7151d4..75e7605df6b434a50cb87b152f2eeb3167063f6f 100644 (file)
@@ -1171,7 +1171,7 @@ void view3d_buttons_register(ARegionType *art)
        BLI_addtail(&art->paneltypes, pt);
 }
 
-static int view3d_properties(bContext *C, wmOperator *UNUSED(op))
+static int view3d_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = view3d_has_buttons_region(sa);
@@ -1188,7 +1188,7 @@ void VIEW3D_OT_properties(wmOperatorType *ot)
        ot->description = "Toggles the properties panel display";
        ot->idname = "VIEW3D_OT_properties";
 
-       ot->exec = view3d_properties;
+       ot->exec = view3d_properties_toggle_exec;
        ot->poll = ED_operator_view3d_active;
 
        /* flags */
index a2dd7d510bd050b7e0168a0d5cbf2812538d550a..0f2f07a1053efe088d050b66caf0a63777ef44f8 100644 (file)
@@ -532,7 +532,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
 
 /* *********************** operators ******************** */
 
-static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
+static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *obedit = CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
@@ -660,11 +660,11 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name = "Snap Selection to Grid";
-       ot->description = "Snap selected item(s) to nearest grid node";
+       ot->description = "Snap selected item(s) to nearest grid division";
        ot->idname = "VIEW3D_OT_snap_selected_to_grid";
        
        /* api callbacks */
-       ot->exec = snap_sel_to_grid;
+       ot->exec = snap_sel_to_grid_exec;
        ot->poll = ED_operator_region_view3d_active;
        
        /* flags */
@@ -673,7 +673,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
 
 /* *************************************************** */
 
-static int snap_sel_to_curs(bContext *C, wmOperator *op)
+static int snap_sel_to_curs_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
@@ -832,7 +832,7 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
        ot->idname = "VIEW3D_OT_snap_selected_to_cursor";
        
        /* api callbacks */
-       ot->exec = snap_sel_to_curs;
+       ot->exec = snap_sel_to_curs_exec;
        ot->poll = ED_operator_view3d_active;
        
        /* flags */
@@ -844,7 +844,7 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
 
 /* *************************************************** */
 
-static int snap_curs_to_grid(bContext *C, wmOperator *UNUSED(op))
+static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
        RegionView3D *rv3d = CTX_wm_region_data(C);
@@ -867,11 +867,11 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name = "Snap Cursor to Grid";
-       ot->description = "Snap cursor to nearest grid node";
+       ot->description = "Snap cursor to nearest grid division";
        ot->idname = "VIEW3D_OT_snap_cursor_to_grid";
        
        /* api callbacks */
-       ot->exec = snap_curs_to_grid;
+       ot->exec = snap_curs_to_grid_exec;
        ot->poll = ED_operator_region_view3d_active;
        
        /* flags */
@@ -1029,7 +1029,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
        return true;
 }
 
-static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op))
+static int snap_curs_to_sel_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
        View3D *v3d = CTX_wm_view3d(C);
@@ -1055,7 +1055,7 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
        ot->idname = "VIEW3D_OT_snap_cursor_to_selected";
        
        /* api callbacks */
-       ot->exec = snap_curs_to_sel;
+       ot->exec = snap_curs_to_sel_exec;
        ot->poll = ED_operator_view3d_active;
        
        /* flags */
@@ -1064,7 +1064,7 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
 
 /* ********************************************** */
 
-static int snap_curs_to_active(bContext *C, wmOperator *UNUSED(op))
+static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *obedit = CTX_data_edit_object(C);
        Object *obact = CTX_data_active_object(C);
@@ -1113,7 +1113,7 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
        ot->idname = "VIEW3D_OT_snap_cursor_to_active";
        
        /* api callbacks */
-       ot->exec = snap_curs_to_active;
+       ot->exec = snap_curs_to_active_exec;
        ot->poll = ED_operator_view3d_active;
        
        /* flags */
@@ -1122,7 +1122,7 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
 
 /* **************************************************** */
 /*New Code - Snap Cursor to Center -*/
-static int snap_curs_to_center(bContext *C, wmOperator *UNUSED(op))
+static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
        View3D *v3d = CTX_wm_view3d(C);
@@ -1144,7 +1144,7 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot)
        ot->idname = "VIEW3D_OT_snap_cursor_to_center";
        
        /* api callbacks */
-       ot->exec = snap_curs_to_center;
+       ot->exec = snap_curs_to_center_exec;
        ot->poll = ED_operator_view3d_active;
        
        /* flags */
index ebb9a7b8c816704165b20ca4c2e20c1de107042f..bdb203ab003121a4b9f2600df391d11d035b3d8c 100644 (file)
@@ -195,7 +195,7 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase)
        uiBlockSetDirection(block, UI_DOWN);
        uiEndBlock(C, block);
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
@@ -258,7 +258,7 @@ void view3d_tool_props_register(ARegionType *art)
 
 /* ********** operator to open/close toolshelf region */
 
-static int view3d_toolshelf(bContext *C, wmOperator *UNUSED(op))
+static int view3d_toolshelf_toggle_exec(bContext *C, wmOperator *UNUSED(op))
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = view3d_has_tools_region(sa);
@@ -275,7 +275,7 @@ void VIEW3D_OT_toolshelf(wmOperatorType *ot)
        ot->description = "Toggles tool shelf display";
        ot->idname = "VIEW3D_OT_toolshelf";
        
-       ot->exec = view3d_toolshelf;
+       ot->exec = view3d_toolshelf_toggle_exec;
        ot->poll = ED_operator_view3d_active;
        
        /* flags */
index e44b9620b6f927bb0187f4bb8bfd8789da25e717..b154acc74560dbd9b2d536609eec67d0f231349f 100644 (file)
@@ -59,7 +59,6 @@
 
 #include "BLI_math.h"
 #include "BLI_blenlib.h"
-#include "BLI_array.h"
 #include "BLI_utildefines.h"
 #include "BLI_smallhash.h"
 
@@ -2129,7 +2128,7 @@ static void createTransEditVerts(TransInfo *t)
        float *mappedcos = NULL, *quats = NULL;
        float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
        float *dists = NULL;
-       int count = 0, countsel = 0, a, totleft;
+       int a;
        int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0;
        int mirror = 0;
        int cd_vert_bweight_offset = -1;
@@ -2165,10 +2164,6 @@ static void createTransEditVerts(TransInfo *t)
                BLI_assert(0);
        }
 
-       countsel = bm->totvertsel;
-       if (propmode) {
-               count = bm->totvert;
-       }
 
        /* check active */
        eve_act = BM_mesh_active_vert_get(bm);
@@ -2179,6 +2174,13 @@ static void createTransEditVerts(TransInfo *t)
        }
 
        if (propmode) {
+               unsigned int count = 0;
+               BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+                       if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+                               count++;
+                       }
+               }
+
                t->total = count;
 
                /* allocating scratch arrays */
@@ -2186,7 +2188,7 @@ static void createTransEditVerts(TransInfo *t)
                        dists = MEM_mallocN(em->bm->totvert * sizeof(float), "scratch nears");
        }
        else {
-               t->total = countsel;
+               t->total = bm->totvertsel;
        }
 
        tob = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mesh EditMode)");
@@ -2218,6 +2220,7 @@ static void createTransEditVerts(TransInfo *t)
        /* detect CrazySpace [tm] */
        if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1) >= 0) {
                if (modifiers_isCorrectableDeformed(t->obedit)) {
+                       int totleft;
                        /* check if we can use deform matrices for modifier from the
                         * start up to stack, they are more accurate than quats */
                        totleft = editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos);
index ef22f4a484cb66eb0ed2e96811f118b5a71643e4..a873702b5b8de19b8ec09894d0f9348288cb5d34 100644 (file)
@@ -49,7 +49,6 @@
 #include "BKE_mesh.h"
 #include "BKE_editmesh.h"
 
-#include "BLI_array.h"
 #include "BLI_buffer.h"
 
 #include "BIF_gl.h"
index 0f7caf126d333a8ab160ad5d4e6a6cf26fcaf64c..0b514e3f6fd00c3853f87712066ba0738426ce69 100644 (file)
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 
+#include "BLI_utildefines.h"
+#include "BLI_alloca.h"
 #include "BLI_math.h"
 #include "BLI_lasso.h"
 #include "BLI_blenlib.h"
 #include "BLI_array.h"
-#include "BLI_utildefines.h"
 
 #include "BKE_context.h"
 #include "BKE_customdata.h"
index 18f4e8cafaf0ee9b10c690cdce98b0c829070dcf..7851eebe269115f4bd4359546ac3252e4f6ab151 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_array.h"
+#include "BLI_utildefines.h"
+#include "BLI_alloca.h"
 #include "BLI_memarena.h"
 #include "BLI_math.h"
 #include "BLI_rand.h"
 #include "BLI_heap.h"
 #include "BLI_boxpack2d.h"
-#include "BLI_utildefines.h"
-
-
 
 #include "ONL_opennl.h"
 
index a100757980c23f8e4520284b61f481df685352a4..af6689e3f6d5f3476ce38852ad3fbf62197369f8 100644 (file)
@@ -44,6 +44,7 @@
 #include "DNA_modifier_types.h"
 
 #include "BLI_utildefines.h"
+#include "BLI_alloca.h"
 #include "BLI_math.h"
 #include "BLI_edgehash.h"
 #include "BLI_uvproject.h"
@@ -65,7 +66,6 @@
 #include "BLI_math.h"
 #include "BLI_edgehash.h"
 #include "BLI_scanfill.h"
-#include "BLI_array.h"
 #include "BLI_uvproject.h"
 
 #include "PIL_time.h"
index c9aa19ccc67531b4f05c1c64be6db884c964ec15..5f1fc078adef1893577201275f8ed8f240c32ce6 100644 (file)
@@ -655,7 +655,8 @@ typedef struct GameData {
        short mode, matmode;
        short occlusionRes;             /* resolution of occlusion Z buffer in pixel */
        short physicsEngine;
-       short exitkey, pad;
+       short exitkey;
+       short vsync; /* Controls vsync: off, on, or adaptive (if supported) */
        short ticrate, maxlogicstep, physubstep, maxphystep;
        short obstacleSimulation;
        short raster_storage;
@@ -691,6 +692,11 @@ typedef struct GameData {
 #define RAS_STORE_VA           2
 #define RAS_STORE_VBO          3
 
+/* vsync */
+#define VSYNC_OFF      0
+#define VSYNC_ON       1
+#define VSYNC_ADAPTIVE 2
+
 /* GameData.flag */
 #define GAME_RESTRICT_ANIM_UPDATES                     (1 << 0)
 #define GAME_ENABLE_ALL_FRAMES                         (1 << 1)
index faf348302e4ac5bb936b2c041a7466604ecc9fe0..f382caaccba0b883fde3552b10f46dccc48e79b8 100644 (file)
@@ -177,8 +177,8 @@ static int replace_if_different(char *tmpfile, const char *dep_files[])
 
 
        if (len_new != len_org) {
-               fclose(fp_new);
-               fclose(fp_org);
+               fclose(fp_new); fp_new = NULL;
+               fclose(fp_org); fp_org = NULL;
                REN_IF_DIFF;
        }
 
@@ -191,8 +191,8 @@ static int replace_if_different(char *tmpfile, const cha