diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-20 03:52:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-20 03:52:24 +0400 |
commit | 5716762c02b753e3d3320176d41e7c4f13359233 (patch) | |
tree | f4f1462478aebacfb73868a68472809ba9664019 /source/blender | |
parent | 347b2571314bc1a8319cfa3daa5637aebae0fd7d (diff) |
fix for changes in own recent commit:
selected linked in face mode was crashing. (needs bmesh operator flags)
also some style edits, remove unused includes and change triangulate modifiers use_beauty to a flag.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh.c | 12 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 3 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_triangulate.c | 39 |
7 files changed, 39 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 3181a0da1b0..9b1720787ed 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -2560,7 +2560,7 @@ void CDDM_calc_edges(DerivedMesh *dm) BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2); j = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - if(j == 0) { + if (j == 0) { med->flag = ME_EDGEDRAW | ME_EDGERENDER; *index = ORIGINDEX_NONE; } diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 062c47dc686..ba5e7569c31 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -92,6 +92,14 @@ void BM_mesh_elem_toolflags_ensure(BMesh *bm) } } +void BM_mesh_elem_toolflags_clear(BMesh *bm) +{ + if (bm->toolflagpool) { + BLI_mempool_destroy(bm->toolflagpool); + bm->toolflagpool = NULL; + } +} + /** * \brief BMesh Make Mesh * @@ -171,9 +179,7 @@ void BM_mesh_data_free(BMesh *bm) BLI_mempool_destroy(bm->fpool); /* destroy flag pool */ - if (bm->toolflagpool) { - BLI_mempool_destroy(bm->toolflagpool); - } + BM_mesh_elem_toolflags_clear(bm); #ifdef USE_BMESH_HOLES BLI_mempool_destroy(bm->looplistpool); diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h index 0dcd3fc2f01..b592f863cd1 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.h +++ b/source/blender/bmesh/intern/bmesh_mesh.h @@ -30,6 +30,7 @@ struct BMAllocTemplate; void BM_mesh_elem_toolflags_ensure(BMesh *bm); +void BM_mesh_elem_toolflags_clear(BMesh *bm); BMesh *BM_mesh_create(struct BMAllocTemplate *allocsize); void BM_mesh_free(BMesh *bm); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 446f641532d..a98983159b3 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -2330,6 +2330,8 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) } if (limit) { + /* grr, shouldn't need to alloca BMO flags here */ + BM_mesh_elem_toolflags_ensure(bm); BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */ BMO_elem_flag_set(bm, e, BM_ELEM_SELECT, !BM_elem_flag_test(e, BM_ELEM_SEAM)); @@ -2350,6 +2352,10 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) } } BMW_end(&walker); + + if (limit) { + BM_mesh_elem_toolflags_clear(bm); + } } else { BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 49b0534711e..7078ee0d51c 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1119,10 +1119,14 @@ enum { typedef struct TriangulateModifierData { ModifierData modifier; - int beauty; + int flag; int pad; } TriangulateModifierData; +enum { + MOD_TRIANGULATE_BEAUTY = (1 << 0), +}; + /* Smooth modifier flags */ #define MOD_LAPLACIANSMOOTH_X (1<<1) #define MOD_LAPLACIANSMOOTH_Y (1<<2) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 53d145072d3..a9a1d81077b 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -3375,10 +3375,9 @@ static void rna_def_modifier_triangulate(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE); prop = RNA_def_property(srna, "use_beauty", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "beauty", 1); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_TRIANGULATE_BEAUTY); RNA_def_property_ui_text(prop, "Beauty Subdivide", "Subdivide across shortest diagonal"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - } void RNA_def_modifier(BlenderRNA *brna) diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c index c876a12e31a..7dfbadac142 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.c +++ b/source/blender/modifiers/intern/MOD_triangulate.c @@ -24,47 +24,40 @@ /** \file blender/modifiers/intern/MOD_triangulate.c * \ingroup modifiers */ -#include <string.h> -#include "MEM_guardedalloc.h" - -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" #include "DNA_object_types.h" -#include "DNA_modifier_types.h" #include "BLI_utildefines.h" -#include "BLI_string.h" -#include "BLI_array.h" #include "BKE_cdderivedmesh.h" -#include "BKE_deform.h" -#include "BKE_DerivedMesh.h" -#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_tessmesh.h" -#include "MOD_util.h" - /* triangulation modifier, directly calls the bmesh operator */ -static DerivedMesh *triangulate(DerivedMesh *dm, char use_beauty) +static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int flag) { DerivedMesh *result; BMesh *bm; bm = DM_to_bmesh(dm); + BM_mesh_elem_toolflags_ensure(bm); BMO_push(bm, NULL); - BMO_op_callf(bm, BMO_FLAG_DEFAULTS, - "triangulate faces=%af use_beauty=%b", use_beauty); + BMO_op_callf(bm, BMO_FLAG_DEFAULTS, + "triangulate faces=%af use_beauty=%b", + (flag & MOD_TRIANGULATE_BEAUTY)); BMO_pop(bm); result = CDDM_from_bmesh(bm, FALSE); BM_mesh_free(bm); + /* we don't really need to calc edges, + * this is called to update the origindex values + * This could be made into a different function? - Campbell */ CDDM_calc_edges(result); + CDDM_calc_normals(result); return result; @@ -77,7 +70,7 @@ static void initData(ModifierData *md) /* Enable in editmode by default */ md->mode |= eModifierMode_Editmode; - tmd->beauty = TRUE; + tmd->flag = MOD_TRIANGULATE_BEAUTY; } @@ -96,7 +89,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, { TriangulateModifierData *tmd = (TriangulateModifierData *)md; DerivedMesh *result; - if (!(result = triangulate(dm, tmd->beauty))) { + if (!(result = triangulate_dm(dm, tmd->flag))) { return dm; } @@ -110,7 +103,7 @@ static DerivedMesh *applyModifier(ModifierData *md, { TriangulateModifierData *tmd = (TriangulateModifierData *)md; DerivedMesh *result; - if(!(result = triangulate(dm, tmd->beauty))) { + if (!(result = triangulate_dm(dm, tmd->flag))) { return dm; } @@ -123,10 +116,10 @@ ModifierTypeInfo modifierType_Triangulate = { /* structSize */ sizeof(TriangulateModifierData), /* type */ eModifierTypeType_Constructive, /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_SupportsMapping | - eModifierTypeFlag_EnableInEditmode | - eModifierTypeFlag_AcceptsCVs, + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_EnableInEditmode | + eModifierTypeFlag_AcceptsCVs, /* copyData */ copyData, /* deformVerts */ NULL, |