Merged revision(s) 58585-58681 from trunk/blender into soc-2013-dingto.
authorThomas Dinges <blender@dingto.org>
Sun, 28 Jul 2013 06:17:10 +0000 (06:17 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 28 Jul 2013 06:17:10 +0000 (06:17 +0000)
77 files changed:
release/scripts/startup/bl_ui/space_view3d.py
source/blender/avi/intern/avi.c
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/mesh_validate.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/text.c
source/blender/blenlib/BLI_buffer.h
source/blender/blenlib/BLI_math_matrix.h
source/blender/blenlib/BLI_string.h
source/blender/blenlib/intern/fileops.c
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/string.c
source/blender/bmesh/CMakeLists.txt
source/blender/bmesh/intern/bmesh_construct.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/operators/bmo_beautify.c
source/blender/bmesh/operators/bmo_bridge.c
source/blender/bmesh/operators/bmo_dissolve.c
source/blender/bmesh/operators/bmo_dupe.c
source/blender/bmesh/operators/bmo_fill_holes.c [new file with mode: 0644]
source/blender/bmesh/operators/bmo_join_triangles.c
source/blender/bmesh/operators/bmo_subdivide_edgering.c
source/blender/bmesh/operators/bmo_utils.c
source/blender/bmesh/tools/bmesh_decimate.h
source/blender/bmesh/tools/bmesh_decimate_dissolve.c
source/blender/collada/ArmatureImporter.cpp
source/blender/editors/animation/anim_intern.h
source/blender/editors/animation/keyframes_general.c
source/blender/editors/armature/armature_edit.c
source/blender/editors/armature/armature_relations.c
source/blender/editors/armature/armature_utils.c
source/blender/editors/include/BIF_glutil.h
source/blender/editors/include/ED_armature.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_regions.c
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_extrude.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/object/object_add.c
source/blender/editors/screen/area.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_view3d/drawarmature.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/imbuf/intern/thumbs.c
source/blender/imbuf/intern/util.c
source/blender/makesrna/intern/rna_armature.c
source/blender/modifiers/intern/MOD_cloth.c
source/blender/modifiers/intern/MOD_simpledeform.c
source/blender/modifiers/intern/MOD_skin.c
source/blender/nodes/texture/node_texture_tree.c
source/blender/render/intern/source/external_engine.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
source/gameengine/GamePlayer/common/GPC_RenderTools.cpp

index 0ad8cdccca892a616b3b61007780216d324fd380..18008553368c4c223cc495270aeb5adcb8bad7f0 100644 (file)
@@ -1822,6 +1822,7 @@ class VIEW3D_MT_edit_mesh(Menu):
         layout.menu("VIEW3D_MT_edit_mesh_edges")
         layout.menu("VIEW3D_MT_edit_mesh_faces")
         layout.menu("VIEW3D_MT_edit_mesh_normals")
+        layout.menu("VIEW3D_MT_edit_mesh_clean")
 
         layout.separator()
 
@@ -2084,6 +2085,15 @@ class VIEW3D_MT_edit_mesh_normals(Menu):
         layout.operator("mesh.flip_normals")
 
 
+class VIEW3D_MT_edit_mesh_clean(Menu):
+    bl_label = "Clean"
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.operator("mesh.fill_holes")
+
+
 class VIEW3D_MT_edit_mesh_delete(Menu):
     bl_label = "Delete"
 
index 48e64695822965e817c1189a9d6e72bdc8c78af3..6f819d438df21f18238b36d5d070c6c5804dc5fd 100644 (file)
@@ -811,12 +811,16 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...)
                movie->streams[i].sh.fcc = FCC("strh");
                movie->streams[i].sh.size = 56;
                movie->streams[i].sh.Type = avi_get_format_type(movie->streams[i].format);
-               if (movie->streams[i].sh.Type == 0)
+               if (movie->streams[i].sh.Type == 0) {
+                       va_end(ap);
                        return AVI_ERROR_FORMAT;
+               }
 
                movie->streams[i].sh.Handler = avi_get_format_fcc(movie->streams[i].format);
-               if (movie->streams[i].sh.Handler == 0)
+               if (movie->streams[i].sh.Handler == 0) {
+                       va_end(ap);
                        return AVI_ERROR_FORMAT;
+               }
 
                movie->streams[i].sh.Flags = 0;
                movie->streams[i].sh.Priority = 0;
@@ -950,6 +954,8 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...)
 
        PUT_FCCN((header_pos2 - header_pos1 + 4L), movie->fp);
 
+       va_end(ap);
+
        return AVI_ERROR_NONE;
 }
 
index 285077f258c9d904888a8f10faba26a8046fccb1..c6a6b0672d1365252b82d86dccbe525b4c7cdb43 100644 (file)
@@ -200,8 +200,8 @@ void CTX_data_dir_set(bContextDataResult *result, const char **member);
 void CTX_data_type_set(struct bContextDataResult *result, short type);
 short CTX_data_type_get(struct bContextDataResult *result);
 
-int CTX_data_equals(const char *member, const char *str);
-int CTX_data_dir(const char *member);
+bool CTX_data_equals(const char *member, const char *str);
+bool CTX_data_dir(const char *member);
 
 #if 0
 void CTX_data_pointer_set(bContextDataResult *result, void *data);
index 749b04d7328a1fa0a5522181154561250a2b1927..78018f044582057860b95cc08248905624a550f0 100644 (file)
@@ -265,7 +265,7 @@ void BKE_sequencer_preprocessed_cache_cleanup_sequence(struct Sequence *seq);
 /* **********************************************************************
  * seqeffects.c
  *
- * Sequencer effect strip managment functions
+ * Sequencer effect strip management functions
  *  **********************************************************************
  */
 
index a47cab7f2361f18301df4a813f5b8d054ee1d1ed..e86561d687d200211a61a280e598adc6ef699ed1 100644 (file)
@@ -408,26 +408,33 @@ void BKE_camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, cons
        }
        else {
                /* that way it's always visible - clipsta+0.1 */
-               float fac;
-               float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x));
+               float fac, scale_x, scale_y;
+               float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ?
+                                           (camera->sensor_y) : (camera->sensor_x));
 
-               *r_drawsize = drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
 
                if (do_clip) {
                        /* fixed depth, variable size (avoids exceeding clipping range) */
-                       depth = -(camera->clipsta + 0.1f);
-                       fac = depth / (camera->lens / (-half_sensor) * scale[2]);
+                       /* r_drawsize shouldn't be used in this case, set to dummy value */
+                       *r_drawsize = 1.0f;
+                       depth = -(camera->clipsta + 0.1f) * scale[2];
+                       fac = depth / (camera->lens / (-half_sensor));
+                       scale_x = 1.0f;
+                       scale_y = 1.0f;
                }
                else {
                        /* fixed size, variable depth (stays a reasonable size in the 3D view) */
+                       *r_drawsize = drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
                        depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2];
                        fac = *r_drawsize;
+                       scale_x = scale[0];
+                       scale_y = scale[1];
                }
 
-               facx = fac * r_asp[0] * scale[0];
-               facy = fac * r_asp[1] * scale[1];
-               r_shift[0] = camera->shiftx * fac * 2 * scale[0];
-               r_shift[1] = camera->shifty * fac * 2 * scale[1];
+               facx = fac * r_asp[0] * scale_x;
+               facy = fac * r_asp[1] * scale_y;
+               r_shift[0] = camera->shiftx * fac * 2.0f * scale_x;
+               r_shift[1] = camera->shifty * fac * 2.0f * scale_y;
        }
 
        r_vec[0][0] = r_shift[0] + facx; r_vec[0][1] = r_shift[1] + facy; r_vec[0][2] = depth;
index bbf254cd7d12b011231a0bc02f443ad225850a44..622b4f6df5a23a2e5a9ec8d17f1bc086dac1e3ed 100644 (file)
@@ -531,12 +531,12 @@ ListBase CTX_data_dir_get(const bContext *C)
        return CTX_data_dir_get_ex(C, TRUE, FALSE, FALSE);
 }
 
-int CTX_data_equals(const char *member, const char *str)
+bool CTX_data_equals(const char *member, const char *str)
 {
        return (strcmp(member, str) == 0);
 }
 
-int CTX_data_dir(const char *member)
+bool CTX_data_dir(const char *member)
 {
        return member[0] == '\0';
 }
index 0dd9d8550bb75af1e924cb3ccbfd03d1a2ed83d4..882085aa5db125623f983c3779b4b7c95924f214 100644 (file)
@@ -537,7 +537,7 @@ void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char body[MAX_V
 
        body[0] = suf[0] = '\0';
 
-       for (i = len - 1; i > 1; i--) {
+       for (i = len; i > 0; i--) {
                if (is_char_sep(string[i])) {
                        BLI_strncpy(body, string, i + 1);
                        BLI_strncpy(suf, string + i,  (len + 1) - i);
@@ -545,7 +545,7 @@ void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char body[MAX_V
                }
        }
 
-       BLI_strncpy(body, string, len);
+       memcpy(body, string, len + 1);
 }
 
 /* "a.b.c" -> ("a.", "b.c") */
index 720500d188b263a260847bd44fcca1dd84a0bf1d..feb18c3babeeeaab8522b4b96b755506c066d054 100644 (file)
@@ -1582,17 +1582,17 @@ static void emDM_release(DerivedMesh *dm)
 
        if (DM_release(dm)) {
                if (bmdm->vertexCos) {
-                       MEM_freeN(bmdm->vertexCos);
+                       MEM_freeN((void *)bmdm->vertexCos);
                        if (bmdm->vertexNos) {
-                               MEM_freeN(bmdm->vertexNos);
+                               MEM_freeN((void *)bmdm->vertexNos);
                        }
                        if (bmdm->polyNos) {
-                               MEM_freeN(bmdm->polyNos);
+                               MEM_freeN((void *)bmdm->polyNos);
                        }
                }
 
                if (bmdm->polyCos) {
-                       MEM_freeN(bmdm->polyCos);
+                       MEM_freeN((void *)bmdm->polyCos);
                }
 
                MEM_freeN(bmdm);
index 878651cdb395fc039226258bbe551305490b16ab..2eced15a147b791fbe581e41b6b83df9586c8fe0 100644 (file)
@@ -294,7 +294,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
 #              define CHECK_FACE_EDGE(a, b) \
                                        if (!BLI_edgehash_haskey(edge_hash, mf->a, mf->b)) { \
                                                PRINT("    face %u: edge " STRINGIFY(a) "/" STRINGIFY(b) \
-                                                     " (%u,%u) is missing egde data\n", i, mf->a, mf->b); \
+                                                     " (%u,%u) is missing edge data\n", i, mf->a, mf->b); \
                                                do_edge_recalc = TRUE; \
                                        } (void)0
 
index daa57afe14e4e44260f92a5d69abaaceb2fe961d..8ac067c03160e6861eb5f889edc75cb9f2e82308 100644 (file)
@@ -693,6 +693,14 @@ void BKE_object_unlink(Object *ob)
                                                sbuts->pinid = NULL;
                                        }
                                }
+                               else if (sl->spacetype == SPACE_NODE) {
+                                       SpaceNode *snode = (SpaceNode *)sl;
+
+                                       if (snode->from == (ID *)ob) {
+                                               snode->flag &= ~SNODE_PIN;
+                                               snode->from = NULL;
+                                       }
+                               }
                        }
 
                        sa = sa->next;
index 06748dfc44d63e08e87c5e8f6fd827d0dfadfbb2..41b9734315d1dde65ade0ab7cf718a7afb7f5954 100644 (file)
@@ -268,8 +268,9 @@ static int  ptcache_particle_write(int index, void *psys_v, void **data, int cfr
        PTCACHE_DATA_FROM(data, BPHYS_DATA_SIZE, &pa->size);
        PTCACHE_DATA_FROM(data, BPHYS_DATA_TIMES, times);
 
-       if (boid)
+       if (boid) {
                PTCACHE_DATA_FROM(data, BPHYS_DATA_BOIDS, &boid->data);
+       }
 
        /* return flag 1+1=2 for newly born particles to copy exact birth location to previously cached frame */
        return 1 + (pa->state.time >= pa->time && pa->prev_state.time <= pa->time);
@@ -304,8 +305,9 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
        else if (cfra > pa->dietime)
                pa->state.time = pa->dietime;
 
-       if (data[BPHYS_DATA_SIZE])
+       if (data[BPHYS_DATA_SIZE]) {
                PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size);
+       }
        
        if (data[BPHYS_DATA_TIMES]) {
                float times[3];
@@ -926,7 +928,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
        /* version header */
        ptcache_file_read(pf, version, 1, sizeof(char) * 4);
        if (strncmp(version, DPAINT_CACHE_VERSION, 4)) {
-               printf("Dynamic Paint: Invalid cache version: %s!\n", version);
+               printf("Dynamic Paint: Invalid cache version: '%c%c%c%c'!\n", UNPACK4(version));
                return 0;
        }
 
index 0daa9de3ae268100f2e22e12687def4e9639d5c8..f0c01e2559810bfae8aae2e1a7abf8707793825a 100644 (file)
@@ -2624,10 +2624,6 @@ void txt_indent(Text *text)
                return;
        }
 
