From 26b0255049974c502fd171e4c4d3387b0d021806 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 1 Apr 2012 00:14:41 +0000 Subject: [PATCH 01/58] Fix for is_orthogonal check which in fact was checking for orthonormal matrix. Separated it into two functions so now it'll be clear if check happens for orthonormal or just orthogonal. --- source/blender/blenlib/BLI_math_matrix.h | 2 ++ source/blender/blenlib/intern/math_matrix.c | 35 ++++++++++++++++--- .../python/mathutils/mathutils_Matrix.c | 22 ++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index de4bd203eb6..00a751f9da3 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -123,6 +123,8 @@ 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]); void adjoint_m3_m3(float R[3][3], float A[3][3]); void adjoint_m4_m4(float R[4][4], float A[4][4]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index e61a8ef041a..76b986d7346 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -816,9 +816,6 @@ int is_orthogonal_m3(float m[][3]) if (fabsf(dot_v3v3(m[i], m[j])) > 1.5f * FLT_EPSILON) return 0; } - - if (fabsf(dot_v3v3(m[i], m[i]) - 1) > 1.5f * FLT_EPSILON) - return 0; } return 1; @@ -834,13 +831,41 @@ int is_orthogonal_m4(float m[][4]) return 0; } - if (fabsf(dot_vn_vn(m[i], m[i], 4) - 1) > 1.5f * FLT_EPSILON) - return 0; } return 1; } +int is_orthonormal_m3(float m[][3]) +{ + if (is_orthogonal_m3(m)) { + int i; + + for (i = 0; i < 3; i++) + if (fabsf(dot_v3v3(m[i], m[i]) - 1) > 1.5f * FLT_EPSILON) + return 0; + + return 1; + } + + return 0; +} + +int is_orthonormal_m4(float m[][4]) +{ + if (is_orthogonal_m4(m)) { + int i; + + for (i = 0; i < 4; i++) + if (fabsf(dot_vn_vn(m[i], m[i], 4) - 1) > 1.5f * FLT_EPSILON) + return 0; + + return 1; + } + + return 0; +} + void normalize_m3(float mat[][3]) { normalize_v3(mat[0]); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 4079d69b87d..f5f54356680 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -2230,6 +2230,27 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu } } +PyDoc_STRVAR(Matrix_is_orthonormal_doc, +"True if this matrix is orthonormal, 3x3 and 4x4 only, (read-only).\n\n:type: bool" +); +static PyObject *Matrix_is_orthonormal_get(MatrixObject *self, void *UNUSED(closure)) +{ + if (BaseMath_ReadCallback(self) == -1) + return NULL; + + /*must be 3-4 cols, 3-4 rows, square matrix*/ + if (self->num_row == 4 && self->num_col == 4) + return PyBool_FromLong(is_orthonormal_m4((float (*)[4])self->matrix)); + else if (self->num_row == 3 && self->num_col == 3) + return PyBool_FromLong(is_orthonormal_m3((float (*)[3])self->matrix)); + else { + PyErr_SetString(PyExc_AttributeError, + "Matrix.is_orthonormal: " + "inappropriate matrix size - expects 3x3 or 4x4 matrix"); + return NULL; + } +} + /*****************************************************************************/ /* Python attributes get/set structure: */ /*****************************************************************************/ @@ -2240,6 +2261,7 @@ static PyGetSetDef Matrix_getseters[] = { {(char *)"col", (getter)Matrix_col_get, (setter)NULL, Matrix_col_doc, NULL}, {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL}, {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, Matrix_is_orthogonal_doc, NULL}, + {(char *)"is_orthonormal", (getter)Matrix_is_orthonormal_get, (setter)NULL, Matrix_is_orthonormal_doc, NULL}, {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ From b1951ac1bad4190ca46b6e6b1a0140fd5ae31a8c Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sun, 1 Apr 2012 10:36:54 +0000 Subject: [PATCH 02/58] fix for [#30738] Shading smooth/flat instability Committing patch from Francisco De La Cruz ([#30753] Shade smooth not preserved when toggling editmode) Thanks for researching this and providing fix. --- source/blender/bmesh/intern/bmesh_mesh_conv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 1db0280b4af..8af31efda81 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -256,10 +256,10 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr) BM_elem_index_set(f, bm->totface - 1); /* set_ok */ /* transfer flag */ - f->head.hflag = BM_face_flag_from_mflag(mpoly->flag & ~SELECT); + f->head.hflag = BM_face_flag_from_mflag(mpoly->flag & ~ME_FACE_SEL); /* this is necessary for selection counts to work properly */ - if (mpoly->flag & SELECT) { + if (mpoly->flag & ME_FACE_SEL) { BM_elem_select_set(bm, f, TRUE); } From e0ead2631280df9c18f966169a7e3fd561e33e1b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 1 Apr 2012 15:02:19 +0000 Subject: [PATCH 03/58] Partial fix [#30744] BMesh: Particle system face/volume emission doesn't work if there is a constructive modifier earlier. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ORIGSPACE is added, it is now a loop data, so we need to mark tessdata as dirty too. Also fixed DM_ensure_tessface to check DM_DIRTY_TESS_CDLAYERS flag! This fixes problems with subsurf + dynapaint + particles, however, some modifiers, like remesh, seems to create a new dm from scratch, hence loosing completely those CD layers… Note this bug already existed in 2.62, so this is not a regression. --- source/blender/blenkernel/intern/DerivedMesh.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 0041553ec44..65ef4e5b431 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -382,6 +382,13 @@ void DM_ensure_tessface(DerivedMesh *dm) __func__, numPolys, dm->type); } } + + else if (dm->dirty && DM_DIRTY_TESS_CDLAYERS) { + BLI_assert(CustomData_has_layer(&dm->faceData, CD_POLYINDEX)); + DM_update_tessface_data(dm); + } + + dm->dirty &= ~DM_DIRTY_TESS_CDLAYERS; } /* Update tessface CD data from loop/poly ones. Needed when not retessellating after modstack evaluation. */ @@ -1629,7 +1636,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos deformedVerts = NULL; } - } + } /* create an orco derivedmesh in parallel */ if (nextmask & CD_MASK_ORCO) { @@ -3061,6 +3068,8 @@ void DM_init_origspace(DerivedMesh *dm) } } } + + dm->dirty |= DM_DIRTY_TESS_CDLAYERS; } From 52f1f292f7f50c55d505802b6db623bccb6935af Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 1 Apr 2012 15:25:07 +0000 Subject: [PATCH 04/58] Reverting some style changes from r45305. See discussion here: http://lists.blender.org/pipermail/bf-committers/2012-April/036098.html --- source/blender/bmesh/operators/bmo_dupe.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 4b559400bb8..2c620cdd5ab 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -195,15 +195,14 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) GHash *vhash, *ehash; /* initialize pointer hashes */ - vhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, - "bmesh dupeops v"); - ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, - "bmesh dupeops e"); + vhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops v"); + ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops e"); /* duplicate flagged vertices */ BM_ITER(v, &viter, source, BM_VERTS_OF_MESH, source) { if (BMO_elem_flag_test(source, v, DUPE_INPUT) && - !BMO_elem_flag_test(source, v, DUPE_DONE)) { + !BMO_elem_flag_test(source, v, DUPE_DONE)) + { BMIter iter; int isolated = 1; @@ -236,7 +235,8 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) /* now we dupe all the edges */ BM_ITER(e, &eiter, source, BM_EDGES_OF_MESH, source) { if (BMO_elem_flag_test(source, e, DUPE_INPUT) && - !BMO_elem_flag_test(source, e, DUPE_DONE)) { + !BMO_elem_flag_test(source, e, DUPE_DONE)) + { /* make sure that verts are copied */ if (!BMO_elem_flag_test(source, e->v1, DUPE_DONE)) { copy_vertex(source, e->v1, target, vhash); From 6c4d6757594dd942304048690ae539e51f9e9d0b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 01:57:56 +0000 Subject: [PATCH 05/58] style cleanup --- source/blender/bmesh/operators/bmo_dupe.c | 57 +++++++++++------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 2c620cdd5ab..e208eb21a3b 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -29,23 +29,22 @@ #include "bmesh.h" /* local flag define */ -#define DUPE_INPUT 1 /* input from operator */ -#define DUPE_NEW 2 -#define DUPE_DONE 4 -#define DUPE_MAPPED 8 +#define DUPE_INPUT 1 /* input from operator */ +#define DUPE_NEW 2 +#define DUPE_DONE 4 +#define DUPE_MAPPED 8 -/* - * COPY VERTEX - * - * Copy an existing vertex from one bmesh to another. +/** + * COPY VERTEX * + * Copy an existing vertex from one bmesh to another. */ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *target_mesh, GHash *vhash) { BMVert *target_vertex = NULL; /* Create a new vertex */ - target_vertex = BM_vert_create(target_mesh, source_vertex->co, NULL); + target_vertex = BM_vert_create(target_mesh, source_vertex->co, NULL); /* Insert new vertex into the vert hash */ BLI_ghash_insert(vhash, source_vertex, target_vertex); @@ -59,11 +58,10 @@ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *tar return target_vertex; } -/* +/** * COPY EDGE * * Copy an existing edge from one bmesh to another. - * */ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, BMEdge *source_edge, BMesh *target_mesh, @@ -115,10 +113,10 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, return target_edge; } -/* +/** * COPY FACE * - * Copy an existing face from one bmesh to another. + * Copy an existing face from one bmesh to another. */ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, @@ -151,10 +149,8 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, /* create new face */ target_face = BM_face_create(target_mesh, vtar, edar, source_face->len, FALSE); - BMO_slot_map_ptr_insert(source_mesh, op, - "facemap", source_face, target_face); - BMO_slot_map_ptr_insert(source_mesh, op, - "facemap", target_face, source_face); + BMO_slot_map_ptr_insert(source_mesh, op, "facemap", source_face, target_face); + BMO_slot_map_ptr_insert(source_mesh, op, "facemap", target_face, source_face); BM_elem_attrs_copy(source_mesh, target_mesh, source_face, target_face); @@ -174,11 +170,12 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, return target_face; } -/* +/** * COPY MESH * * Internal Copy function. */ + static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) { @@ -201,7 +198,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) /* duplicate flagged vertices */ BM_ITER(v, &viter, source, BM_VERTS_OF_MESH, source) { if (BMO_elem_flag_test(source, v, DUPE_INPUT) && - !BMO_elem_flag_test(source, v, DUPE_DONE)) + !BMO_elem_flag_test(source, v, DUPE_DONE)) { BMIter iter; int isolated = 1; @@ -235,7 +232,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) /* now we dupe all the edges */ BM_ITER(e, &eiter, source, BM_EDGES_OF_MESH, source) { if (BMO_elem_flag_test(source, e, DUPE_INPUT) && - !BMO_elem_flag_test(source, e, DUPE_DONE)) + !BMO_elem_flag_test(source, e, DUPE_DONE)) { /* make sure that verts are copied */ if (!BMO_elem_flag_test(source, e->v1, DUPE_DONE)) { @@ -247,7 +244,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) BMO_elem_flag_enable(source, e->v2, DUPE_DONE); } /* now copy the actual edge */ - copy_edge(op, source, e, target, vhash, ehash); + copy_edge(op, source, e, target, vhash, ehash); BMO_elem_flag_enable(source, e, DUPE_DONE); } } @@ -266,7 +263,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) /* edge pass */ BM_ITER(e, &eiter, source, BM_EDGES_OF_FACE, f) { if (!BMO_elem_flag_test(source, e, DUPE_DONE)) { - copy_edge(op, source, e, target, vhash, ehash); + copy_edge(op, source, e, target, vhash, ehash); BMO_elem_flag_enable(source, e, DUPE_DONE); } } @@ -291,7 +288,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) BLI_array_free(edar); /* free edge pointer array */ } -/* +/** * Duplicate Operator * * Duplicates verts, edges and faces of a mesh. @@ -310,7 +307,6 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) * BMOP_DUPE_VNEW: Buffer containing pointers to the new mesh vertices * BMOP_DUPE_ENEW: Buffer containing pointers to the new mesh edges * BMOP_DUPE_FNEW: Buffer containing pointers to the new mesh faces - * */ void bmo_dupe_exec(BMesh *bm, BMOperator *op) @@ -352,7 +348,7 @@ void BMO_dupe_from_flag(BMesh *bm, int htype, const char hflag) } #endif -/* +/** * Split Operator * * Duplicates verts, edges and faces of a mesh but also deletes the originals. @@ -370,7 +366,8 @@ void BMO_dupe_from_flag(BMesh *bm, int htype, const char hflag) * BMOP_DUPE_FOUTPUT: Buffer containing pointers to the split mesh faces */ -#define SPLIT_INPUT 1 +#define SPLIT_INPUT 1 + void bmo_split_exec(BMesh *bm, BMOperator *op) { BMOperator *splitop = op; @@ -432,10 +429,8 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) /* now we make our outputs by copying the dupe output */ BMO_slot_copy(&dupeop, splitop, "newout", "geomout"); - BMO_slot_copy(&dupeop, splitop, "boundarymap", - "boundarymap"); - BMO_slot_copy(&dupeop, splitop, "isovertmap", - "isovertmap"); + BMO_slot_copy(&dupeop, splitop, "boundarymap", "boundarymap"); + BMO_slot_copy(&dupeop, splitop, "isovertmap", "isovertmap"); /* cleanup */ BMO_op_finish(bm, &delop); @@ -457,7 +452,7 @@ void bmo_del_exec(BMesh *bm, BMOperator *op) #undef DEL_INPUT } -/* +/** * Spin Operator * * Extrude or duplicate geometry a number of times, From 670cdd5381b23b7ae1808262a12c0423c8fa73c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 02:41:28 +0000 Subject: [PATCH 06/58] code cleanup: always use if (...) even if the macros dont require it (confuses parsers) define macros without the ';'s included. --- .../blender/editors/animation/anim_filter.c | 27 +++-- .../blender/editors/space_graph/graph_draw.c | 4 +- .../editors/transform/transform_conversions.c | 2 +- .../editors/transform/transform_manipulator.c | 2 +- .../transform/transform_orientations.c | 2 +- source/blender/imbuf/intern/anim_movie.c | 8 +- source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/makesrna/intern/rna_test.c | 111 +++++++++--------- source/blender/modifiers/intern/MOD_explode.c | 23 ++-- .../nodes/node_composite_bilateralblur.c | 24 ++-- .../render/intern/source/convertblender.c | 2 +- .../blender/render/intern/source/volumetric.c | 2 +- 12 files changed, 112 insertions(+), 97 deletions(-) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 5729ee79cef..e5822c76fa1 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -362,7 +362,10 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac) else {\ filter_mode |= ANIMFILTER_TMP_PEEK; \ } \ - (void) _doSubChannels; + \ + { \ + (void) _doSubChannels; \ + } /* ... standard sub-channel filtering can go on here now ... */ #define END_ANIMFILTER_SUBCHANNELS \ filter_mode = _filter; \ @@ -954,7 +957,7 @@ static FCurve *animfilter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGr /* only work with this channel and its subchannels if it is editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_FCU(fcu)) { /* only include this curve if selected in a way consistent with the filtering requirements */ - if ( ANIMCHANNEL_SELOK(SEL_FCU(fcu)) && ANIMCHANNEL_SELEDITOK(SEL_FCU(fcu)) ) { + if (ANIMCHANNEL_SELOK(SEL_FCU(fcu)) && ANIMCHANNEL_SELEDITOK(SEL_FCU(fcu))) { /* only include if this curve is active */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) { /* name based filtering... */ @@ -1168,7 +1171,7 @@ static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDo /* only work with this channel and its subchannels if it is editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) { /* only include this track if selected in a way consistent with the filtering requirements */ - if ( ANIMCHANNEL_SELOK(SEL_NLT(nlt)) ) { + if (ANIMCHANNEL_SELOK(SEL_NLT(nlt))) { /* only include if this track is active */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (nlt->flag & NLATRACK_ACTIVE)) { ANIMCHANNEL_NEW_CHANNEL(nlt, ANIMTYPE_NLATRACK, owner_id); @@ -1348,7 +1351,7 @@ static size_t animdata_filter_ds_nodetree (bAnimContext *ac, ListBase *anim_data /* include data-expand widget first */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by active status */ - if ANIMCHANNEL_ACTIVEOK(ntree) { + if (ANIMCHANNEL_ACTIVEOK(ntree)) { ANIMCHANNEL_NEW_CHANNEL(ntree, ANIMTYPE_DSNTREE, owner_id); } } @@ -1433,7 +1436,7 @@ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data /* include texture-expand widget? */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by active status */ - if ANIMCHANNEL_ACTIVEOK(tex) { + if (ANIMCHANNEL_ACTIVEOK(tex)) { ANIMCHANNEL_NEW_CHANNEL(tex, ANIMTYPE_DSTEX, owner_id); } } @@ -1485,7 +1488,7 @@ static size_t animdata_filter_ds_materials (bAnimContext *ac, ListBase *anim_dat // hmm... do we need to store the index of this material in the array anywhere? if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by active status */ - if ANIMCHANNEL_ACTIVEOK(ma) { + if (ANIMCHANNEL_ACTIVEOK(ma)) { ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma); } } @@ -1527,7 +1530,7 @@ static size_t animdata_filter_ds_particles (bAnimContext *ac, ListBase *anim_dat /* include particle-expand widget first */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by active status */ - if ANIMCHANNEL_ACTIVEOK(psys->part) { + if (ANIMCHANNEL_ACTIVEOK(psys->part)) { ANIMCHANNEL_NEW_CHANNEL(psys->part, ANIMTYPE_DSPART, psys->part); } } @@ -1667,7 +1670,7 @@ static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, /* include data-expand widget first */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by active status */ - if ANIMCHANNEL_ACTIVEOK(iat) { + if (ANIMCHANNEL_ACTIVEOK(iat)) { ANIMCHANNEL_NEW_CHANNEL(iat, type, iat); } } @@ -1701,7 +1704,7 @@ static size_t animdata_filter_ds_keyanim (bAnimContext *ac, ListBase *anim_data, if (tmp_items) { /* include key-expand widget first */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { - if ANIMCHANNEL_ACTIVEOK(key) { + if (ANIMCHANNEL_ACTIVEOK(key)) { ANIMCHANNEL_NEW_CHANNEL(key, ANIMTYPE_DSSKEY, ob); } } @@ -1818,7 +1821,7 @@ static size_t animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_dat if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by selection */ // XXX: double-check on this - most of the time, a lot of tools need to filter out these channels! - if ANIMCHANNEL_SELOK((base->flag & SELECT)) { + if (ANIMCHANNEL_SELOK((base->flag & SELECT))) { /* check if filtering by active status */ if (ANIMCHANNEL_ACTIVEOK(ob)) { ANIMCHANNEL_NEW_CHANNEL(base, ANIMTYPE_OBJECT, ob); @@ -1863,7 +1866,7 @@ static size_t animdata_filter_ds_world (bAnimContext *ac, ListBase *anim_data, b /* include data-expand widget first */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by active status */ - if ANIMCHANNEL_ACTIVEOK(wo) { + if (ANIMCHANNEL_ACTIVEOK(wo)) { ANIMCHANNEL_NEW_CHANNEL(wo, ANIMTYPE_DSWOR, sce); } } @@ -1968,7 +1971,7 @@ static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_ /* firstly add object expander if required */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by selection */ - if ANIMCHANNEL_SELOK((sce->flag & SCE_DS_SELECTED)) { + if (ANIMCHANNEL_SELOK((sce->flag & SCE_DS_SELECTED))) { /* NOTE: active-status doesn't matter for this! */ ANIMCHANNEL_NEW_CHANNEL(sce, ANIMTYPE_SCENE, sce); } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 25998e7bce2..fc84cfc46a2 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -118,7 +118,7 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) /* only draw if visible * - min/max here are fixed, not relative */ - if IN_RANGE(fed->time, (v2d->cur.xmin - fac), (v2d->cur.xmax + fac)) { + if (IN_RANGE(fed->time, (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) { glVertex2f(fed->time, fed->min); glVertex2f(fed->time, fed->max); } @@ -149,7 +149,7 @@ static void draw_fcurve_vertices_keyframes (FCurve *fcu, SpaceIpo *UNUSED(sipo), /* as an optimization step, only draw those in view * - we apply a correction factor to ensure that points don't pop in/out due to slight twitches of view size */ - if IN_RANGE(bezt->vec[1][0], (v2d->cur.xmin - fac), (v2d->cur.xmax + fac)) { + if (IN_RANGE(bezt->vec[1][0], (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) { if (edit) { /* 'Keyframe' vertex only, as handle lines and handles have already been drawn * - only draw those with correct selection state for the current drawing color diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 4754e1731c8..c273d6a5b4c 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4491,7 +4491,7 @@ static void set_trans_object_base_flags(TransInfo *t) if (parsel->flag & SELECT) { Base *parbase = object_in_scene(parsel, scene); if (parbase) { /* in rare cases this can fail */ - if TESTBASELIB_BGMODE(v3d, scene, parbase) { + if (TESTBASELIB_BGMODE(v3d, scene, parbase)) { break; } } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 513f7df1957..c6b8403d54f 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -531,7 +531,7 @@ int calc_manipulator_stats(const bContext *C) if (ob && !(ob->flag & SELECT)) ob= NULL; for (base= scene->base.first; base; base= base->next) { - if TESTBASELIB(v3d, base) { + if (TESTBASELIB(v3d, base)) { if (ob==NULL) ob= base->object; calc_tw_center(scene, base->object->obmat[3]); diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index d2cf74881f2..d822bb0aaf7 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -859,7 +859,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], if (ob && !(ob->flag & SELECT)) ob = NULL; for (base= scene->base.first; base; base= base->next) { - if TESTBASELIB(v3d, base) { + if (TESTBASELIB(v3d, base)) { if (ob == NULL) { ob= base->object; break; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 8a700053d30..01a9a0a7303 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -45,8 +45,12 @@ #undef AVIIF_KEYFRAME // redefined in AVI_avi.h #undef AVIIF_LIST // redefined in AVI_avi.h -#define FIXCC(fcc) if (fcc == 0) fcc = mmioFOURCC('N', 'o', 'n', 'e'); \ - if (fcc == BI_RLE8) fcc = mmioFOURCC('R', 'l', 'e', '8'); +#define FIXCC(fcc) \ + { \ + if (fcc == 0) { fcc = mmioFOURCC('N', 'o', 'n', 'e'); } \ + if (fcc == BI_RLE8) { fcc = mmioFOURCC('R', 'l', 'e', '8'); } \ + } + #endif #include diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 6f73fc65151..02917f1bce8 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -93,7 +93,7 @@ static int replace_if_different(char *tmpfile, const char *dep_files[]) return -1; \ } \ remove(tmpfile); \ - return 1; \ + return 1 \ /* end REN_IF_DIFF */ diff --git a/source/blender/makesrna/intern/rna_test.c b/source/blender/makesrna/intern/rna_test.c index e094423995e..8bc545f34b7 100644 --- a/source/blender/makesrna/intern/rna_test.c +++ b/source/blender/makesrna/intern/rna_test.c @@ -47,66 +47,69 @@ #ifdef UNIT_TEST -#define DEF_VARS(type, prefix) \ - static type prefix ## arr[ARRAY_SIZE]; \ - static type prefix ## darr[DYNAMIC_ARRAY_SIZE]; \ - static int prefix ## darr_len = ARRAY_SIZE; \ - static type prefix ## marr MARRAY_DIM; \ - static type prefix ## dmarr DYNAMIC_MARRAY_DIM; \ - static int prefix ## dmarr_len = sizeof(prefix ## dmarr); +#define DEF_VARS(type, prefix) \ + static type prefix ## arr[ARRAY_SIZE]; \ + static type prefix ## darr[DYNAMIC_ARRAY_SIZE]; \ + static int prefix ## darr_len = ARRAY_SIZE; \ + static type prefix ## marr MARRAY_DIM; \ + static type prefix ## dmarr DYNAMIC_MARRAY_DIM; \ + static int prefix ## dmarr_len = sizeof(prefix ## dmarr); \ + (void)0 -#define DEF_GET_SET(type, arr) \ - void rna_Test_ ## arr ## _get(PointerRNA *ptr, type *values) \ - { \ - memcpy(values, arr, sizeof(arr)); \ - } \ - \ - void rna_Test_ ## arr ## _set(PointerRNA *ptr, const type *values) \ - { \ - memcpy(arr, values, sizeof(arr)); \ - } +#define DEF_GET_SET(type, arr) \ + void rna_Test_ ## arr ## _get(PointerRNA * ptr, type * values) \ + { \ + memcpy(values, arr, sizeof(arr)); \ + } \ + \ + void rna_Test_ ## arr ## _set(PointerRNA * ptr, const type * values) \ + { \ + memcpy(arr, values, sizeof(arr)); \ + } \ + (void)0 -#define DEF_GET_SET_LEN(arr, max) \ - static int rna_Test_ ## arr ## _get_length(PointerRNA *ptr) \ - { \ - return arr ## _len; \ - } \ - \ - static int rna_Test_ ## arr ## _set_length(PointerRNA *ptr, int length) \ - { \ - if (length > max) \ - return 0; \ - \ - arr ## _len = length; \ - \ - return 1; \ - } \ +#define DEF_GET_SET_LEN(arr, max) \ + static int rna_Test_ ## arr ## _get_length(PointerRNA * ptr) \ + { \ + return arr ## _len; \ + } \ + \ + static int rna_Test_ ## arr ## _set_length(PointerRNA * ptr, int length) \ + { \ + if (length > max) \ + return 0; \ + \ + arr ## _len = length; \ + \ + return 1; \ + } \ + (void)0 -DEF_VARS(float, f) -DEF_VARS(int, i) -DEF_VARS(int, b) +DEF_VARS(float, f); +DEF_VARS(int, i); +DEF_VARS(int, b); -DEF_GET_SET(float, farr) -DEF_GET_SET(int, iarr) -DEF_GET_SET(int, barr) +DEF_GET_SET(float, farr); +DEF_GET_SET(int, iarr); +DEF_GET_SET(int, barr); -DEF_GET_SET(float, fmarr) -DEF_GET_SET(int, imarr) -DEF_GET_SET(int, bmarr) +DEF_GET_SET(float, fmarr); +DEF_GET_SET(int, imarr); +DEF_GET_SET(int, bmarr); -DEF_GET_SET(float, fdarr) -DEF_GET_SET_LEN(fdarr, DYNAMIC_ARRAY_SIZE) -DEF_GET_SET(int, idarr) -DEF_GET_SET_LEN(idarr, DYNAMIC_ARRAY_SIZE) -DEF_GET_SET(int, bdarr) -DEF_GET_SET_LEN(bdarr, DYNAMIC_ARRAY_SIZE) +DEF_GET_SET(float, fdarr); +DEF_GET_SET_LEN(fdarr, DYNAMIC_ARRAY_SIZE); +DEF_GET_SET(int, idarr); +DEF_GET_SET_LEN(idarr, DYNAMIC_ARRAY_SIZE); +DEF_GET_SET(int, bdarr); +DEF_GET_SET_LEN(bdarr, DYNAMIC_ARRAY_SIZE); -DEF_GET_SET(float, fdmarr) -DEF_GET_SET_LEN(fdmarr, DYNAMIC_MARRAY_SIZE(float)) -DEF_GET_SET(int, idmarr) -DEF_GET_SET_LEN(idmarr, DYNAMIC_MARRAY_SIZE(int)) -DEF_GET_SET(int, bdmarr) -DEF_GET_SET_LEN(bdmarr, DYNAMIC_MARRAY_SIZE(int)) +DEF_GET_SET(float, fdmarr); +DEF_GET_SET_LEN(fdmarr, DYNAMIC_MARRAY_SIZE(float)); +DEF_GET_SET(int, idmarr); +DEF_GET_SET_LEN(idmarr, DYNAMIC_MARRAY_SIZE(int)); +DEF_GET_SET(int, bdmarr); +DEF_GET_SET_LEN(bdmarr, DYNAMIC_MARRAY_SIZE(int)); #endif @@ -186,4 +189,4 @@ void RNA_def_test(BlenderRNA *brna) #endif } -#endif /* RNA_RUNTIME */ +#endif /* RNA_RUNTIME */ diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 56aa0f3c939..32d88fe28bc 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -205,10 +205,11 @@ static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFa } #define SET_VERTS(a, b, c, d) \ - v[0]=mf->v##a; uv[0]=a-1; \ - v[1]=mf->v##b; uv[1]=b-1; \ - v[2]=mf->v##c; uv[2]=c-1; \ - v[3]=mf->v##d; uv[3]=d-1; + v[0] = mf->v##a; uv[0]=a-1; \ + v[1] = mf->v##b; uv[1]=b-1; \ + v[2] = mf->v##c; uv[2]=c-1; \ + v[3] = mf->v##d; uv[3]=d-1; \ + (void)0 #define GET_ES(v1, v2) edgecut_get(eh, v1, v2) #define INT_UV(uvf, c0, c1) interp_v2_v2v2(uvf, mf->uv[c0], mf->uv[c1], 0.5f) @@ -683,30 +684,30 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) case 10: case 11: case 15: - SET_VERTS(1, 2, 3, 4) + SET_VERTS(1, 2, 3, 4); break; case 5: case 6: case 7: - SET_VERTS(2, 3, 4, 1) + SET_VERTS(2, 3, 4, 1); break; case 9: case 13: - SET_VERTS(4, 1, 2, 3) + SET_VERTS(4, 1, 2, 3); break; case 12: case 14: - SET_VERTS(3, 4, 1, 2) + SET_VERTS(3, 4, 1, 2); break; case 21: case 23: - SET_VERTS(1, 2, 3, 4) + SET_VERTS(1, 2, 3, 4); break; case 19: - SET_VERTS(2, 3, 1, 4) + SET_VERTS(2, 3, 1, 4); break; case 22: - SET_VERTS(3, 1, 2, 4) + SET_VERTS(3, 1, 2, 4); break; } diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index 8faa060244a..f42fd83c13d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -48,7 +48,8 @@ static bNodeSocketTemplate cmp_node_bilateralblur_out[]= { mean1[0] = src[0]; \ mean1[1] = src[1]; \ mean1[2] = src[2]; \ - mean1[3] = src[3]; + mean1[3] = src[3]; \ + (void)0 /* finds color distances */ #define COLOR_DISTANCE_C3(c1, c2) \ @@ -66,25 +67,28 @@ static bNodeSocketTemplate cmp_node_bilateralblur_out[]= { (double)COLOR_DISTANCE_C3(ref, ref_color ) * i2sigma_color; \ w = 1.0/(w*w + 1); \ mean0 += w; \ - mean1[0] += (double)temp_color[0]*w; \ - mean1[1] += (double)temp_color[1]*w; \ - mean1[2] += (double)temp_color[2]*w; \ - mean1[3] += (double)temp_color[3]*w; + mean1[0] += (double)temp_color[0] * w; \ + mean1[1] += (double)temp_color[1] * w; \ + mean1[2] += (double)temp_color[2] * w; \ + mean1[3] += (double)temp_color[3] * w; \ + (void)0 /* write blurred values to image */ #define UPDATE_OUTPUT_C3 \ mean0 = 1.0/mean0; \ - dest[x*pix + 0] = mean1[0]*mean0; \ - dest[x*pix + 1] = mean1[1]*mean0; \ - dest[x*pix + 2] = mean1[2]*mean0; \ - dest[x*pix + 3] = mean1[3]*mean0; + dest[x * pix + 0] = mean1[0] * mean0; \ + dest[x * pix + 1] = mean1[1] * mean0; \ + dest[x * pix + 2] = mean1[2] * mean0; \ + dest[x * pix + 3] = mean1[3] * mean0; \ + (void)0 /* initializes deltas for fast access to neighbor pixels */ #define INIT_3X3_DELTAS( deltas, step, nch ) \ ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \ (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \ (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \ - (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); + (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); \ + (void)0 /* code of this node was heavily inspired by the smooth function of opencv library. diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index b8935b5f960..9b12d556320 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -5861,7 +5861,7 @@ void RE_make_sticky(Scene *scene, View3D *v3d) RE_SetView(re, mat); for (base= FIRSTBASE; base; base= base->next) { - if TESTBASELIB(v3d, base) { + if (TESTBASELIB(v3d, base)) { if (base->object->type==OB_MESH) { ob= base->object; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 02dcc72f525..fa0326e2c97 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -397,7 +397,7 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3 case MA_VOL_PH_RAYLEIGH: return normalize * 3.f/4.f * (1 + costheta * costheta); case MA_VOL_PH_HG: - return normalize * (1.f - g*g) / powf(1.f + g*g - 2.f * g * costheta, 1.5f)); + return normalize * (1.f - g * g) / powf(1.f + g * g - 2.f * g * costheta, 1.5f); case MA_VOL_PH_SCHLICK: { const float k = 1.55f * g - .55f * g * g * g; From 56c127e721681f6978870218b28d8edf5287fbf7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 03:51:16 +0000 Subject: [PATCH 07/58] fix - extrude could create hidden faces when the only connected face to an edge was hidden, the hidden setting would be copied to the newly created face. --- source/blender/bmesh/operators/bmo_extrude.c | 46 ++++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 77ba69b2372..981232b4d66 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -116,46 +116,46 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e, BMEdge *newedge) { BMIter iter; - BMLoop *l, *l2; - - /* copy attribute */ - l = BM_iter_new(&iter, bm, BM_LOOPS_OF_FACE, f); - for ( ; l; l = BM_iter_step(&iter)) { + BMLoop *l, *l_other; + /* copy attributes */ + BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { if (l->e != e && l->e != newedge) { continue; } - l2 = l->radial_next; + l_other = l->radial_next; - if (l2 == l) { - l2 = newedge->l; + if (l_other == l) { + l_other = newedge->l; - if (l2 != l) { - BM_elem_attrs_copy(bm, bm, l2->f, l->f); + if (l_other != l) { + BM_elem_attrs_copy(bm, bm, l_other->f, f); + BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */ - BM_elem_attrs_copy(bm, bm, l2, l); - l2 = l2->next; + BM_elem_attrs_copy(bm, bm, l_other, l); + l_other = l_other->next; l = l->next; - BM_elem_attrs_copy(bm, bm, l2, l); + BM_elem_attrs_copy(bm, bm, l_other, l); } } else { - BM_elem_attrs_copy(bm, bm, l2->f, l->f); + BM_elem_attrs_copy(bm, bm, l_other->f, f); + BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */ - /* copy dat */ - if (l2->v == l->v) { - BM_elem_attrs_copy(bm, bm, l2, l); - l2 = l2->next; + /* copy data */ + if (l_other->v == l->v) { + BM_elem_attrs_copy(bm, bm, l_other, l); + l_other = l_other->next; l = l->next; - BM_elem_attrs_copy(bm, bm, l2, l); + BM_elem_attrs_copy(bm, bm, l_other, l); } else { - l2 = l2->next; - BM_elem_attrs_copy(bm, bm, l2, l); - l2 = l2->prev; + l_other = l_other->next; + BM_elem_attrs_copy(bm, bm, l_other, l); + l_other = l_other->prev; l = l->next; - BM_elem_attrs_copy(bm, bm, l2, l); + BM_elem_attrs_copy(bm, bm, l_other, l); } } } From 4253e52771c40b347ddc0d02586f2c405afa30d4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 04:45:44 +0000 Subject: [PATCH 08/58] fix [#30768] Project from View UV map tool includes hidden geometry r45323 select all could select hidden faces, now BM_mesh_elem_flag_enable/disable_all takes an argument to skip hidden elements. --- source/blender/bmesh/intern/bmesh_marking.c | 26 ++++++++++++++++--- source/blender/bmesh/intern/bmesh_marking.h | 4 +-- source/blender/bmesh/operators/bmo_inset.c | 4 +-- .../blender/bmesh/operators/bmo_subdivide.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 2 +- source/blender/editors/mesh/editmesh_utils.c | 6 ++--- source/blender/modifiers/intern/MOD_array.c | 16 ++++++------ 7 files changed, 39 insertions(+), 21 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 2116acc337e..3117c74c1a7 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -762,7 +762,7 @@ void BM_select_history_validate(BMesh *bm) } } -void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag) +void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag, int respecthide) { const char iter_types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, @@ -778,7 +778,10 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag BM_select_history_clear(bm); } - if (htype == (BM_VERT | BM_EDGE | BM_FACE) && (hflag == BM_ELEM_SELECT)) { + if ((htype == (BM_VERT | BM_EDGE | BM_FACE)) && + (hflag == BM_ELEM_SELECT) && + (respecthide == FALSE)) + { /* fast path for deselect all, avoid topology loops * since we know all will be de-selected anyway. */ for (i = 0; i < 3; i++) { @@ -794,6 +797,11 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag if (htype & flag_types[i]) { ele = BM_iter_new(&iter, bm, iter_types[i], NULL); for ( ; ele; ele = BM_iter_step(&iter)) { + + if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) { + continue; + } + if (hflag & BM_ELEM_SELECT) { BM_elem_select_set(bm, ele, FALSE); } @@ -804,7 +812,7 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag } } -void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag) +void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag, int respecthide) { const char iter_types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, @@ -812,6 +820,11 @@ void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag) const char flag_types[3] = {BM_VERT, BM_EDGE, BM_FACE}; + /* use the nosel version when setting so under no + * condition may a hidden face become selected. + * Applying other flags to hidden faces is OK. */ + const char hflag_nosel = hflag & ~BM_ELEM_SELECT; + BMIter iter; BMElem *ele; int i; @@ -828,10 +841,15 @@ void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag) if (htype & flag_types[i]) { ele = BM_iter_new(&iter, bm, iter_types[i], NULL); for ( ; ele; ele = BM_iter_step(&iter)) { + + if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) { + continue; + } + if (hflag & BM_ELEM_SELECT) { BM_elem_select_set(bm, ele, TRUE); } - BM_elem_flag_enable(ele, hflag); + BM_elem_flag_enable(ele, hflag_nosel); } } } diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h index a02931b0e88..fa078c74b2e 100644 --- a/source/blender/bmesh/intern/bmesh_marking.h +++ b/source/blender/bmesh/intern/bmesh_marking.h @@ -45,8 +45,8 @@ void BM_face_hide_set(BMesh *bm, BMFace *f, int hide); #define BM_elem_select_set(bm, ele, hide) _bm_elem_select_set(bm, &(ele)->head, hide) void _bm_elem_select_set(BMesh *bm, BMHeader *ele, int select); -void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag); -void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag); +void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag, int respecthide); +void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag, int respecthide); /* individual element select functions, BM_elem_select_set is a shortcut for these * that automatically detects which one to use*/ diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 4a426b40995..23255d1c514 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -119,11 +119,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) int i, j, k; if (use_outset == FALSE) { - BM_mesh_elem_flag_disable_all(bm, BM_FACE, BM_ELEM_TAG); + BM_mesh_elem_flag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); BMO_slot_buffer_hflag_enable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE); } else { - BM_mesh_elem_flag_enable_all(bm, BM_FACE, BM_ELEM_TAG); + BM_mesh_elem_flag_enable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); BMO_slot_buffer_hflag_disable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE); } diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 03f9fe04394..bcd9566ce98 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -1053,7 +1053,7 @@ void BM_mesh_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float s // int i; /* deselect input */ - BM_mesh_elem_flag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT); + BM_mesh_elem_flag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); ele = BMO_iter_new(&iter, bm, &op, "outinner", BM_EDGE|BM_VERT); for ( ; ele; ele = BMO_iter_step(&iter)) { diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 45cef5ca7ef..a2d73eaa6bd 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3463,7 +3463,7 @@ static int edbm_split_exec(bContext *C, wmOperator *op) EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, FALSE); BMO_op_exec(em->bm, &bmop); - BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT); + BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ALL, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index f824a9062c9..40ca1e64fad 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -225,7 +225,7 @@ int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *selects BMO_op_exec(bm, &bmop); - BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT); + BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); BMO_slot_buffer_hflag_enable(em->bm, &bmop, selectslot, BM_ALL, BM_ELEM_SELECT, TRUE); @@ -490,12 +490,12 @@ int EDBM_editselection_active_get(BMEditMesh *em, BMEditSelection *ese) void EDBM_flag_disable_all(BMEditMesh *em, const char hflag) { - BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag); + BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag, FALSE); } void EDBM_flag_enable_all(BMEditMesh *em, const char hflag) { - BM_mesh_elem_flag_enable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag); + BM_mesh_elem_flag_enable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag, TRUE); } /**************-------------- Undo ------------*****************/ diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index d552e73bc32..ba74eba04a5 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -474,20 +474,20 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, } if ((amd->flags & MOD_ARR_MERGE) && - (amd->flags & MOD_ARR_MERGEFINAL) && - (count > 1)) { + (amd->flags & MOD_ARR_MERGEFINAL) && + (count > 1)) + { /* Merge first and last copies. Note that we can't use the - indexMap for this because (unless the array is forming a - loop) the offset between first and last is different from - dupe X to dupe X+1. */ + * indexMap for this because (unless the array is forming a + * loop) the offset between first and last is different from + * dupe X to dupe X+1. */ merge_first_last(em->bm, amd, &first_dupe_op, &dupe_op, &weld_op); } /* start capping */ - if (start_cap || end_cap) - { - BM_mesh_elem_flag_enable_all(em->bm, BM_VERT, BM_ELEM_TAG); + if (start_cap || end_cap) { + BM_mesh_elem_flag_enable_all(em->bm, BM_VERT, BM_ELEM_TAG, FALSE); if (start_cap) { float startoffset[4][4]; From c78b88940fa48684067b345627c4414863b6325a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 05:34:58 +0000 Subject: [PATCH 09/58] patch [#30721] Fly Operator Stack Corruption from Jason Wilkins (jwilkins) slight change to fix in patch. --- source/blender/editors/space_view3d/view3d_fly.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 0e7c71f0c0a..f8ab7ab5aad 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -982,10 +982,10 @@ static int flyApply(bContext *C, FlyInfo *fly) /* pause */ zero_v3(dvec_tmp); } - if (!fly->use_freelook) { + else if (!fly->use_freelook) { /* Normal operation */ /* define dvec, view direction vector */ - dvec_tmp[0] = dvec_tmp[1] = dvec_tmp[2] = 0.0f; + zero_v3(dvec_tmp); /* move along the current axis */ dvec_tmp[fly->axis] = 1.0f; From e23f752184ab0b5997deb98aaee3b2fc582834c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 06:26:52 +0000 Subject: [PATCH 10/58] style cleanup --- .../blender/editors/space_view3d/view3d_fly.c | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index f8ab7ab5aad..31beda3b3f9 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -56,7 +56,7 @@ #include "PIL_time.h" /* smoothview */ -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */ enum { FLY_MODAL_CANCEL = 1, @@ -272,7 +272,7 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), struct ARegion *UNUSE static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event) { wmWindow *win = CTX_wm_window(C); - float upvec[3]; // tmp + float upvec[3]; /* tmp */ float mat[3][3]; fly->rv3d = CTX_wm_region_view3d(C); @@ -376,7 +376,7 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event else { /* perspective or ortho */ if (fly->rv3d->persp == RV3D_ORTHO) - fly->rv3d->persp = RV3D_PERSP; /*if ortho projection, make perspective */ + fly->rv3d->persp = RV3D_PERSP; /* if ortho projection, make perspective */ copy_qt_qt(fly->rot_backup, fly->rv3d->viewquat); copy_v3_v3(fly->ofs_backup, fly->rv3d->ofs); @@ -390,10 +390,10 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event fly->rv3d->dist = 0.0f; - upvec[2] = fly->dist_backup; /*x and y are 0*/ + upvec[2] = fly->dist_backup; /* x and y are 0 */ mul_m3_v3(mat, upvec); sub_v3_v3(fly->rv3d->ofs, upvec); - /*Done with correcting for the dist*/ + /* Done with correcting for the dist */ } /* center the mouse, probably the UI mafia are against this but without its quite annoying */ @@ -449,11 +449,11 @@ static int flyEnd(bContext *C, FlyInfo *fly) /* restore the dist */ float mat[3][3]; upvec[0] = upvec[1] = 0; - upvec[2] = fly->dist_backup; /*x and y are 0*/ + upvec[2] = fly->dist_backup; /* x and y are 0 */ copy_m3_m4(mat, rv3d->viewinv); mul_m3_v3(mat, upvec); add_v3_v3(rv3d->ofs, upvec); - /*Done with correcting for the dist */ + /* Done with correcting for the dist */ } if (fly->is_ortho_cam) { @@ -486,20 +486,20 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) copy_v2_v2_int(fly->mval, event->mval); } else if (event->type == NDOF_MOTION) { - // do these automagically get delivered? yes. + /* do these automagically get delivered? yes. */ // puts("ndof motion detected in fly mode!"); // static const char* tag_name = "3D mouse position"; wmNDOFMotionData *incoming_ndof = (wmNDOFMotionData *)event->customdata; switch (incoming_ndof->progress) { case P_STARTING: - // start keeping track of 3D mouse position + /* start keeping track of 3D mouse position */ #ifdef NDOF_FLY_DEBUG puts("start keeping track of 3D mouse position"); #endif - // fall through... + /* fall through... */ case P_IN_PROGRESS: - // update 3D mouse position + /* update 3D mouse position */ #ifdef NDOF_FLY_DEBUG putchar('.'); fflush(stdout); #endif @@ -547,8 +547,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) time_currwheel = PIL_check_seconds_timer(); time_wheel = (float)(time_currwheel - fly->time_lastwheel); fly->time_lastwheel = time_currwheel; - /*printf("Wheel %f\n", time_wheel);*/ - /*Mouse wheel delays range from 0.5==slow to 0.01==fast*/ + /* Mouse wheel delays range from 0.5==slow to 0.01==fast */ time_wheel = 1.0f + (10.0f - (20.0f * MIN2(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */ if (fly->speed < 0.0f) { @@ -845,7 +844,6 @@ static int flyApply(bContext *C, FlyInfo *fly) time_redraw = (float)(time_current - fly->time_lastdraw); time_redraw_clamped = MIN2(0.05f, time_redraw); /* clamp redraw time to avoid jitter in roll correction */ fly->time_lastdraw = time_current; - /*fprintf(stderr, "%f\n", time_redraw);*//* 0.002 is a small redraw 0.02 is larger */ /* Scale the time to use shift to scale the speed down- just like * shift slows many other areas of blender down */ @@ -883,7 +881,7 @@ static int flyApply(bContext *C, FlyInfo *fly) mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); if (fly->xlock) - fly->xlock = 2; /*check for rotation*/ + fly->xlock = 2; /* check for rotation */ if (fly->zlock) fly->zlock = 2; fly->xlock_momentum = 0.0f; @@ -919,7 +917,7 @@ static int flyApply(bContext *C, FlyInfo *fly) mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); if (fly->xlock) - fly->xlock = 2; /*check for rotation*/ + fly->xlock = 2; /* check for rotation */ if (fly->zlock) fly->zlock = 2; } @@ -930,10 +928,10 @@ static int flyApply(bContext *C, FlyInfo *fly) upvec[2] = 0.0f; mul_m3_v3(mat, upvec); - /*make sure we have some z rolling*/ + /* make sure we have some z rolling */ if (fabsf(upvec[2]) > 0.00001f) { roll = upvec[2] * 5.0f; - upvec[0] = 0.0f; /*rotate the view about this axis*/ + upvec[0] = 0.0f; /* rotate the view about this axis */ upvec[1] = 0.0f; upvec[2] = 1.0f; @@ -951,16 +949,16 @@ static int flyApply(bContext *C, FlyInfo *fly) } } - if (fly->xlock == 2 && moffset[1] == 0) { /*only apply xcorrect when mouse isn't applying x rot*/ + if (fly->xlock == 2 && moffset[1] == 0) { /* only apply xcorrect when mouse isn't applying x rot */ upvec[0] = 0; upvec[1] = 0; upvec[2] = 1; mul_m3_v3(mat, upvec); - /*make sure we have some z rolling*/ + /* make sure we have some z rolling */ if (fabsf(upvec[2]) > 0.00001f) { roll = upvec[2] * -5.0f; - upvec[0] = 1.0f; /*rotate the view about this axis*/ + upvec[0] = 1.0f; /* rotate the view about this axis */ upvec[1] = 0.0f; upvec[2] = 0.0f; @@ -1041,22 +1039,23 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) shouldTranslate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM)); #endif - int shouldRotate = (fly->pan_view == FALSE), shouldTranslate = TRUE; + int shouldRotate = (fly->pan_view == FALSE); + int shouldTranslate = TRUE; float view_inv[4]; invert_qt_qt(view_inv, rv3d->viewquat); - rv3d->rot_angle = 0.f; // disable onscreen rotation doo-dad + rv3d->rot_angle = 0.0f; /* disable onscreen rotation doo-dad */ if (shouldTranslate) { - const float forward_sensitivity = 1.f; + const float forward_sensitivity = 1.0f; const float vertical_sensitivity = 0.4f; - const float lateral_sensitivity = 0.6f; + const float lateral_sensitivity = 0.6f; - float speed = 10.f; /* blender units per second */ + float speed = 10.0f; /* blender units per second */ /* ^^ this is ok for default cube scene, but should scale with.. something */ - float trans[3] = {lateral_sensitivity *ndof->tvec[0], + float trans[3] = {lateral_sensitivity * ndof->tvec[0], vertical_sensitivity * ndof->tvec[1], forward_sensitivity * ndof->tvec[2]}; @@ -1065,7 +1064,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) mul_v3_fl(trans, speed * dt); - // transform motion from view to world coordinates + /* transform motion from view to world coordinates */ mul_qt_v3(view_inv, trans); if (flag & NDOF_FLY_HELICOPTER) { @@ -1074,7 +1073,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) } if (rv3d->persp == RV3D_CAMOB) { - // respect camera position locks + /* respect camera position locks */ Object *lock_ob = fly->root_parent ? fly->root_parent : fly->v3d->camera; if (lock_ob->protectflag & OB_LOCK_LOCX) trans[0] = 0.0f; if (lock_ob->protectflag & OB_LOCK_LOCY) trans[1] = 0.0f; @@ -1082,7 +1081,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) } if (!is_zero_v3(trans)) { - // move center of view opposite of hand motion (this is camera mode, not object mode) + /* move center of view opposite of hand motion (this is camera mode, not object mode) */ sub_v3_v3(rv3d->ofs, trans); shouldTranslate = TRUE; } @@ -1092,7 +1091,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) } if (shouldRotate) { - const float turn_sensitivity = 1.f; + const float turn_sensitivity = 1.0f; float rotation[4]; float axis[3]; @@ -1107,15 +1106,15 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) /* transform rotation axis from view to world coordinates */ mul_qt_v3(view_inv, axis); - // apply rotation to view + /* apply rotation to view */ axis_angle_to_quat(rotation, axis, angle); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rotation); if (flag & NDOF_LOCK_HORIZON) { /* force an upright viewpoint * TODO: make this less... sudden */ - float view_horizon[3] = {1.f, 0.f, 0.f}; /* view +x */ - float view_direction[3] = {0.f, 0.f, -1.f}; /* view -z (into screen) */ + float view_horizon[3] = {1.0f, 0.0f, 0.0f}; /* view +x */ + float view_direction[3] = {0.0f, 0.0f, -1.0f}; /* view -z (into screen) */ /* find new inverse since viewquat has changed */ invert_qt_qt(view_inv, rv3d->viewquat); From d2d2b8c2f2d991427d497a9cd27382e9d6654e2c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 06:43:16 +0000 Subject: [PATCH 11/58] code cleanup: replace inline axis angle conversion with axis_angle_to_mat3() --- source/blender/blenlib/intern/math_rotation.c | 7 +++++-- source/blender/bmesh/operators/bmo_dupe.c | 13 +++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index dbba672100e..ec5fd39cd87 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -708,7 +708,10 @@ void eulO_to_axis_angle(float axis[3], float *angle, const float eul[3], const s quat_to_axis_angle(axis, angle, q); } -/* axis angle to 3x3 matrix - safer version (normalization of axis performed) */ +/* axis angle to 3x3 matrix - safer version (normalization of axis performed) + * + * note: we may want a normalized and non normalized version of this function. + */ void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle) { float nor[3], nsi[3], co, si, ico; @@ -818,7 +821,7 @@ void single_axis_angle_to_mat3(float mat[3][3], const char axis, const float ang /****************************** Vector/Rotation ******************************/ /* TODO: the following calls should probably be depreceated sometime */ -/* axis angle to 3x3 matrix */ +/* ODO, replace use of this function with axis_angle_to_mat3() */ void vec_rot_to_mat3(float mat[][3], const float vec[3], const float phi) { /* rotation of phi radials around vec */ diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index e208eb21a3b..18ad784dc94 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -464,9 +464,8 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op) BMOperator dupop, extop; float cent[3], dvec[3]; float axis[3] = {0.0f, 0.0f, 1.0f}; - float q[4]; float rmat[3][3]; - float phi, si; + float phi; int steps, do_dupli, a, usedvec; BMO_slot_vec_get(op, "cent", cent); @@ -475,16 +474,10 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op) BMO_slot_vec_get(op, "dvec", dvec); usedvec = !is_zero_v3(dvec); steps = BMO_slot_int_get(op, "steps"); - phi = BMO_slot_float_get(op, "ang") * (float)M_PI / (360.0f * steps); + phi = BMO_slot_float_get(op, "ang") * DEG2RADF(1.0f) / steps; do_dupli = BMO_slot_bool_get(op, "do_dupli"); - /* BMESH_TODO - can replace this with BLI_math? */ - si = (float)sin(phi); - q[0] = (float)cos(phi); - q[1] = axis[0] * si; - q[2] = axis[1] * si; - q[3] = axis[2] * si; - quat_to_mat3(rmat, q); + axis_angle_to_mat3(rmat, axis, phi); BMO_slot_copy(op, op, "geom", "lastout"); for (a = 0; a < steps; a++) { From 66e8efd40cfb7185d1eea9ea7b6bc9320ceecbee Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 2 Apr 2012 06:56:16 +0000 Subject: [PATCH 12/58] Minor UI messages fix... --- source/blender/editors/render/render_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 180e72c8cd7..397f2cc6978 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -687,7 +687,7 @@ void RENDER_OT_opengl(wmOperatorType *ot) prop = RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "sequencer", 0, "Sequencer", "Render using the sequencers OpenGL display"); + prop = RNA_def_boolean(ot->srna, "sequencer", 0, "Sequencer", "Render using the sequencer's OpenGL display"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); From aa7cc852cd246805342abd1b5b00a30124ca7f09 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 2 Apr 2012 07:54:12 +0000 Subject: [PATCH 13/58] Constraint UI: * Adjust "no py constraint" message to be a bit more meaningful. --- release/scripts/startup/bl_ui/properties_object_constraint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_object_constraint.py b/release/scripts/startup/bl_ui/properties_object_constraint.py index c1b49d087ca..ce6c7ad4e92 100644 --- a/release/scripts/startup/bl_ui/properties_object_constraint.py +++ b/release/scripts/startup/bl_ui/properties_object_constraint.py @@ -816,7 +816,7 @@ class ConstraintButtonsPanel(): layout.operator("clip.constraint_to_fcurve") def SCRIPT(self, context, layout, con): - layout.label("Blender 2.5 has no py-constraints") + layout.label("Blender 2.6 doesn't support python constraints yet.") class OBJECT_PT_constraints(ConstraintButtonsPanel, Panel): From 7d184567d7a39811856dac6a6813baa1165fed44 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 08:35:12 +0000 Subject: [PATCH 14/58] fix [#30758] bmesh: unable to rip a single vertex this also adds the ability to rip disconnected face fans apart which is handy. --- source/blender/editors/mesh/editmesh_tools.c | 89 ++++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index a2d73eaa6bd..b7ae1f3ba99 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2132,6 +2132,8 @@ static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *c return dist_to_line_segment_v2(mvalf, vec1, vec2); } + + /* based on mouse cursor position, it defines how is being ripped */ static int edbm_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) { @@ -2174,6 +2176,7 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) * then rip two adjacent edges in the vert fan. */ if (bm->totvertsel == 1 && bm->totedgesel == 0 && bm->totfacesel == 0) { BMEditSelection ese; + int totboundary_edge = 0; singlesel = TRUE; /* find selected vert - same some time and check history first */ @@ -2196,17 +2199,93 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) if (v->e) { /* find closest edge to mouse cursor */ BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v) { - if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN) && BM_edge_face_count(e) == 2) { - d = mesh_rip_edgedist(ar, projectMat, e->v1->co, e->v2->co, fmval); - if (d < dist) { - dist = d; - e2 = e; + int is_boundary = BM_edge_is_boundary(e); + /* consider wire as boundary for this purpose, + * otherwise we can't a face away from a wire edge */ + totboundary_edge += (is_boundary != 0 || BM_edge_is_wire(e)); + if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { + if (is_boundary == FALSE && BM_edge_face_count(e) == 2) { + d = mesh_rip_edgedist(ar, projectMat, e->v1->co, e->v2->co, fmval); + if (d < dist) { + dist = d; + e2 = e; + } } } } } + /* should we go ahead with edge rip or do we need to do special case, split off vertex?: + * split off vertex if... + * - we cant find an edge - this means we are ripping a faces vert that is connected to other + * geometry only at the vertex. + * - the boundary edge total is greater then 2, + * in this case edge split _can_ work but we get far nicer results if we use this special case. */ + if (totboundary_edge > 2) { + BMVert **vout; + int vout_len; + + BM_elem_select_set(bm, v, FALSE); + bmesh_vert_separate(bm, v, &vout, &vout_len); + + if (vout_len < 2) { + /* should never happen */ + BKE_report(op->reports, RPT_ERROR, "Error ripping vertex from faces"); + return OPERATOR_CANCELLED; + } + else { + int vi_best = 0; + + dist = FLT_MAX; + + for (i = 0; i < vout_len; i++) { + BM_ITER(l, &iter, bm, BM_LOOPS_OF_VERT, vout[i]) { + if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) { + float l_mid_co[3]; + BM_loop_face_tangent(l, l_mid_co); + + /* scale to average of surrounding edge size, only needs to be approx */ + mul_v3_fl(l_mid_co, (BM_edge_length_calc(l->e) + BM_edge_length_calc(l->prev->e)) / 2.0f); + add_v3_v3(l_mid_co, v->co); + + d = mesh_rip_edgedist(ar, projectMat, v->co, l_mid_co, fmval); + + if (d < dist) { + dist = d; + vi_best = i; + } + } + } + } + + /* select the vert from the best region */ + v = vout[vi_best]; + BM_elem_select_set(bm, v, TRUE); + + /* splice all others back together */ + if (vout_len > 2) { + + /* vout[0] == best + * vout[1] == glue + * vout[2+] == splice with glue + */ + if (vi_best != 0) { + SWAP(BMVert *, vout[0], vout[vi_best]); + vi_best = 0; + } + + for (i = 2; i < vout_len; i++) { + BM_vert_splice(bm, vout[i], vout[1]); + } + } + + MEM_freeN(vout); + + return OPERATOR_FINISHED; + } + } + if (!e2) { BKE_report(op->reports, RPT_ERROR, "Selected vertex has no edge/face pairs attached"); return OPERATOR_CANCELLED; From 7d9f0232df771b7dc9f5fd33ab0d0a9b7b6f1ad6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 08:58:26 +0000 Subject: [PATCH 15/58] adding back boundary inset support. was disabled because at one point it was unstable. --- source/blender/bmesh/operators/bmo_inset.c | 3 ++- source/blender/editors/mesh/editmesh_tools.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 23255d1c514..7aeeca99d58 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -187,6 +187,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) edge_loop_tangent(es->e_new, es->l, es->no); if (es->e_new == es->e_old) { /* happens on boundary edges */ + /* take care here, we're creating this double edge which _must_ have its verts replaced later on */ es->e_old = BM_edge_create(bm, es->e_new->v1, es->e_new->v2, es->e_new, FALSE); } @@ -254,7 +255,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) /* find adjacent */ BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v_split) { if (BM_elem_flag_test(e, BM_ELEM_TAG) && - BM_elem_flag_test(e->l->f, BM_ELEM_TAG)) + e->l && BM_elem_flag_test(e->l->f, BM_ELEM_TAG)) { if (vert_edge_tag_tot < 2) { vecpair[vert_edge_tag_tot] = BM_elem_index_get(e); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index b7ae1f3ba99..f27de884b95 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4505,7 +4505,7 @@ static int edbm_inset_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; - const int use_boundary = FALSE; //RNA_boolean_get(op->ptr, "use_boundary"); + const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); const float thickness = RNA_float_get(op->ptr, "thickness"); @@ -4548,7 +4548,7 @@ void MESH_OT_inset(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - // RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundries"); + RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundries"); RNA_def_boolean(ot->srna, "use_even_offset", TRUE, "Offset Even", "Scale the offset to give more even thickness"); RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Offset Relative", "Scale the offset by surrounding geometry"); From 48059cc32968e008b809571ccb80ffdd5f876ce6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 09:07:02 +0000 Subject: [PATCH 16/58] fix problem with select invert - flush selection. previously this wasnt needed because doing an undo push would flush the selection. --- source/blender/editors/mesh/editmesh_tools.c | 3 ++- source/blender/editors/uvedit/uvedit_ops.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index f27de884b95..4fc637a3505 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -658,9 +658,10 @@ static int edbm_select_all_exec(bContext *C, wmOperator *op) break; case SEL_INVERT: EDBM_select_swap(em); + EDBM_selectmode_flush(em); break; } - + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit); return OPERATOR_FINISHED; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 3f4352d8ab3..05b3ba6ea07 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1620,6 +1620,7 @@ static void select_all_perform(bContext *C, int action) break; case SEL_INVERT: EDBM_select_swap(em); + EDBM_selectmode_flush(em); break; } } From 7b9d9ecab2c2b95cc20c589ae329144846995147 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 10:20:10 +0000 Subject: [PATCH 17/58] fix for a bug with Ctrl+Click extrude in curve editmode, it would use the wrong handle type in some cases. also make it re-calculate the handle locations which is much more useful. --- source/blender/editors/curve/editcurve.c | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index a5188ea769e..9190cd940d6 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4378,6 +4378,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) BPoint *bp, *newbp = NULL; float imat[4][4], temp[3]; int ok= 0; + BezTriple *bezt_recalc[3] = {NULL}; invert_m4_m4(imat, obedit->obmat); @@ -4471,9 +4472,14 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) newbezt+= nu->pntsu; BEZ_SEL(newbezt); cu->lastsel= newbezt; - newbezt->h2= newbezt->h1; + newbezt->h1 = newbezt->h2; bezt= nu->bezt+nu->pntsu-1; ok= 1; + + if (nu->pntsu > 1) { + bezt_recalc[1] = newbezt; + bezt_recalc[0] = newbezt - 1; + } } else if (bezt== nu->bezt) { /* first */ BEZ_DESEL(bezt); @@ -4489,6 +4495,11 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) nu->bezt= newbezt; bezt= newbezt+1; ok= 1; + + if (nu->pntsu > 1) { + bezt_recalc[1] = newbezt; + bezt_recalc[2] = newbezt + 1; + } } else if (mode!='e') { BEZ_DESEL(bezt); @@ -4523,8 +4534,19 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) else { mul_v3_m4v3(newbezt->vec[1], imat, location); sub_v3_v3v3(temp, newbezt->vec[1],temp); - add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp); - add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp); + + if (bezt_recalc[1]) { + const char h1 = bezt_recalc[1]->h1, h2 = bezt_recalc[1]->h2; + bezt_recalc[1]->h1 = bezt_recalc[1]->h2 = HD_AUTO; + calchandleNurb(bezt_recalc[1], bezt_recalc[0], bezt_recalc[2], 0); + bezt_recalc[1]->h1 = h1; + bezt_recalc[1]->h2 = h2; + } + else { + add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp); + add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp); + } + if (newnu) calchandlesNurb(newnu); else calchandlesNurb(nu); From 86c68c0569b3cd82a1de27470b3d4858cde96e30 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Apr 2012 11:04:24 +0000 Subject: [PATCH 18/58] Multithreaded EXR files loading Use multithreaded loading of EXR files which is enabling by call of setGlobalThreadCount function from OpenEXR library to set up number of used threads to number of system threads which speeds up loading high-resolution files on multi-core / multi-cpu systems and allows to work with high-resolution sequences in clip editor and sequencer. --- source/blender/imbuf/intern/filetype.c | 2 +- source/blender/imbuf/intern/openexr/openexr_api.cpp | 7 +++++++ source/blender/imbuf/intern/openexr/openexr_api.h | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index 9ece4bd9f6d..74fd601e3f6 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -80,7 +80,7 @@ ImFileType IMB_FILE_TYPES[]= { {NULL, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR}, #endif #ifdef WITH_OPENJPEG - {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2}, + {imb_initopenexr, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2}, #endif #ifdef WITH_DDS {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS}, diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 3d90267b030..5090155522d 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -51,6 +51,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include "BLI_blenlib.h" #include "BLI_math_color.h" +#include "BLI_threads.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -1066,5 +1067,11 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags) } +void imb_initopenexr(void) +{ + int num_threads = BLI_system_thread_count(); + + setGlobalThreadCount(num_threads); +} } // export "C" diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h index e0358361713..d12fe2fc49f 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.h +++ b/source/blender/imbuf/intern/openexr/openexr_api.h @@ -43,7 +43,9 @@ extern "C" { * Test presence of OpenEXR file. * \param mem pointer to loaded OpenEXR bitstream */ - + +void imb_initopenexr (void); + int imb_is_a_openexr (unsigned char *mem); int imb_save_openexr (struct ImBuf *ibuf, const char *name, int flags); From c563eb71b74cd31eb42f4738fc8df053af9a13c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 11:28:26 +0000 Subject: [PATCH 19/58] wrap RNA's RNA_property_collection_clear from python. --- source/blender/python/intern/bpy_rna.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 7af53b489bd..53f9e46ba13 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3869,6 +3869,13 @@ static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyOb Py_RETURN_NONE; } +static PyObject *pyrna_prop_collection_idprop_clear(BPy_PropertyRNA *self) +{ + RNA_property_collection_clear(&self->ptr, self->prop); + + Py_RETURN_NONE; +} + static PyObject *pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, PyObject *args) { int key = 0, pos = 0; @@ -4580,6 +4587,7 @@ static struct PyMethodDef pyrna_prop_collection_methods[] = { static struct PyMethodDef pyrna_prop_collection_idprop_methods[] = { {"add", (PyCFunction)pyrna_prop_collection_idprop_add, METH_NOARGS, NULL}, {"remove", (PyCFunction)pyrna_prop_collection_idprop_remove, METH_O, NULL}, + {"clear", (PyCFunction)pyrna_prop_collection_idprop_clear, METH_NOARGS, NULL}, {"move", (PyCFunction)pyrna_prop_collection_idprop_move, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; From 4458ce1abaea10256d19090d0ca1efa2c23f402c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 2 Apr 2012 11:51:36 +0000 Subject: [PATCH 20/58] Fix #30770: missing node editor redraw when changing active material by clicking on face in edit mode. --- source/blender/editors/mesh/editmesh_select.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 51449f846d5..57041e967e9 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1499,12 +1499,13 @@ int mouse_mesh(bContext *C, const int mval[2], short extend) EDBM_selectmode_flush(vc.em); -// if (EM_texFaceCheck()) { - + /* change active material on object */ if (efa && efa->mat_nr != vc.obedit->actcol - 1) { vc.obedit->actcol = efa->mat_nr + 1; vc.em->mat_nr = efa->mat_nr; -// BIF_preview_changed(ID_MA); + + WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); + } WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit); From b07f9446c7b28ec1a8a72c29f44af505fdfe346e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Apr 2012 12:36:00 +0000 Subject: [PATCH 21/58] Hopefully last change to matrix orthogonal check, touches Py API only - is_orthogonal now checks matrix in the same way as it's defined by linear algebra, meaning that it'll use is_orhonormal C check - Added is_orthogonal_axis_vectors to check if vectors which defines axises are orthogonal --- .../python/mathutils/mathutils_Matrix.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index f5f54356680..bd37b645cbb 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -2219,9 +2219,9 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu /*must be 3-4 cols, 3-4 rows, square matrix*/ if (self->num_row == 4 && self->num_col == 4) - return PyBool_FromLong(is_orthogonal_m4((float (*)[4])self->matrix)); + return PyBool_FromLong(is_orthonormal_m4((float (*)[4])self->matrix)); else if (self->num_row == 3 && self->num_col == 3) - return PyBool_FromLong(is_orthogonal_m3((float (*)[3])self->matrix)); + return PyBool_FromLong(is_orthonormal_m3((float (*)[3])self->matrix)); else { PyErr_SetString(PyExc_AttributeError, "Matrix.is_orthogonal: " @@ -2230,22 +2230,22 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu } } -PyDoc_STRVAR(Matrix_is_orthonormal_doc, -"True if this matrix is orthonormal, 3x3 and 4x4 only, (read-only).\n\n:type: bool" +PyDoc_STRVAR(Matrix_is_orthogonal_axis_vectors_doc, +"True if this matrix has got orthogonal axis vectors, 3x3 and 4x4 only, (read-only).\n\n:type: bool" ); -static PyObject *Matrix_is_orthonormal_get(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) return NULL; /*must be 3-4 cols, 3-4 rows, square matrix*/ if (self->num_row == 4 && self->num_col == 4) - return PyBool_FromLong(is_orthonormal_m4((float (*)[4])self->matrix)); + return PyBool_FromLong(is_orthogonal_m4((float (*)[4])self->matrix)); else if (self->num_row == 3 && self->num_col == 3) - return PyBool_FromLong(is_orthonormal_m3((float (*)[3])self->matrix)); + return PyBool_FromLong(is_orthogonal_m3((float (*)[3])self->matrix)); else { PyErr_SetString(PyExc_AttributeError, - "Matrix.is_orthonormal: " + "Matrix.is_orthogonal_axis_vectors: " "inappropriate matrix size - expects 3x3 or 4x4 matrix"); return NULL; } @@ -2261,7 +2261,7 @@ static PyGetSetDef Matrix_getseters[] = { {(char *)"col", (getter)Matrix_col_get, (setter)NULL, Matrix_col_doc, NULL}, {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL}, {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, Matrix_is_orthogonal_doc, NULL}, - {(char *)"is_orthonormal", (getter)Matrix_is_orthonormal_get, (setter)NULL, Matrix_is_orthonormal_doc, NULL}, + {(char *)"is_orthogonal_axis_vectors", (getter)Matrix_is_orthogonal_axis_vectors_get, (setter)NULL, Matrix_is_orthogonal_axis_vectors_doc, NULL}, {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ From 824304850710b7897baa640ea6908483d765ff2d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Apr 2012 12:37:03 +0000 Subject: [PATCH 22/58] Fix #30767: VSE timeline marker update Patch by Dan Eicher, thanks! --- source/blender/makesrna/intern/rna_timeline.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_timeline.c b/source/blender/makesrna/intern/rna_timeline.c index 93c28ce2720..a33e415ce11 100644 --- a/source/blender/makesrna/intern/rna_timeline.c +++ b/source/blender/makesrna/intern/rna_timeline.c @@ -37,6 +37,14 @@ #ifdef RNA_RUNTIME +#include "WM_api.h" + +static void rna_TimelineMarker_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); +} + #else static void rna_def_timeline_marker(BlenderRNA *brna) @@ -52,16 +60,16 @@ static void rna_def_timeline_marker(BlenderRNA *brna) prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", ""); RNA_def_struct_name_property(srna, prop); - RNA_def_property_update(prop, NC_ANIMATION, NULL); + RNA_def_property_update(prop, 0, "rna_TimelineMarker_update"); prop = RNA_def_property(srna, "frame", PROP_INT, PROP_TIME); RNA_def_property_ui_text(prop, "Frame", "The frame on which the timeline marker appears"); - RNA_def_property_update(prop, NC_ANIMATION, NULL); + RNA_def_property_update(prop, 0, "rna_TimelineMarker_update"); prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", 1 /*SELECT*/); RNA_def_property_ui_text(prop, "Select", "Marker selection state"); - RNA_def_property_update(prop, NC_ANIMATION, NULL); + RNA_def_property_update(prop, 0, "rna_TimelineMarker_update"); #ifdef DURIAN_CAMERA_SWITCH prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); From ff951270d53280ee670f9a1346c0207667161b55 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 2 Apr 2012 13:48:20 +0000 Subject: [PATCH 23/58] Solve namespace conflicts for ole grumpy MinGW. It seems FLOAT is also defined in a windef.h header. --- .../imbuf/intern/openexr/openexr_api.cpp | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 5090155522d..142ed335913 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -94,7 +94,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) using namespace Imf; using namespace Imath; -class Mem_IStream: public IStream +class Mem_IStream: public Imf::IStream { public: @@ -212,7 +212,7 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags if (ibuf->planes==32 && channels >= 4) header.channels().insert ("A", Channel (HALF)); if (write_zbuf) // z we do as float always - header.channels().insert ("Z", Channel (FLOAT)); + header.channels().insert ("Z", Channel (Imf::FLOAT)); FrameBuffer frameBuffer; OutputFile *file = new OutputFile(name, header); @@ -230,7 +230,7 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags if (ibuf->planes==32 && channels >= 4) frameBuffer.insert ("A", Slice (HALF, (char *) &pixels[0].a, xstride, ystride)); if (write_zbuf) - frameBuffer.insert ("Z", Slice (FLOAT, (char *)(ibuf->zbuf_float + (height-1)*width), + frameBuffer.insert ("Z", Slice (Imf::FLOAT, (char *)(ibuf->zbuf_float + (height-1)*width), sizeof(float), sizeof(float) * -width)); if (ibuf->rect_float) { float *from; @@ -316,13 +316,13 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS); openexr_header_metadata(&header, ibuf); - header.channels().insert ("R", Channel (FLOAT)); - header.channels().insert ("G", Channel (FLOAT)); - header.channels().insert ("B", Channel (FLOAT)); + header.channels().insert ("R", Channel (Imf::FLOAT)); + header.channels().insert ("G", Channel (Imf::FLOAT)); + header.channels().insert ("B", Channel (Imf::FLOAT)); if (ibuf->planes==32 && channels >= 4) - header.channels().insert ("A", Channel (FLOAT)); + header.channels().insert ("A", Channel (Imf::FLOAT)); if (write_zbuf) - header.channels().insert ("Z", Channel (FLOAT)); + header.channels().insert ("Z", Channel (Imf::FLOAT)); FrameBuffer frameBuffer; OutputFile *file = new OutputFile(name, header); @@ -336,13 +336,13 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag rect[2]= rect[0]+2; rect[3]= (channels >= 4)? rect[0]+3:rect[0]; /* red as alpha, is this needed since alpha isn't written? */ - frameBuffer.insert ("R", Slice (FLOAT, (char *)rect[0], xstride, ystride)); - frameBuffer.insert ("G", Slice (FLOAT, (char *)rect[1], xstride, ystride)); - frameBuffer.insert ("B", Slice (FLOAT, (char *)rect[2], xstride, ystride)); + frameBuffer.insert ("R", Slice (Imf::FLOAT, (char *)rect[0], xstride, ystride)); + frameBuffer.insert ("G", Slice (Imf::FLOAT, (char *)rect[1], xstride, ystride)); + frameBuffer.insert ("B", Slice (Imf::FLOAT, (char *)rect[2], xstride, ystride)); if (ibuf->planes==32 && channels >= 4) - frameBuffer.insert ("A", Slice (FLOAT, (char *)rect[3], xstride, ystride)); + frameBuffer.insert ("A", Slice (Imf::FLOAT, (char *)rect[3], xstride, ystride)); if (write_zbuf) - frameBuffer.insert ("Z", Slice (FLOAT, (char *) (ibuf->zbuf_float + (height-1)*width), + frameBuffer.insert ("Z", Slice (Imf::FLOAT, (char *) (ibuf->zbuf_float + (height-1)*width), sizeof(float), sizeof(float) * -width)); file->setFrameBuffer (frameBuffer); file->writePixels (height); @@ -481,7 +481,7 @@ int IMB_exr_begin_write(void *handle, const char *filename, int width, int heigh data->height= height; for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) - header.channels().insert (echan->name, Channel (FLOAT)); + header.channels().insert (echan->name, Channel (Imf::FLOAT)); openexr_header_compression(&header, compress); // openexr_header_metadata(&header, ibuf); // no imbuf. cant write @@ -514,7 +514,7 @@ void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int data->mipmap= mipmap; for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) - header.channels().insert (echan->name, Channel (FLOAT)); + header.channels().insert (echan->name, Channel (Imf::FLOAT)); header.setTileDescription (TileDescription (tilex, tiley, (mipmap)? MIPMAP_LEVELS: ONE_LEVEL)); header.lineOrder() = RANDOM_Y; @@ -591,7 +591,7 @@ void IMB_exrtile_write_channels(void *handle, int partx, int party, int level) for (echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) { float *rect= echan->rect - echan->xstride*partx - echan->ystride*party; - frameBuffer.insert (echan->name, Slice (FLOAT, (char *)rect, + frameBuffer.insert (echan->name, Slice (Imf::FLOAT, (char *)rect, echan->xstride*sizeof(float), echan->ystride*sizeof(float))); } @@ -617,7 +617,7 @@ void IMB_exr_write_channels(void *handle) /* last scanline, stride negative */ float *rect = echan->rect + echan->xstride*(data->height-1)*data->width; - frameBuffer.insert (echan->name, Slice (FLOAT, (char *)rect, + frameBuffer.insert (echan->name, Slice (Imf::FLOAT, (char *)rect, echan->xstride*sizeof(float), -echan->ystride*sizeof(float))); } @@ -648,10 +648,10 @@ void IMB_exr_read_channels(void *handle) if (echan->rect) { if (flip) - frameBuffer.insert (echan->name, Slice (FLOAT, (char *)echan->rect, + frameBuffer.insert (echan->name, Slice (Imf::FLOAT, (char *)echan->rect, echan->xstride*sizeof(float), echan->ystride*sizeof(float))); else - frameBuffer.insert (echan->name, Slice (FLOAT, (char *)(echan->rect + echan->xstride*(data->height-1)*data->width), + frameBuffer.insert (echan->name, Slice (Imf::FLOAT, (char *)(echan->rect + echan->xstride*(data->height-1)*data->width), echan->xstride*sizeof(float), -echan->ystride*sizeof(float))); } else @@ -1018,14 +1018,14 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags) first+= 4*(height-1)*width; frameBuffer.insert ( exr_rgba_channelname(file, "R"), - Slice (FLOAT, (char *) first, xstride, ystride)); + Slice (Imf::FLOAT, (char *) first, xstride, ystride)); frameBuffer.insert ( exr_rgba_channelname(file, "G"), - Slice (FLOAT, (char *) (first+1), xstride, ystride)); + Slice (Imf::FLOAT, (char *) (first+1), xstride, ystride)); frameBuffer.insert ( exr_rgba_channelname(file, "B"), - Slice (FLOAT, (char *) (first+2), xstride, ystride)); + Slice (Imf::FLOAT, (char *) (first+2), xstride, ystride)); frameBuffer.insert ( exr_rgba_channelname(file, "A"), - Slice (FLOAT, (char *) (first+3), xstride, ystride, 1, 1, 1.0f)); /* 1.0 is fill value */ + Slice (Imf::FLOAT, (char *) (first+3), xstride, ystride, 1, 1, 1.0f)); /* 1.0 is fill value */ if (exr_has_zbuffer(file)) { @@ -1034,7 +1034,7 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags) addzbuffloatImBuf(ibuf); firstz= ibuf->zbuf_float - (dw.min.x - dw.min.y*width); firstz+= (height-1)*width; - frameBuffer.insert ("Z", Slice (FLOAT, (char *)firstz , sizeof(float), -width*sizeof(float))); + frameBuffer.insert ("Z", Slice (Imf::FLOAT, (char *)firstz , sizeof(float), -width*sizeof(float))); } file->setFrameBuffer (frameBuffer); From b05955488231c16676d69a8f7899f070e58bbb4b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Apr 2012 13:56:39 +0000 Subject: [PATCH 24/58] Expand active scene's clip when linking scene. --- source/blender/blenloader/intern/readfile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 0780a7b6292..798c48dfaac 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -14340,6 +14340,8 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) } } #endif + + expand_doit(fd, mainvar, sce->clip); } static void expand_camera(FileData *fd, Main *mainvar, Camera *ca) From 7c4bb6f4b761329d6d4d27e9660f6cf03d6d6946 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Apr 2012 15:06:21 +0000 Subject: [PATCH 25/58] Fix #30398: Mesh objects with curve modifiers render in thier 'rest' position, not thier 'pose' position Do not recalculate curve's path if displist is building for orco -- in this case modifiers are not applying on curve which makes path be calculated and later used by dependent objects with it's non-modified state. --- source/blender/blenkernel/intern/displist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 692eadd6bd3..c54461a5a13 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1401,7 +1401,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba curve_to_filledpoly(cu, nubase, dispbase); } - if (cu->flag & CU_PATH) calc_curvepath(ob); + if ((cu->flag & CU_PATH) && !forOrco) calc_curvepath(ob); /* make copy of 'undeformed" displist for texture space calculation * actually, it's not totally undeformed -- pre-tessellation modifiers are From 095118d21e2d39dc82ee02730732c4b1d0b662b9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 2 Apr 2012 16:29:34 +0000 Subject: [PATCH 26/58] Fix #30776: image editor pan not using continuous grab if enabled. --- source/blender/editors/space_image/image_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index ad4921d225c..1602fe48a17 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -342,7 +342,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot) ot->poll = space_image_main_area_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, From 186d16e325cc16d0a108e1a82fb428792ee64536 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 2 Apr 2012 16:30:01 +0000 Subject: [PATCH 27/58] Fix #30769: cycles showing wrong image from active face in the uv editor, with multiple material slots. --- source/blender/editors/sculpt_paint/paint_image.c | 4 ++-- source/blender/editors/space_image/space_image.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 9cf8cc21996..5cea8d11c09 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -531,7 +531,7 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index) if (scene_use_new_shading_nodes(s->scene)) { MFace *mf = &s->dm_mface[face_index]; - ED_object_get_active_image(s->ob, mf->mat_nr, &ima, NULL, NULL); + ED_object_get_active_image(s->ob, mf->mat_nr+1, &ima, NULL, NULL); } else { MTFace *tf = &s->dm_mtface[face_index]; @@ -547,7 +547,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtfa if (ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ MFace *mf = ps->dm_mface + face_index; - ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL, NULL); + ED_object_get_active_image(ps->ob, mf->mat_nr+1, &ima, NULL, NULL); } else { ima = dm_mtface[face_index].tpage; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index c6d36842207..55130406e7a 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -603,7 +603,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (efa) { Image *node_ima; - ED_object_get_active_image(obedit, efa->mat_nr, &node_ima, NULL, NULL); + ED_object_get_active_image(obedit, efa->mat_nr+1, &node_ima, NULL, NULL); if (node_ima) sima->image = node_ima; From 2ff9b5a7f57450ab0fd1d354c2d18fa10486f699 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 2 Apr 2012 19:38:26 +0000 Subject: [PATCH 28/58] Further fix for #30769: cycles assigning image to wrong material form the uv image editor. --- source/blender/editors/uvedit/uvedit_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 05b3ba6ea07..69ca67930b1 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -191,7 +191,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im BMFace *efa= BM_active_face_get(em->bm, sloppy); if (efa) - ED_object_assign_active_image(bmain, obedit, efa->mat_nr, ima); + ED_object_assign_active_image(bmain, obedit, efa->mat_nr+1, ima); } else { /* old shading system, assign image to selected faces */ From 3c1b5b56324377816063975bd5d245f9d321a59a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 22:26:00 +0000 Subject: [PATCH 29/58] stule cleanup: edits for files which were recently cleaned up. --- .../blender/blenkernel/intern/cdderivedmesh.c | 7 +++-- .../blender/blenkernel/intern/dynamicpaint.c | 2 +- source/blender/bmesh/intern/bmesh_marking.c | 10 +++---- source/blender/bmesh/intern/bmesh_operators.c | 28 +++++++++---------- .../editors/sculpt_paint/paint_image.c | 4 +-- .../blender/editors/space_image/space_image.c | 2 +- source/blender/editors/uvedit/uvedit_ops.c | 2 +- source/blender/gpu/intern/gpu_buffers.c | 4 +-- .../modifiers/intern/MOD_boolean_util.c | 2 +- 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b457e71affd..2b38c5fff4b 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -583,10 +583,11 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, GPU_normal_setup( dm ); if ( !GPU_buffer_legacy(dm) ) { glShadeModel(GL_SMOOTH); - for ( a = 0; a < dm->drawObject->totmaterial; a++ ) { - if ( setMaterial(dm->drawObject->materials[a].mat_nr+1, NULL) ) + for (a = 0; a < dm->drawObject->totmaterial; a++) { + if (setMaterial(dm->drawObject->materials[a].mat_nr + 1, NULL)) { glDrawArrays(GL_TRIANGLES, dm->drawObject->materials[a].start, - dm->drawObject->materials[a].totpoint); + dm->drawObject->materials[a].totpoint); + } } } GPU_buffer_unbind( ); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 40d829808ca..872f678d456 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -1633,7 +1633,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData #pragma omp parallel for schedule(static) for (i=0; islottype == BMO_OP_SLOT_ELEMENT_BUF); if (totelement) { BMHeader *ele; BMHeader **ele_array; - int test = (test_for_enabled ? oflag : 0); + const char hflag_test = (test_for_enabled ? oflag : 0); bmo_slot_buffer_alloc(op, slotname, totelement); @@ -822,7 +822,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo if (htype & BM_VERT) { for (ele = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { - if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == test) { + if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { ele_array[i] = ele; i++; } @@ -831,7 +831,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo if (htype & BM_EDGE) { for (ele = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { - if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == test) { + if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { ele_array[i] = ele; i++; } @@ -840,7 +840,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo if (htype & BM_FACE) { for (ele = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { - if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == test) { + if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { ele_array[i] = ele; i++; } @@ -853,13 +853,13 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo } void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname, - const char htype, const short oflag) + const char htype, const short oflag) { bmo_slot_buffer_from_flag(bm, op, slotname, htype, oflag, TRUE); } void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname, - const char htype, const short oflag) + const char htype, const short oflag) { bmo_slot_buffer_from_flag(bm, op, slotname, htype, oflag, FALSE); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 5cea8d11c09..18f3094fa31 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -531,7 +531,7 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index) if (scene_use_new_shading_nodes(s->scene)) { MFace *mf = &s->dm_mface[face_index]; - ED_object_get_active_image(s->ob, mf->mat_nr+1, &ima, NULL, NULL); + ED_object_get_active_image(s->ob, mf->mat_nr + 1, &ima, NULL, NULL); } else { MTFace *tf = &s->dm_mtface[face_index]; @@ -547,7 +547,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtfa if (ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ MFace *mf = ps->dm_mface + face_index; - ED_object_get_active_image(ps->ob, mf->mat_nr+1, &ima, NULL, NULL); + ED_object_get_active_image(ps->ob, mf->mat_nr + 1, &ima, NULL, NULL); } else { ima = dm_mtface[face_index].tpage; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 55130406e7a..3c1c8ac9941 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -603,7 +603,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (efa) { Image *node_ima; - ED_object_get_active_image(obedit, efa->mat_nr+1, &node_ima, NULL, NULL); + ED_object_get_active_image(obedit, efa->mat_nr + 1, &node_ima, NULL, NULL); if (node_ima) sima->image = node_ima; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 69ca67930b1..4bffc7098b3 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -191,7 +191,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im BMFace *efa= BM_active_face_get(em->bm, sloppy); if (efa) - ED_object_assign_active_image(bmain, obedit, efa->mat_nr+1, ima); + ED_object_assign_active_image(bmain, obedit, efa->mat_nr + 1, ima); } else { /* old shading system, assign image to selected faces */ diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 53555346caf..869cc0444aa 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -1774,7 +1774,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) if (buffers->totface) { const MFace *f = &buffers->mface[buffers->face_indices[0]]; - if (!setMaterial(f->mat_nr+1, NULL)) + if (!setMaterial(f->mat_nr + 1, NULL)) return; smooth = f->flag & ME_SMOOTH; @@ -1782,7 +1782,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) } else if (buffers->totgrid) { const DMFlagMat *f = &buffers->grid_flag_mats[buffers->grid_indices[0]]; - if (!setMaterial(f->mat_nr+1, NULL)) + if (!setMaterial(f->mat_nr + 1, NULL)) return; smooth = f->flag & ME_SMOOTH; diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 7d4ec3c3d81..8341bc67107 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -418,7 +418,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( mface->v4 = (csgface.vertex_number == 4)? csgface.vertex_index[3]: 0; // set material, based on lookup in hash table - orig_mat= give_current_material(orig_ob, mface->mat_nr+1); + orig_mat = give_current_material(orig_ob, mface->mat_nr + 1); if (mat && orig_mat) { if (!BLI_ghash_haskey(material_hash, orig_mat)) { From c56bc8cb0f10af769470dd3e12ec96326fd5cf3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 22:40:02 +0000 Subject: [PATCH 30/58] style cleanup: multi-line if's & whitespace. --- source/blender/bmesh/intern/bmesh_operators.c | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 6b207fc3696..3d410fcd855 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -274,8 +274,7 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, } if (!dest_slot->data.ghash) { - dest_slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, - BLI_ghashutil_ptrcmp, "bmesh operator 2"); + dest_slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh operator 2"); } BLI_ghashIterator_init(&it, source_slot->data.ghash); @@ -459,27 +458,24 @@ void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3]) static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag, int test_for_enabled) { - BMIter elements; + const char iter_types[3] = {BM_VERTS_OF_MESH, + BM_EDGES_OF_MESH, + BM_FACES_OF_MESH}; + + const char flag_types[3] = {BM_VERT, BM_EDGE, BM_FACE}; + + BMIter iter; int count = 0; BMElemF *ele_f; - int test = (test_for_enabled ? oflag : 0); + const char hflag_test = (test_for_enabled ? oflag : 0); + int i; - if (htype & BM_VERT) { - for (ele_f = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); ele_f; ele_f = BM_iter_step(&elements)) { - if (BMO_elem_flag_test(bm, ele_f, oflag) == test) - count++; - } - } - if (htype & BM_EDGE) { - for (ele_f = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); ele_f; ele_f = BM_iter_step(&elements)) { - if (BMO_elem_flag_test(bm, ele_f, oflag) == test) - count++; - } - } - if (htype & BM_FACE) { - for (ele_f = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); ele_f; ele_f = BM_iter_step(&elements)) { - if (BMO_elem_flag_test(bm, ele_f, oflag) == test) - count++; + for (i = 0; i < 3; i++) { + if (htype & flag_types[i]) { + BM_ITER(ele_f, &iter, bm, iter_types[i], NULL) { + if (BMO_elem_flag_test(bm, ele_f, oflag) == hflag_test) + count++; + } } } @@ -559,8 +555,7 @@ void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname memcpy(mapping + 1, data, len); if (!slot->data.ghash) { - slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, - BLI_ghashutil_ptrcmp, "bmesh slot map hash"); + slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh slot map hash"); } BLI_ghash_insert(slot->data.ghash, element, mapping); @@ -707,14 +702,15 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl totelement = BM_mesh_disabled_flag_count(bm, htype, hflag, TRUE); if (totelement) { - int test = (test_for_enabled ? hflag : 0); + const char hflag_test = (test_for_enabled ? hflag : 0); bmo_slot_buffer_alloc(op, slotname, totelement); if (htype & BM_VERT) { for (ele = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && - BM_elem_flag_test(ele, hflag) == test) { + BM_elem_flag_test(ele, hflag) == hflag_test) + { ((BMElem **)output->data.p)[i] = ele; i++; } @@ -724,7 +720,8 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl if (htype & BM_EDGE) { for (ele = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && - BM_elem_flag_test(ele, hflag) == test) { + BM_elem_flag_test(ele, hflag) == hflag_test) + { ((BMElem **)output->data.p)[i] = ele; i++; } @@ -734,7 +731,8 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl if (htype & BM_FACE) { for (ele = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && - BM_elem_flag_test(ele, hflag) == test) { + BM_elem_flag_test(ele, hflag) == hflag_test) + { ((BMElem **)output->data.p)[i] = ele; i++; } @@ -768,7 +766,7 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, BMOpSlot *other_slot = BMO_slot_get(other_op, other_slot_name); BLI_assert(output_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF && - other_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + other_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); if (output_slot->len == 0) { /* output slot is empty, copy rather than append */ From 9fff51e83dc03d38aec9c2a168eb62cf92df9de8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2012 23:17:56 +0000 Subject: [PATCH 31/58] code cleanup: BM_select_mode_set had loops over verts and edges but did nothing (set 0 flags), turns out setting any flags isnt needed since flushing manages this so '#if 0' for now. --- source/blender/bmesh/intern/bmesh_marking.c | 51 ++++++++++++--------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 223815c168f..4ff78faa472 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -397,39 +397,48 @@ void BM_face_select_set(BMesh *bm, BMFace *f, int select) */ void BM_select_mode_set(BMesh *bm, int selectmode) { - BMVert *v; - BMEdge *e; - BMFace *f; - - BMIter verts; - BMIter edges; - BMIter faces; + BMIter iter; + BMElem *ele; bm->selectmode = selectmode; if (bm->selectmode & SCE_SELECT_VERTEX) { - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) - BM_elem_flag_disable(e, 0); - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) - BM_elem_flag_disable(f, 0); + /* disabled because selection flushing handles these */ +#if 0 + BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { + BM_elem_flag_disable(ele, BM_ELEM_SELECT); + } + BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) { + BM_elem_flag_disable(ele, BM_ELEM_SELECT); + } +#endif BM_mesh_select_mode_flush(bm); } else if (bm->selectmode & SCE_SELECT_EDGE) { - for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BM_iter_step(&verts)) - BM_elem_flag_disable(v, 0); - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) { - if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { - BM_edge_select_set(bm, e, TRUE); + /* disabled because selection flushing handles these */ +#if 0 + BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) { + BM_elem_flag_disable(ele, BM_ELEM_SELECT); + } +#endif + + BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { + if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { + BM_edge_select_set(bm, (BMEdge *)ele, TRUE); } } BM_mesh_select_mode_flush(bm); } else if (bm->selectmode & SCE_SELECT_FACE) { - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) - BM_elem_flag_disable(e, 0); - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) { - if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { - BM_face_select_set(bm, f, TRUE); + /* disabled because selection flushing handles these */ +#if 0 + BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { + BM_elem_flag_disable(ele, BM_ELEM_SELECT); + } +#endif + BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) { + if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { + BM_face_select_set(bm, (BMFace *)ele, TRUE); } } BM_mesh_select_mode_flush(bm); From 3f3b88ff426e63f37bc32d3bac05984eafee1062 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 00:28:38 +0000 Subject: [PATCH 32/58] bmesh iterators were passing the BMesh as data argument to BM_iter_new(), harmless but incorrect. replace these cases with iterator macro. --- source/blender/bmesh/intern/bmesh_construct.c | 54 ++++++++-------- source/blender/bmesh/intern/bmesh_marking.c | 26 ++++---- source/blender/bmesh/intern/bmesh_mesh.c | 14 ++--- source/blender/bmesh/intern/bmesh_operators.c | 62 +++++++++++-------- 4 files changed, 83 insertions(+), 73 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index aebad342f7e..974bc814d9b 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -532,18 +532,19 @@ static void bmo_remove_tagged_context_verts(BMesh *bm, const short oflag) BMEdge *e; BMFace *f; - BMIter verts; - BMIter edges; - BMIter faces; + BMIter iter; + BMIter itersub; - for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BM_iter_step(&verts)) { + BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (BMO_elem_flag_test(bm, v, oflag)) { /* Visit edge */ - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_VERT, v); e; e = BM_iter_step(&edges)) + BM_ITER(e, &itersub, bm, BM_EDGES_OF_VERT, v) { BMO_elem_flag_enable(bm, e, oflag); + } /* Visit face */ - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_VERT, v); f; f = BM_iter_step(&faces)) + BM_ITER(f, &itersub, bm, BM_FACES_OF_VERT, v) { BMO_elem_flag_enable(bm, f, oflag); + } } } @@ -557,12 +558,12 @@ static void bmo_remove_tagged_context_edges(BMesh *bm, const short oflag) BMEdge *e; BMFace *f; - BMIter edges; - BMIter faces; + BMIter iter; + BMIter itersub; - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) { + BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BMO_elem_flag_test(bm, e, oflag)) { - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_EDGE, e); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &itersub, bm, BM_FACES_OF_EDGE, e) { BMO_elem_flag_enable(bm, f, oflag); } } @@ -585,9 +586,9 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type) BMEdge *e; BMFace *f; - BMIter verts; - BMIter edges; - BMIter faces; + BMIter viter; + BMIter eiter; + BMIter fiter; switch (type) { case DEL_VERTS: @@ -599,7 +600,7 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type) case DEL_EDGES: { /* flush down to vert */ - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) { + BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) { if (BMO_elem_flag_test(bm, e, oflag)) { BMO_elem_flag_enable(bm, e->v1, oflag); BMO_elem_flag_enable(bm, e->v2, oflag); @@ -607,7 +608,7 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type) } bmo_remove_tagged_context_edges(bm, oflag); /* remove loose vertice */ - for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BM_iter_step(&verts)) { + BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) { if (BMO_elem_flag_test(bm, v, oflag) && (!(v->e))) BMO_elem_flag_enable(bm, v, DEL_WIREVERT); } @@ -638,27 +639,27 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type) case DEL_FACES: { /* go through and mark all edges and all verts of all faces for delet */ - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) { if (BMO_elem_flag_test(bm, f, oflag)) { - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&edges)) + for (e = BM_iter_new(&eiter, bm, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&eiter)) BMO_elem_flag_enable(bm, e, oflag); - for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&verts)) + for (v = BM_iter_new(&viter, bm, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&viter)) BMO_elem_flag_enable(bm, v, oflag); } } /* now go through and mark all remaining faces all edges for keeping */ - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) { if (!BMO_elem_flag_test(bm, f, oflag)) { - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&edges)) { + for (e = BM_iter_new(&eiter, bm, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&eiter)) { BMO_elem_flag_disable(bm, e, oflag); } - for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&verts)) { + for (v = BM_iter_new(&viter, bm, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&viter)) { BMO_elem_flag_disable(bm, v, oflag); } } } /* also mark all the vertices of remaining edges for keeping */ - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) { + BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) { if (!BMO_elem_flag_test(bm, e, oflag)) { BMO_elem_flag_disable(bm, e->v1, oflag); BMO_elem_flag_disable(bm, e->v2, oflag); @@ -676,12 +677,15 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type) case DEL_ALL: { /* does this option even belong in here? */ - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) + BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) { BMO_elem_flag_enable(bm, f, oflag); - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) + } + BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) { BMO_elem_flag_enable(bm, e, oflag); - for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BM_iter_step(&verts)) + } + BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) { BMO_elem_flag_enable(bm, v, oflag); + } BMO_remove_tagged_faces(bm, oflag); BMO_remove_tagged_edges(bm, oflag); diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 4ff78faa472..ed826cbf75a 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -78,13 +78,13 @@ void BM_mesh_select_mode_flush(BMesh *bm) BMLoop *l_first; BMFace *f; - BMIter edges; - BMIter faces; + BMIter eiter; + BMIter fiter; int ok; if (bm->selectmode & SCE_SELECT_VERTEX) { - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) { + BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) { if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) @@ -95,7 +95,7 @@ void BM_mesh_select_mode_flush(BMesh *bm) BM_elem_flag_disable(e, BM_ELEM_SELECT); } } - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) { ok = TRUE; if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { l_iter = l_first = BM_FACE_FIRST_LOOP(f); @@ -114,7 +114,7 @@ void BM_mesh_select_mode_flush(BMesh *bm) } } else if (bm->selectmode & SCE_SELECT_EDGE) { - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) { ok = TRUE; if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { l_iter = l_first = BM_FACE_FIRST_LOOP(f); @@ -149,12 +149,12 @@ void BM_mesh_deselect_flush(BMesh *bm) BMLoop *l_first; BMFace *f; - BMIter edges; - BMIter faces; + BMIter eiter; + BMIter fiter; int ok; - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) { + BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) { if (!(BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN))) @@ -163,7 +163,7 @@ void BM_mesh_deselect_flush(BMesh *bm) } } - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) { ok = TRUE; if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { l_iter = l_first = BM_FACE_FIRST_LOOP(f); @@ -200,12 +200,12 @@ void BM_mesh_select_flush(BMesh *bm) BMLoop *l_first; BMFace *f; - BMIter edges; - BMIter faces; + BMIter eiter; + BMIter fiter; int ok; - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) { + BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) { if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) @@ -214,7 +214,7 @@ void BM_mesh_select_flush(BMesh *bm) } } - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) { ok = TRUE; if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { l_iter = l_first = BM_FACE_FIRST_LOOP(f); diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index f69a46e7d8c..c15937abf1d 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -101,20 +101,18 @@ void BM_mesh_data_free(BMesh *bm) BMFace *f; - BMIter verts; - BMIter edges; - BMIter faces; - BMIter loops; + BMIter iter; + BMIter itersub; - for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BM_iter_step(&verts)) { + BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { CustomData_bmesh_free_block(&(bm->vdata), &(v->head.data)); } - for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) { + BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { CustomData_bmesh_free_block(&(bm->edata), &(e->head.data)); } - for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) { + BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { CustomData_bmesh_free_block(&(bm->pdata), &(f->head.data)); - for (l = BM_iter_new(&loops, bm, BM_LOOPS_OF_FACE, f); l; l = BM_iter_step(&loops)) { + BM_ITER(l, &itersub, bm, BM_LOOPS_OF_FACE, f) { CustomData_bmesh_free_block(&(bm->ldata), &(l->head.data)); } } diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 3d410fcd855..44eed679cbe 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -646,8 +646,6 @@ static void *bmo_slot_buffer_alloc(BMOperator *op, const char *slotname, int len */ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slotname, const char htype) { - BMIter elements; - BMHeader *e; BMOpSlot *output = BMO_slot_get(op, slotname); int totelement = 0, i = 0; @@ -656,25 +654,30 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot if (htype & BM_FACE) totelement += bm->totface; if (totelement) { + BMIter iter; + BMHeader *ele; + bmo_slot_buffer_alloc(op, slotname, totelement); + /* TODO - collapse these loops into one */ + if (htype & BM_VERT) { - for (e = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BM_iter_step(&elements)) { - ((BMHeader **)output->data.p)[i] = e; + BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) { + ((BMHeader **)output->data.p)[i] = ele; i++; } } if (htype & BM_EDGE) { - for (e = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&elements)) { - ((BMHeader **)output->data.p)[i] = e; + BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { + ((BMHeader **)output->data.p)[i] = ele; i++; } } if (htype & BM_FACE) { - for (e = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BM_iter_step(&elements)) { - ((BMHeader **)output->data.p)[i] = e; + BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) { + ((BMHeader **)output->data.p)[i] = ele; i++; } } @@ -691,8 +694,6 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl const char htype, const char hflag, int test_for_enabled) { - BMIter elements; - BMElem *ele; BMOpSlot *output = BMO_slot_get(op, slotname); int totelement = 0, i = 0; @@ -702,12 +703,17 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl totelement = BM_mesh_disabled_flag_count(bm, htype, hflag, TRUE); if (totelement) { + BMIter iter; + BMElem *ele; + const char hflag_test = (test_for_enabled ? hflag : 0); bmo_slot_buffer_alloc(op, slotname, totelement); + /* TODO - collapse these loops into one */ + if (htype & BM_VERT) { - for (ele = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { + BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && BM_elem_flag_test(ele, hflag) == hflag_test) { @@ -718,7 +724,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl } if (htype & BM_EDGE) { - for (ele = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { + BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && BM_elem_flag_test(ele, hflag) == hflag_test) { @@ -729,7 +735,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl } if (htype & BM_FACE) { - for (ele = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { + BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && BM_elem_flag_test(ele, hflag) == hflag_test) { @@ -760,7 +766,7 @@ void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char * * Copies the values from another slot to the end of the output slot. */ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, - BMOperator *other_op, const char *other_slot_name) + BMOperator *other_op, const char *other_slot_name) { BMOpSlot *output_slot = BMO_slot_get(output_op, output_slot_name); BMOpSlot *other_slot = BMO_slot_get(other_op, other_slot_name); @@ -798,7 +804,6 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo const char htype, const short oflag, int test_for_enabled) { - BMIter elements; BMOpSlot *slot = BMO_slot_get(op, slotname); int totelement, i = 0; @@ -810,6 +815,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); if (totelement) { + BMIter iter; BMHeader *ele; BMHeader **ele_array; const char hflag_test = (test_for_enabled ? oflag : 0); @@ -818,8 +824,10 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo ele_array = (BMHeader **)slot->data.p; + /* TODO - collapse these loops into one */ + if (htype & BM_VERT) { - for (ele = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { + BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { ele_array[i] = ele; i++; @@ -828,7 +836,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo } if (htype & BM_EDGE) { - for (ele = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { + BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { ele_array[i] = ele; i++; @@ -837,7 +845,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo } if (htype & BM_FACE) { - for (ele = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) { + BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) { if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { ele_array[i] = ele; i++; @@ -1026,19 +1034,19 @@ static void bmo_flag_layer_alloc(BMesh *bm) bm->toolflagpool = newpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, 512, 512, 0); /* now go through and memcpy all the flags. Loops don't get a flag layer at this time.. */ - for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_VERTS_OF_MESH, NULL, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, old_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ } - for (ele = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_EDGES_OF_MESH, NULL, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, old_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ } - for (ele = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_FACES_OF_MESH, NULL, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, old_totflags_size); @@ -1071,19 +1079,19 @@ static void bmo_flag_layer_free(BMesh *bm) bm->toolflagpool = newpool = BLI_mempool_create(new_totflags_size, 512, 512, BLI_MEMPOOL_SYSMALLOC); /* now go through and memcpy all the flag */ - for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_VERTS_OF_MESH, NULL, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, new_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ } - for (ele = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_EDGES_OF_MESH, NULL, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, new_totflags_size); BM_elem_index_set(ele, i); /* set_inline */ } - for (ele = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_FACES_OF_MESH, NULL, i) { oldflags = ele->oflags; ele->oflags = BLI_mempool_calloc(newpool); memcpy(ele->oflags, oldflags, new_totflags_size); @@ -1106,15 +1114,15 @@ static void bmo_flag_layer_clear(BMesh *bm) const int totflags_offset = bm->totflags - 1; /* now go through and memcpy all the flag */ - for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_VERTS_OF_MESH, NULL, i) { memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer)); BM_elem_index_set(ele, i); /* set_inline */ } - for (ele = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_EDGES_OF_MESH, NULL, i) { memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer)); BM_elem_index_set(ele, i); /* set_inline */ } - for (ele = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) { + BM_ITER_INDEX(ele, &iter, bm, BM_FACES_OF_MESH, NULL, i) { memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer)); BM_elem_index_set(ele, i); /* set_inline */ } From d37d17019c52649646ea5d26a4e5793e656c2c76 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 02:16:27 +0000 Subject: [PATCH 33/58] fix for vertex group blend - wasn't functional since the deform verts were being tken from a NULL array, also made some other improvements - make it work in weight paint vert sel mode (some unused code for this was in the function). - add factor slider. - add to weight paint toolbar. --- release/scripts/startup/bl_ui/space_view3d.py | 1 + .../startup/bl_ui/space_view3d_toolbar.py | 1 + source/blender/editors/object/object_vgroup.c | 190 ++++++++++++------ 3 files changed, 135 insertions(+), 57 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 3fadfd1c45b..905843fcfec 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1188,6 +1188,7 @@ class VIEW3D_MT_paint_weight(Menu): layout.operator("object.vertex_group_invert", text="Invert") layout.operator("object.vertex_group_clean", text="Clean") layout.operator("object.vertex_group_levels", text="Levels") + layout.operator("object.vertex_group_blend", text="Blend") layout.operator("object.vertex_group_fix", text="Fix Deforms") layout.separator() diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index e6c89478287..55eb4f26c3f 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -977,6 +977,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel): col.operator("object.vertex_group_invert", text="Invert") col.operator("object.vertex_group_clean", text="Clean") col.operator("object.vertex_group_levels", text="Levels") + col.operator("object.vertex_group_blend", text="Blend") col.operator("object.vertex_group_fix", text="Fix Deforms") diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index e0f808aa1a1..a87268a2402 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1249,91 +1249,132 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_ } } -static void vgroup_blend(Object *ob) +static void vgroup_blend(Object *ob, const float fac) { + MDeformVert *dv; MDeformWeight *dw; - MDeformVert *dvert_array=NULL, *dvert; int i, dvert_tot=0; - const int def_nr= ob->actdef-1; + const int def_nr= ob->actdef - 1; - BMEditMesh *em; + BLI_assert(fac >= 0.0 && fac <= 1.0f); - if (ob->type != OB_MESH || ((em = BMEdit_FromObject(ob)) == NULL)) { + if (ob->type != OB_MESH) { return; } if (BLI_findlink(&ob->defbase, def_nr)) { + const float ifac = 1.0f - fac; + int i1, i2; + + BMEditMesh *em = BMEdit_FromObject(ob); + BMesh *bm = em ? em->bm : NULL; + Mesh *me = em ? NULL : ob->data; + + /* bmesh only*/ BMEdge *eed; BMVert *eve; BMIter iter; - int i1, i2; + /* mesh only */ + MDeformVert *dvert_array = NULL; + float *vg_weights; float *vg_users; int sel1, sel2; - BM_mesh_elem_index_ensure(em->bm, BM_VERT); + if (bm) { + BM_mesh_elem_index_ensure(bm, BM_VERT); + dvert_tot = bm->totvert; + } + else { + dvert_tot = me->totvert; + dvert_array = me->dvert; + } - dvert_tot= em->bm->totvert; + vg_weights = MEM_callocN(sizeof(float) * dvert_tot, "vgroup_blend_f"); + vg_users = MEM_callocN(sizeof(int) * dvert_tot, "vgroup_blend_i"); - vg_weights= MEM_callocN(sizeof(float)*dvert_tot, "vgroup_blend_f"); - vg_users= MEM_callocN(sizeof(int)*dvert_tot, "vgroup_blend_i"); + if (bm) { + BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) { + sel1 = BM_elem_flag_test(eed->v1, BM_ELEM_SELECT); + sel2 = BM_elem_flag_test(eed->v2, BM_ELEM_SELECT); - BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - sel1= BM_elem_flag_test(eed->v1, BM_ELEM_SELECT); - sel2= BM_elem_flag_test(eed->v2, BM_ELEM_SELECT); + if (sel1 != sel2) { + /* i1 is always the selected one */ + if (sel1) { + i1= BM_elem_index_get(eed->v1); + i2= BM_elem_index_get(eed->v2); + eve= eed->v2; + } + else { + i2= BM_elem_index_get(eed->v1); + i1= BM_elem_index_get(eed->v2); + eve= eed->v1; + } - if (sel1 != sel2) { - /* i1 is always the selected one */ - if (sel1==TRUE && sel2==FALSE) { - i1= BM_elem_index_get(eed->v1); - i2= BM_elem_index_get(eed->v2); - eve= eed->v2; + dv = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MDEFORMVERT); + dw = defvert_find_index(dv, def_nr); + if (dw) { + vg_weights[i1] += dw->weight; + } + vg_users[i1]++; } - else { - i2= BM_elem_index_get(eed->v1); - i1= BM_elem_index_get(eed->v2); - eve= eed->v1; + } + + BM_ITER_INDEX(eve, &iter, bm, BM_VERTS_OF_MESH, NULL, i) { + if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && vg_users[i] > 0) { + dv = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MDEFORMVERT); + + dw = defvert_verify_index(dv, def_nr); + dw->weight = (fac * (vg_weights[i] / (float)vg_users[i])) + (ifac * dw->weight); + /* in case of division errors */ + CLAMP(dw->weight, 0.0f, 1.0f); } + } + } + else { + MEdge *ed = me->medge; + MVert *mv; - vg_users[i1]++; + for (i = 0; i < me->totedge; i++, ed++) { + sel1 = me->mvert[ed->v1].flag & SELECT; + sel2 = me->mvert[ed->v2].flag & SELECT; - /* TODO, we may want object mode blending */ -#if 0 - if (em) { - dvert = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); - } - else -#endif - { - dvert= dvert_array+i2; + if (sel1 != sel2) { + /* i1 is always the selected one */ + if (sel1) { + i1 = ed->v1; + i2 = ed->v2; + } + else { + i2 = ed->v1; + i1 = ed->v2; + } + + dv = &dvert_array[i2]; + dw = defvert_find_index(dv, def_nr); + if (dw) { + vg_weights[i1] += dw->weight; + } + vg_users[i1]++; } + } - dw = defvert_find_index(dvert, def_nr); + mv = me->mvert; + dv = dvert_array; - if (dw) { - vg_weights[i1] += dw->weight; + for (i = 0; i < dvert_tot; i++, mv++, dv++) { + if ((mv->flag & SELECT) && (vg_users[i] > 0)) { + dw = defvert_verify_index(dv, def_nr); + dw->weight = (fac * (vg_weights[i] / (float)vg_users[i])) + (ifac * dw->weight); + + /* in case of division errors */ + CLAMP(dw->weight, 0.0f, 1.0f); } } } - i= 0; - BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && vg_users[i] > 0) { - /* TODO, we may want object mode blending */ - if (em) dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); - else dvert= dvert_array+i; - - dw= defvert_verify_index(dvert, def_nr); - dw->weight= vg_weights[i] / (float)vg_users[i]; - - /* in case of division errors */ - CLAMP(dw->weight, 0.0f, 1.0f); - } - - i++; - } MEM_freeN(vg_weights); MEM_freeN(vg_users); } @@ -2482,11 +2523,12 @@ void OBJECT_OT_vertex_group_invert(wmOperatorType *ot) } -static int vertex_group_blend_exec(bContext *C, wmOperator *UNUSED(op)) +static int vertex_group_blend_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); + float fac = RNA_float_get(op->ptr, "factor"); - vgroup_blend(ob); + vgroup_blend(ob, fac); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -2495,19 +2537,53 @@ static int vertex_group_blend_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } +/* check we have a vertex selection, either in weight paint or editmode */ +static int vertex_group_blend_poll(bContext *C) +{ + Object *ob = ED_object_context(C); + ID *data = (ob) ? ob->data: NULL; + + if (!(ob && !ob->id.lib && data && !data->lib)) + return FALSE; + + if (vgroup_object_in_edit_mode(ob)) { + return TRUE; + } + else if ((ob->type == OB_MESH) && (ob->mode & OB_MODE_WEIGHT_PAINT)) { + if (ME_EDIT_PAINT_SEL_MODE(((Mesh *)data)) == SCE_SELECT_VERTEX) { + return TRUE; + } + else { + CTX_wm_operator_poll_msg_set(C, "Vertex select needs to be enabled in weight paint mode"); + return FALSE; + } + + } + else { + return FALSE; + } +} + void OBJECT_OT_vertex_group_blend(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Blend Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_blend"; - ot->description = ""; + ot->description = "Blend selected vertex weights with unselected for the active group"; /* api callbacks */ - ot->poll = vertex_group_poll_edit; /* TODO - add object mode support */ + ot->poll = vertex_group_blend_poll; ot->exec = vertex_group_blend_exec; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + prop = RNA_def_property(ot->srna, "factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_ui_text(prop, "Factor", ""); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_default(prop, 1.0f); } From db9c9f6c64c250e04add203a2d853a09235b5156 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 02:38:27 +0000 Subject: [PATCH 34/58] fix [#30772] No more than two subdivions give correct result when adding an icosphere bug was introduced in r45297, which inadvertently broke testing for multiple flags at once. added BM_elem_flag_test_bool() and BMO_elem_flag_test_bool() to get TRUE/FALSE results rather then the flag value. --- source/blender/bmesh/intern/bmesh_inline.h | 18 ++++++---- source/blender/bmesh/intern/bmesh_marking.c | 11 +++--- .../blender/bmesh/intern/bmesh_operator_api.h | 36 ++++++++++--------- .../bmesh/intern/bmesh_operator_api_inline.h | 21 ++++++----- source/blender/bmesh/intern/bmesh_operators.c | 33 ++++++++--------- 5 files changed, 67 insertions(+), 52 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_inline.h b/source/blender/bmesh/intern/bmesh_inline.h index 2cfaf49d51e..400f4a55b0e 100644 --- a/source/blender/bmesh/intern/bmesh_inline.h +++ b/source/blender/bmesh/intern/bmesh_inline.h @@ -30,18 +30,24 @@ #define __BMESH_INLINE_H__ /* stuff for dealing with header flags */ -#define BM_elem_flag_test( ele, hflag) _bm_elem_flag_test (&(ele)->head, hflag) -#define BM_elem_flag_enable( ele, hflag) _bm_elem_flag_enable (&(ele)->head, hflag) -#define BM_elem_flag_disable(ele, hflag) _bm_elem_flag_disable (&(ele)->head, hflag) -#define BM_elem_flag_set( ele, hflag, val) _bm_elem_flag_set (&(ele)->head, hflag, val) -#define BM_elem_flag_toggle( ele, hflag) _bm_elem_flag_toggle (&(ele)->head, hflag) -#define BM_elem_flag_merge( ele_a, ele_b) _bm_elem_flag_merge (&(ele_a)->head, &(ele_b)->head) +#define BM_elem_flag_test( ele, hflag) _bm_elem_flag_test (&(ele)->head, hflag) +#define BM_elem_flag_test_bool(ele, hflag) _bm_elem_flag_test_bool(&(ele)->head, hflag) +#define BM_elem_flag_enable( ele, hflag) _bm_elem_flag_enable (&(ele)->head, hflag) +#define BM_elem_flag_disable( ele, hflag) _bm_elem_flag_disable (&(ele)->head, hflag) +#define BM_elem_flag_set( ele, hflag, val) _bm_elem_flag_set (&(ele)->head, hflag, val) +#define BM_elem_flag_toggle( ele, hflag) _bm_elem_flag_toggle (&(ele)->head, hflag) +#define BM_elem_flag_merge( ele_a, ele_b) _bm_elem_flag_merge (&(ele_a)->head, &(ele_b)->head) BLI_INLINE char _bm_elem_flag_test(const BMHeader *head, const char hflag) { return head->hflag & hflag; } +BLI_INLINE short _bm_elem_flag_test_bool(const BMHeader *head, const char hflag) +{ + return (head->hflag & hflag) != 0; +} + BLI_INLINE void _bm_elem_flag_enable(BMHeader *head, const char hflag) { head->hflag |= hflag; diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index ed826cbf75a..03c4d3c9cbb 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -449,29 +449,30 @@ void BM_select_mode_set(BMesh *bm, int selectmode) * counts number of elements with flag enabled/disabled */ static int bm_mesh_flag_count(BMesh *bm, const char htype, const char hflag, - int respecthide, int test_for_enabled) + const short respecthide, const short test_for_enabled) { BMElem *ele; BMIter iter; - const char hflag_test = (test_for_enabled ? hflag : 0); int tot = 0; + BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); + if (htype & BM_VERT) { for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); ele; ele = BM_iter_step(&iter)) { if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue; - if (BM_elem_flag_test(ele, hflag) == hflag_test) tot++; + if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++; } } if (htype & BM_EDGE) { for (ele = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); ele; ele = BM_iter_step(&iter)) { if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue; - if (BM_elem_flag_test(ele, hflag) == hflag_test) tot++; + if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++; } } if (htype & BM_FACE) { for (ele = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); ele; ele = BM_iter_step(&iter)) { if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue; - if (BM_elem_flag_test(ele, hflag) == hflag_test) tot++; + if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++; } } diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index bb980a63861..7cba66995c9 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -75,17 +75,19 @@ extern "C" { struct GHashIterator; -#define BMO_elem_flag_test( bm, ele, oflag) _bmo_elem_flag_test (bm, (ele)->oflags, oflag) -#define BMO_elem_flag_enable( bm, ele, oflag) _bmo_elem_flag_enable (bm, (ele)->oflags, oflag) -#define BMO_elem_flag_disable(bm, ele, oflag) _bmo_elem_flag_disable (bm, (ele)->oflags, oflag) -#define BMO_elem_flag_set( bm, ele, oflag, val) _bmo_elem_flag_set (bm, (ele)->oflags, oflag, val) -#define BMO_elem_flag_toggle( bm, ele, oflag) _bmo_elem_flag_toggle (bm, (ele)->oflags, oflag) +#define BMO_elem_flag_test( bm, ele, oflag) _bmo_elem_flag_test (bm, (ele)->oflags, oflag) +#define BMO_elem_flag_test_bool(bm, ele, oflag) _bmo_elem_flag_test_bool(bm, (ele)->oflags, oflag) +#define BMO_elem_flag_enable( bm, ele, oflag) _bmo_elem_flag_enable (bm, (ele)->oflags, oflag) +#define BMO_elem_flag_disable( bm, ele, oflag) _bmo_elem_flag_disable (bm, (ele)->oflags, oflag) +#define BMO_elem_flag_set( bm, ele, oflag, val) _bmo_elem_flag_set (bm, (ele)->oflags, oflag, val) +#define BMO_elem_flag_toggle( bm, ele, oflag) _bmo_elem_flag_toggle (bm, (ele)->oflags, oflag) -BLI_INLINE short _bmo_elem_flag_test(BMesh *bm, BMFlagLayer *oflags, const short oflag); -BLI_INLINE void _bmo_elem_flag_enable(BMesh *bm, BMFlagLayer *oflags, const short oflag); -BLI_INLINE void _bmo_elem_flag_disable(BMesh *bm, BMFlagLayer *oflags, const short oflag); -BLI_INLINE void _bmo_elem_flag_set(BMesh *bm, BMFlagLayer *oflags, const short oflag, int val); -BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const short oflag); +BLI_INLINE short _bmo_elem_flag_test( BMesh *bm, BMFlagLayer *oflags, const short oflag); +BLI_INLINE short _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag); +BLI_INLINE void _bmo_elem_flag_enable( BMesh *bm, BMFlagLayer *oflags, const short oflag); +BLI_INLINE void _bmo_elem_flag_disable( BMesh *bm, BMFlagLayer *oflags, const short oflag); +BLI_INLINE void _bmo_elem_flag_set( BMesh *bm, BMFlagLayer *oflags, const short oflag, int val); +BLI_INLINE void _bmo_elem_flag_toggle( BMesh *bm, BMFlagLayer *oflags, const short oflag); /* slot type arrays are terminated by the last member * having a slot type of 0.*/ @@ -297,17 +299,17 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *op, const char htype, cons /* copies the values from another slot to the end of the output slot */ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot, - BMOperator *other_op, const char *other_op_slot); + BMOperator *other_op, const char *other_op_slot); /* puts every element of type 'type' (which is a bitmask) with tool * flag 'flag', into a slot. */ void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname, - const char htype, const short oflag); + const char htype, const short oflag); /* puts every element of type 'type' (which is a bitmask) without tool * flag 'flag', into a slot. */ void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname, - const char htype, const short oflag); + const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname, @@ -327,15 +329,15 @@ void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slotna * flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, - const char *slotname, - const char htype, const char hflag); + const char *slotname, + const char htype, const char hflag); /* puts every element of type 'type' (which is a bitmask) without * header flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, - const char *slotname, - const char htype, const char hflag); + const char *slotname, + const char htype, const char hflag); /* counts number of elements inside a slot array. */ int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slotname); diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h index 268736cfe0e..e04079f42c9 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -40,7 +40,12 @@ /* flags 15 and 16 (1 << 14 and 1 << 15) are reserved for bmesh api use */ BLI_INLINE short _bmo_elem_flag_test(BMesh *bm, BMFlagLayer *oflags, const short oflag) { - return oflags[bm->stackdepth - 1].f & oflag; + return oflags[bm->stackdepth - 1].f & oflag; +} + +BLI_INLINE short _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag) +{ + return (oflags[bm->stackdepth - 1].f & oflag) != 0; } BLI_INLINE void _bmo_elem_flag_enable(BMesh *bm, BMFlagLayer *oflags, const short oflag) @@ -65,13 +70,13 @@ BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const shor } BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname, - void *element, int val) + void *element, int val) { BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int)); } BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname, - void *element, float val) + void *element, float val) { BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float)); } @@ -83,7 +88,7 @@ BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */ BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname, - void *element, void *val) + void *element, void *val) { BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void *)); } @@ -100,7 +105,7 @@ BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const ch } BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, - void *element) + void *element) { BMOElemMapping *mapping; BMOpSlot *slot = BMO_slot_get(op, slotname); @@ -117,7 +122,7 @@ BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const } BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname, - void *element) + void *element) { float *val = (float *) BMO_slot_map_data_get(bm, op, slotname, element); if (val) return *val; @@ -126,7 +131,7 @@ BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *s } BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname, - void *element) + void *element) { int *val = (int *) BMO_slot_map_data_get(bm, op, slotname, element); if (val) return *val; @@ -135,7 +140,7 @@ BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotn } BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname, - void *element) + void *element) { void **val = (void **) BMO_slot_map_data_get(bm, op, slotname, element); if (val) return *val; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 44eed679cbe..00292e481b2 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -456,7 +456,7 @@ void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3]) */ static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag, - int test_for_enabled) + const short test_for_enabled) { const char iter_types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, @@ -467,13 +467,14 @@ static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag, BMIter iter; int count = 0; BMElemF *ele_f; - const char hflag_test = (test_for_enabled ? oflag : 0); int i; + BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); + for (i = 0; i < 3; i++) { if (htype & flag_types[i]) { BM_ITER(ele_f, &iter, bm, iter_types[i], NULL) { - if (BMO_elem_flag_test(bm, ele_f, oflag) == hflag_test) + if (BMO_elem_flag_test_bool(bm, ele_f, oflag) == test_for_enabled) count++; } } @@ -692,11 +693,13 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot */ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slotname, const char htype, const char hflag, - int test_for_enabled) + const short test_for_enabled) { BMOpSlot *output = BMO_slot_get(op, slotname); int totelement = 0, i = 0; + BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); + if (test_for_enabled) totelement = BM_mesh_enabled_flag_count(bm, htype, hflag, TRUE); else @@ -706,8 +709,6 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl BMIter iter; BMElem *ele; - const char hflag_test = (test_for_enabled ? hflag : 0); - bmo_slot_buffer_alloc(op, slotname, totelement); /* TODO - collapse these loops into one */ @@ -715,7 +716,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl if (htype & BM_VERT) { BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && - BM_elem_flag_test(ele, hflag) == hflag_test) + BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { ((BMElem **)output->data.p)[i] = ele; i++; @@ -726,7 +727,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl if (htype & BM_EDGE) { BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && - BM_elem_flag_test(ele, hflag) == hflag_test) + BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { ((BMElem **)output->data.p)[i] = ele; i++; @@ -737,7 +738,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl if (htype & BM_FACE) { BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) && - BM_elem_flag_test(ele, hflag) == hflag_test) + BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { ((BMElem **)output->data.p)[i] = ele; i++; @@ -786,8 +787,7 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, /* copy slot data */ memcpy(buf, output_slot->data.buf, elem_size * output_slot->len); - memcpy(((char*)buf) + elem_size * output_slot->len, - other_slot->data.buf, elem_size * other_slot->len); + memcpy(((char *)buf) + elem_size * output_slot->len, other_slot->data.buf, elem_size * other_slot->len); output_slot->data.buf = buf; output_slot->len += other_slot->len; @@ -802,11 +802,13 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, */ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slotname, const char htype, const short oflag, - int test_for_enabled) + const short test_for_enabled) { BMOpSlot *slot = BMO_slot_get(op, slotname); int totelement, i = 0; + BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); + if (test_for_enabled) totelement = BMO_mesh_enabled_flag_count(bm, htype, oflag); else @@ -818,7 +820,6 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo BMIter iter; BMHeader *ele; BMHeader **ele_array; - const char hflag_test = (test_for_enabled ? oflag : 0); bmo_slot_buffer_alloc(op, slotname, totelement); @@ -828,7 +829,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo if (htype & BM_VERT) { BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { + if (BMO_elem_flag_test_bool(bm, (BMElemF *)ele, oflag) == test_for_enabled) { ele_array[i] = ele; i++; } @@ -837,7 +838,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo if (htype & BM_EDGE) { BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { - if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { + if (BMO_elem_flag_test_bool(bm, (BMElemF *)ele, oflag) == test_for_enabled) { ele_array[i] = ele; i++; } @@ -846,7 +847,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo if (htype & BM_FACE) { BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) { - if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag) == hflag_test) { + if (BMO_elem_flag_test_bool(bm, (BMElemF *)ele, oflag) == test_for_enabled) { ele_array[i] = ele; i++; } From 817a407a62df5b79bf2a12d87ccbd0bc7e12d56c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 02:46:44 +0000 Subject: [PATCH 35/58] patch [#30779] Multiselect mode cause inconsistent selection growing from Francisco De La Cruz (xercesblue) The test to use faces was incorrect since mixed vertex and edge mode would be treated as faces. made own minor change. --- source/blender/editors/mesh/editmesh_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 40ca1e64fad..11f58303215 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -426,7 +426,7 @@ void EDBM_select_flush(BMEditMesh *em) void EDBM_select_more(BMEditMesh *em) { BMOperator bmop; - int use_faces = em->selectmode > SCE_SELECT_EDGE; + int use_faces = em->selectmode == SCE_SELECT_FACE; BMO_op_initf(em->bm, &bmop, "regionextend geom=%hvef constrict=%b use_faces=%b", @@ -442,7 +442,7 @@ void EDBM_select_more(BMEditMesh *em) void EDBM_select_less(BMEditMesh *em) { BMOperator bmop; - int use_faces = em->selectmode > SCE_SELECT_EDGE; + int use_faces = em->selectmode == SCE_SELECT_FACE; BMO_op_initf(em->bm, &bmop, "regionextend geom=%hvef constrict=%b use_faces=%b", From d98c1770f9be7a384676076a39df3426ec01ebb4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 02:52:34 +0000 Subject: [PATCH 36/58] patch [#30780] Transform operator leak in aborted edge slide mode from Francisco De La Cruz (xercesblue) --- source/blender/editors/transform/transform.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 71bca7bfce8..f2e2d5dd281 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4402,7 +4402,7 @@ static int createSlideVerts(TransInfo *t) int numsel, i, j; if (!v3d) { - /*ok, let's try to survive this*/ + /* ok, let's try to survive this */ unit_m4(projectMat); } else { @@ -4428,15 +4428,20 @@ static int createSlideVerts(TransInfo *t) } if (numsel == 0 || numsel > 2) { - return 0; //invalid edge selection + MEM_freeN(sld); + BMBVH_FreeBVH(btree); + return 0; /* invalid edge selection */ } } } BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { - if (BM_edge_face_count(e) != 2) - return 0; //can only handle exactly 2 faces around each edge + if (BM_edge_face_count(e) != 2) { + MEM_freeN(sld); + BMBVH_FreeBVH(btree); + return 0; /* can only handle exactly 2 faces around each edge */ + } } } @@ -4452,8 +4457,11 @@ static int createSlideVerts(TransInfo *t) } } - if (!j) + if (!j) { + MEM_freeN(sld); + BMBVH_FreeBVH(btree); return 0; + } tempsv = MEM_callocN(sizeof(TransDataSlideVert)*j, "tempsv"); From 431eafe559a651a02eb333cee1e17998d702d864 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 03:17:49 +0000 Subject: [PATCH 37/58] partial fix [#30777] python console utf-8 problem backspace/del now doesn't split up multi-byte characters. Ctlr+Backspace/Del now work for deleting whole words. --- .../editors/space_console/console_intern.h | 2 +- .../editors/space_console/console_ops.c | 38 ++++++++++++++----- .../editors/space_console/space_console.c | 10 ++--- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h index ca0e999d7ea..33588cc0923 100644 --- a/source/blender/editors/space_console/console_intern.h +++ b/source/blender/editors/space_console/console_intern.h @@ -64,6 +64,6 @@ void CONSOLE_OT_paste(struct wmOperatorType *ot); void CONSOLE_OT_select_set(struct wmOperatorType *ot); enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD }; -enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL }; +enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_NEXT_WORD, DEL_PREV_WORD, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL }; #endif /* __CONSOLE_INTERN_H__ */ diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index d80b9e2ffb9..ef036b071be 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -434,8 +434,8 @@ void CONSOLE_OT_insert(wmOperatorType *ot) static EnumPropertyItem console_delete_type_items[] = { {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, -// {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""}, -// {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""}, + {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""}, + {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""}, {0, NULL, 0, NULL, NULL} }; @@ -444,6 +444,8 @@ static int console_delete_exec(bContext *C, wmOperator *op) SpaceConsole *sc = CTX_wm_space_console(C); ARegion *ar = CTX_wm_region(C); ConsoleLine *ci = console_history_verify(C); + int pos; + int stride; const short type = RNA_enum_get(op->ptr, "type"); int done = 0; @@ -454,22 +456,38 @@ static int console_delete_exec(bContext *C, wmOperator *op) switch (type) { case DEL_NEXT_CHAR: + case DEL_NEXT_WORD: if (ci->cursor < ci->len) { - memmove(ci->line + ci->cursor, ci->line + ci->cursor + 1, (ci->len - ci->cursor) + 1); - ci->len--; - done = 1; + pos = ci->cursor; + BLI_str_cursor_step_utf8(ci->line, ci->len, + &pos, STRCUR_DIR_NEXT, + (type == DEL_NEXT_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM); + stride = pos - ci->cursor; + if (stride) { + memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); + ci->len -= stride; + done = 1; + } } break; case DEL_PREV_CHAR: + case DEL_PREV_WORD: if (ci->cursor > 0) { - ci->cursor--; /* same as above */ - memmove(ci->line + ci->cursor, ci->line + ci->cursor + 1, (ci->len - ci->cursor) + 1); - ci->len--; - done = 1; + pos = ci->cursor; + BLI_str_cursor_step_utf8(ci->line, ci->len, + &pos, STRCUR_DIR_PREV, + (type == DEL_PREV_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM); + stride = ci->cursor - pos; + if (stride) { + ci->cursor -= stride; /* same as above */ + memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); + ci->len -= stride; + done = 1; + } } break; } - + if (!done) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 0dbd4876a65..b71ca6c36c4 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -303,19 +303,15 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_LINE); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_PAGE); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_PAGE); - - - //RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR); - RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_CHAR); - //RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR); - RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); - RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); #endif RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */ + RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); + #ifdef WITH_PYTHON WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */ WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0); From 6d31d795bee5c8a56d86aaa39d89d54114dcac21 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 3 Apr 2012 05:23:23 +0000 Subject: [PATCH 38/58] r45338 added multithreaded OpenEXR loading. Path to pthread was missing. --- source/blender/imbuf/intern/openexr/SConscript | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/imbuf/intern/openexr/SConscript b/source/blender/imbuf/intern/openexr/SConscript index 082bb82c322..e590077db2b 100644 --- a/source/blender/imbuf/intern/openexr/SConscript +++ b/source/blender/imbuf/intern/openexr/SConscript @@ -15,4 +15,7 @@ incs += Split(env['BF_OPENEXR_INC']) defs = ['WITH_OPENEXR'] +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): + incs.append(env['BF_PTHREADS_INC']) + env.BlenderLib ('bf_imbuf_openexr', source_files, incs, defs, libtype=['core','player'], priority = [225,180]) From be0d4f8e4566c8907b69a267f203f60842219058 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 06:05:43 +0000 Subject: [PATCH 39/58] BM_mesh_esubdivideflag was adjusting the totedgesel variable when this is handled by selection functions. --- source/blender/bmesh/operators/bmo_subdivide.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index bcd9566ce98..df92324d3a3 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -1069,14 +1069,12 @@ void BM_mesh_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float s BM_elem_flag_test(e->v2, BM_ELEM_SELECT)) { BM_elem_select_set(bm, e, TRUE); - bm->totedgesel += 1; } else if (BM_elem_flag_test(e, BM_ELEM_SELECT) && (!BM_elem_flag_test(e->v1, BM_ELEM_SELECT) || !BM_elem_flag_test(e->v2, BM_ELEM_SELECT))) { BM_elem_select_set(bm, e, FALSE); - bm->totedgesel -= 1; } } } From 817a96f243490e8a1c0eb1dff19a45e73a7b9e8b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 06:12:04 +0000 Subject: [PATCH 40/58] fix [#30735] bmesh: loop-cut cuts faces isolated by hidden faces --- source/blender/bmesh/operators/bmo_subdivide.c | 6 +++--- source/blender/editors/mesh/editmesh_loopcut.c | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index df92324d3a3..f9758e3bf7f 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -1023,9 +1023,9 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) /* editmesh-emulating function */ void BM_mesh_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth, - float fractal, int beauty, int numcuts, - int seltype, int cornertype, int singleedge, - int gridfill, int seed) + float fractal, int beauty, int numcuts, + int seltype, int cornertype, int singleedge, + int gridfill, int seed) { BMOperator op; diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 638eaabbfd3..90698a79c25 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -206,7 +206,7 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) if (select) { BMW_init(&walker, em->bm, BMW_EDGERING, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, - BMW_FLAG_NOP, /* BMESH_TODO - should be BMW_FLAG_TEST_HIDDEN ? */ + BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); eed = BMW_begin(&walker, startedge); @@ -220,7 +220,7 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) BMW_init(&walker, em->bm, BMW_EDGERING, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, - BMW_FLAG_NOP, /* BMESH_TODO - should be BMW_FLAG_TEST_HIDDEN ? */ + BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); eed = startedge = BMW_begin(&walker, startedge); @@ -240,6 +240,8 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) edgering_find_order(em, lasteed, eed, lastv1, v); lastv1 = v[0][0]; + BLI_array_growitems(edges, previewlines); + for (i = 1; i <= previewlines; i++) { co[0][0] = (v[0][1]->co[0] - v[0][0]->co[0]) * (i / ((float)previewlines + 1)) + v[0][0]->co[0]; co[0][1] = (v[0][1]->co[1] - v[0][0]->co[1]) * (i / ((float)previewlines + 1)) + v[0][0]->co[1]; @@ -249,7 +251,6 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1]) * (i / ((float)previewlines + 1)) + v[1][0]->co[1]; co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2]) * (i / ((float)previewlines + 1)) + v[1][0]->co[2]; - BLI_array_growone(edges); copy_v3_v3(edges[tot][0], co[0]); copy_v3_v3(edges[tot][1], co[1]); tot++; @@ -264,6 +265,8 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) edgering_find_order(em, lasteed, startedge, lastv1, v); + BLI_array_growitems(edges, previewlines); + for (i = 1; i <= previewlines; i++) { if (!v[0][0] || !v[0][1] || !v[1][0] || !v[1][1]) continue; @@ -276,7 +279,6 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1]) * (i / ((float)previewlines + 1)) + v[1][0]->co[1]; co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2]) * (i / ((float)previewlines + 1)) + v[1][0]->co[2]; - BLI_array_growone(edges); copy_v3_v3(edges[tot][0], co[0]); copy_v3_v3(edges[tot][1], co[1]); tot++; From 285970753ee81ef383bf74c59fa97987d90c5698 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 07:31:11 +0000 Subject: [PATCH 41/58] fix/workaround an error related to [#30735] when a single face in a loop is hidden, loop cut will subdivide edges on both sides. creating an edge between the hidden faces. without this workaround the edge ends up hidden and selected. added a check in BM_mesh_validate() for hidden/selected elements. --- source/blender/bmesh/intern/bmesh_mesh_validate.c | 14 +++++++++++++- source/blender/editors/transform/transform.c | 8 +++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c index 0ec13f1df8f..f91e9d82879 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_validate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c @@ -71,9 +71,13 @@ int BM_mesh_validate(BMesh *bm) BM_mesh_elem_index_ensure(bm, BM_ALL); BM_ITER_INDEX(v, &iter, bm, BM_VERTS_OF_MESH, NULL, i) { + if (BM_elem_flag_test(v, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) { + ERRMSG("vert %d: is hidden and selected", i); + } + if (v->e) { if (!BM_vert_in_edge(v->e, v)) { - ERRMSG("vert: %d - is not in its referenced edge: %d", i, BM_elem_index_get(v->e)); + ERRMSG("vert %d: is not in its referenced edge: %d", i, BM_elem_index_get(v->e)); } } } @@ -86,6 +90,10 @@ int BM_mesh_validate(BMesh *bm) /* edge radial structure */ BM_ITER_INDEX(e, &iter, bm, BM_EDGES_OF_MESH, NULL, i) { + if (BM_elem_flag_test(e, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) { + ERRMSG("edge %d: is hidden and selected", i); + } + if (e->l) { BMLoop *l_iter; BMLoop *l_first; @@ -113,6 +121,10 @@ int BM_mesh_validate(BMesh *bm) BMLoop *l_iter; BMLoop *l_first; + if (BM_elem_flag_test(f, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) { + ERRMSG("face %d: is hidden and selected", i); + } + l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f2e2d5dd281..374268dc735 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4768,12 +4768,14 @@ void projectSVData(TransInfo *t, int final) } } - /*make sure face-attributes are correct (e.g. MTexPoly)*/ + /* make sure face-attributes are correct (e.g. MTexPoly) */ BM_elem_attrs_copy(em->bm, em->bm, copyf2, f); - /*restore selection and hidden flags*/ + /* restore selection and hidden flags */ BM_elem_select_set(em->bm, f, sel); - BM_elem_hide_set(em->bm, f, hide); + if (!hide) { /* this check is a workaround for bug, see note - [#30735], without this edge can be hidden and selected */ + BM_elem_hide_set(em->bm, f, hide); + } } } From cc6b8bd3e65ec848cee0374688219307864f58e9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 07:35:50 +0000 Subject: [PATCH 42/58] fix [#30786] bmesh: select linked not ignoring hidden verts/edges/faces (part 2) --- source/blender/editors/mesh/editmesh_select.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 57041e967e9..355d64a9fe1 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1919,7 +1919,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) BMW_init(&walker, em->bm, BMW_SHELL, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, - BMW_FLAG_NOP, /* BMESH_TODO - should be BMW_FLAG_TEST_HIDDEN ? */ + BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { From a7798884a5ab806723a9e773fbd3a387369786b0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 3 Apr 2012 09:11:26 +0000 Subject: [PATCH 43/58] Fixed mistake made in threaded EXR commit. --- source/blender/imbuf/intern/filetype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index 74fd601e3f6..59c10165974 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -77,10 +77,10 @@ ImFileType IMB_FILE_TYPES[]= { {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR}, #endif #ifdef WITH_OPENEXR - {NULL, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR}, + {imb_initopenexr, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR}, #endif #ifdef WITH_OPENJPEG - {imb_initopenexr, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2}, + {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2}, #endif #ifdef WITH_DDS {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS}, From 64d2a32f922e7b701a4c3b0fdbbf89b52f156c9c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 11:10:26 +0000 Subject: [PATCH 44/58] rna/py api - rename layers with polygon prefix, since there are edge and vertex layers too. --- source/blender/makesrna/intern/rna_mesh.c | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 2421cebeaf3..d786c673256 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -759,14 +759,14 @@ static int rna_float_layer_check(CollectionPropertyIterator *iter, void *data) return (layer->type != CD_PROP_FLT); } -static void rna_Mesh_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Mesh_polygon_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { CustomData *pdata = rna_mesh_pdata(ptr); rna_iterator_array_begin(iter, (void*)pdata->layers, sizeof(CustomDataLayer), pdata->totlayer, 0, rna_float_layer_check); } -static int rna_Mesh_float_layers_length(PointerRNA *ptr) +static int rna_Mesh_polygon_float_layers_length(PointerRNA *ptr) { return CustomData_number_of_layers(rna_mesh_pdata(ptr), CD_PROP_FLT); } @@ -790,14 +790,14 @@ static int rna_MeshIntPropertyLayer_data_length(PointerRNA *ptr) return me->totface; } -static void rna_Mesh_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Mesh_polygon_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { CustomData *pdata = rna_mesh_pdata(ptr); rna_iterator_array_begin(iter, (void*)pdata->layers, sizeof(CustomDataLayer), pdata->totlayer, 0, rna_int_layer_check); } -static int rna_Mesh_int_layers_length(PointerRNA *ptr) +static int rna_Mesh_polygon_int_layers_length(PointerRNA *ptr) { return CustomData_number_of_layers(rna_mesh_pdata(ptr), CD_PROP_INT); } @@ -821,14 +821,14 @@ static int rna_MeshStringPropertyLayer_data_length(PointerRNA *ptr) return me->totface; } -static void rna_Mesh_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Mesh_polygon_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { CustomData *pdata = rna_mesh_pdata(ptr); rna_iterator_array_begin(iter, (void*)pdata->layers, sizeof(CustomDataLayer), pdata->totlayer, 0, rna_string_layer_check); } -static int rna_Mesh_string_layers_length(PointerRNA *ptr) +static int rna_Mesh_polygon_string_layers_length(PointerRNA *ptr) { return CustomData_number_of_layers(rna_mesh_pdata(ptr), CD_PROP_STR); } @@ -1213,7 +1213,7 @@ static PointerRNA rna_Mesh_tessface_vertex_color_new(struct Mesh *me, struct bCo return ptr; } -static PointerRNA rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name) +static PointerRNA rna_Mesh_polygon_int_property_new(struct Mesh *me, struct bContext *C, const char *name) { PointerRNA ptr; CustomDataLayer *cdl = NULL; @@ -1228,7 +1228,7 @@ static PointerRNA rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, return ptr; } -static PointerRNA rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name) +static PointerRNA rna_Mesh_polygon_float_property_new(struct Mesh *me, struct bContext *C, const char *name) { PointerRNA ptr; CustomDataLayer *cdl = NULL; @@ -1243,7 +1243,7 @@ static PointerRNA rna_Mesh_float_property_new(struct Mesh *me, struct bContext * return ptr; } -static PointerRNA rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name) +static PointerRNA rna_Mesh_polygon_string_property_new(struct Mesh *me, struct bContext *C, const char *name) { PointerRNA ptr; CustomDataLayer *cdl = NULL; @@ -2324,7 +2324,7 @@ static void rna_def_uv_loop_layers(BlenderRNA *brna, PropertyRNA *cprop) } /* mesh int layers */ -static void rna_def_int_layers(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_polygon_int_layers(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -2336,7 +2336,7 @@ static void rna_def_int_layers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "Mesh"); RNA_def_struct_ui_text(srna, "Int Properties", "Collection of int properties"); - func = RNA_def_function(srna, "new", "rna_Mesh_int_property_new"); + func = RNA_def_function(srna, "new", "rna_Mesh_polygon_int_property_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a integer property layer to Mesh"); RNA_def_string(func, "name", "Int Prop", 0, "", "Int property name"); @@ -2346,7 +2346,7 @@ static void rna_def_int_layers(BlenderRNA *brna, PropertyRNA *cprop) } /* mesh float layers */ -static void rna_def_float_layers(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_polygon_float_layers(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -2358,7 +2358,7 @@ static void rna_def_float_layers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "Mesh"); RNA_def_struct_ui_text(srna, "Float Properties", "Collection of float properties"); - func = RNA_def_function(srna, "new", "rna_Mesh_float_property_new"); + func = RNA_def_function(srna, "new", "rna_Mesh_polygon_float_property_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a float property layer to Mesh"); RNA_def_string(func, "name", "Float Prop", 0, "", "Float property name"); @@ -2368,7 +2368,7 @@ static void rna_def_float_layers(BlenderRNA *brna, PropertyRNA *cprop) } /* mesh string layers */ -static void rna_def_string_layers(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_polygon_string_layers(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -2380,7 +2380,7 @@ static void rna_def_string_layers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "Mesh"); RNA_def_struct_ui_text(srna, "String Properties", "Collection of string properties"); - func = RNA_def_function(srna, "new", "rna_Mesh_string_property_new"); + func = RNA_def_function(srna, "new", "rna_Mesh_polygon_string_property_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a string property layer to Mesh"); RNA_def_string(func, "name", "String Prop", 0, "", "String property name"); @@ -2619,29 +2619,29 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vertex Colors", "All vertex colors"); rna_def_loop_colors(brna, prop); - prop = RNA_def_property(srna, "layers_float", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(srna, "polygon_layers_float", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", NULL, NULL, NULL, - "rna_Mesh_float_layers_length", NULL, NULL, NULL); + RNA_def_property_collection_funcs(prop, "rna_Mesh_polygon_float_layers_begin", NULL, NULL, NULL, + "rna_Mesh_polygon_float_layers_length", NULL, NULL, NULL); RNA_def_property_struct_type(prop, "MeshFloatPropertyLayer"); RNA_def_property_ui_text(prop, "Float Property Layers", ""); - rna_def_float_layers(brna, prop); + rna_def_polygon_float_layers(brna, prop); - prop = RNA_def_property(srna, "layers_int", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(srna, "polygon_layers_int", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", NULL, NULL, NULL, - "rna_Mesh_int_layers_length", NULL, NULL, NULL); + RNA_def_property_collection_funcs(prop, "rna_Mesh_polygon_int_layers_begin", NULL, NULL, NULL, + "rna_Mesh_polygon_int_layers_length", NULL, NULL, NULL); RNA_def_property_struct_type(prop, "MeshIntPropertyLayer"); RNA_def_property_ui_text(prop, "Int Property Layers", ""); - rna_def_int_layers(brna, prop); + rna_def_polygon_int_layers(brna, prop); - prop = RNA_def_property(srna, "layers_string", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(srna, "polygon_layers_string", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", NULL, NULL, NULL, - "rna_Mesh_string_layers_length", NULL, NULL, NULL); + RNA_def_property_collection_funcs(prop, "rna_Mesh_polygon_string_layers_begin", NULL, NULL, NULL, + "rna_Mesh_polygon_string_layers_length", NULL, NULL, NULL); RNA_def_property_struct_type(prop, "MeshStringPropertyLayer"); RNA_def_property_ui_text(prop, "String Property Layers", ""); - rna_def_string_layers(brna, prop); + rna_def_polygon_string_layers(brna, prop); prop = RNA_def_property(srna, "use_auto_smooth", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_AUTOSMOOTH); From 03479c04edbf94d7de92f13a9a9653f0f9a14cb0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 11:19:58 +0000 Subject: [PATCH 45/58] fix [#30608] Regression: BMesh merge broke customdata int/float/string layers --- source/blender/makesrna/intern/rna_mesh.c | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index d786c673256..8e1457499ca 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -744,13 +744,13 @@ static void rna_MeshFloatPropertyLayer_data_begin(CollectionPropertyIterator *it { Mesh *me = rna_mesh(ptr); CustomDataLayer *layer = (CustomDataLayer*)ptr->data; - rna_iterator_array_begin(iter, layer->data, sizeof(MFloatProperty), me->totface, 0, NULL); + rna_iterator_array_begin(iter, layer->data, sizeof(MFloatProperty), me->totpoly, 0, NULL); } static int rna_MeshFloatPropertyLayer_data_length(PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); - return me->totface; + return me->totpoly; } static int rna_float_layer_check(CollectionPropertyIterator *iter, void *data) @@ -781,13 +781,13 @@ static void rna_MeshIntPropertyLayer_data_begin(CollectionPropertyIterator *iter { Mesh *me = rna_mesh(ptr); CustomDataLayer *layer = (CustomDataLayer*)ptr->data; - rna_iterator_array_begin(iter, layer->data, sizeof(MIntProperty), me->totface, 0, NULL); + rna_iterator_array_begin(iter, layer->data, sizeof(MIntProperty), me->totpoly, 0, NULL); } static int rna_MeshIntPropertyLayer_data_length(PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); - return me->totface; + return me->totpoly; } static void rna_Mesh_polygon_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -812,13 +812,13 @@ static void rna_MeshStringPropertyLayer_data_begin(CollectionPropertyIterator *i { Mesh *me = rna_mesh(ptr); CustomDataLayer *layer = (CustomDataLayer*)ptr->data; - rna_iterator_array_begin(iter, layer->data, sizeof(MStringProperty), me->totface, 0, NULL); + rna_iterator_array_begin(iter, layer->data, sizeof(MStringProperty), me->totpoly, 0, NULL); } static int rna_MeshStringPropertyLayer_data_length(PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); - return me->totface; + return me->totpoly; } static void rna_Mesh_polygon_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -1219,10 +1219,10 @@ static PointerRNA rna_Mesh_polygon_int_property_new(struct Mesh *me, struct bCon CustomDataLayer *cdl = NULL; int index; - CustomData_add_layer_named(&me->fdata, CD_PROP_INT, CD_DEFAULT, NULL, me->totface, name); - index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_INT, name); + CustomData_add_layer_named(&me->pdata, CD_PROP_INT, CD_DEFAULT, NULL, me->totpoly, name); + index = CustomData_get_named_layer_index(&me->pdata, CD_PROP_INT, name); - cdl = (index == -1) ? NULL : &(me->fdata.layers[index]); + cdl = (index == -1) ? NULL : &(me->pdata.layers[index]); RNA_pointer_create(&me->id, &RNA_MeshIntPropertyLayer, cdl, &ptr); return ptr; @@ -1234,10 +1234,10 @@ static PointerRNA rna_Mesh_polygon_float_property_new(struct Mesh *me, struct bC CustomDataLayer *cdl = NULL; int index; - CustomData_add_layer_named(&me->fdata, CD_PROP_FLT, CD_DEFAULT, NULL, me->totface, name); - index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_FLT, name); + CustomData_add_layer_named(&me->pdata, CD_PROP_FLT, CD_DEFAULT, NULL, me->totpoly, name); + index = CustomData_get_named_layer_index(&me->pdata, CD_PROP_FLT, name); - cdl = (index == -1) ? NULL : &(me->fdata.layers[index]); + cdl = (index == -1) ? NULL : &(me->pdata.layers[index]); RNA_pointer_create(&me->id, &RNA_MeshFloatPropertyLayer, cdl, &ptr); return ptr; @@ -1249,10 +1249,10 @@ static PointerRNA rna_Mesh_polygon_string_property_new(struct Mesh *me, struct b CustomDataLayer *cdl = NULL; int index; - CustomData_add_layer_named(&me->fdata, CD_PROP_STR, CD_DEFAULT, NULL, me->totface, name); - index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_STR, name); + CustomData_add_layer_named(&me->pdata, CD_PROP_STR, CD_DEFAULT, NULL, me->totpoly, name); + index = CustomData_get_named_layer_index(&me->pdata, CD_PROP_STR, name); - cdl = (index == -1) ? NULL : &(me->fdata.layers[index]); + cdl = (index == -1) ? NULL : &(me->pdata.layers[index]); RNA_pointer_create(&me->id, &RNA_MeshStringPropertyLayer, cdl, &ptr); return ptr; From 0d69b18a0503c3b4ab2c7c36bf0a953ce498a58a Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 3 Apr 2012 11:53:38 +0000 Subject: [PATCH 46/58] Make sure Multilayer EXR from other apps are read in as multilayer. --- .../blender/imbuf/intern/openexr/openexr_api.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 142ed335913..caca00cbe20 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -945,12 +946,17 @@ static int exr_has_zbuffer(InputFile *file) return !(file->header().channels().findChannel("Z") == NULL); } -static int exr_is_renderresult(InputFile *file) +static int exr_is_multilayer(InputFile *file) { const StringAttribute *comments= file->header().findTypedAttribute("BlenderMultiChannel"); - if (comments) -// if (comments->value() == "Blender MultiChannel") + const ChannelList &channels = file->header().channels(); + std::set layerNames; + + channels.layers(layerNames); + + if (comments || layerNames.size()>1) return 1; + return 0; } @@ -977,7 +983,7 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags) if (0) // debug exr_print_filecontents(file); - is_multi= exr_is_renderresult(file); + is_multi= exr_is_multilayer(file); /* do not make an ibuf when */ if (is_multi && !(flags & IB_test) && !(flags & IB_multilayer)) From 012fe4646c07e50fcfec23c838249106f01da66d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 12:02:32 +0000 Subject: [PATCH 47/58] avoid confusion with image 'Edit Externally' operator, disallow editing of packed images, resolves bug [#30506]. --- release/scripts/startup/bl_operators/image.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 754e993dacb..1b7d5e3a40d 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -96,6 +96,10 @@ class EditExternally(Operator): self.report({'ERROR'}, "Context incorrect, image not found") return {'CANCELLED'} + if image.packed_file: + self.report({'ERROR'}, "Image is packed, unpack before editing") + return {'CANCELLED'} + filepath = bpy.path.abspath(image.filepath, library=image.library) self.filepath = os.path.normpath(filepath) From 9776176cc91e30810bbfd02f78a7c3a3b677d1fb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 12:20:44 +0000 Subject: [PATCH 48/58] fix [#30340] bpy.ops.pose.select_hierarchy() doesn't work on disconnected parents/children --- source/blender/editors/armature/poseobject.c | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 6768c884868..9d84b236aad 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -407,8 +407,30 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) } } else { /* direction == BONE_SELECT_CHILD */ + + /* the child member is only assigned to connected bones, see [#30340] */ +#if 0 if (pchan->child == NULL) continue; else chbone = pchan->child->bone; +#else + /* instead. find _any_ visible child bone, using the first one is a little arbitrary - campbell */ + chbone = pchan->child ? pchan->child->bone : NULL; + if (chbone == NULL) { + bPoseChannel *pchan_child; + + for (pchan_child = ob->pose->chanbase.first; pchan_child; pchan_child = pchan_child->next) { + /* possible we have multiple children, some invisible */ + if (PBONE_VISIBLE(arm, pchan_child->bone)) { + if (pchan_child->parent == pchan) { + chbone = pchan_child->bone; + break; + } + } + } + } + + if (chbone == NULL) continue; +#endif if (PBONE_VISIBLE(arm, chbone)) { if (!add_to_sel) curbone->flag &= ~BONE_SELECTED; From 81cc7833d4fe7d2ccf98f8141e2ad1b10f7cd281 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 3 Apr 2012 13:35:00 +0000 Subject: [PATCH 49/58] Fix #28279: Shift S used twice in maya keyconfig It looks to be non-maintained keymap anymore, this commit only resolves keymap conflict changing snap menu to ctrl-shift-s, no more global changes to not break muscule memory so close to release. --- release/scripts/presets/keyconfig/maya.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index d9228514a72..4a869c3c1c8 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -164,7 +164,7 @@ kmi = km.keymap_items.new('view3d.zoom_border', 'B', 'PRESS', shift=True) kmi = km.keymap_items.new('view3d.render_border', 'B', 'PRESS', shift=True) kmi = km.keymap_items.new('view3d.camera_to_view', 'NUMPAD_0', 'PRESS', ctrl=True, alt=True) kmi = km.keymap_items.new('view3d.object_as_camera', 'NUMPAD_0', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True) +kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True, ctrl=True) kmi.properties.name = 'VIEW3D_MT_snap' kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS') kmi.properties.data_path = 'space_data.pivot_point' From f137ba074abb599ea2b4226f47a4234cb6995f1e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Apr 2012 14:08:04 +0000 Subject: [PATCH 50/58] Fix #30789: cycles still taking into account textured solid option when it should have no effect. --- .../blender/editors/space_view3d/drawobject.c | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 6d76da3b0e0..31f7cf322bc 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -109,12 +109,6 @@ #include "view3d_intern.h" // own include - -/* this condition has been made more complex since editmode can draw textures */ -#define CHECK_OB_DRAWTEXTURE(vd, dt) \ - ((ELEM(vd->drawtype, OB_TEXTURE, OB_MATERIAL) && dt > OB_SOLID) || \ - (vd->drawtype == OB_SOLID && vd->flag2 & V3D_SOLID_TEX)) - typedef enum eWireDrawMode { OBDRAW_WIRE_OFF = 0, OBDRAW_WIRE_ON = 1, @@ -183,6 +177,20 @@ static void drawcircle_size(float size); static void draw_empty_sphere(float size); static void draw_empty_cone(float size); +/* this condition has been made more complex since editmode can draw textures */ +static int check_object_draw_texture(Scene *scene, View3D *v3d, int drawtype) +{ + /* texture and material draw modes */ + if(ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) && drawtype > OB_SOLID) + return TRUE; + + /* textured solid */ + if(v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !scene_use_new_shading_nodes(scene)) + return TRUE; + + return FALSE; +} + static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) { if ((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0) @@ -315,7 +323,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if (G.f & G_PICKSEL) return 0; - if (!CHECK_OB_DRAWTEXTURE(v3d, dt)) + if (!check_object_draw_texture(scene, v3d, dt)) return 0; if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; @@ -3032,7 +3040,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, EDBM_index_arrays_init(em, 1, 1, 1); if (dt > OB_WIRE) { - if (CHECK_OB_DRAWTEXTURE(v3d, dt)) { + if (check_object_draw_texture(scene, v3d, dt)) { if (draw_glsl_material(scene, ob, v3d, dt)) { glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); @@ -3085,7 +3093,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, glDepthMask(0); // disable write in zbuffer, needed for nice transp /* don't draw unselected faces, only selected, this is MUCH nicer when texturing */ - if (CHECK_OB_DRAWTEXTURE(v3d, dt)) + if (check_object_draw_texture(scene, v3d, dt)) col1[3] = 0; draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); @@ -3112,7 +3120,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, } /* here starts all fancy draw-extra over */ - if ((me->drawflag & ME_DRAWEDGES) == 0 && CHECK_OB_DRAWTEXTURE(v3d, dt)) { + if ((me->drawflag & ME_DRAWEDGES) == 0 && check_object_draw_texture(scene, v3d, dt)) { /* we are drawing textures and 'ME_DRAWEDGES' is disabled, don't draw any edges */ /* only draw selected edges otherwise there is no way of telling if a face is selected */ @@ -3258,7 +3266,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D draw_wire = OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */ } else if ( (draw_flags & DRAW_FACE_SELECT || (is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) || - CHECK_OB_DRAWTEXTURE(v3d, dt)) + check_object_draw_texture(scene, v3d, dt)) { if ( (v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && From 123f7d3eb3e7ba14c05e4097a57119bf75e08019 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 3 Apr 2012 15:18:59 +0000 Subject: [PATCH 51/58] Popup menu layout inherits context store from button. When adding extra context data in a layout using uiLayoutSetContextPointer, this info was not inherited by popup menus generated in this layout. While operators from regular buttons work fine, the data is missing in operators from menus and such. This patch copies the bContextStore from buttons to the new uiLayout used for popups. --- source/blender/blenkernel/BKE_context.h | 1 + source/blender/blenkernel/intern/context.c | 29 +++++++++++++++++++ source/blender/editors/include/UI_interface.h | 2 ++ .../editors/interface/interface_layout.c | 6 ++++ .../editors/interface/interface_regions.c | 6 ++-- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 5966f8e0ff0..944cce675cc 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -117,6 +117,7 @@ bContext *CTX_copy(const bContext *C); /* Stored Context */ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *ptr); +bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context); void CTX_store_set(bContext *C, bContextStore *store); bContextStore *CTX_store_copy(bContextStore *store); void CTX_store_free(bContextStore *store); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index a725b5f4c52..e9dd4d01b0e 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -141,6 +141,35 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p return ctx; } +bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context) +{ + bContextStoreEntry *entry, *tentry; + bContextStore *ctx, *lastctx; + + /* ensure we have a context to put the entries in, if it was already used + * we have to copy the context to ensure */ + ctx= contexts->last; + + if (!ctx || ctx->used) { + if (ctx) { + lastctx= ctx; + ctx= MEM_dupallocN(lastctx); + BLI_duplicatelist(&ctx->entries, &lastctx->entries); + } + else + ctx= MEM_callocN(sizeof(bContextStore), "bContextStore"); + + BLI_addtail(contexts, ctx); + } + + for (tentry= context->entries.first; tentry; tentry= tentry->next) { + entry= MEM_dupallocN(tentry); + BLI_addtail(&ctx->entries, entry); + } + + return ctx; +} + void CTX_store_set(bContext *C, bContextStore *store) { C->wm.store= store; diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 18e2af939fd..cdb2472706c 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -48,6 +48,7 @@ struct wmWindowManager; struct wmOperator; struct AutoComplete; struct bContext; +struct bContextStore; struct Panel; struct PanelType; struct PointerRNA; @@ -692,6 +693,7 @@ uiBlock *uiLayoutGetBlock(uiLayout *layout); void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv); void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr); +void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context); const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag); struct MenuType *uiButGetMenuType(uiBut *but); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 91e38e7d914..58b54fef0df 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2722,6 +2722,12 @@ void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *p layout->context = CTX_store_add(&block->contexts, name, ptr); } +void uiLayoutContextCopy(uiLayout *layout, bContextStore *context) +{ + uiBlock *block= layout->root->block; + layout->context= CTX_store_add_all(&block->contexts, context); +} + /* introspect funcs */ #include "BLI_dynstr.h" diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 1c37fcdd488..b5d56f278e5 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2404,16 +2404,18 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut /* some enums reversing is strange, currently we have no good way to * reverse some enum's but not others, so reverse all so the first menu * items are always close to the mouse cursor */ -#if 0 else { +#if 0 /* if this is an rna button then we can assume its an enum * flipping enums is generally not good since the order can be * important [#28786] */ if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { pup->block->flag |= UI_BLOCK_NO_FLIP; } - } #endif + if (but->context) + uiLayoutContextCopy(pup->layout, but->context); + } if (str) { /* menu is created from a string */ From b44ae0c387857a587f92c6b0439ebae804495afb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Apr 2012 17:09:47 +0000 Subject: [PATCH 52/58] Fix #30791: BMEdge.is_manifold also returned true for edges with only one face attached to it. A manifold edge should have exactly 2 faces attached to it, sticking to the standard definition for "manifold". --- source/blender/bmesh/intern/bmesh_queries.c | 8 ++++---- source/blender/bmesh/intern/bmesh_walkers_impl.c | 4 ++-- source/blender/bmesh/tools/BME_bevel.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 24c60e22a90..435818a5921 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -537,21 +537,21 @@ int BM_vert_is_manifold(BMVert *v) /** * Tests whether or not this edge is manifold. - * A manifold edge either has 1 or 2 faces attached to it. + * A manifold edge has exactly 2 faces attached to it. */ #if 1 /* fast path for checking manifold */ int BM_edge_is_manifold(BMEdge *e) { const BMLoop *l = e->l; - return (l && ((l->radial_next == l) || /* 1 face user */ - (l->radial_next->radial_next == l))); /* 2 face users */ + return (l && (l->radial_next != l) && /* not 0 or 1 face users */ + (l->radial_next->radial_next == l)); /* 2 face users */ } #else int BM_edge_is_manifold(BMEdge *e) { int count = BM_edge_face_count(e); - if (count == 2 || count == 1) { + if (count == 2) { return TRUE; } else { diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 818a7fb3cfa..5391c7c56d2 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -667,7 +667,7 @@ static int bmw_FaceLoopWalker_edge_begins_loop(BMWalker *walker, BMEdge *e) /* Don't start a loop from a boundary edge if it cannot * be extended to cover any faces */ - if (BM_edge_face_count(e) == 1) { + if (BM_edge_is_boundary(e)) { if (!bmw_FaceLoopWalker_include_face(walker, e->l)) { return FALSE; } @@ -843,7 +843,7 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker) int i, len; #endif -#define EDGE_CHECK(e) (bmw_mask_check_edge(walker, e) && BM_edge_is_manifold(e)) +#define EDGE_CHECK(e) (bmw_mask_check_edge(walker, e) && (BM_edge_is_boundary(e) || BM_edge_is_manifold(e))) BMW_state_remove(walker); diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index 3b8337f46ae..9160848aa60 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -905,7 +905,7 @@ static BMesh *BME_bevel_initialize(BMesh *bm, int options, int UNUSED(defgrp_ind BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { BMO_elem_flag_enable(bm, e, BME_BEVEL_ORIG); - if (!BM_edge_is_manifold(e)) { + if (!(BM_edge_is_boundary(e) || BM_edge_is_manifold(e))) { BMO_elem_flag_enable(bm, e->v1, BME_BEVEL_NONMAN); BMO_elem_flag_enable(bm, e->v2, BME_BEVEL_NONMAN); BMO_elem_flag_enable(bm, e, BME_BEVEL_NONMAN); From b7c6327d1fb94a867c067d576b75d951636d77c5 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 3 Apr 2012 17:19:58 +0000 Subject: [PATCH 53/58] Fix [#30665] UV-Editor: UV -> Copy Mirrored UV coords: mesh.faces_mirror_uv op now uses poly/loops (bmesh todo). --- release/scripts/startup/bl_operators/mesh.py | 79 +++++++++++--------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index cc5442d41aa..2d4c703dbf2 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -55,7 +55,7 @@ class MeshMirrorUV(Operator): mirror_gt = {} mirror_lt = {} - vcos = [v.co.to_tuple(5) for v in mesh.vertices] + vcos = (v.co.to_tuple(5) for v in mesh.vertices) for i, co in enumerate(vcos): if co[0] > 0.0: @@ -76,51 +76,60 @@ class MeshMirrorUV(Operator): if j is not None: vmap[i] = j - active_uv_layer = mesh.uv_textures.active.data - fuvs = [(uv.uv1, uv.uv2, uv.uv3, uv.uv4) for uv in active_uv_layer] - fuvs_cpy = [(uv[0].copy(), uv[1].copy(), uv[2].copy(), uv[3].copy()) - for uv in fuvs] + polys = mesh.polygons + loops = mesh.loops + verts = mesh.vertices + uv_loops = mesh.uv_loop_layers.active.data + nbr_polys = len(polys) - # as a list - # BMESH_TODO - use polygons - faces = mesh.faces[:] + mirror_pm = {} + pmap = {} + puvs = [None] * nbr_polys + puvs_cpy = [None] * nbr_polys + puvsel = [None] * nbr_polys + pcents = [None] * nbr_polys + vidxs = [None] * nbr_polys + for i, p in enumerate(polys): + lstart = lend = p.loop_start + lend += p.loop_total + puvs[i] = tuple(uv.uv for uv in uv_loops[lstart:lend]) + puvs_cpy[i] = tuple(uv.copy() for uv in puvs[i]) + puvsel[i] = (False not in + (uv.select for uv in uv_loops[lstart:lend])) + # Vert idx of the poly. + vidxs[i] = tuple(sorted(l.vertex_index + for l in loops[lstart:lend])) + # As we have no poly.center yet... + pcents[i] = tuple(map(lambda x : x / p.loop_total, + map(sum, zip(*(verts[idx].co + for idx in vidxs[i]))))) + # Preparing next step finding matching polys. + mirror_pm[vidxs[i]] = i - fuvsel = [(False not in uv.select_uv) for uv in active_uv_layer] - fcents = [f.center for f in faces] - - # find mirror faces - mirror_fm = {} - for i, f in enumerate(faces): - verts = list(f.vertices) - verts.sort() - verts = tuple(verts) - mirror_fm[verts] = i - - fmap = {} - for i, f in enumerate(faces): - verts = [vmap.get(j) for j in f.vertices] - if None not in verts: - verts.sort() - j = mirror_fm.get(tuple(verts)) + for i in range(nbr_polys): + # Find matching mirror poly. + tvidxs = [vmap.get(j) for j in vidxs[i]] + if None not in tvidxs: + tvidxs.sort() + j = mirror_pm.get(tuple(tvidxs)) if j is not None: - fmap[i] = j + pmap[i] = j - for i, j in fmap.items(): - - if not fuvsel[i] or not fuvsel[j]: + for i, j in pmap.items(): + if not puvsel[i] or not puvsel[j]: continue - elif DIR == 0 and fcents[i][0] < 0.0: + elif DIR == 0 and pcents[i][0] < 0.0: continue - elif DIR == 1 and fcents[i][0] > 0.0: + elif DIR == 1 and pcents[i][0] > 0.0: continue # copy UVs - uv1 = fuvs[i] - uv2 = fuvs_cpy[j] + uv1 = puvs[i] + uv2 = puvs_cpy[j] # get the correct rotation - v1 = faces[j].vertices[:] - v2 = [vmap[k] for k in faces[i].vertices[:]] + v1 = vidxs[j] + v2 = tuple(vmap[k] for k in vidxs[i]) if len(v1) == len(v2): for k in range(len(v1)): From 51afa3b7c67e33f089da192d05be5ec1dd9969b6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Apr 2012 17:26:57 +0000 Subject: [PATCH 54/58] Fix #30795: draw other objects in uv editor not working. --- source/blender/editors/uvedit/uvedit_draw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 4690f11d9af..0a444bea084 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -383,14 +383,14 @@ static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage) if ((ob->type==OB_MESH) && (ob!=obedit)) { Mesh *me= ob->data; - if (me->mtface) { + if (me->mtpoly) { MPoly *mface= me->mpoly; - MTexPoly *tface= me->mtpoly; + MTexPoly *mtpoly= me->mtpoly; MLoopUV *mloopuv; int a, b; - for (a=me->totpoly; a>0; a--, tface++, mface++) { - if (tface->tpage == curimage) { + for (a=me->totpoly; a>0; a--, mtpoly++, mface++) { + if (mtpoly->tpage == curimage) { glBegin(GL_LINE_LOOP); mloopuv = me->mloopuv + mface->loopstart; From c86b17ddb7c64e396670e9ef3a8233ec287daf22 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 3 Apr 2012 18:41:40 +0000 Subject: [PATCH 55/58] Fix bug #30778, sculpt w/ modifiers + undo causes collapse of vertices Was caused by earlier refactoring of undo, used index array before it gets initialized. Fixed by swapping order of copying. Also changed normals calculation on undo restore to operate on tessellated data (which sculpt still uses), fixes console warning print. --- .../editors/sculpt_paint/sculpt_undo.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 5378ce7872a..89a786d02a9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -274,7 +274,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) if (ss->modifiers_active) { Mesh *mesh = ob->data; - mesh_calc_normals_mapping(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL); + mesh_calc_normals_tessface(mesh->mvert, mesh->totvert, + mesh->mface, mesh->totface, NULL); free_sculptsession_deformMats(ss); tag_update |= 1; @@ -471,14 +472,6 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, BLI_unlock_thread(LOCK_CUSTOM1); /* copy threaded, hopefully this is the performance critical part */ - switch (type) { - case SCULPT_UNDO_COORDS: - sculpt_undo_store_coords(ob, unode); - break; - case SCULPT_UNDO_HIDDEN: - sculpt_undo_store_hidden(ob, unode); - break; - } if (unode->grids) { int totgrid, *grids; @@ -493,6 +486,15 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, memcpy(unode->index, vert_indices, sizeof(int) * unode->totvert); } + switch (type) { + case SCULPT_UNDO_COORDS: + sculpt_undo_store_coords(ob, unode); + break; + case SCULPT_UNDO_HIDDEN: + sculpt_undo_store_hidden(ob, unode); + break; + } + /* store active shape key */ if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); else unode->shapeName[0] = '\0'; From ff14479983f0606678a9242f869f6b0fc5a78f99 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Apr 2012 19:08:06 +0000 Subject: [PATCH 56/58] Fix #30796: uv vertex coordinates panel in uv editor incorrectly taking into account selected uvs from hidden faces. --- source/blender/editors/uvedit/uvedit_buttons.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index ff673fa0eab..1b5cef6f07d 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -62,16 +62,21 @@ /* UV Utilities */ -static int uvedit_center(Scene *scene, BMEditMesh *em, Image *UNUSED(ima), float center[2]) +static int uvedit_center(Scene *scene, BMEditMesh *em, Image *ima, float center[2]) { BMFace *f; BMLoop *l; BMIter iter, liter; + MTexPoly *tf; MLoopUV *luv; int tot = 0.0; zero_v2(center); BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) { + tf = CustomData_bmesh_get(&em->bm->pdata, f->head.data, CD_MTEXPOLY); + if (!uvedit_face_visible(scene, ima, f, tf)) + continue; + BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); if (uvedit_uv_selected(em, scene, l)) { From 320aa33e653b5ea74719cf0a1525bffad307be53 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2012 23:40:24 +0000 Subject: [PATCH 57/58] rename MPoly vars called mface or mf, to avoid confusion with MFace types. --- .../blender/blenkernel/intern/cdderivedmesh.c | 24 ++- source/blender/blenkernel/intern/particle.c | 8 +- .../blender/blenkernel/intern/subsurf_ccg.c | 12 +- source/blender/editors/mesh/editface.c | 176 +++++++++--------- .../editors/sculpt_paint/paint_vertex.c | 22 +-- .../blender/editors/space_view3d/drawmesh.c | 4 +- source/blender/editors/uvedit/uvedit_draw.c | 18 +- 7 files changed, 135 insertions(+), 129 deletions(-) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 2b38c5fff4b..03f2851531c 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1467,13 +1467,13 @@ static void cdDM_foreachMappedFaceCenter( { CDDerivedMesh *cddm = (CDDerivedMesh*)dm; MVert *mv = cddm->mvert; - MPoly *mf = cddm->mpoly; + MPoly *mp = cddm->mpoly; MLoop *ml = cddm->mloop; int i, j, orig, *index; index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX); - mf = cddm->mpoly; - for (i = 0; i < dm->numPolyData; i++, mf++) { + mp = cddm->mpoly; + for (i = 0; i < dm->numPolyData; i++, mp++) { float cent[3]; float no[3]; @@ -1484,20 +1484,26 @@ static void cdDM_foreachMappedFaceCenter( else orig = i; - ml = &cddm->mloop[mf->loopstart]; + ml = &cddm->mloop[mp->loopstart]; cent[0] = cent[1] = cent[2] = 0.0f; - for (j=0; jtotloop; j++, ml++) { + for (j=0; jtotloop; j++, ml++) { add_v3_v3v3(cent, cent, mv[ml->v].co); } mul_v3_fl(cent, 1.0f / (float)j); - ml = &cddm->mloop[mf->loopstart]; + ml = &cddm->mloop[mp->loopstart]; if (j > 3) { - normal_quad_v3(no, mv[ml->v].co, mv[(ml+1)->v].co, - mv[(ml+2)->v].co, mv[(ml+3)->v].co); + normal_quad_v3(no, + mv[(ml + 0)->v].co, + mv[(ml + 1)->v].co, + mv[(ml + 2)->v].co, + mv[(ml + 3)->v].co); } else { - normal_tri_v3(no, mv[ml->v].co, mv[(ml+1)->v].co, mv[(ml+2)->v].co); + normal_tri_v3(no, + mv[(ml + 0)->v].co, + mv[(ml + 1)->v].co, + mv[(ml + 2)->v].co); } func(userData, orig, cent, no); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index dd1546d694b..a851c440230 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1616,13 +1616,13 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4 int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const float fw[4], struct LinkNode *node) { Mesh *me= (Mesh*)ob->data; - MPoly *mface; + MPoly *mpoly; OrigSpaceFace *osface; int *origindex; int quad, findex, totface; float uv[2], (*faceuv)[2]; - mface = dm->getPolyArray(dm); + mpoly = dm->getPolyArray(dm); origindex = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); osface = dm->getTessFaceDataArray(dm, CD_ORIGSPACE); @@ -1648,7 +1648,7 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f for (;node; node=node->next) { findex= GET_INT_FROM_POINTER(node->link); faceuv= osface[findex].uv; - quad = (mface[findex].totloop == 4); + quad = (mpoly[findex].totloop == 4); /* check that this intersects - Its possible this misses :/ - * could also check its not between */ @@ -1664,7 +1664,7 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f for (findex=0; findexss; @@ -1291,12 +1291,12 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mface) for (S = 0; S < numVerts; S++) { for (y = 0; y < gridSize - 1; y++) { for (x = 0; x < gridSize - 1; x++) { - MPoly *mf = &mface[i]; + MPoly *mp = &mpoly[i]; - mf->mat_nr = mat_nr; - mf->flag = flag; - mf->loopstart = k; - mf->totloop = 4; + mp->mat_nr = mat_nr; + mp->flag = flag; + mp->loopstart = k; + mp->totloop = 4; k += 4; i++; diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index d2446d1ad0e..d4a799764df 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -163,26 +163,26 @@ static int facesel_face_pick(struct bContext *C, Mesh *me, Object *ob, const int void paintface_hide(Object *ob, const int unselected) { Mesh *me; - MPoly *mface; + MPoly *mpoly; int a; me = get_mesh(ob); if (me == NULL || me->totpoly == 0) return; - mface = me->mpoly; + mpoly = me->mpoly; a = me->totpoly; while (a--) { - if ((mface->flag & ME_HIDE) == 0) { + if ((mpoly->flag & ME_HIDE) == 0) { if (unselected) { - if ( (mface->flag & ME_FACE_SEL) == 0) mface->flag |= ME_HIDE; + if ( (mpoly->flag & ME_FACE_SEL) == 0) mpoly->flag |= ME_HIDE; } else { - if ( (mface->flag & ME_FACE_SEL)) mface->flag |= ME_HIDE; + if ( (mpoly->flag & ME_FACE_SEL)) mpoly->flag |= ME_HIDE; } } - if (mface->flag & ME_HIDE) mface->flag &= ~ME_FACE_SEL; + if (mpoly->flag & ME_HIDE) mpoly->flag &= ~ME_FACE_SEL; - mface++; + mpoly++; } paintface_flush_flags(ob); @@ -192,20 +192,20 @@ void paintface_hide(Object *ob, const int unselected) void paintface_reveal(Object *ob) { Mesh *me; - MPoly *mface; + MPoly *mpoly; int a; me = get_mesh(ob); if (me == NULL || me->totpoly == 0) return; - mface = me->mpoly; + mpoly = me->mpoly; a = me->totpoly; while (a--) { - if (mface->flag & ME_HIDE) { - mface->flag |= ME_FACE_SEL; - mface->flag -= ME_HIDE; + if (mpoly->flag & ME_HIDE) { + mpoly->flag |= ME_FACE_SEL; + mpoly->flag -= ME_HIDE; } - mface++; + mpoly++; } paintface_flush_flags(ob); @@ -227,7 +227,7 @@ static void hash_add_face(EdgeHash *ehash, MPoly *mp, MLoop *mloop) static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index) { EdgeHash *ehash, *seamhash; - MPoly *mf; + MPoly *mp; MLoop *ml; MEdge *med; char *linkflag; @@ -243,17 +243,17 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind if (mode == 0 || mode == 1) { /* only put face under cursor in array */ - mf = ((MPoly *)me->mpoly) + index; - hash_add_face(ehash, mf, me->mloop + mf->loopstart); + mp = ((MPoly *)me->mpoly) + index; + hash_add_face(ehash, mp, me->mloop + mp->loopstart); linkflag[index] = 1; } else { /* fill array by selection */ - mf = me->mpoly; - for (a = 0; a < me->totpoly; a++, mf++) { - if (mf->flag & ME_HIDE) ; - else if (mf->flag & ME_FACE_SEL) { - hash_add_face(ehash, mf, me->mloop + mf->loopstart); + mp = me->mpoly; + for (a = 0; a < me->totpoly; a++, mp++) { + if (mp->flag & ME_HIDE) ; + else if (mp->flag & ME_FACE_SEL) { + hash_add_face(ehash, mp, me->mloop + mp->loopstart); linkflag[a] = 1; } } @@ -263,18 +263,18 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind doit = 0; /* expand selection */ - mf = me->mpoly; - for (a = 0; a < me->totpoly; a++, mf++) { - if (mf->flag & ME_HIDE) + mp = me->mpoly; + for (a = 0; a < me->totpoly; a++, mp++) { + if (mp->flag & ME_HIDE) continue; if (!linkflag[a]) { MLoop *mnextl; mark = 0; - ml = me->mloop + mf->loopstart; - for (b = 0; b < mf->totloop; b++, ml++) { - mnextl = b < mf->totloop - 1 ? ml - 1 : me->mloop + mf->loopstart; + ml = me->mloop + mp->loopstart; + for (b = 0; b < mp->totloop; b++, ml++) { + mnextl = b < mp->totloop - 1 ? ml - 1 : me->mloop + mp->loopstart; if (!BLI_edgehash_haskey(seamhash, ml->v, mnextl->v)) if (!BLI_edgehash_haskey(ehash, ml->v, mnextl->v)) mark = 1; @@ -282,7 +282,7 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind if (mark) { linkflag[a] = 1; - hash_add_face(ehash, mf, me->mloop + mf->loopstart); + hash_add_face(ehash, mp, me->mloop + mp->loopstart); doit = 1; } } @@ -294,26 +294,26 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind BLI_edgehash_free(seamhash, NULL); if (mode == 0 || mode == 2) { - for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++) + for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++) if (linkflag[a]) - mf->flag |= ME_FACE_SEL; + mp->flag |= ME_FACE_SEL; else - mf->flag &= ~ME_FACE_SEL; + mp->flag &= ~ME_FACE_SEL; } else if (mode == 1) { - for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++) - if (linkflag[a] && (mf->flag & ME_FACE_SEL)) + for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++) + if (linkflag[a] && (mp->flag & ME_FACE_SEL)) break; if (a < me->totpoly) { - for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++) + for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++) if (linkflag[a]) - mf->flag &= ~ME_FACE_SEL; + mp->flag &= ~ME_FACE_SEL; } else { - for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++) + for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++) if (linkflag[a]) - mf->flag |= ME_FACE_SEL; + mp->flag |= ME_FACE_SEL; } } @@ -344,54 +344,54 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2] void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) { Mesh *me; - MPoly *mface; + MPoly *mpoly; int a; me = get_mesh(ob); if (me == NULL) return; if (action == SEL_INVERT) { - mface = me->mpoly; + mpoly = me->mpoly; a = me->totpoly; while (a--) { - if ((mface->flag & ME_HIDE) == 0) { - mface->flag ^= ME_FACE_SEL; + if ((mpoly->flag & ME_HIDE) == 0) { + mpoly->flag ^= ME_FACE_SEL; } - mface++; + mpoly++; } } else { if (action == SEL_TOGGLE) { action = SEL_SELECT; - mface = me->mpoly; + mpoly = me->mpoly; a = me->totpoly; while (a--) { - if ((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) { + if ((mpoly->flag & ME_HIDE) == 0 && mpoly->flag & ME_FACE_SEL) { action = SEL_DESELECT; break; } - mface++; + mpoly++; } } - mface = me->mpoly; + mpoly = me->mpoly; a = me->totpoly; while (a--) { - if ((mface->flag & ME_HIDE) == 0) { + if ((mpoly->flag & ME_HIDE) == 0) { switch (action) { case SEL_SELECT: - mface->flag |= ME_FACE_SEL; + mpoly->flag |= ME_FACE_SEL; break; case SEL_DESELECT: - mface->flag &= ~ME_FACE_SEL; + mpoly->flag &= ~ME_FACE_SEL; break; case SEL_INVERT: - mface->flag ^= ME_FACE_SEL; + mpoly->flag ^= ME_FACE_SEL; break; } } - mface++; + mpoly++; } } @@ -403,7 +403,7 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) int paintface_minmax(Object *ob, float *min, float *max) { Mesh *me; - MPoly *mf; + MPoly *mp; MTexPoly *tf; MLoop *ml; MVert *mvert; @@ -416,14 +416,14 @@ int paintface_minmax(Object *ob, float *min, float *max) copy_m3_m4(bmat, ob->obmat); mvert = me->mvert; - mf = me->mpoly; + mp = me->mpoly; tf = me->mtpoly; - for (a = me->totpoly; a > 0; a--, mf++, tf++) { - if (mf->flag & ME_HIDE || !(mf->flag & ME_FACE_SEL)) + for (a = me->totpoly; a > 0; a--, mp++, tf++) { + if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL)) continue; - ml = me->mloop + mf->totloop; - for (b = 0; b < mf->totloop; b++, ml++) { + ml = me->mloop + mp->totloop; + for (b = 0; b < mp->totloop; b++, ml++) { copy_v3_v3(vec, (mvert[ml->v].co)); mul_m3_v3(bmat, vec); add_v3_v3v3(vec, vec, ob->obmat[3]); @@ -438,14 +438,14 @@ int paintface_minmax(Object *ob, float *min, float *max) /* *************************************** */ #if 0 -static void seam_edgehash_insert_face(EdgeHash *ehash, MPoly *mf, MLoop *loopstart) +static void seam_edgehash_insert_face(EdgeHash *ehash, MPoly *mp, MLoop *loopstart) { MLoop *ml1, *ml2; int a; - for (a = 0; a < mf->totloop; a++) { + for (a = 0; a < mp->totloop; a++) { ml1 = loopstart + a; - ml2 = loopstart + (a + 1) % mf->totloop; + ml2 = loopstart + (a + 1) % mp->totloop; BLI_edgehash_insert(ehash, ml1->v, ml2->v, NULL); } @@ -454,7 +454,7 @@ static void seam_edgehash_insert_face(EdgeHash *ehash, MPoly *mf, MLoop *loopsta void seam_mark_clear_tface(Scene *scene, short mode) { Mesh *me; - MPoly *mf; + MPoly *mp; MLoop *ml1, *ml2; MEdge *med; int a, b; @@ -471,9 +471,9 @@ void seam_mark_clear_tface(Scene *scene, short mode) if (mode == 2) { EdgeHash *ehash = BLI_edgehash_new(); - for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++) - if (!(mf->flag & ME_HIDE) && (mf->flag & ME_FACE_SEL)) - seam_edgehash_insert_face(ehash, mf, me->mloop + mf->loopstart); + for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++) + if (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL)) + seam_edgehash_insert_face(ehash, mp, me->mloop + mp->loopstart); for (a = 0, med = me->medge; a < me->totedge; a++, med++) if (BLI_edgehash_haskey(ehash, med->v1, med->v2)) @@ -486,11 +486,11 @@ void seam_mark_clear_tface(Scene *scene, short mode) EdgeHash *ehash1 = BLI_edgehash_new(); EdgeHash *ehash2 = BLI_edgehash_new(); - for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++) { - if ((mf->flag & ME_HIDE) || !(mf->flag & ME_FACE_SEL)) - seam_edgehash_insert_face(ehash1, mf, me->mloop + mf->loopstart); + for (a = 0, mp = me->mpoly; a < me->totpoly; a++, mp++) { + if ((mp->flag & ME_HIDE) || !(mp->flag & ME_FACE_SEL)) + seam_edgehash_insert_face(ehash1, mp, me->mloop + mp->loopstart); else - seam_edgehash_insert_face(ehash2, mf, me->mloop + mf->loopstart); + seam_edgehash_insert_face(ehash2, mp, me->mloop + mp->loopstart); } for (a = 0, med = me->medge; a < me->totedge; a++, med++) @@ -512,7 +512,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], int extend) { Mesh *me; - MPoly *mface, *msel; + MPoly *mpoly, *mpoly_sel; unsigned int a, index; /* Get the face under the cursor */ @@ -524,28 +524,28 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in if (index >= me->totpoly || index < 0) return 0; - msel = me->mpoly + index; - if (msel->flag & ME_HIDE) return 0; + mpoly_sel = me->mpoly + index; + if (mpoly_sel->flag & ME_HIDE) return 0; /* clear flags */ - mface = me->mpoly; + mpoly = me->mpoly; a = me->totpoly; if (!extend) { while (a--) { - mface->flag &= ~ME_FACE_SEL; - mface++; + mpoly->flag &= ~ME_FACE_SEL; + mpoly++; } } me->act_face = (int)index; if (extend) { - if (msel->flag & ME_FACE_SEL) - msel->flag &= ~ME_FACE_SEL; + if (mpoly_sel->flag & ME_FACE_SEL) + mpoly_sel->flag &= ~ME_FACE_SEL; else - msel->flag |= ME_FACE_SEL; + mpoly_sel->flag |= ME_FACE_SEL; } - else msel->flag |= ME_FACE_SEL; + else mpoly_sel->flag |= ME_FACE_SEL; /* image window redraw */ @@ -559,7 +559,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) { Object *ob = vc->obact; Mesh *me; - MPoly *mface; + MPoly *mpoly; struct ImBuf *ibuf; unsigned int *rt; char *selar; @@ -577,10 +577,10 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) if (extend == 0 && select) { paintface_deselect_all_visible(vc->obact, SEL_DESELECT, FALSE); - mface = me->mpoly; - for (a = 1; a <= me->totpoly; a++, mface++) { - if ((mface->flag & ME_HIDE) == 0) - mface->flag &= ~ME_FACE_SEL; + mpoly = me->mpoly; + for (a = 1; a <= me->totpoly; a++, mpoly++) { + if ((mpoly->flag & ME_HIDE) == 0) + mpoly->flag &= ~ME_FACE_SEL; } } @@ -600,13 +600,13 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) rt++; } - mface = me->mpoly; - for (a = 1; a <= me->totpoly; a++, mface++) { + mpoly = me->mpoly; + for (a = 1; a <= me->totpoly; a++, mpoly++) { if (selar[a]) { - if (mface->flag & ME_HIDE) ; + if (mpoly->flag & ME_HIDE) ; else { - if (select) mface->flag |= ME_FACE_SEL; - else mface->flag &= ~ME_FACE_SEL; + if (select) mpoly->flag |= ME_FACE_SEL; + else mpoly->flag &= ~ME_FACE_SEL; } } } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index ae0c19d7245..1aeaad1bfab 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -473,7 +473,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol) void wpaint_fill(VPaint *wp, Object *ob, float paintweight) { Mesh *me = ob->data; - MPoly *mf; + MPoly *mp; MDeformWeight *dw, *dw_prev; int vgroup_active, vgroup_mirror = -1; unsigned int index; @@ -492,15 +492,15 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) copy_wpaint_prev(wp, me->dvert, me->totvert); - for (index = 0, mf = me->mpoly; index < me->totpoly; index++, mf++) { - unsigned int fidx = mf->totloop - 1; + for (index = 0, mp = me->mpoly; index < me->totpoly; index++, mp++) { + unsigned int fidx = mp->totloop - 1; - if ((paint_selmode == SCE_SELECT_FACE) && !(mf->flag & ME_FACE_SEL)) { + if ((paint_selmode == SCE_SELECT_FACE) && !(mp->flag & ME_FACE_SEL)) { continue; } do { - unsigned int vidx = me->mloop[mf->loopstart + fidx].v; + unsigned int vidx = me->mloop[mp->loopstart + fidx].v; if (!me->dvert[vidx].flag) { if ((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) { @@ -1032,7 +1032,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) BKE_report(op->reports, RPT_WARNING, "The modifier used does not support deformed locations"); } else { - MPoly *mf = ((MPoly *)me->mpoly) + index - 1; + MPoly *mp = ((MPoly *)me->mpoly) + (index - 1); const int vgroup_active = vc.obact->actdef - 1; ToolSettings *ts = vc.scene->toolsettings; float mval_f[2]; @@ -1043,10 +1043,10 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) mval_f[0] = (float)event->mval[0]; mval_f[1] = (float)event->mval[1]; - fidx = mf->totloop - 1; + fidx = mp->totloop - 1; do { float co[3], sco[3], len; - const int v_idx = me->mloop[mf->loopstart + fidx].v; + const int v_idx = me->mloop[mp->loopstart + fidx].v; dm->getVertCo(dm, v_idx, co); project_float_noclip(vc.ar, co, sco); len = len_squared_v2v2(mval_f, sco); @@ -1112,13 +1112,13 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA if (index && index <= me->totpoly) { const int defbase_tot = BLI_countlist(&vc.obact->defbase); if (defbase_tot) { - MPoly *mf = ((MPoly *)me->mpoly) + index - 1; - unsigned int fidx = mf->totloop - 1; + MPoly *mp = ((MPoly *)me->mpoly) + (index - 1); + unsigned int fidx = mp->totloop - 1; int *groups = MEM_callocN(defbase_tot * sizeof(int), "groups"); int found = FALSE; do { - MDeformVert *dvert = me->dvert + me->mloop[mf->loopstart + fidx].v; + MDeformVert *dvert = me->dvert + me->mloop[mp->loopstart + fidx].v; int i = dvert->totweight; MDeformWeight *dw; for (dw = dvert->dw; i > 0; dw++, i--) { diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 39f1552c8a6..e808a66bc24 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -172,8 +172,8 @@ static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int i { Mesh *me = (Mesh *)userData; - MPoly *mface = &me->mpoly[index]; - if (!(mface->flag & ME_HIDE) && !(mface->flag & ME_FACE_SEL)) + MPoly *mpoly = &me->mpoly[index]; + if (!(mpoly->flag & ME_HIDE) && !(mpoly->flag & ME_FACE_SEL)) return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ else return DM_DRAW_OPTION_SKIP; diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 0a444bea084..2fe007a42e8 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -384,17 +384,17 @@ static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage) Mesh *me= ob->data; if (me->mtpoly) { - MPoly *mface= me->mpoly; - MTexPoly *mtpoly= me->mtpoly; + MPoly *mpoly = me->mpoly; + MTexPoly *mtpoly = me->mtpoly; MLoopUV *mloopuv; int a, b; - for (a=me->totpoly; a>0; a--, mtpoly++, mface++) { + for (a = me->totpoly; a > 0; a--, mtpoly++, mpoly++) { if (mtpoly->tpage == curimage) { glBegin(GL_LINE_LOOP); - mloopuv = me->mloopuv + mface->loopstart; - for (b=0; btotloop; b++, mloopuv++) { + mloopuv = me->mloopuv + mpoly->loopstart; + for (b = 0; b < mpoly->totloop; b++, mloopuv++) { glVertex2fv(mloopuv->uv); } glEnd(); @@ -416,17 +416,17 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob) glColor3ub(112, 112, 112); if (me->mtface) { - MPoly *mface= me->mpoly; + MPoly *mpoly= me->mpoly; MTexPoly *tface= me->mtpoly; MLoopUV *mloopuv; int a, b; - for (a=me->totpoly; a>0; a--, tface++, mface++) { + for (a=me->totpoly; a>0; a--, tface++, mpoly++) { if (tface->tpage == curimage) { glBegin(GL_LINE_LOOP); - mloopuv = me->mloopuv + mface->loopstart; - for (b=0; btotloop; b++, mloopuv++) { + mloopuv = me->mloopuv + mpoly->loopstart; + for (b=0; btotloop; b++, mloopuv++) { glVertex2fv(mloopuv->uv); } glEnd(); From 3bb72e33df8a050c1b4dec3c29e3bfa87268869b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Apr 2012 00:02:48 +0000 Subject: [PATCH 58/58] fix for reconstructing shape keys (found when looking into bug [#30797], but not a fix for this bug). --- source/blender/bmesh/intern/bmesh_mesh_conv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 8af31efda81..69defb15112 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -849,10 +849,8 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess) mvert = me->mvert; while (eve) { keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX); - if (!keyi) { - break; - } - if (*keyi >= 0 && *keyi < currkey->totelem) { // valid old vertex + + if (keyi && *keyi != ORIGINDEX_NONE && *keyi < currkey->totelem) { /* valid old vertex */ if (currkey == actkey) { if (actkey == me->key->refkey) { copy_v3_v3(fp, mvert->co);