-       if (!text) return;
-       if (!text->curl) return;
-       if (!text->sell) return;
-
        /* insert spaces rather than tabs */
        if (text->flags & TXT_TABSTOSPACES) {
                add = tab_to_spaces;
@@ -2687,9 +2683,9 @@ void txt_unindent(Text *text)
        /* hardcoded: TXT_TABSIZE = 4 spaces: */
        int spaceslen = TXT_TABSIZE;
 
-       if (!text) return;
-       if (!text->curl) return;
-       if (!text->sell) return;
+       if (ELEM3(NULL, text, text->curl, text->sell)) {
+               return;
+       }
 
        /* insert spaces rather than tabs */
        if (text->flags & TXT_TABSTOSPACES) {
index fe835e7cadc85c602a2312f92397d0b0f8e72b38..879ef8696530522b132b42c5801fd7b3b41e0c40 100644 (file)
@@ -53,7 +53,7 @@ enum {
 
 #define BLI_buffer_declare_static(type_, name_, flag_, static_count_) \
        char name_ ## user;  /* warn for free only */ \
-       type_ *name_ ## _static_[static_count_]; \
+       type_ name_ ## _static_[static_count_]; \
        BLI_Buffer name_ = { \
        /* clear the static memory if this is a calloc'd array */ \
        ((void)((flag_ & BLI_BUFFER_USE_CALLOC) ? \
index 723122d7814cfc348e950873182df860a5e8b0f4..a4b0f449dc3242a62e2298d5d8ecee33c37b3102 100644 (file)
@@ -133,12 +133,12 @@ void normalize_m4_m4(float R[4][4], float A[4][4]);
 void orthogonalize_m3(float R[3][3], int axis);
 void orthogonalize_m4(float R[4][4], int axis);
 
-int is_orthogonal_m3(float mat[3][3]);
-int is_orthogonal_m4(float mat[4][4]);
-int is_orthonormal_m3(float mat[3][3]);
-int is_orthonormal_m4(float mat[4][4]);
+bool is_orthogonal_m3(float mat[3][3]);
+bool is_orthogonal_m4(float mat[4][4]);
+bool is_orthonormal_m3(float mat[3][3]);
+bool is_orthonormal_m4(float mat[4][4]);
 
-int is_uniform_scaled_m3(float mat[3][3]);
+bool is_uniform_scaled_m3(float mat[3][3]);
 
 void adjoint_m2_m2(float R[2][2], float A[2][2]);
 void adjoint_m3_m3(float R[3][3], float A[3][3]);
@@ -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 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]);
@@ -194,8 +194,11 @@ void loc_axisangle_size_to_mat4(float R[4][4],
 void blend_m3_m3m3(float R[3][3], float A[3][3], float B[3][3], const float t);
 void blend_m4_m4m4(float R[4][4], float A[4][4], float B[4][4], const float t);
 
-int is_negative_m3(float mat[3][3]);
-int is_negative_m4(float mat[4][4]);
+bool is_negative_m3(float mat[3][3]);
+bool is_negative_m4(float mat[4][4]);
+
+bool is_zero_m3(float mat[3][3]);
+bool is_zero_m4(float mat[4][4]);
 
 /*********************************** Other ***********************************/
 
index 02eb0734f8cf6a6bcc56d232de72b2037410c351..4816ac19fce9299b0e78fb5c2bb074ed02b2ba27 100644 (file)
@@ -86,7 +86,7 @@ __attribute__((nonnull))
 #endif
 ;
 
-char *BLI_replacestr(char *__restrict str, const char *__restrict oldText, const char *__restrict newText)
+char *BLI_replacestrN(const char *__restrict str, const char *__restrict substr_old, const char *__restrict substr_new)
 #ifdef __GNUC__
 __attribute__((warn_unused_result))
 __attribute__((nonnull))
index af0359c00872a8a52cebb4e187686a643d6533a8..4809ba59aaf7c4412310ffea5fc79c7afd667bc8 100644 (file)
@@ -911,18 +911,15 @@ void BLI_dir_create_recursive(const char *dirname)
        char static_buf[MAXPATHLEN];
 #endif
        char *tmp;
-       int needs_free;
 
        if (BLI_exists(dirname)) return;
 
 #ifdef MAXPATHLEN
        size = MAXPATHLEN;
        tmp = static_buf;
-       needs_free = 0;
 #else
        size = strlen(dirname) + 1;
-       tmp = MEM_callocN(size, "BLI_dir_create_recursive tmp");
-       needs_free = 1;
+       tmp = MEM_callocN(size, __func__);
 #endif
 
        BLI_strncpy(tmp, dirname, size);
@@ -934,8 +931,9 @@ void BLI_dir_create_recursive(const char *dirname)
                BLI_dir_create_recursive(tmp);
        }
 
-       if (needs_free)
-               MEM_freeN(tmp);
+#ifndef MAXPATHLEN
+       MEM_freeN(tmp);
+#endif
 
        mkdir(dirname, 0777);
 }
index 312805e23f64c301be5fe962fd1fa1d01f0f385c..8565698110e26fc6fe396431465ba9f9ab354d4e 100644 (file)
@@ -930,7 +930,7 @@ void orthogonalize_m4(float mat[4][4], int axis)
        mul_v3_fl(mat[2], size[2]);
 }
 
-int is_orthogonal_m3(float m[3][3])
+bool is_orthogonal_m3(float m[3][3])
 {
        int i, j;
 
@@ -944,7 +944,7 @@ int is_orthogonal_m3(float m[3][3])
        return 1;
 }
 
-int is_orthogonal_m4(float m[4][4])
+bool is_orthogonal_m4(float m[4][4])
 {
        int i, j;
 
@@ -959,7 +959,7 @@ int is_orthogonal_m4(float m[4][4])
        return 1;
 }
 
-int is_orthonormal_m3(float m[3][3])
+bool is_orthonormal_m3(float m[3][3])
 {
        if (is_orthogonal_m3(m)) {
                int i;
@@ -974,7 +974,7 @@ int is_orthonormal_m3(float m[3][3])
        return 0;
 }
 
-int is_orthonormal_m4(float m[4][4])
+bool is_orthonormal_m4(float m[4][4])
 {
        if (is_orthogonal_m4(m)) {
                int i;
@@ -989,7 +989,7 @@ int is_orthonormal_m4(float m[4][4])
        return 0;
 }
 
-int is_uniform_scaled_m3(float m[3][3])
+bool is_uniform_scaled_m3(float m[3][3])
 {
        const float eps = 1e-7;
        float t[3][3];
@@ -1374,6 +1374,21 @@ 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])
+{
+       float tmat[4][4];
+
+       unit_m4(tmat);
+
+       copy_v3_v3(tmat[3], pivot);
+       mul_m4_m4m4(mat, tmat, mat);
+
+       /* invert the matrix */
+       negate_v3(tmat[3]);
+       mul_m4_m4m4(mat, mat, tmat);
+}
+
 void blend_m3_m3m3(float out[3][3], float dst[3][3], float src[3][3], const float srcweight)
 {
        float srot[3][3], drot[3][3];
@@ -1419,20 +1434,34 @@ void blend_m4_m4m4(float out[4][4], float dst[4][4], float src[4][4], const floa
        loc_quat_size_to_mat4(out, floc, fquat, fsize);
 }
 
-int is_negative_m3(float mat[3][3])
+bool is_negative_m3(float mat[3][3])
 {
        float vec[3];
        cross_v3_v3v3(vec, mat[0], mat[1]);
        return (dot_v3v3(vec, mat[2]) < 0.0f);
 }
 
-int is_negative_m4(float mat[4][4])
+bool is_negative_m4(float mat[4][4])
 {
        float vec[3];
        cross_v3_v3v3(vec, mat[0], mat[1]);
        return (dot_v3v3(vec, mat[2]) < 0.0f);
 }
 
+bool is_zero_m3(float mat[3][3])
+{
+       return (is_zero_v3(mat[0]) &&
+               is_zero_v3(mat[1]) &&
+               is_zero_v3(mat[2]));
+}
+bool is_zero_m4(float mat[4][4])
+{
+       return (is_zero_v4(mat[0]) &&
+               is_zero_v4(mat[1]) &&
+               is_zero_v4(mat[2]) &&
+               is_zero_v4(mat[3]));
+}
+
 /* make a 4x4 matrix out of 3 transform components */
 /* matrices are made in the order: scale * rot * loc */
 /* TODO: need to have a version that allows for rotation order... */
index 3de57ccb54f313d9d591f4425b30b813cf878aaf..5bd07ac877895caf2c1e0ad4cc77d43165b22686 100644 (file)
@@ -305,34 +305,30 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
 }
 
 /**
+ * string with all instances of substr_old replaced with substr_new,
  * Returns a copy of the cstring \a str into a newly mallocN'd
- * string with all instances of oldText replaced with newText,
  * and returns it.
  *
  * \note A rather wasteful string-replacement utility, though this shall do for now...
  * Feel free to replace this with an even safe + nicer alternative
  *
- * \param str The string to replace occurrences of oldText in
- * \param oldText The text in the string to find and replace
- * \param newText The text in the string to find and replace
+ * \param str The string to replace occurrences of substr_old in
+ * \param substr_old The text in the string to find and replace
+ * \param substr_new The text in the string to find and replace
  * \retval Returns the duplicated string
  */
-char *BLI_replacestr(char *__restrict str, const char *__restrict oldText, const char *__restrict newText)
+char *BLI_replacestrN(const char *__restrict str, const char *__restrict substr_old, const char *__restrict substr_new)
 {
        DynStr *ds = NULL;
-       size_t lenOld = strlen(oldText);
-       char *match;
-       
-       /* sanity checks */
-       if ((str == NULL) || (str[0] == 0))
-               return NULL;
-       else if ((oldText == NULL) || (newText == NULL) || (oldText[0] == 0))
-               return BLI_strdup(str);
-       
+       size_t len_old = strlen(substr_old);
+       const char *match;
+
+       BLI_assert(substr_old[0] != '\0');
+
        /* while we can still find a match for the old substring that we're searching for, 
         * keep dicing and replacing
         */
-       while ( (match = strstr(str, oldText)) ) {
+       while ((match = strstr(str, substr_old))) {
                /* the assembly buffer only gets created when we actually need to rebuild the string */
                if (ds == NULL)
                        ds = BLI_dynstr_new();
@@ -341,27 +337,24 @@ char *BLI_replacestr(char *__restrict str, const char *__restrict oldText, const
                 * copy the text up to this position and advance the current position in the string
                 */
                if (str != match) {
-                       /* replace the token at the 'match' position with \0 so that the copied string will be ok,
-                        * add the segment of the string from str to match to the buffer, then restore the value at match
+                       /* add the segment of the string from str to match to the buffer, then restore the value at match
                         */
-                       match[0] = 0;
-                       BLI_dynstr_append(ds, str);
-                       match[0] = oldText[0];
+                       BLI_dynstr_nappend(ds, str, (match - str));
                        
                        /* now our current position should be set on the start of the match */
                        str = match;
                }
                
                /* add the replacement text to the accumulation buffer */
-               BLI_dynstr_append(ds, newText);
+               BLI_dynstr_append(ds, substr_new);
                
                /* advance the current position of the string up to the end of the replaced segment */
-               str += lenOld;
+               str += len_old;
        }
        
        /* finish off and return a new string that has had all occurrences of */
        if (ds) {
-               char *newStr;
+               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
@@ -370,10 +363,10 @@ char *BLI_replacestr(char *__restrict str, const char *__restrict oldText, const
                        BLI_dynstr_append(ds, str);
                
                /* convert to new c-string (MEM_malloc'd), and free the buffer */
-               newStr = BLI_dynstr_get_cstring(ds);
+               str_new = BLI_dynstr_get_cstring(ds);
                BLI_dynstr_free(ds);
                
-               return newStr;
+               return str_new;
        }
        else {
                /* just create a new copy of the entire string - we avoid going through the assembly buffer 
index 350c1d71a434a47eab6cbaf04133531bcda629a6..c49c290e81e6cebff62d410acbe8822f045417b2 100644 (file)
@@ -51,6 +51,7 @@ set(SRC
        operators/bmo_extrude.c
        operators/bmo_fill_edgeloop.c
        operators/bmo_fill_grid.c
+       operators/bmo_fill_holes.c
        operators/bmo_hull.c
        operators/bmo_inset.c
        operators/bmo_join_triangles.c
index 39b127c410e71e2ae8ad4adbd79e6d51e3393f28..4d3653b1a82edd44170e3142aca157b5db7aa553 100644 (file)
@@ -200,6 +200,8 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, c
        ev1 = edges[0]->v1;
        ev2 = edges[0]->v2;
 
+       BLI_assert(ELEM(v1, ev1, ev2) && ELEM(v2, ev1, ev2));
+
        if (v1 == ev2) {
                /* Swapping here improves performance and consistency of face
                 * structure in the special case that the edges are already in
@@ -322,6 +324,7 @@ BMFace *BM_face_create_ngon_verts(BMesh *bm, BMVert **vert_arr, const int len, c
        BMEdge **edge_arr = BLI_array_alloca(edge_arr, len);
        unsigned int winding[2] = {0, 0};
        int i, i_prev = len - 1;
+       BMVert *v_winding[2] = {vert_arr[i_prev], vert_arr[0]};
 
        BLI_assert(len > 2);
 
@@ -344,6 +347,7 @@ BMFace *BM_face_create_ngon_verts(BMesh *bm, BMVert **vert_arr, const int len, c
                                /* we want to use the reverse winding to the existing order */
                                BM_edge_ordered_verts(edge_arr[i], &test_v2, &test_v1);
                                winding[(vert_arr[i_prev] == test_v2)]++;
+                               BLI_assert(vert_arr[i_prev] == test_v2 || vert_arr[i_prev] == test_v1);
                        }
                }
 
@@ -370,7 +374,11 @@ BMFace *BM_face_create_ngon_verts(BMesh *bm, BMVert **vert_arr, const int len, c
        /* --- */
 
        /* create the face */
-       return BM_face_create_ngon(bm, vert_arr[winding[0]], vert_arr[winding[1]], edge_arr, len, create_flag);
+       return BM_face_create_ngon(
+               bm,
+               v_winding[winding[0]],
+               v_winding[winding[1]],
+               edge_arr, len, create_flag);
 }
 
 
index cb8e9bd70040d9fa343781bd9f054000fb8f176b..77cb2717f8419201f57d97eeba10dfa6197b8bb0 100644 (file)
@@ -1073,7 +1073,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f
        f_hflag_prev_1 = l1->f->head.hflag;
        f_hflag_prev_2 = l2->f->head.hflag;
 
-       /* don't delete the edge, manually remove the egde after so we can copy its attributes */
+       /* don't delete the edge, manually remove the edge after so we can copy its attributes */
        f = BM_faces_join_pair(bm, l1->f, l2->f, NULL, true);
 
        if (f == NULL) {
index 497c9e1c153d6ff80329754a71f5b124144ffa9a..b56ed15b901d58026d0947d23bf208695ffb5f1e 100644 (file)
@@ -518,6 +518,7 @@ static BMOpDefine bmo_bridge_loops_def = {
         {"use_cyclic",         BMO_OP_SLOT_BOOL},
         {"use_merge",          BMO_OP_SLOT_BOOL},
         {"merge_factor",       BMO_OP_SLOT_FLT},
+        {"twist_offset",       BMO_OP_SLOT_INT},
         {{'\0'}},
        },
        /* slots_out */
@@ -552,6 +553,29 @@ static BMOpDefine bmo_grid_fill_def = {
        BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
 };
 
+
+/*
+ * Fill Holes.
+ *
+ * Fill boundary edges with faces, copying surrounding customdata.
+ */
+static BMOpDefine bmo_holes_fill_def = {
+       "holes_fill",
+       /* slots_in */
+       {{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* input edges */
+        {"sides",          BMO_OP_SLOT_INT},   /* number of face sides to fill */
+        {{'\0'}},
+       },
+       /* slots_out */
+       /* maps new faces to the group numbers they came from */
+       {{"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},     /* new faces */
+        {{'\0'}},
+       },
+       bmo_holes_fill_exec,
+       BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
+};
+
+
 /*
  * Edge Loop Fill.
  *
@@ -639,6 +663,7 @@ static BMOpDefine bmo_rotate_def = {
        {{"cent",            BMO_OP_SLOT_VEC},  /* center of rotation */
         {"matrix",          BMO_OP_SLOT_MAT},  /* matrix defining rotation */
         {"verts",           BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},  /* input vertices */
+        {"space",           BMO_OP_SLOT_MAT},  /* matrix to define the space (typically object matrix) */
         {{'\0'}},
        },
        {{{'\0'}}},  /* no output */
@@ -655,6 +680,7 @@ static BMOpDefine bmo_translate_def = {
        "translate",
        /* slots_in */
        {{"vec", BMO_OP_SLOT_VEC},  /* translation offset */
+        {"space", BMO_OP_SLOT_MAT},  /* matrix to define the space (typically object matrix) */
         {"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},  /* input vertices */
         {{'\0'}},
        },
@@ -672,6 +698,7 @@ static BMOpDefine bmo_scale_def = {
        "scale",
        /* slots_in */
        {{"vec", BMO_OP_SLOT_VEC},  /* scale factor */
+        {"space", BMO_OP_SLOT_MAT},  /* matrix to define the space (typically object matrix) */
         {"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},  /* input vertices */
         {{'\0'}},
        },
@@ -691,6 +718,7 @@ static BMOpDefine bmo_transform_def = {
        "transform",
        /* slots_in */
        {{"matrix",          BMO_OP_SLOT_MAT},  /* transform matrix */
+        {"space",           BMO_OP_SLOT_MAT},  /* matrix to define the space (typically object matrix) */
         {"verts",           BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},  /* input vertices */
         {{'\0'}},
        },
@@ -947,7 +975,9 @@ static BMOpDefine bmo_dissolve_limit_def = {
         {"delimit", BMO_OP_SLOT_INT},
         {{'\0'}},
        },
-       {{{'\0'}}},  /* no output */
+       /* slots_out */
+       {{"region.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},
+        {{'\0'}}},
        bmo_dissolve_limit_exec,
        BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
 };
@@ -1044,7 +1074,7 @@ static BMOpDefine bmo_subdivide_edgering_def = {
         {{'\0'}},
        },
        {{"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* output faces */
-        {{'\0'}}},  /* no output */
+        {{'\0'}}},
        bmo_subdivide_edgering_exec,
        BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
 };
@@ -1133,6 +1163,7 @@ static BMOpDefine bmo_spin_def = {
         {"axis", BMO_OP_SLOT_VEC},             /* rotation axis */
         {"dvec", BMO_OP_SLOT_VEC},             /* translation delta per step */
         {"angle", BMO_OP_SLOT_FLT},            /* total rotation angle (radians) */
+        {"space", BMO_OP_SLOT_MAT},            /* matrix to define the space (typically object matrix) */
         {"steps", BMO_OP_SLOT_INT},            /* number of steps */
         {"use_duplicate", BMO_OP_SLOT_BOOL},   /* duplicate or extrude? */
         {{'\0'}},
@@ -1224,7 +1255,6 @@ static BMOpDefine bmo_rotate_uvs_def = {
         {"use_ccw", BMO_OP_SLOT_BOOL},         /* rotate counter-clockwise if true, otherwise clockwise */
         {{'\0'}},
        },
-       /* slots_out */
        {{{'\0'}}},  /* no output */
        bmo_rotate_uvs_exec,
        BMO_OPTYPE_FLAG_NOP,
@@ -1723,6 +1753,7 @@ const BMOpDefine *bmo_opdefines[] = {
        &bmo_dissolve_limit_def,
        &bmo_dissolve_verts_def,
        &bmo_duplicate_def,
+       &bmo_holes_fill_def,
        &bmo_edgeloop_fill_def,
        &bmo_edgenet_fill_def,
        &bmo_edgenet_prepare_def,
index 63c00d5b5456e0cdf92b31cc061c12f8ebaf01e0..e0268d6b504fc3c05a94cb404461dd0ef810f0fa 100644 (file)
@@ -411,7 +411,7 @@ void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], cons
        slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4);
        
        if (size == 4) {
-               memcpy(slot->data.p, mat, sizeof(float) * 4 * 4);
+               copy_m4_m4(slot->data.p, (float (*)[4])mat);
        }
        else if (size == 3) {
                copy_m4_m3(slot->data.p, (float (*)[3])mat);
index e6a4760060c2d7ced6560879829afa1f7b862f8f..e029ad0d12420526d2744781e6a3cada115a2bb5 100644 (file)
@@ -58,6 +58,7 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op);
 void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op);
 void bmo_duplicate_exec(BMesh *bm, BMOperator *op);
 void bmo_edgeloop_fill_exec(BMesh *bm, BMOperator *op);
+void bmo_holes_fill_exec(BMesh *bm, BMOperator *op);
 void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op);
 void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op);
 void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op);
index 2c0bc7f95d9bd2f44a44edbcd0dbac3bf111d3b3..22b686db64e1cf143f60253c722c0f802591cd0d 100644 (file)
@@ -276,7 +276,7 @@ static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode *
        }
 }
 
-/* we have rotated an edge, tag other egdes and clear this one */
+/* we have rotated an edge, tag other edges and clear this one */
 static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GHash **edge_state_arr,
                                        const int flag)
 {
@@ -415,9 +415,9 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
 
                /* edge is manifold and can be rotated */
                if (BM_edge_rotate_check(e) &&
-                       /* faces are tagged */
-                       BMO_elem_flag_test(bm, e->l->f, FACE_MARK) &&
-                       BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK))
+                   /* faces are tagged */
+                   BMO_elem_flag_test(bm, e->l->f, FACE_MARK) &&
+                   BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK))
                {
                        BM_elem_index_set(e, edge_array_len);  /* set_dirty */
                        BM_elem_flag_enable(e, BM_ELEM_TAG);
index 5b046524e9537a45052c3547c76cae5f2727f3a9..f63e742d8ba648f4770e9300c573c6348d922335 100644 (file)
@@ -142,7 +142,7 @@ static bool bm_edge_test_cb(BMEdge *e, void *bm_v)
 static void bridge_loop_pair(BMesh *bm,
                              struct BMEdgeLoopStore *el_store_a,
                              struct BMEdgeLoopStore *el_store_b,
-                             const bool use_merge, const float merge_factor)
+                             const bool use_merge, const float merge_factor, const int twist_offset)
 {
        const float eps = 0.00001f;
        LinkData *el_a_first, *el_b_first;
@@ -268,6 +268,15 @@ static void bridge_loop_pair(BMesh *bm,
 
        if (is_closed) {
                bm_bridge_best_rotation(el_store_a, el_store_b);
+
+               /* add twist */
+               if (twist_offset != 0) {
+                       const int len_b = BM_edgeloop_length_get(el_store_b);
+                       ListBase *lb_b = BM_edgeloop_verts_get(el_store_b);
+                       const int offset = twist_offset % len_b;
+                       LinkData *el_b = BLI_rfindlink(lb_b, (offset < 0) ? (offset + len_b) : offset);
+                       BLI_rotatelist(lb_b, el_b);
+               }
        }
 
        /* Assign after flipping is finalized */
@@ -476,6 +485,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
        const bool  use_merge    = BMO_slot_bool_get(op->slots_in,  "use_merge");
        const float merge_factor = BMO_slot_float_get(op->slots_in, "merge_factor");
        const bool  use_cyclic   = BMO_slot_bool_get(op->slots_in,  "use_cyclic") && (use_merge == false);
+       const int   twist_offset = BMO_slot_int_get(op->slots_in,   "twist_offset");
        int count;
        bool change = false;
 
@@ -535,7 +545,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
                bridge_loop_pair(bm,
                                 (struct BMEdgeLoopStore *)el_store,
                                 (struct BMEdgeLoopStore *)el_store_next,
-                                use_merge, merge_factor);
+                                use_merge, merge_factor, twist_offset);
                if (use_pairs) {
                        el_store = el_store->next;
                }
index e4f2423ca17805d995768890bd6af663735c9429..a3f674503806e87d95045a75b3ad454b99926d18 100644 (file)
@@ -430,5 +430,8 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op)
 
        BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries, delimit,
                                     (BMVert **)BMO_SLOT_AS_BUFFER(vinput), vinput->len,
-                                    (BMEdge **)BMO_SLOT_AS_BUFFER(einput), einput->len);
+                                    (BMEdge **)BMO_SLOT_AS_BUFFER(einput), einput->len,
+                                    FACE_NEW);
+
+       BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "region.out", BM_FACE, FACE_NEW);
 }
index 481039694740db1a535a2f5b165289d5346512bf..59e018eccf136c22a7fd086fe79eae5649b50920 100644 (file)
@@ -489,8 +489,8 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op)
                        BMO_op_initf(bm, &dupop, op->flag, "duplicate geom=%S", op, "geom_last.out");
                        BMO_op_exec(bm, &dupop);
                        BMO_op_callf(bm, op->flag,
-                                    "rotate cent=%v matrix=%m3 verts=%S",
-                                    cent, rmat, &dupop, "geom.out");
+                                    "rotate cent=%v matrix=%m3 space=%s verts=%S",
+                                    cent, rmat, op, "space", &dupop, "geom.out");
                        BMO_slot_copy(&dupop, slots_out, "geom.out",
                                      op,     slots_out, "geom_last.out");
                        BMO_op_finish(bm, &dupop);
@@ -500,8 +500,8 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op)
                                     op, "geom_last.out");
                        BMO_op_exec(bm, &extop);
                        BMO_op_callf(bm, op->flag,
-                                    "rotate cent=%v matrix=%m3 verts=%S",
-                                    cent, rmat, &extop, "geom.out");
+                                    "rotate cent=%v matrix=%m3 space=%s verts=%S",
+                                    cent, rmat, op, "space", &extop, "geom.out");
                        BMO_slot_copy(&extop, slots_out, "geom.out",
                                      op,     slots_out, "geom_last.out");
                        BMO_op_finish(bm, &extop);
@@ -510,8 +510,8 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op)
                if (usedvec) {
                        mul_m3_v3(rmat, dvec);
                        BMO_op_callf(bm, op->flag,
-                                    "translate vec=%v verts=%S",
-                                    dvec, op, "geom_last.out");
+                                    "translate vec=%v space=%s verts=%S",
+                                    dvec, op, "space", op, "geom_last.out");
                }
        }
 }
diff --git a/source/blender/bmesh/operators/bmo_fill_holes.c b/source/blender/bmesh/operators/bmo_fill_holes.c
new file mode 100644 (file)
index 0000000..dca8644
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * ***** 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_fill_holes.c
+ *  \ingroup bmesh
+ *
+ * Fill boundary edge loop(s) with faces.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_array.h"
+#include "BLI_math.h"
+
+#include "bmesh.h"
+
+#include "intern/bmesh_operators_private.h" /* own include */
+
+#define EDGE_MARK      2
+#define ELE_OUT                4
+
+/**
+ * Clone of BM_face_find_longest_loop that ensures the loop has an adjacent face
+ */
+static BMLoop *bm_face_find_longest_loop_manifold(BMFace *f)
+{
+       BMLoop *longest_loop = NULL;
+       float longest_len = 0.0f;
+       BMLoop *l_iter, *l_first;
+
+       l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+
+       do {
+               if (BM_edge_is_wire(l_iter->e) == false) {
+                       const float len = len_squared_v3v3(l_iter->v->co, l_iter->next->v->co);
+                       if (len >= longest_len) {
+                               longest_loop = l_iter;
+                               longest_len = len;
+                       }
+               }
+       } while ((l_iter = l_iter->next) != l_first);
+
+       return longest_loop;
+}
+
+static BMFace *bm_face_from_eloop(BMesh *bm, struct BMEdgeLoopStore *el_store)
+{
+       LinkData *node = BM_edgeloop_verts_get(el_store)->first;
+       const int len = BM_edgeloop_length_get(el_store);
+       BMVert **f_verts = BLI_array_alloca(f_verts, len);
+       BMFace *f;
+       BMLoop *l;
+       unsigned int i = 0;
+
+       do {
+               f_verts[i++] = node->data;
+       } while ((node = node->next));
+
+       f = BM_face_create_ngon_verts(bm, f_verts, len, 0, true, false);
+       BM_face_copy_shared(bm, f);
+
+       l = bm_face_find_longest_loop_manifold(f);
+       if (l) {
+               BMFace *f_other = l->radial_next->f;
+               BLI_assert(l->radial_next != l);
+               BM_elem_attrs_copy(bm, bm, f_other, f);
+       }
+
+       return f;
+}
+
+static bool bm_edge_test_cb(BMEdge *e, void *bm_v)
+{
+       return BMO_elem_flag_test((BMesh *)bm_v, e, EDGE_MARK);
+}
+
+void bmo_holes_fill_exec(BMesh *bm, BMOperator *op)
+{
+       ListBase eloops = {NULL, NULL};
+       LinkData *el_store;
+
+       BMEdge *e;
+       int count;
+
+       BMOIter siter;
+
+       const int  sides    = BMO_slot_int_get(op->slots_in,  "sides");
+
+       /* clear tags */
+
+       BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, false);
+
+       /* tag edges that may be apart of loops */
+       BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
+               BMO_elem_flag_set(bm, e, EDGE_MARK, BM_edge_is_boundary(e));
+       }
+
+       count = BM_mesh_edgeloops_find(bm, &eloops, bm_edge_test_cb, (void *)bm);
+
+       for (el_store = eloops.first; el_store; el_store = el_store->next) {
+               if (BM_edgeloop_is_closed((struct BMEdgeLoopStore *)el_store)) {
+                       const int len = BM_edgeloop_length_get((struct BMEdgeLoopStore *)el_store);
+                       if ((sides == 0) || (len <= sides)) {
+                               BMFace *f;
+
+                               f = bm_face_from_eloop(bm, (struct BMEdgeLoopStore *)el_store);
+                               BMO_elem_flag_enable(bm, f, ELE_OUT);
+                       }
+               }
+       }
+
+       (void)count;
+
+       BM_mesh_edgeloops_free(&eloops);
+
+       BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, ELE_OUT);
+}
index 39f7b0953b1d2953d44d3bfb9b8c4b638398ccbc..5ee03b8a5418426f0d2df6fc8049cd210f7e70ac 100644 (file)
@@ -34,7 +34,6 @@
 #include "DNA_meshdata_types.h"
 
 #include "BLI_math.h"
-#include "BLI_array.h"
 
 #include "BKE_customdata.h"
 
@@ -42,6 +41,8 @@
 
 #include "intern/bmesh_operators_private.h" /* own include */
 
+#define FACE_OUT (1 << 0)
+
 /* assumes edges are validated before reaching this poin */
 static float measure_facepair(const float v1[3], const float v2[3],
                               const float v3[3], const float v4[3], float limit)
@@ -195,10 +196,9 @@ static int fplcmp(const void *v1, const void *v2)
 {
        const JoinEdge *e1 = (JoinEdge *)v1, *e2 = (JoinEdge *)v2;
 
-       if (e1->weight > e2->weight) return 1;
+       if      (e1->weight > e2->weight) return  1;
        else if (e1->weight < e2->weight) return -1;
-
-       return 0;
+       else                              return  0;
 }
 
 void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
@@ -210,148 +210,138 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
        const bool do_mat   = BMO_slot_bool_get(op->slots_in, "cmp_materials");
        const float limit   = BMO_slot_float_get(op->slots_in, "limit");
 
-       BMIter iter, liter;
+       BMIter iter;
        BMOIter siter;
        BMFace *f;
-       BMLoop *l;
        BMEdge *e;
-       BLI_array_declare(jedges);
        JoinEdge *jedges = NULL;
-       int i, totedge;
+       unsigned i, totedge;
+       unsigned int totedge_tag = 0;
 
        /* flag all edges of all input face */
        BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
                BMO_elem_flag_enable(bm, f, FACE_INPUT);
-               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
-                       BMO_elem_flag_enable(bm, l->e, EDGE_MARK);
-               }
        }
 
-       /* unflag edges that are invalid; e.g. aren't surrounded by triangle */
+       /* flag edges surrounded by 2 flagged triangles */
        BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
-               BMFace *f1, *f2;
-               if (!BMO_elem_flag_test(bm, e, EDGE_MARK))
-                       continue;
-
-               if (!BM_edge_face_pair(e, &f1, &f2)) {
-                       BMO_elem_flag_disable(bm, e, EDGE_MARK);
-                       continue;
-               }
-
-               if (f1->len != 3 || f2->len != 3) {
-                       BMO_elem_flag_disable(bm, e, EDGE_MARK);
-                       continue;
+               BMFace *f_a, *f_b;
+               if (BM_edge_face_pair(e, &f_a, &f_b) &&
+                   (f_a->len == 3 && f_b->len == 3) &&
+                   (BMO_elem_flag_test(bm, f_a, FACE_INPUT) && BMO_elem_flag_test(bm, f_b, FACE_INPUT)))
+               {
+                       BMO_elem_flag_enable(bm, e, EDGE_MARK);
+                       totedge_tag++;
                }
+       }
 
-               if (!BMO_elem_flag_test(bm, f1, FACE_INPUT) || !BMO_elem_flag_test(bm, f2, FACE_INPUT)) {
-                       BMO_elem_flag_disable(bm, e, EDGE_MARK);
-                       continue;
-               }
+       if (totedge_tag == 0) {
+               return;
        }
-       
+
+       /* over alloc, some of the edges will be delimited */
+       jedges = MEM_mallocN(sizeof(*jedges) * totedge_tag, __func__);
+
        i = 0;
        BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                BMVert *v1, *v2, *v3, *v4;
-               BMFace *f1, *f2;
+               BMFace *f_a, *f_b;
                float measure;
 
                if (!BMO_elem_flag_test(bm, e, EDGE_MARK))
                        continue;
 
-               f1 = e->l->f;
-               f2 = e->l->radial_next->f;
-
-               v1 = e->l->v;
-               v2 = e->l->prev->v;
-               v3 = e->l->next->v;
-               v4 = e->l->radial_next->prev->v;
+               f_a = e->l->f;
+               f_b = e->l->radial_next->f;
 
                if (do_sharp && !BM_elem_flag_test(e, BM_ELEM_SMOOTH))
                        continue;
 
-               if (do_mat && f1->mat_nr != f2->mat_nr)
+               if (do_mat && f_a->mat_nr != f_b->mat_nr)
                        continue;
 
                if ((do_uv || do_tf || do_vcol) && (bm_edge_faces_cmp(bm, e, do_uv, do_tf, do_vcol) == false))
                        continue;
 
+               v1 = e->l->v;
+               v2 = e->l->prev->v;
+               v3 = e->l->next->v;
+               v4 = e->l->radial_next->prev->v;
+
                measure = measure_facepair(v1->co, v2->co, v3->co, v4->co, limit);
                if (measure < limit) {
-                       BLI_array_grow_one(jedges);
-
                        jedges[i].e = e;
                        jedges[i].weight = measure;
-
                        i++;
                }
        }
 
-       if (!jedges)
-               return;
+       totedge = i;
+       qsort(jedges, totedge, sizeof(JoinEdge), fplcmp);
 
-       qsort(jedges, BLI_array_count(jedges), sizeof(JoinEdge), fplcmp);
-
-       totedge = BLI_array_count(jedges);
        for (i = 0; i < totedge; i++) {
-               BMFace *f1, *f2;
+               BMFace *f_a, *f_b;
 
                e = jedges[i].e;
-               f1 = e->l->f;
-               f2 = e->l->radial_next->f;
-
-               if (BMO_elem_flag_test(bm, f1, FACE_MARK) || BMO_elem_flag_test(bm, f2, FACE_MARK))
-                       continue;
+               f_a = e->l->f;
+               f_b = e->l->radial_next->f;
 
-               BMO_elem_flag_enable(bm, f1, FACE_MARK);
-               BMO_elem_flag_enable(bm, f2, FACE_MARK);
-               BMO_elem_flag_enable(bm, e, EDGE_CHOSEN);
+               /* check if another edge already claimed this face */
+               if ((BMO_elem_flag_test(bm, f_a, FACE_MARK) == false) ||
+                   (BMO_elem_flag_test(bm, f_b, FACE_MARK) == false))
+               {
+                       BMO_elem_flag_enable(bm, f_a, FACE_MARK);
+                       BMO_elem_flag_enable(bm, f_b, FACE_MARK);
+                       BMO_elem_flag_enable(bm, e, EDGE_CHOSEN);
+               }
        }
 
+       MEM_freeN(jedges);
+
+       /* join best weighted */
        BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
-               BMFace *f1, *f2;
+               BMFace *f_new;
+               BMFace *f_a, *f_b;
 
                if (!BMO_elem_flag_test(bm, e, EDGE_CHOSEN))
                        continue;
 
-
-               BM_edge_face_pair(e, &f1, &f2); /* checked above */
-               BM_faces_join_pair(bm, f1, f2, e, true);
+               BM_edge_face_pair(e, &f_a, &f_b); /* checked above */
+               f_new = BM_faces_join_pair(bm, f_a, f_b, e, true);
+               if (f_new) {
+                       BMO_elem_flag_enable(bm, f_new, FACE_OUT);
+               }
        }
 
+       /* join 2-tri islands */
        BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (BMO_elem_flag_test(bm, e, EDGE_MARK)) {
-                       BMFace *f1, *f2;
+                       BMLoop *l_a, *l_b;
+                       BMFace *f_a, *f_b;
 
                        /* ok, this edge wasn't merged, check if it's
-                        * in a 2-tri-pair island, and if so merg */
+                        * in a 2-tri-pair island, and if so merge */
+                       l_a = e->l;
+                       l_b = e->l->radial_next;
 
-                       f1 = e->l->f;
-                       f2 = e->l->radial_next->f;
+                       f_a = l_a->f;
+                       f_b = l_b->f;
                        
-                       if (f1->len != 3 || f2->len != 3)
-                               continue;
-
-                       for (i = 0; i < 2; i++) {
-                               BM_ITER_ELEM (l, &liter, i ? f2 : f1, BM_LOOPS_OF_FACE) {
-                                       if (l->e != e && BMO_elem_flag_test(bm, l->e, EDGE_MARK)) {
-                                               break;
-                                       }
-                               }
-                               
-                               /* if l isn't NULL, we broke out of the loop */
-                               if (l) {
-                                       break;
+                       /* check the other 2 edges in both tris are untagged */
+                       if ((f_a->len == 3 && f_b->len == 3) &&
+                           (BMO_elem_flag_test(bm, l_a->next->e, EDGE_MARK) == false) &&
+                           (BMO_elem_flag_test(bm, l_a->prev->e, EDGE_MARK) == false) &&
+                           (BMO_elem_flag_test(bm, l_b->next->e, EDGE_MARK) == false) &&
+                           (BMO_elem_flag_test(bm, l_b->prev->e, EDGE_MARK) == false))
+                       {
+                               BMFace *f_new;
+                               f_new = BM_faces_join_pair(bm, f_a, f_b, e, true);
+                               if (f_new) {
+                                       BMO_elem_flag_enable(bm, f_new, FACE_OUT);
                                }
                        }
-
-                       /* if i isn't 2, we broke out of that loop */
-                       if (i != 2) {
-                               continue;
-                       }
-
-                       BM_faces_join_pair(bm, f1, f2, e, true);
                }
        }
 
-       BLI_array_free(jedges);
+       BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_OUT);
 }
index 44d4b63f5c40c51bbb1a8c37193d1a000a842418..f69d2f27346ea8b2261588921cf7051d87a0d22a 100644 (file)
@@ -1167,6 +1167,7 @@ void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op)
                        bm_edgering_pair_ringsubd(bm, lpair, el_store_a, el_store_b,
                                                  interp_mode, cuts, smooth, falloff_cache);
                        bm_edgering_pair_store_free(lpair, interp_mode);
+                       change = true;
                }
                else {
                        BMO_error_raise(bm, op, BMERR_INVALID_SELECTION,
@@ -1217,6 +1218,7 @@ void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op)
                                bm_edgering_pair_ringsubd(bm, lpair, el_store_a, el_store_b,
                                                          interp_mode, cuts, smooth, falloff_cache);
                                bm_edgering_pair_store_free(lpair, interp_mode);
+                               change = true;
                        }
 
                        BLI_assert(bm_verts_tag_count(bm) == 0);
@@ -1229,6 +1231,6 @@ cleanup:
 
        /* flag output */
        if (change) {
-               BMO_slot_buffer_flag_enable(bm, op->slots_out, "faces.out", BM_FACE, FACE_OUT);
+               BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_OUT);
        }
 }
index 2a0a786449993a7052f65e9e7247501d889f71b9..85bd8a853765e900b8438bbcf8cb2d3d88b1bdbc 100644 (file)
@@ -55,9 +55,15 @@ void bmo_transform_exec(BMesh *UNUSED(bm), BMOperator *op)
 {
        BMOIter iter;
        BMVert *v;
-       float mat[4][4];
+       float mat[4][4], mat_space[4][4], imat_space[4][4];
 
        BMO_slot_mat4_get(op->slots_in, "matrix", mat);
+       BMO_slot_mat4_get(op->slots_in, "space", mat_space);
+
+       if (!is_zero_m4(mat_space)) {
+               invert_m4_m4(imat_space, mat_space);
+               mul_serie_m4(mat, imat_space, mat, mat_space, NULL, NULL, NULL, NULL, NULL);
+       }
 
        BMO_ITER (v, &iter, op->slots_in, "verts", BM_VERT) {
                mul_m4_v3(mat, v->co);
@@ -73,7 +79,7 @@ void bmo_translate_exec(BMesh *bm, BMOperator *op)
        unit_m4(mat);
        copy_v3_v3(mat[3], vec);
 
-       BMO_op_callf(bm, op->flag, "transform matrix=%m4 verts=%s", mat, op, "verts");
+       BMO_op_callf(bm, op->flag, "transform matrix=%m4 space=%s verts=%s", mat, op, "space", op, "verts");
 }
 
 void bmo_scale_exec(BMesh *bm, BMOperator *op)
@@ -87,25 +93,19 @@ void bmo_scale_exec(BMesh *bm, BMOperator *op)
        mat[1][1] = vec[1];
        mat[2][2] = vec[2];
 
-       BMO_op_callf(bm, op->flag, "transform matrix=%m3 verts=%s", mat, op, "verts");
+       BMO_op_callf(bm, op->flag, "transform matrix=%m3 space=%s verts=%s", mat, op, "space", op, "verts");
 }
 
 void bmo_rotate_exec(BMesh *bm, BMOperator *op)
 {
-       float vec[3];
-       
-       BMO_slot_vec_get(op->slots_in, "cent", vec);
-       
-       /* there has to be a proper matrix way to do this, but
-        * this is how editmesh did it and I'm too tired to think
-        * through the math right now. */
-       mul_v3_fl(vec, -1.0f);
-       BMO_op_callf(bm, op->flag, "translate verts=%s vec=%v", op, "verts", vec);
+       float center[3];
+       float mat[4][4];
 
-       BMO_op_callf(bm, op->flag, "transform matrix=%s verts=%s", op, "matrix", op, "verts");
+       BMO_slot_vec_get(op->slots_in, "cent", center);
+       BMO_slot_mat4_get(op->slots_in, "matrix", mat);
+       pivot_m4(mat, center);
 
-       mul_v3_fl(vec, -1.0f);
-       BMO_op_callf(bm, op->flag, "translate verts=%s vec=%v", op, "verts", vec);
+       BMO_op_callf(bm, op->flag, "transform matrix=%m4 space=%s verts=%s", mat, op, "space", op, "verts");
 }
 
 void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op)
index c77cb18c5187c980b7b51e9aa6a84e3ca17f5f97..a1b26990587eb429409c571ee0802dba92b3afc5 100644 (file)
@@ -35,7 +35,8 @@ void BM_mesh_decimate_unsubdivide(BMesh *bm, const int iterations);
 void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                   const BMO_Delimit delimit,
                                   BMVert **vinput_arr, const int vinput_len,
-                                  BMEdge **einput_arr, const int einput_len);
+                                  BMEdge **einput_arr, const int einput_len,
+                                  const short oflag_out);
 void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                const BMO_Delimit delimit);
 
index 9d4e01d19cd64ca0511e62704e1ebb6304bbc63e..9f97d8f4287c39a442db13e89b18372796d8ef6a 100644 (file)
@@ -72,7 +72,8 @@ static int dissolve_elem_cmp(const void *a1, const void *a2)
 void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                   const BMO_Delimit delimit,
                                   BMVert **vinput_arr, const int vinput_len,
-                                  BMEdge **einput_arr, const int einput_len)
+                                  BMEdge **einput_arr, const int einput_len,
+                                  const short oflag_out)
 {
        const float angle_max = (float)M_PI / 2.0f;
        DissolveElemWeight *weight_elems = MEM_mallocN(max_ii(einput_len, vinput_len) *
@@ -155,6 +156,9 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool
                                /* there may be some errors, we don't mind, just move on */
                                if (f_new) {
                                        BM_face_normal_update(f_new);
+                                       if (oflag_out) {
+                                               BMO_elem_flag_enable(bm, f_new, oflag_out);
+                                       }
                                }
                                else {
                                        BMO_error_clear(bm);
@@ -269,7 +273,8 @@ void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const bool do
        BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries,
                                     delimit,
                                     vinput_arr, vinput_len,
-                                    einput_arr, einput_len);
+                                    einput_arr, einput_len,
+                                    0);
 
        MEM_freeN(vinput_arr);
        MEM_freeN(einput_arr);
index eb92b089f481dca9f93a9769f75f3babaded659c..c1ba40d95f92b1a84f8bc54764e769d0660b8627 100644 (file)
@@ -204,16 +204,21 @@ void ArmatureImporter::add_leaf_bone(float mat[4][4], EditBone *bone,  COLLADAFW
 
 void ArmatureImporter::fix_leaf_bones( )
 {
+       // Collada only knows Joints, Here we guess a reasonable
+       // leaf bone length
+       float leaf_length = (leaf_bone_length == FLT_MAX) ? 1.0:leaf_bone_length;
+
        // just setting tail for leaf bones here
        std::vector<LeafBone>::iterator it;
        for (it = leaf_bones.begin(); it != leaf_bones.end(); it++) {
+
                LeafBone& leaf = *it;
 
                // pointing up
                float vec[3] = {0.0f, 0.0f, 0.1f};
                
                sub_v3_v3v3(vec, leaf.bone->tail , leaf.bone->head);
-               mul_v3_fl(vec, leaf_bone_length);
+               mul_v3_fl(vec, leaf_length);
                add_v3_v3v3(leaf.bone->tail, leaf.bone->head , vec);
 
        }
index 54c7f7ea30f81662dc133a8a32943313ffc2825c..c571da1ba7451b9b1ef329223a4cc1cdd2ff06af 100644 (file)
@@ -54,14 +54,14 @@ void ANIM_OT_keyframe_insert_menu(struct wmOperatorType *ot);
 void ANIM_OT_keyframe_delete_v3d(struct wmOperatorType *ot);
 void ANIM_OT_keyframe_clear_v3d(struct wmOperatorType *ot);
 
-/* Keyframe managment operators for UI buttons (RMB menu). */
+/* Keyframe management operators for UI buttons (RMB menu). */
 void ANIM_OT_keyframe_insert_button(struct wmOperatorType *ot);
 void ANIM_OT_keyframe_delete_button(struct wmOperatorType *ot);
 void ANIM_OT_keyframe_clear_button(struct wmOperatorType *ot);
 
 /* .......... */
 
-/* KeyingSet managment operators for UI buttons (RMB menu) */
+/* KeyingSet management operators for UI buttons (RMB menu) */
 void ANIM_OT_keyingset_button_add(struct wmOperatorType *ot);
 void ANIM_OT_keyingset_button_remove(struct wmOperatorType *ot);
 
index 2cb2f6683efacfe3e106213999a854de44847c76..cfa5f9f032cc03698533203a34323919760b056e 100644 (file)
@@ -628,9 +628,8 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f
                                PropertyRNA *prop;
                                
                                RNA_id_pointer_create(aci->id, &id_ptr);
-                               RNA_path_resolve(&id_ptr, aci->rna_path, &rptr, &prop);
                                
-                               if (prop) {
+                               if (RNA_path_resolve_property(&id_ptr, aci->rna_path, &rptr, &prop)) {
                                        const char *identifier = RNA_property_identifier(prop);
                                        int len_id = strlen(identifier);
                                        int len_path = strlen(fcu->rna_path);
index 12602c1095524bd6dc49c16ddca9fc4c3ce89877..90c1a439a1966c4496dd80e3b7f82aeb0636920c 100644 (file)
@@ -78,11 +78,10 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
        
        /* Do the rotations */
        for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
-               float delta[3], tmat[3][3];
+               float tmat[3][3];
                
                /* find the current bone's roll matrix */
-               sub_v3_v3v3(delta, ebone->tail, ebone->head);
-               vec_roll_to_mat3(delta, ebone->roll, tmat);
+               ED_armature_ebone_to_mat3(ebone, tmat);
                
                /* transform the roll matrix */
                mul_m3_m3m3(tmat, mat3, tmat);
@@ -282,15 +281,14 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
                        mul_m3_v3(imat, vec);
                }
                else if (type == CALC_ROLL_ACTIVE) {
-                       float mat[3][3], nor[3];
+                       float mat[3][3];
                        ebone = (EditBone *)arm->act_edbone;
                        if (ebone == NULL) {
                                BKE_report(op->reports, RPT_ERROR, "No active bone set");
                                return OPERATOR_CANCELLED;
                        }
                        
-                       sub_v3_v3v3(nor, ebone->tail, ebone->head);
-                       vec_roll_to_mat3(nor, ebone->roll, mat);
+                       ED_armature_ebone_to_mat3(ebone, mat);
                        copy_v3_v3(vec, mat[2]);
                }
                else { /* Axis */
index 289901076a17efb90227d526a34077822cd468e9..79d75c9fcdab327b0385356decfef91c89a32e44 100644 (file)
@@ -242,21 +242,18 @@ int join_armature_exec(bContext *C, wmOperator *op)
                                        float difmat[4][4];
                                        float imat[4][4];
                                        float temp[3][3];
-                                       float delta[3];
                                        
                                        /* Get the premat */
-                                       sub_v3_v3v3(delta, curbone->tail, curbone->head);
-                                       vec_roll_to_mat3(delta, curbone->roll, temp);
+                                       ED_armature_ebone_to_mat3(curbone, temp);
                                        
-                                       unit_m4(premat); /* Mat4MulMat34 only sets 3x3 part */
+                                       unit_m4(premat); /* mul_m4_m3m4 only sets 3x3 part */
                                        mul_m4_m3m4(premat, temp, mat);
                                        
                                        mul_m4_v3(mat, curbone->head);
                                        mul_m4_v3(mat, curbone->tail);
                                        
                                        /* Get the postmat */
-                                       sub_v3_v3v3(delta, curbone->tail, curbone->head);
-                                       vec_roll_to_mat3(delta, curbone->roll, temp);
+                                       ED_armature_ebone_to_mat3(curbone, temp);
                                        copy_m4_m3(postmat, temp);
                                        
                                        /* Find the roll */
index 0e93a00b01db52c71a7581ec1d17c62e778f2284..4991ef63cf53e881b14a02e406e3af91c780f092 100644 (file)
@@ -156,6 +156,25 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon
        return false;
 }
 
+void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3])
+{
+       float delta[3];
+
+       /* Find the current bone matrix */
+       sub_v3_v3v3(delta, ebone->tail, ebone->head);
+       vec_roll_to_mat3(delta, ebone->roll, mat);
+}
+
+void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4])
+{
+       float m3[3][3];
+
+       ED_armature_ebone_to_mat3(ebone, m3);
+
+       copy_m4_m3(mat, m3);
+       copy_v3_v3(mat[3], ebone->head);
+}
+
 /* *************************************************************** */
 /* Mirroring */
 
@@ -389,7 +408,6 @@ static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist)
        float postmat[3][3];
        float difmat[3][3];
        float imat[3][3];
-       float delta[3];
        
        for (curBone = bonelist->first; curBone; curBone = curBone->next) {
                /* sets local matrix and arm_mat (restpos) */
@@ -402,8 +420,7 @@ static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist)
                
                if (ebone) {
                        /* Get the ebone premat */
-                       sub_v3_v3v3(delta, ebone->tail, ebone->head);
-                       vec_roll_to_mat3(delta, ebone->roll, premat);
+                       ED_armature_ebone_to_mat3(ebone, premat);
                        
                        /* Get the bone postmat */
                        copy_m3_m4(postmat, curBone->arm_mat);
@@ -503,11 +520,9 @@ void ED_armature_from_edit(Object *obedit)
                        {
                                float M_parentRest[3][3];
                                float iM_parentRest[3][3];
-                               float delta[3];
                                
                                /* Get the parent's  matrix (rotation only) */
-                               sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head);
-                               vec_roll_to_mat3(delta, eBone->parent->roll, M_parentRest);
+                               ED_armature_ebone_to_mat3(eBone->parent, M_parentRest);
                                
                                /* Invert the parent matrix */
                                invert_m3_m3(iM_parentRest, M_parentRest);
index dfb02fa9c1b04873e7f0aedb740a3dd88c829a56..352a74cf172f78bfc4ecb00efee7fba5de88384b 100644 (file)
@@ -54,7 +54,6 @@ void fdrawXORcirc(float xofs, float yofs, float rad);
 
 void fdrawcheckerboard(float x1, float y1, float x2, float y2);
 
-/* OpenGL stipple defines */
 /* OpenGL stipple defines */
 extern const unsigned char stipple_halftone[128];
 extern const unsigned char stipple_quarttone[128];
index 9b9a4c154db39058d8d5ba0084277b64f3d43b69..fab179da7bc4d2b5ac99dc79122a3a4cb0c08ada 100644 (file)
@@ -135,8 +135,12 @@ void ED_armature_validate_active(struct bArmature *arm);
 void add_primitive_bone(struct Object *obedit_arm, bool view_aligned);
 struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
 void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
+
 bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
 
+void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]);
+void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]);
+
 void transform_armature_mirror_update(struct Object *obedit);
 void ED_armature_origin_set(struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
 
index e5cc0dd8ea726d31ddc28fd04aed3edbb4e0ba9c..2daab0724356eb4bd40153747b4b0ad86e7ece08 100644 (file)
@@ -327,7 +327,11 @@ typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
 
 typedef struct uiPopupMenu uiPopupMenu;
 
-struct uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon);
+struct uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
 void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
 
index 042ca942722c19c8b3b168c2fc18e523c2a46372..6504c198b21a3aa470fa2ad8383f17b8282eba1c 100644 (file)
@@ -559,19 +559,19 @@ static void ui_draw_links(uiBlock *block)
 /* ************** BLOCK ENDING FUNCTION ************* */
 
 /* NOTE: if but->poin is allocated memory for every defbut, things fail... */
-static bool ui_but_equals_old(uiBut *but, uiBut *oldbut)
+static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut)
 {
        /* various properties are being compared here, hopefully sufficient
         * to catch all cases, but it is simple to add more checks later */
        if (but->retval != oldbut->retval) return false;
        if (but->rnapoin.data != oldbut->rnapoin.data) return false;
-       if (but->rnaprop != oldbut->rnaprop)
-               if (but->rnaindex != oldbut->rnaindex) return false;
+       if (but->rnaprop != oldbut->rnaprop && but->rnaindex != oldbut->rnaindex) return false;
        if (but->func != oldbut->func) return false;
        if (but->funcN != oldbut->funcN) return false;
        if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return false;
        if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return false;
-       if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return false;
+       if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) ||
+                           (but->pointype != oldbut->pointype))) return false;
        if (but->optype != oldbut->optype) return false;
 
        return true;
@@ -620,7 +620,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
                return found;
 
        for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) {
-               if (ui_but_equals_old(oldbut, but)) {
+               if (ui_but_equals_old(but, oldbut)) {
                        if (oldbut->active) {
 #if 0
 //                             but->flag = oldbut->flag;
@@ -2426,35 +2426,37 @@ void ui_check_but(uiBut *but)
                case NUM:
                case NUMSLI:
 
-                       UI_GET_BUT_VALUE_INIT(but, value);
+                       if (!but->editstr) {
+                               UI_GET_BUT_VALUE_INIT(but, value);
 
-                       if (ui_is_but_float(but)) {
-                               if (value == (double) FLT_MAX) {
-                                       BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str);
-                               }
-                               else if (value == (double) -FLT_MAX) {
-                                       BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str);
-                               }
-                               /* support length type buttons */
-                               else if (ui_is_but_unit(but)) {
-                                       char new_str[sizeof(but->drawstr)];
-                                       ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE, -1);
-                                       BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str);
+                               if (ui_is_but_float(but)) {
+                                       if (value == (double) FLT_MAX) {
+                                               BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str);
+                                       }
+                                       else if (value == (double) -FLT_MAX) {
+                                               BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str);
+                                       }
+                                       /* support length type buttons */
+                                       else if (ui_is_but_unit(but)) {
+                                               char new_str[sizeof(but->drawstr)];
+                                               ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE, -1);
+                                               BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str);
+                                       }
+                                       else {
+                                               const int prec = ui_but_float_precision(but, value);
+                                               BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
+                                       }
                                }
                                else {
-                                       const int prec = ui_but_float_precision(but, value);
-                                       BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
+                                       BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value);
+                               }
+
+                               if (but->rnaprop) {
+                                       PropertySubType pstype = RNA_property_subtype(but->rnaprop);
+
+                                       if (pstype == PROP_PERCENTAGE)
+                                               strcat(but->drawstr, "%");
                                }
-                       }
-                       else {
-                               BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value);
-                       }
-                       
-                       if (but->rnaprop) {
-                               PropertySubType pstype = RNA_property_subtype(but->rnaprop);
-                       
-                               if (pstype == PROP_PERCENTAGE)
-                                       strcat(but->drawstr, "%");
                        }
                        break;
 
@@ -2477,29 +2479,30 @@ void ui_check_but(uiBut *but)
                        if (!but->editstr) {
                                char str[UI_MAX_DRAW_STR];
 
-                               ui_get_but_string(but, str, UI_MAX_DRAW_STR - strlen(but->str));
-
+                               ui_get_but_string(but, str, UI_MAX_DRAW_STR);
                                BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str);
                        }
                        break;
        
                case KEYEVT:
-                       BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+               {
+                       const char *str;
                        if (but->flag & UI_SELECT) {
-                               strcat(but->drawstr, "Press a key");
+                               str = "Press a key";
                        }
                        else {
                                UI_GET_BUT_VALUE_INIT(but, value);
-                               strcat(but->drawstr, WM_key_event_string((short)value));
+                               str = WM_key_event_string((short)value);
                        }
+                       BLI_snprintf(but->drawstr, UI_MAX_DRAW_STR, "%s%s", but->str, str);
                        break;
-               
+               }
                case HOTKEYEVT:
                        if (but->flag & UI_SELECT) {
-                               but->drawstr[0] = '\0';
 
                                if (but->modifier_key) {
                                        char *str = but->drawstr;
+                                       but->drawstr[0] = '\0';
 
                                        if (but->modifier_key & KM_SHIFT)
                                                str += BLI_strcpy_rlen(str, "Shift ");
@@ -2512,8 +2515,9 @@ void ui_check_but(uiBut *but)
 
                                        (void)str; /* UNUSED */
                                }
-                               else
-                                       strcat(but->drawstr, "Press a key  ");
+                               else {
+                                       BLI_strncpy(but->drawstr, "Press a key", UI_MAX_DRAW_STR);
+                               }
                        }
                        else
                                BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
index c60e533551b3e158844addf89471d7f8a7d5b49c..8efad17133f904e0e91387da2010ace51d484fde 100644 (file)
@@ -4944,7 +4944,6 @@ static bool ui_but_menu(bContext *C, uiBut *but)
        uiPopupMenu *pup;
        uiLayout *layout;
        bool is_array, is_array_component;
-       const char *name;
        uiStringInfo label = {BUT_GET_LABEL, NULL};
 
 /*     if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/
@@ -4957,12 +4956,11 @@ static bool ui_but_menu(bContext *C, uiBut *but)
        
        button_timers_tooltip_remove(C, but);
 
+       /* highly unlikely getting the label ever fails */
        uiButGetStrInfo(C, but, &label, NULL);
-       name = label.strinfo;
 
-       pup = uiPupMenuBegin(C, name, ICON_NONE);
+       pup = uiPupMenuBegin(C, label.strinfo ? label.strinfo : "", ICON_NONE);
        layout = uiPupMenuLayout(pup);
-
        if (label.strinfo)
                MEM_freeN(label.strinfo);
 
index 55a7f1a1e371136d9add2badd6aae66d55349c85..d2a8c47b34789c7780f12913a8a7a574acf957b0 100644 (file)
@@ -452,7 +452,7 @@ struct uiPopupBlockHandle {
        int butretval;
        int menuretval;
        float retvalue;
-       float retvec[3];
+       float retvec[4];
 
        /* menu direction */
        int direction;
index 9c6a606333d17efa929c94e8254c6bdf21255a89..3405d81e04abc567b449a216b77016a35201ac3f 100644 (file)
@@ -2528,7 +2528,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
        uiStyle *style = UI_GetStyleDraw();
        uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu");
        uiBut *but;
-       
+
        pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
        pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
        pup->block->puphash = ui_popup_menu_hash(title);
@@ -2542,7 +2542,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
        pup->block->handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
        
        /* create title button */
-       if (title && title[0]) {
+       if (title[0]) {
                char titlestr[256];
                
                if (icon) {
index e544592365de55adeb81e133cd7b673c511d97e3..f372053db559ee51e92e9dee59420469e5a02660 100644 (file)
@@ -118,9 +118,10 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Plane"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out",
-                                     "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
-                                     1, 1, RNA_float_get(op->ptr, "radius"), mat))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
+               1, 1, RNA_float_get(op->ptr, "radius"), mat))
        {
                return OPERATOR_CANCELLED;
        }
@@ -162,8 +163,10 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Cube"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_cube matrix=%m4 size=%f",
-                                     mat, RNA_float_get(op->ptr, "radius") * 2.0f))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_cube matrix=%m4 size=%f",
+               mat, RNA_float_get(op->ptr, "radius") * 2.0f))
        {
                return OPERATOR_CANCELLED;
        }
@@ -216,10 +219,11 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Circle"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out",
-                                     "create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b matrix=%m4",
-                                     RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
-                                     cap_end, cap_tri, mat))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b matrix=%m4",
+               RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
+               cap_end, cap_tri, mat))
        {
                return OPERATOR_CANCELLED;
        }
@@ -269,7 +273,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
        em = BKE_editmesh_from_object(obedit);
 
        if (!EDBM_op_call_and_selectf(
-               em, op, "verts.out",
+               em, op, "verts.out", false,
                "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4",
                RNA_int_get(op->ptr, "vertices"),
                RNA_float_get(op->ptr, "radius"),
@@ -329,7 +333,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
        em = BKE_editmesh_from_object(obedit);
 
        if (!EDBM_op_call_and_selectf(
-               em, op, "verts.out",
+               em, op, "verts.out", false,
                "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4",
                RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
                RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
@@ -385,11 +389,12 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Grid"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out",
-                                     "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
-                                     RNA_int_get(op->ptr, "x_subdivisions"),
-                                     RNA_int_get(op->ptr, "y_subdivisions"),
-                                     RNA_float_get(op->ptr, "radius"), mat))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
+               RNA_int_get(op->ptr, "x_subdivisions"),
+               RNA_int_get(op->ptr, "y_subdivisions"),
+               RNA_float_get(op->ptr, "radius"), mat))
        {
                return OPERATOR_CANCELLED;
        }
@@ -444,7 +449,10 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
 
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_monkey matrix=%m4", mat)) {
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out",  false,
+               "create_monkey matrix=%m4", mat))
+       {
                return OPERATOR_CANCELLED;
        }
 
@@ -485,10 +493,11 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Sphere"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out",
-                                     "create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4",
-                                     RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"),
-                                     RNA_float_get(op->ptr, "size"), mat))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4",
+               RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"),
+               RNA_float_get(op->ptr, "size"), mat))
        {
                return OPERATOR_CANCELLED;
        }
@@ -538,7 +547,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
        em = BKE_editmesh_from_object(obedit);
 
        if (!EDBM_op_call_and_selectf(
-               em, op, "verts.out",
+               em, op, "verts.out", false,
                "create_icosphere subdivisions=%i diameter=%f matrix=%m4",
                RNA_int_get(op->ptr, "subdivisions"),
                RNA_float_get(op->ptr, "size"), mat))
index 65c528dbe03738b517177485ad7939828dffc906..b38f09b1dec7cf5e05528644d54121ee7926a0fb 100644 (file)
@@ -713,7 +713,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
        BMesh *bm = em->bm;
        BMOperator spinop;
-       float cent[3], axis[3], imat[3][3];
+       float cent[3], axis[3];
        float d[3] = {0.0f, 0.0f, 0.0f};
        int steps, dupli;
        float angle;
@@ -726,15 +726,10 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
        angle = -angle;
        dupli = RNA_boolean_get(op->ptr, "dupli");
 
-       /* undo object transformation */
-       copy_m3_m4(imat, obedit->imat);
-       sub_v3_v3(cent, obedit->obmat[3]);
-       mul_m3_v3(imat, cent);
-       mul_m3_v3(imat, axis);
-
+       /* keep the values in worldspace since we're passing the obmat */
        if (!EDBM_op_init(em, &spinop, op,
-                         "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b",
-                         BM_ELEM_SELECT, cent, axis, d, steps, angle, dupli))
+                         "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 use_duplicate=%b",
+                         BM_ELEM_SELECT, cent, axis, d, steps, angle, obedit->obmat, dupli))
        {
                return OPERATOR_CANCELLED;
        }
@@ -800,8 +795,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
        BMVert *eve, *v1, *v2;
        BMIter iter, eiter;
        BMOperator spinop;
-       float dvec[3], nor[3], cent[3], axis[3];
-       float imat[3][3];
+       float dvec[3], nor[3], cent[3], axis[3], v1_co_global[3], v2_co_global[3];
        int steps, turns;
        int valence;
 
@@ -811,13 +805,6 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
        RNA_float_get_array(op->ptr, "center", cent);
        RNA_float_get_array(op->ptr, "axis", axis);
 
-       /* undo object transformation */
-       copy_m3_m4(imat, obedit->imat);
-       sub_v3_v3(cent, obedit->obmat[3]);
-       mul_m3_v3(imat, cent);
-       mul_m3_v3(imat, axis);
-
-
        /* find two vertices with valence count == 1, more or less is wrong */
        v1 = NULL;
        v2 = NULL;
@@ -850,15 +837,17 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
        }
 
        /* calculate dvec */
-       sub_v3_v3v3(dvec, v1->co, v2->co);
+       mul_v3_m4v3(v1_co_global, obedit->obmat, v1->co);
+       mul_v3_m4v3(v2_co_global, obedit->obmat, v2->co);
+       sub_v3_v3v3(dvec, v1_co_global, v2_co_global);
        mul_v3_fl(dvec, 1.0f / steps);
 
-       if (dot_v3v3(nor, dvec) > 0.000f)
+       if (dot_v3v3(nor, dvec) > 0.0f)
                negate_v3(dvec);
 
        if (!EDBM_op_init(em, &spinop, op,
-                         "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b",
-                         BM_ELEM_SELECT, cent, axis, dvec, turns * steps, DEG2RADF(360.0f * turns), false))
+                         "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 use_duplicate=%b",
+                         BM_ELEM_SELECT, cent, axis, dvec, turns * steps, DEG2RADF(360.0f * turns), obedit->obmat, false))
        {
                return OPERATOR_CANCELLED;
        }
index e152c83fb9af12df1f4cc6edb64741282e2e372b..99638696ccd9b4d29625b4f1d10fc839be559cf3 100644 (file)
@@ -2752,15 +2752,56 @@ void MESH_OT_fill_grid(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+static int edbm_fill_holes_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit = CTX_data_edit_object(C);
+       BMEditMesh *em = BKE_editmesh_from_object(obedit);
+       const int sides = RNA_int_get(op->ptr, "sides");
+
+       if (!EDBM_op_call_and_selectf(
+               em, op,
+               "faces.out", true,
+               "holes_fill edges=%he sides=%i",
+               BM_ELEM_SELECT, sides))
+       {
+               return OPERATOR_CANCELLED;
+       }
+
+       EDBM_update_generic(em, true, true);
 
+       return OPERATOR_FINISHED;
+
+}
+
+void MESH_OT_fill_holes(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Fill Holes";
+       ot->idname = "MESH_OT_fill_holes";
+       ot->description = "Fill in holes (boundary edge loops)";
+
+       /* api callbacks */
+       ot->exec = edbm_fill_holes_exec;
+       ot->poll = ED_operator_editmesh;
+
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+       RNA_def_int(ot->srna, "sides", 4, 0, INT_MAX, "Sides", "Number of sides (zero disables)", 0, 100);
+}
 
 static int edbm_beautify_fill_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf edges=ae", BM_ELEM_SELECT))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "geom.out", true,
+               "beautify_fill faces=%hf edges=ae",
+               BM_ELEM_SELECT))
+       {
                return OPERATOR_CANCELLED;
+       }
 
        EDBM_update_generic(em, true, true);
        
@@ -2855,11 +2896,14 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op)
        EDBM_op_init(em, &bmop, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty);
        BMO_op_exec(em->bm, &bmop);
 
+       BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
+
        /* now call beauty fill */
        if (use_beauty) {
-               EDBM_op_callf(em, op,
-                             "beautify_fill faces=%S edges=%S",
-                             &bmop, "faces.out", &bmop, "edges.out");
+               EDBM_op_call_and_selectf(
+                           em, op, "geom.out", true,
+                           "beautify_fill faces=%S edges=%S",
+                           &bmop, "faces.out", &bmop, "edges.out");
        }
 
        if (!EDBM_op_finish(em, &bmop, op, true)) {
@@ -2901,9 +2945,11 @@ static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op)
        dovcols = RNA_boolean_get(op->ptr, "vcols");
        domaterials = RNA_boolean_get(op->ptr, "materials");
 
-       if (!EDBM_op_callf(em, op,
-                          "join_triangles faces=%hf limit=%f cmp_sharp=%b cmp_uvs=%b cmp_vcols=%b cmp_materials=%b",
-                          BM_ELEM_SELECT, limit, dosharp, douvs, dovcols, domaterials))
+       if (!EDBM_op_call_and_selectf(
+               em, op,
+               "faces.out", true,
+               "join_triangles faces=%hf limit=%f cmp_sharp=%b cmp_uvs=%b cmp_vcols=%b cmp_materials=%b",
+               BM_ELEM_SELECT, limit, dosharp, douvs, dovcols, domaterials))
        {
                return OPERATOR_CANCELLED;
        }
@@ -3094,12 +3140,10 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
                dissolve_flag = BM_ELEM_SELECT;
        }
 
-       if (!EDBM_op_callf(em, op,
-                          "dissolve_limit edges=%he verts=%hv angle_limit=%f use_dissolve_boundaries=%b delimit=%i",
-                          dissolve_flag, dissolve_flag, angle_limit, use_dissolve_boundaries, delimit))
-       {
-               return OPERATOR_CANCELLED;
-       }
+       EDBM_op_call_and_selectf(
+                   em, op, "region.out", true,
+                   "dissolve_limit edges=%he verts=%hv angle_limit=%f use_dissolve_boundaries=%b delimit=%i",
+                   dissolve_flag, dissolve_flag, angle_limit, use_dissolve_boundaries, delimit);
 
        EDBM_update_generic(em, true, true);
 
@@ -3936,6 +3980,7 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
        const bool use_cyclic = (type == 1);
        const bool use_merge = RNA_boolean_get(op->ptr, "use_merge");
        const float merge_factor = RNA_float_get(op->ptr, "merge_factor");
+       const int twist_offset = RNA_int_get(op->ptr, "twist_offset");
        const bool use_faces = (em->bm->totfacesel != 0);
        char edge_hflag;
 
@@ -3963,8 +4008,8 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
        }
 
        EDBM_op_init(em, &bmop, op,
-                    "bridge_loops edges=%he use_pairs=%b use_cyclic=%b use_merge=%b merge_factor=%f",
-                    edge_hflag, use_pairs, use_cyclic, use_merge, merge_factor);
+                    "bridge_loops edges=%he use_pairs=%b use_cyclic=%b use_merge=%b merge_factor=%f twist_offset=%i",
+                    edge_hflag, use_pairs, use_cyclic, use_merge, merge_factor, twist_offset);
 
        BMO_op_exec(em->bm, &bmop);
 
@@ -3991,14 +4036,23 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
                        mesh_operator_edgering_props_get(op, &op_props);
 
                        if (op_props.cuts) {
+                               BMOperator bmop_subd;
                                /* we only need face normals updated */
                                EDBM_mesh_normals_update(em);
 
-                               BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS,
-                                            "subdivide_edgering edges=%S interp_mode=%i cuts=%i smooth=%f "
-                                            "profile_shape=%i profile_shape_factor=%f",
-                                            &bmop, "edges.out", op_props.interp_mode, op_props.cuts, op_props.smooth,
-                                            op_props.profile_shape, op_props.profile_shape_factor);
+                               BMO_op_initf(
+                                       em->bm, &bmop_subd, op->flag,
+                                       "subdivide_edgering edges=%S interp_mode=%i cuts=%i smooth=%f "
+                                       "profile_shape=%i profile_shape_factor=%f",
+                                       &bmop, "edges.out", op_props.interp_mode, op_props.cuts, op_props.smooth,
+                                       op_props.profile_shape, op_props.profile_shape_factor
+                                       );
+                               BMO_op_exec(em->bm, &bmop_subd);
+
+                               BMO_slot_buffer_hflag_enable(em->bm, bmop_subd.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
+
+                               BMO_op_finish(em->bm, &bmop_subd);
+
                        }
                }
        }
@@ -4044,6 +4098,7 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
 
        RNA_def_boolean(ot->srna, "use_merge", false, "Merge", "Merge rather than creating faces");
        RNA_def_float(ot->srna, "merge_factor", 0.5f, 0.0f, 1.0f, "Merge Factor", "", 0.0f, 1.0f);
+       RNA_def_int(ot->srna, "twist_offset", 0, -1000, 1000, "Twist", "Twist offset for closed loops", -1000, 1000);
 
        mesh_operator_edgering_props(ot, 0);
 }
index f64ea569100df2b601c35a9126298e56278b8fdb..3a3a734eef03201c169ce9907234a2d0016016e9 100644 (file)
@@ -270,7 +270,9 @@ bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...)
        return EDBM_op_finish(em, &bmop, op, true);
 }
 
-bool EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_slot_out, const char *fmt, ...)
+bool EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op,
+                              const char *select_slot_out, const bool select_extend,
+                              const char *fmt, ...)
 {
        BMOpSlot *slot_select_out;
        BMesh *bm = em->bm;
@@ -294,8 +296,11 @@ bool EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select
 
        slot_select_out = BMO_slot_get(bmop.slots_out, select_slot_out);
        hflag = slot_select_out->slot_subtype.elem & BM_ALL_NOLOOP;
+       BLI_assert(hflag != 0);
 
-       BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
+       if (select_extend == false) {
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
+       }
 
        BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, select_slot_out, hflag, BM_ELEM_SELECT, true);
 
index 69f471670edf8c52905663f524446800f4410f42..c76b9819f753989b27eab3082edbfdd1a584e15d 100644 (file)
@@ -59,7 +59,8 @@ struct LinkNode;
 /* Calls a bmesh op, reporting errors to the user, etc */
 bool EDBM_op_callf(struct BMEditMesh *em, struct wmOperator *op, const char *fmt, ...);
 bool EDBM_op_call_and_selectf(struct BMEditMesh *em, struct wmOperator *op,
-                              const char *selectslot, const char *fmt, ...);
+                              const char *select_slot, const bool select_replace,
+                              const char *fmt, ...);
 /* Same as above, but doesn't report errors.*/
 bool EDBM_op_call_silentf(struct BMEditMesh *em, const char *fmt, ...);
 
@@ -195,6 +196,7 @@ void MESH_OT_knife_cut(struct wmOperatorType *ot);
 void MESH_OT_separate(struct wmOperatorType *ot);
 void MESH_OT_fill(struct wmOperatorType *ot);
 void MESH_OT_fill_grid(struct wmOperatorType *ot);
+void MESH_OT_fill_holes(struct wmOperatorType *ot);
 void MESH_OT_beautify_fill(struct wmOperatorType *ot);
 void MESH_OT_quads_convert_to_tris(struct wmOperatorType *ot);
 void MESH_OT_tris_convert_to_quads(struct wmOperatorType *ot);
index 4f2924293eafe32945f23a132b173db397ca0a4b..74aaa58d32db9de7dac921aef62c4b5527db6116 100644 (file)
@@ -102,6 +102,7 @@ void ED_operatortypes_mesh(void)
        
        WM_operatortype_append(MESH_OT_fill);
        WM_operatortype_append(MESH_OT_fill_grid);
+       WM_operatortype_append(MESH_OT_fill_holes);
        WM_operatortype_append(MESH_OT_beautify_fill);
        WM_operatortype_append(MESH_OT_quads_convert_to_tris);
        WM_operatortype_append(MESH_OT_tris_convert_to_quads);
index 5b100d7b6c2dc73dc8739eb42551fa1f6b546e5e..ce61b4fce502f4c3accf9dfcd475a10db32a304f 100644 (file)
@@ -1431,7 +1431,7 @@ static int convert_exec(bContext *C, wmOperator *op)
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
-       Base *basen = NULL, *basact = NULL, *basedel = NULL;
+       Base *basen = NULL, *basact = NULL;
        Object *ob, *ob1, *newob, *obact = CTX_data_active_object(C);
        DerivedMesh *dm;
        Curve *cu;
@@ -1687,14 +1687,6 @@ static int convert_exec(bContext *C, wmOperator *op)
                        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                        ((ID *)ob->data)->flag &= ~LIB_DOIT; /* flag not to convert this datablock again */
                }
-
-               /* delete original if needed */
-               if (basedel) {
-                       if (!keep_original)
-                               ED_base_object_free_and_unlink(bmain, scene, basedel);
-
-                       basedel = NULL;
-               }
        }
        CTX_DATA_END;
 
index 6c0d5ccd844c4eb499760a9d628d0e09b3b4eb38..1f1da35f8239375550d83d06eda6624e5a9c27c8 100644 (file)
@@ -420,7 +420,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
        /* note; this sets state, so we can use wmOrtho and friends */
        wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct);
        
-       UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0);
+       UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);
        
        /* optional header info instead? */
        if (ar->headerstr) {
index 72d7bcd43ce71e8ae667703e3225b2ff38e76481..d32be69255817355510a01ceb796a04d8c4c95f6 100644 (file)
@@ -266,6 +266,7 @@ static void buttons_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *
                                        break;
                                case ND_POSE:
                                        buttons_area_redraw(sa, BCONTEXT_DATA);
+                                       break;
                                case ND_BONE_ACTIVE:
                                case ND_BONE_SELECT:
                                        buttons_area_redraw(sa, BCONTEXT_BONE);
index 7d7149e22ffed121aa2851e89f542d5af3dabfaf..49b87a6160ac1fcb586f2537903bc61928dd2ded 100644 (file)
@@ -1711,7 +1711,9 @@ static int clear_track_path_exec(bContext *C, wmOperator *op)
 
        if (clear_active) {
                track = BKE_tracking_track_get_active(tracking);
-               BKE_tracking_track_path_clear(track, framenr, action);
+               if (track) {
+                       BKE_tracking_track_path_clear(track, framenr, action);
+               }
        }
        else {
                track = tracksbase->first;
index a81c0d6dfd6f1a0b7596acc49a31d4a90742b0b7..c4315c56376eed5ebb48682c79a7623f90cdc6e7 100644 (file)
 
 /* -------------- */
 
-static void do_graph_region_buttons(bContext *UNUSED(C), void *UNUSED(arg), int event)
-{
-       //Scene *scene = CTX_data_scene(C);
-       
-       switch (event) {
-
-       }
-       
-       /* default for now */
-       //WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
-}
-
-/* -------------- */
-
 static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu)
 {
        bAnimContext ac;
@@ -170,7 +156,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
                return;
        
        block = uiLayoutGetBlock(layout);
-       uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
+       /* uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); */
        
        /* F-Curve pointer */
        RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
@@ -281,7 +267,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
                return;
        
        block = uiLayoutGetBlock(layout);
-       uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
+       /* uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); */
        
        /* only show this info if there are keyframes to edit */
        if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
index 7d3ec148662ca58c1430e893039d3f4b5e59aa81..eb33d799dff1dade2a104cf4487207f3ad23abfc 100644 (file)
@@ -1140,7 +1140,7 @@ static int need_add_seq_dup(Sequence *seq)
         */
        p = seq->prev;
        while (p) {
-               if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) {
+               if ((!p->strip) || (!p->strip->stripdata)) {
                        p = p->prev;
                        continue;
                }
@@ -1152,7 +1152,7 @@ static int need_add_seq_dup(Sequence *seq)
 
        p = seq->next;
        while (p) {
-               if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) {
+               if ((!p->strip) || (!p->strip->stripdata)) {
                        p = p->next;
                        continue;
                }
index fb20f0820855efaf1e3bd4080137908cde6c0276..68f656bbf57678bf0e982c8455871a9b27fc3339 100644 (file)
@@ -2060,20 +2060,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 }
 
 /* in editmode, we don't store the bone matrix... */
-static void get_matrix_editbone(EditBone *eBone, float bmat[4][4])
+static void get_matrix_editbone(EditBone *ebone, float bmat[4][4])
 {
-       float delta[3];
-       float mat[3][3];
-       
-       /* Compose the parent transforms (i.e. their translations) */
-       sub_v3_v3v3(delta, eBone->tail, eBone->head);
-       
-       eBone->length = (float)sqrt(delta[0] * delta[0] + delta[1] * delta[1] + delta[2] * delta[2]);
-       
-       vec_roll_to_mat3(delta, eBone->roll, mat);
-       copy_m4_m3(bmat, mat);
-
-       add_v3_v3(bmat[3], eBone->head);
+       ebone->length = len_v3v3(ebone->tail, ebone->head);
+       ED_armature_ebone_to_mat4(ebone, bmat);
 }
 
 static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
index 92bf8214336c25af552c801525b9a7c925632519..dfbc973ee859238f441ebc1d74f649888c76fc4d 100644 (file)
@@ -1141,17 +1141,17 @@ const char *view3d_context_dir[] = {
 
 static int view3d_context(const bContext *C, const char *member, bContextDataResult *result)
 {
-       View3D *v3d = CTX_wm_view3d(C);
-       Scene *scene = CTX_data_scene(C);
-       Base *base;
        /* fallback to the scene layer, allows duplicate and other object operators to run outside the 3d view */
-       unsigned int lay = v3d ? v3d->lay : scene->lay;
 
        if (CTX_data_dir(member)) {
                CTX_data_dir_set(result, view3d_context_dir);
        }
        else if (CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) {
-               int selected_objects = CTX_data_equals(member, "selected_objects");
+               View3D *v3d = CTX_wm_view3d(C);
+               Scene *scene = CTX_data_scene(C);
+               const unsigned int lay = v3d ? v3d->lay : scene->lay;
+               Base *base;
+               const bool selected_objects = CTX_data_equals(member, "selected_objects");
 
                for (base = scene->base.first; base; base = base->next) {
                        if ((base->flag & SELECT) && (base->lay & lay)) {
@@ -1167,7 +1167,11 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                return 1;
        }
        else if (CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) {
-               int selected_editable_objects = CTX_data_equals(member, "selected_editable_objects");
+               View3D *v3d = CTX_wm_view3d(C);
+               Scene *scene = CTX_data_scene(C);
+               const unsigned int lay = v3d ? v3d->lay : scene->lay;
+               Base *base;
+               const bool selected_editable_objects = CTX_data_equals(member, "selected_editable_objects");
 
                for (base = scene->base.first; base; base = base->next) {
                        if ((base->flag & SELECT) && (base->lay & lay)) {
@@ -1185,7 +1189,11 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                return 1;
        }
        else if (CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) {
-               int visible_objects = CTX_data_equals(member, "visible_objects");
+               View3D *v3d = CTX_wm_view3d(C);
+               Scene *scene = CTX_data_scene(C);
+               const unsigned int lay = v3d ? v3d->lay : scene->lay;
+               Base *base;
+               const bool visible_objects = CTX_data_equals(member, "visible_objects");
 
                for (base = scene->base.first; base; base = base->next) {
                        if (base->lay & lay) {
@@ -1201,7 +1209,11 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                return 1;
        }
        else if (CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) {
-               int selectable_objects = CTX_data_equals(member, "selectable_objects");
+               View3D *v3d = CTX_wm_view3d(C);
+               Scene *scene = CTX_data_scene(C);
+               const unsigned int lay = v3d ? v3d->lay : scene->lay;
+               Base *base;
+               const bool selectable_objects = CTX_data_equals(member, "selectable_objects");
 
                for (base = scene->base.first; base; base = base->next) {
                        if (base->lay & lay) {
@@ -1217,6 +1229,9 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                return 1;
        }
        else if (CTX_data_equals(member, "active_base")) {
+               View3D *v3d = CTX_wm_view3d(C);
+               Scene *scene = CTX_data_scene(C);
+               const unsigned int lay = v3d ? v3d->lay : scene->lay;
                if (scene->basact && (scene->basact->lay & lay)) {
                        Object *ob = scene->basact->object;
                        /* if hidden but in edit mode, we still display, can happen with animation */
@@ -1227,6 +1242,9 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                return 1;
        }
        else if (CTX_data_equals(member, "active_object")) {
+               View3D *v3d = CTX_wm_view3d(C);
+               Scene *scene = CTX_data_scene(C);
+               const unsigned int lay = v3d ? v3d->lay : scene->lay;
                if (scene->basact && (scene->basact->lay & lay)) {
                        Object *ob = scene->basact->object;
                        if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT))
index bfc64d1d37ac3f807d437d7e81777b9a8d971f63..7b8c197f3e69d52dd2b333de0e70a8fa6cf5bd95 100644 (file)
@@ -3241,16 +3241,11 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar,
                        align_active = false;
                }
                else {
-                       const float z_flip_quat[4] = {0.0f, 0.0f, 0.0f, 1.0f};
                        float obact_quat[4];
                        float twmat[3][3];
 
-                       /* flip the input, the end result being that an object
-                        * with no rotation behaves as if 'align_active' is off */
-                       mul_qt_qtqt(new_quat, new_quat, z_flip_quat);
-
                        /* same as transform manipulator when normal is set */
-                       ED_getTransformOrientationMatrix(C, twmat, false);
+                       ED_getTransformOrientationMatrix(C, twmat, true);
 
                        mat3_to_quat(obact_quat, twmat);
                        invert_qt(obact_quat);
@@ -4205,28 +4200,27 @@ float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float
  */
 void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist)
 {
+       float nmat[3][3];
+
+       /* dist depends on offset */
+       BLI_assert(dist == NULL || ofs != NULL);
+
+       copy_m3_m4(nmat, mat);
+       normalize_m3(nmat);
+
        /* Offset */
        if (ofs)
                negate_v3_v3(ofs, mat[3]);
 
        /* Quat */
        if (quat) {
-               float imat[4][4];
-               normalize_m4_m4(imat, mat);
-               invert_m4(imat);
-               mat4_to_quat(quat, imat);
+               float imat[3][3];
+               invert_m3_m3(imat, nmat);
+               mat3_to_quat(quat, imat);
        }
 
-       if (dist) {
-               float nmat[3][3];
-               float vec[3];
-
-               vec[0] = 0.0f;
-               vec[1] = 0.0f;
-               vec[2] = -(*dist);
-
-               copy_m3_m4(nmat, mat);
-               normalize_m3(nmat);
+       if (ofs && dist) {
+               float vec[3] = {0.0f, 0.0f, -(*dist)};
 
                mul_m3_v3(nmat, vec);
                sub_v3_v3(ofs, vec);
index 3638690a0a5ba6d7a781440fe2f6c6a3101ee967..4a14aa79e4171f0d4b2c1002330c698e46c18a02 100644 (file)
@@ -202,7 +202,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
        }
        
        /* skip smooth viewing for render engine draw */
-       if (C && U.smooth_viewtx && v3d->drawtype != OB_RENDER) {
+       if (U.smooth_viewtx && v3d->drawtype != OB_RENDER) {
                bool changed = false; /* zero means no difference */
                
                if (oldcamera != camera)
@@ -753,7 +753,7 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect)
        glGetFloatv(GL_PROJECTION_MATRIX, (float *)rv3d->winmat);
 }
 
-static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short smooth)
+static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
 {
        float bmat[4][4];
        float tmat[3][3];
@@ -766,36 +766,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short
        
        /* view quat calculation, needed for add object */
        copy_m3_m4(tmat, rv3d->viewmat);
-       if (smooth) {
-               float new_quat[4];
-               if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
-                       /* were from a camera view */
-                       
-                       float orig_ofs[3];
-                       float orig_dist = rv3d->dist;
-                       float orig_lens = v3d->lens;
-                       copy_v3_v3(orig_ofs, rv3d->ofs);
-                       
-                       /* Switch from camera view */
-                       mat3_to_quat(new_quat, tmat);
-                       
-                       rv3d->persp = RV3D_PERSP;
-                       rv3d->dist = 0.0;
-                       
-                       ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens);
-                       view3d_smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */
-
-                       rv3d->persp = RV3D_CAMOB; /* just to be polite, not needed */
-                       
-               }
-               else {
-                       mat3_to_quat(new_quat, tmat);
-                       view3d_smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */
-               }
-       }
-       else {
-               mat3_to_quat(rv3d->viewquat, tmat);
-       }
+       mat3_to_quat(rv3d->viewquat, tmat);
 }
 
 #define QUATSET(a, b, c, d, e) { a[0] = b; a[1] = c; a[2] = d; a[3] = e; } (void)0
@@ -839,7 +810,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d)
        if (rv3d->persp == RV3D_CAMOB) {      /* obs/camera */
                if (v3d->camera) {
                        BKE_object_where_is_calc(scene, v3d->camera);
-                       obmat_to_viewmat(v3d, rv3d, v3d->camera, 0);
+                       obmat_to_viewmat(rv3d, v3d->camera);
                }
                else {
                        quat_to_mat4(rv3d->viewmat, rv3d->viewquat);
@@ -1562,40 +1533,6 @@ void VIEW3D_OT_game_start(wmOperatorType *ot)
 
 /* ************************************** */
 
-static void UNUSED_FUNCTION(view3d_align_axis_to_vector)(View3D *v3d, RegionView3D *rv3d, int axisidx, float vec[3])
-{
-       float alignaxis[3] = {0.0, 0.0, 0.0};
-       float norm[3], axis[3], angle, new_quat[4];
-       
-       if (axisidx > 0) alignaxis[axisidx - 1] = 1.0;
-       else alignaxis[-axisidx - 1] = -1.0;
-
-       normalize_v3_v3(norm, vec);
-
-       angle = (float)acos(dot_v3v3(alignaxis, norm));
-       cross_v3_v3v3(axis, alignaxis, norm);
-       axis_angle_to_quat(new_quat, axis, -angle);
-       
-       rv3d->view = RV3D_VIEW_USER;
-       
-       if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
-               /* switch out of camera view */
-               float orig_ofs[3];
-               float orig_dist = rv3d->dist;
-               float orig_lens = v3d->lens;
-               
-               copy_v3_v3(orig_ofs, rv3d->ofs);
-               rv3d->persp = RV3D_PERSP;
-               rv3d->dist = 0.0;
-               ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens);
-               view3d_smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */
-       }
-       else {
-               if (rv3d->persp == RV3D_CAMOB) rv3d->persp = RV3D_PERSP;  /* switch out of camera mode */
-               view3d_smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */
-       }
-}
-
 float ED_view3d_pixel_size(RegionView3D *rv3d, const float co[3])
 {
        return mul_project_m4_v3_zfac(rv3d->persmat, co) * rv3d->pixsize * U.pixelsize;
index 0a8687339a5be38ff345091e413c63b3c4ee87db..e44b9620b6f927bb0187f4bb8bfd8789da25e717 100644 (file)
@@ -1047,7 +1047,7 @@ static void createTransArmatureVerts(TransInfo *t)
        bArmature *arm = t->obedit->data;
        ListBase *edbo = arm->edbo;
        TransData *td;
-       float mtx[3][3], smtx[3][3], delta[3], bonemat[3][3];
+       float mtx[3][3], smtx[3][3], bonemat[3][3];
        
        /* special hack for envelope drawmode and scaling:
         *  to allow scaling the size of the envelope around single points,
@@ -1139,8 +1139,7 @@ static void createTransArmatureVerts(TransInfo *t)
                                        td->flag = TD_SELECTED;
 
                                        /* use local bone matrix */
-                                       sub_v3_v3v3(delta, ebo->tail, ebo->head);
-                                       vec_roll_to_mat3(delta, ebo->roll, bonemat);
+                                       ED_armature_ebone_to_mat3(ebo, bonemat);
                                        mul_m3_m3m3(td->mtx, mtx, bonemat);
                                        invert_m3_m3(td->smtx, td->mtx);
 
@@ -1180,8 +1179,7 @@ static void createTransArmatureVerts(TransInfo *t)
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
 
-                                       sub_v3_v3v3(delta, ebo->tail, ebo->head);
-                                       vec_roll_to_mat3(delta, ebo->roll, td->axismtx);
+                                       ED_armature_ebone_to_mat3(ebo, td->axismtx);
 
                                        if ((ebo->flag & BONE_ROOTSEL) == 0) {
                                                td->extra = ebo;
@@ -1204,8 +1202,7 @@ static void createTransArmatureVerts(TransInfo *t)
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
 
-                                       sub_v3_v3v3(delta, ebo->tail, ebo->head);
-                                       vec_roll_to_mat3(delta, ebo->roll, td->axismtx);
+                                       ED_armature_ebone_to_mat3(ebo, td->axismtx);
 
                                        td->extra = ebo; /* to fix roll */
 
index c6cc7bc133084493393535d5af79a05171081c7d..55d80d63234f9c82c68688251b6d8c55b83cf1d8 100644 (file)
@@ -256,13 +256,19 @@ bool createSpaceNormal(float mat[3][3], const float normal[3])
        return true;
 }
 
+/**
+ * \note To recreate an orientation from the matrix:
+ * - (plane  == mat[1])
+ * - (normal == mat[2])
+ */
 bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const float tangent[3])
 {
        if (normalize_v3_v3(mat[2], normal) == 0.0f) {
                return false;  /* error return */
        }
 
-       copy_v3_v3(mat[1], tangent);
+       /* negate so we can use values from the matrix as input */
+       negate_v3_v3(mat[1], tangent);
        /* preempt zero length tangent from causing trouble */
        if (is_zero_v3(mat[1])) {
                mat[1][2] = 1.0f;
@@ -691,6 +697,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
                                        result = ORIENTATION_VERT;
                                }
                        }
+
+                       /* not needed but this matches 2.68 and older behavior */
+                       negate_v3(plane);
+
                } /* end editmesh */
                else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
                        Curve *cu = obedit->data;
@@ -773,7 +783,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
 
                                copy_v3_v3(normal, qmat[2]);
 
-                               negate_v3_v3(plane, qmat[1]);
+                               copy_v3_v3(plane, qmat[1]);
                                
                                result = ORIENTATION_FACE;
                        }
@@ -781,45 +791,33 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
                else if (obedit->type == OB_ARMATURE) {
                        bArmature *arm = obedit->data;
                        EditBone *ebone;
-                       int ok = FALSE;
-                       
-                       /* grr. but better then duplicate code */
-#define EBONE_CALC_NORMAL_PLANE  { \
-                       float tmat[3][3]; \
-                       float vec[3]; \
-                       sub_v3_v3v3(vec, ebone->tail, ebone->head); \
-                       normalize_v3(vec); \
-                       add_v3_v3(normal, vec); \
-                       \
-                       vec_roll_to_mat3(vec, ebone->roll, tmat); \
-                       add_v3_v3(plane, tmat[2]); \
-               } (void)0
-
+                       bool ok = false;
+                       float tmat[3][3];
 
                        if (activeOnly && (ebone = arm->act_edbone)) {
-                               EBONE_CALC_NORMAL_PLANE;
-                               ok = TRUE;
+                               ED_armature_ebone_to_mat3(ebone, tmat);
+                               add_v3_v3(normal, tmat[2]);
+                               add_v3_v3(plane, tmat[1]);
+                               ok = true;
                        }
                        else {
                                for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
                                        if (arm->layer & ebone->layer) {
                                                if (ebone->flag & BONE_SELECTED) {
-                                                       EBONE_CALC_NORMAL_PLANE;
-                                                       ok = TRUE;
+                                                       ED_armature_ebone_to_mat3(ebone, tmat);
+                                                       add_v3_v3(normal, tmat[2]);
+                                                       add_v3_v3(plane, tmat[1]);
+                                                       ok = true;
                                                }
                                        }
                                }
                        }
                        
                        if (ok) {
-                               normalize_v3(normal);
-                               normalize_v3(plane);
-
                                if (!is_zero_v3(plane)) {
                                        result = ORIENTATION_EDGE;
                                }
                        }
-#undef EBONE_CALC_NORMAL_PLANE
                }
 
                /* Vectors from edges don't need the special transpose inverse multiplication */
@@ -861,8 +859,6 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
 
                /* use for both active & all */
                if (ok) {
-                       negate_v3(plane);
-                       
                        /* we need the transpose of the inverse for a normal... */
                        copy_m3_m4(imat, ob->obmat);
                        
@@ -880,11 +876,14 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
        else {
                /* we need the one selected object, if its not active */
                ob = OBACT;
-               if (ob && !(ob->flag & SELECT)) ob = NULL;
-               
-               for (base = scene->base.first; base; base = base->next) {
-                       if (TESTBASELIB(v3d, base)) {
-                               if (ob == NULL) {
+               if (ob && (ob->flag & SELECT)) {
+                       /* pass */
+               }
+               else {
+                       /* first selected */
+                       ob = NULL;
+                       for (base = scene->base.first; base; base = base->next) {
+                               if (TESTBASELIB(v3d, base)) {
                                        ob = base->object;
                                        break;
                                }
index 438f6bbdb9c0151dc7b8ba9fe6e19ea877e393db..ef22f4a484cb66eb0ed2e96811f118b5a71643e4 100644 (file)
 
 #include "uvedit_intern.h"
 
+/* use editmesh tessface */
+#define USE_EDBM_LOOPTRIS
+
+
 void draw_image_cursor(SpaceImage *sima, ARegion *ar)
 {
        float zoom[2], x_fac, y_fac;
@@ -257,6 +261,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
                                                weight_to_rgb(col, areadiff);
                                                glColor3fv(col);
                                                
+                                               /* TODO: USE_EDBM_LOOPTRIS */
                                                glBegin(GL_POLYGON);
                                                BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
                                                        luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -321,6 +326,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
                                                ang[i] = angle_normalized_v3v3(av[i], av[(i + 1) % efa_len]);
                                        }
 
+                                       /* TODO: USE_EDBM_LOOPTRIS */
                                        glBegin(GL_POLYGON);
                                        BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
                                                luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -421,6 +427,23 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob)
        }
 }
 
+#ifdef USE_EDBM_LOOPTRIS
+static void draw_uvs_looptri(BMEditMesh *em, unsigned int *r_loop_index, const int cd_loop_uv_offset)
+{
+       unsigned int i = *r_loop_index;
+       BMFace *f = em->looptris[i][0]->f;
+       do {
+               unsigned int j;
+               for (j = 0; j < 3; j++) {
+                       MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(em->looptris[i][j], cd_loop_uv_offset);
+                       glVertex2fv(luv->uv);
+               }
+               i++;
+       } while (i != em->tottri && (f == em->looptris[i][0]->f));
+       *r_loop_index = i - 1;
+}
+#endif
+
 /* draws uv's in the image space */
 static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
 {
@@ -428,7 +451,10 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
        Mesh *me = obedit->data;
        BMEditMesh *em = me->edit_btmesh;
        BMesh *bm = em->bm;
-       BMFace *efa, *efa_act, *activef;
+       BMFace *efa, *efa_act;
+#ifndef USE_EDBM_LOOPTRIS
+       BMFace *activef;
+#endif
        BMLoop *l;
        BMIter iter, liter;
        MTexPoly *tf, *activetf = NULL;
@@ -443,7 +469,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
        const int cd_poly_tex_offset = CustomData_get_offset(&bm->pdata, CD_MTEXPOLY);
 
        activetf = EDBM_mtexpoly_active_get(em, &efa_act, FALSE, FALSE); /* will be set to NULL if hidden */
+#ifndef USE_EDBM_LOOPTRIS
        activef = BM_mesh_active_face_get(bm, FALSE, FALSE);
+#endif
        ts = scene->toolsettings;
 
        drawfaces = draw_uvs_face_check(scene);
@@ -490,9 +518,42 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                glEnable(GL_BLEND);
                
+#ifdef USE_EDBM_LOOPTRIS
+               {
+                       unsigned int i;
+                       for (i = 0; i < em->tottri; i++) {
+                               efa = em->looptris[i][0]->f;
+                               tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
+                               if (uvedit_face_visible_test(scene, ima, efa, tf)) {
+                                       const bool is_select = uvedit_face_select_test(scene, efa, cd_loop_uv_offset);
+                                       BM_elem_flag_enable(efa, BM_ELEM_TAG);
+
+                                       if (tf == activetf) {
+                                               /* only once */
+                                               glEnable(GL_POLYGON_STIPPLE);
+                                               glPolygonStipple(stipple_quarttone);
+                                               UI_ThemeColor4(TH_EDITMESH_ACTIVE);
+                                       }
+                                       else {
+                                               glColor4ubv((GLubyte *)(is_select ? col2 : col1));
+                                       }
+
+                                       glBegin(GL_TRIANGLES);
+                                       draw_uvs_looptri(em, &i, cd_loop_uv_offset);
+                                       glEnd();
+
+                                       if (tf == activetf) {
+                                               glDisable(GL_POLYGON_STIPPLE);
+                                       }
+                               }
+                               else {
+                                       BM_elem_flag_disable(efa, BM_ELEM_TAG);
+                               }
+                       }
+               }
+#else
                BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
                        tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
-                       
                        if (uvedit_face_visible_test(scene, ima, efa, tf)) {
                                BM_elem_flag_enable(efa, BM_ELEM_TAG);
                                if (tf == activetf) continue;  /* important the temp boolean is set above */
@@ -515,6 +576,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
                                BM_elem_flag_disable(efa, BM_ELEM_TAG);
                        }
                }
+#endif
                glDisable(GL_BLEND);
        }
        else {
@@ -536,7 +598,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
        }
 
        /* 3. draw active face stippled */
-
+#ifndef USE_EDBM_LOOPTRIS
        if (activef) {
                tf = BM_ELEM_CD_GET_VOID_P(activef, cd_poly_tex_offset);
                if (uvedit_face_visible_test(scene, ima, activef, tf)) {
@@ -558,6 +620,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
                        glDisable(GL_BLEND);
                }
        }
+#endif
        
        /* 4. draw edges */
 
index 7266001e290d65bc5f1ef5f6ee55be6f5ef74674..18268043a04863b5bdc004d4911d5a59ff722029 100644 (file)
@@ -67,7 +67,7 @@
 #  include <unistd.h>
 #endif
 
-#define URI_MAX FILE_MAX * 3 + 8
+#define URI_MAX (FILE_MAX * 3 + 8)
 
 static int get_thumb_dir(char *dir, ThumbSize size)
 {
@@ -200,20 +200,20 @@ static int uri_from_filename(const char *path, char *uri)
                strcat(orig_uri, vol);
                dirstart += 2;
        }
-#else
-       BLI_strncpy(orig_uri, "file://", FILE_MAX);
-#endif
        strcat(orig_uri, dirstart);
        BLI_char_switch(orig_uri, '\\', '/');
+#else
+       BLI_snprintf(orig_uri, URI_MAX, "file://%s", dirstart);
+#endif
        
 #ifdef WITH_ICONV
        {
-               char uri_utf8[FILE_MAX * 3 + 8];
-               escape_uri_string(orig_uri, uri_utf8, FILE_MAX * 3 + 8, UNSAFE_PATH);
+               char uri_utf8[URI_MAX];
+               escape_uri_string(orig_uri, uri_utf8, URI_MAX, UNSAFE_PATH);
                BLI_string_to_utf8(uri_utf8, uri, NULL);
        }
 #else 
-       escape_uri_string(orig_uri, uri, FILE_MAX * 3 + 8, UNSAFE_PATH);
+       escape_uri_string(orig_uri, uri, URI_MAX, UNSAFE_PATH);
 #endif
        return 1;
 }
@@ -401,7 +401,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
 ImBuf *IMB_thumb_read(const char *path, ThumbSize size)
 {
        char thumb[FILE_MAX];
-       char uri[FILE_MAX * 3 + 8];
+       char uri[URI_MAX];
        ImBuf *img = NULL;
 
        if (!uri_from_filename(path, uri)) {
@@ -418,7 +418,7 @@ ImBuf *IMB_thumb_read(const char *path, ThumbSize size)
 void IMB_thumb_delete(const char *path, ThumbSize size)
 {
        char thumb[FILE_MAX];
-       char uri[FILE_MAX * 3 + 8];
+       char uri[URI_MAX];
 
        if (!uri_from_filename(path, uri)) {
                return;
@@ -438,7 +438,7 @@ void IMB_thumb_delete(const char *path, ThumbSize size)
 ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
 {
        char thumb[FILE_MAX];
-       char uri[FILE_MAX * 3 + 8];
+       char uri[URI_MAX];
        struct stat st;
        ImBuf *img = NULL;
        
index 4ec5879cfacf3f9a21a5f853f41f8f5eb1b27e12..a4b0e61d544dec8357f9889a2329479525283f55 100644 (file)
@@ -253,11 +253,11 @@ static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_lis
 {
        if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) {
                size_t n;
-               va_list arg2;
+               va_list args_cpy;
 
-               va_copy(arg2, arg);
-
-               n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, arg2);
+               va_copy(args_cpy, arg);
+               n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, args_cpy);
+               va_end(args_cpy);
 
                /* strip trailing \n */
                ffmpeg_last_error[n - 1] = '\0';
index fd151ccebb9cff6e75d0582335116da689dcb236..a832a8cdf964a6cccd858f5da81ab7f7e2b846a9 100644 (file)
@@ -398,16 +398,7 @@ static void rna_EditBone_parent_set(PointerRNA *ptr, PointerRNA value)
 static void rna_EditBone_matrix_get(PointerRNA *ptr, float *values)
 {
        EditBone *ebone = (EditBone *)(ptr->data);
-
-       float delta[3], tmat[3][3], mat[4][4];
-
-       /* Find the current bone matrix */
-       sub_v3_v3v3(delta, ebone->tail, ebone->head);
-       vec_roll_to_mat3(delta, ebone->roll, tmat);
-       copy_m4_m3(mat, tmat);
-       copy_v3_v3(mat[3], ebone->head);
-
-       memcpy(values, mat, 16 * sizeof(float));
+       ED_armature_ebone_to_mat4(ebone, (float(*)[4])values);
 }
 
 static void rna_Armature_editbone_transform_update(Main *bmain, Scene *scene, PointerRNA *ptr)
index ec3212d4cbb57b0cf45820d39b84b2d8d5c9055d..81f139e48ce364c936012e47d7aff85469b64915 100644 (file)
@@ -72,7 +72,6 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
 {
        DerivedMesh *dm;
        ClothModifierData *clmd = (ClothModifierData *) md;
-       DerivedMesh *result = NULL;
        
        /* check for alloc failing */
        if (!clmd->sim_parms || !clmd->coll_parms) {
@@ -92,11 +91,6 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
 
        clothModifier_do(clmd, md->scene, ob, dm, vertexCos);
 
-       if (result) {
-               result->getVertCos(result, vertexCos);
-               result->release(result);
-       }
-
        dm->release(dm);
 }
 
index d6dc8482ee2c370d0729d548b52d878aa03c7e60..d260312fe3d3a22e727ed62fb42e68f0f39b0c87 100644 (file)
@@ -262,7 +262,7 @@ static void copyData(ModifierData *md, ModifierData *target)
        tsmd->axis  = smd->axis;
        tsmd->origin = smd->origin;
        tsmd->factor = smd->factor;
-       memcpy(tsmd->limit, smd->limit, sizeof(tsmd->limit));
+       copy_v2_v2(tsmd->limit, smd->limit);
        BLI_strncpy(tsmd->vgroup_name, smd->vgroup_name, sizeof(tsmd->vgroup_name));
 }
 
index daf0e5c9dc34113decba4def9b0ffd5e9de3f5a4..91dcf721e4b37c35486ccdca143c8986fb65e74a 100644 (file)
@@ -690,7 +690,7 @@ static void build_emats_stack(BLI_Stack *stack, int *visited_e, EMat *emat,
        /* Add neighbors to stack */
        for (i = 0; i < emap[v].count; i++) {
                /* Add neighbors to stack */
-               memcpy(stack_elem.mat, emat[e].mat, sizeof(float) * 3 * 3);
+               copy_m3_m3(stack_elem.mat, emat[e].mat);
                stack_elem.e = emap[v].indices[i];
                stack_elem.parent_v = v;
                BLI_stack_push(stack, &stack_elem);
index 859636ed4e5d2b163e01069ac6cda256d1b6bda7..5e863da96353b99c55cb49476e63453dca5143c8 100644 (file)
@@ -283,10 +283,12 @@ void ntreeTexEndExecTree_internal(bNodeTreeExec *exec)
 void ntreeTexEndExecTree(bNodeTreeExec *exec)
 {
        if (exec) {
+               /* exec may get freed, so assign ntree */
+               bNodeTree *ntree = exec->nodetree;
                ntreeTexEndExecTree_internal(exec);
                
                /* XXX clear nodetree backpointer to exec data, same problem as noted in ntreeBeginExecTree */
-               exec->nodetree->execdata = NULL;
+               ntree->execdata = NULL;
        }
 }
 
index 616dd623b948304b8d420bfc30189140fd814391..ea22423985bd0ced6fc17a048cda84cea0f4924e 100644 (file)
@@ -311,7 +311,7 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char
        else if (info && info[0])
                BLI_strncpy(engine->text, info, sizeof(engine->text));
        else if (stats && stats[0])
-               BLI_strncpy(engine->text, info, sizeof(engine->text));
+               BLI_strncpy(engine->text, stats, sizeof(engine->text));
 }
 
 void RE_engine_update_progress(RenderEngine *engine, float progress)
index ca57299fe1eb628be72393cc061740e1ea6ae899..21502492c0544a07190946bdd1567a65b99d2980 100644 (file)
@@ -226,6 +226,7 @@ struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *
 void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer) {STUB_ASSERT(0);}
 void ED_armature_edit_bone_remove(struct bArmature *arm, struct EditBone *exBone) {STUB_ASSERT(0);}
 void object_test_constraints(struct Object *owner) {STUB_ASSERT(0);}
+void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) {STUB_ASSERT(0);}
 void ED_object_parent(struct Object *ob, struct Object *par, int type, const char *substr) {STUB_ASSERT(0);}
 void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) {STUB_ASSERT(0);}
 void ED_node_composit_default(struct bContext *C, struct Scene *scene) {STUB_ASSERT(0);}
index db9445b728dd3a93b848ccd082dd5461ad89d268..1fcda74d3bdaf8959f2c4c4187d7557c469f10f3 100644 (file)
@@ -37,6 +37,7 @@
 #include "RAS_LightObject.h"
 #include "RAS_ICanvas.h"
 #include "RAS_GLExtensionManager.h"
+#include "RAS_MeshObject.h"
 
 #include "KX_GameObject.h"
 #include "KX_PolygonMaterial.h"
@@ -157,6 +158,11 @@ void KX_BlenderRenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj)
 bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void * const data)
 {
        double* const oglmatrix = (double* const) data;
+
+       RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
+       if (!poly->IsVisible())
+               return false;
+
        MT_Point3 resultpoint(result->m_hitPoint);
        MT_Vector3 resultnormal(result->m_hitNormal);
        MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
index 70a05f7425b88902f81dab6a12c1e129bcc93402..e8c29d5aa4f87a8a0f24da178f8201617f710757 100644 (file)
@@ -37,6 +37,7 @@
 #include "RAS_LightObject.h"
 #include "RAS_ICanvas.h"
 #include "RAS_GLExtensionManager.h"
+#include "RAS_MeshObject.h"
 
 #include "KX_GameObject.h"
 #include "KX_PolygonMaterial.h"
@@ -166,6 +167,11 @@ void GPC_RenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj)
 bool GPC_RenderTools::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void * const data)
 {
        double* const oglmatrix = (double* const) data;
+
+       RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
+       if (!poly->IsVisible())
+               return false;
+
        MT_Point3 resultpoint(result->m_hitPoint);
        MT_Vector3 resultnormal(result->m_hitNormal);
        MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);