Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c2
-rw-r--r--source/blender/modifiers/intern/MOD_array.c75
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c44
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c1
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c5
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c6
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c6
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c20
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c144
-rw-r--r--source/blender/modifiers/intern/MOD_util.c1
10 files changed, 240 insertions, 64 deletions
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 7219038b087..7ab3a5df531 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -58,7 +58,7 @@ static void initData(ModifierData *md)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
- amd->deformflag = ARM_DEF_ENVELOPE | ARM_DEF_VGROUP;
+ amd->deformflag = ARM_DEF_VGROUP;
}
static void copyData(ModifierData *md, ModifierData *target)
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index b9dd37ac50c..d4463098f07 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -178,14 +178,14 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op,
amd->merge_dist, dupe_op, "geom");
BMO_op_exec(bm, &find_op);
-
+
i = 0;
- BMO_ITER (ele, &oiter, bm, dupe_op, "geom", BM_ALL) {
+ BMO_ITER (ele, &oiter, dupe_op->slots_in, "geom", BM_ALL) {
BM_elem_index_set(ele, i); /* set_dirty */
i++;
}
- BMO_ITER (ele, &oiter, bm, dupe_op, "newout", BM_ALL) {
+ BMO_ITER (ele, &oiter, dupe_op->slots_out, "geom.out", BM_ALL) {
BM_elem_index_set(ele, i); /* set_dirty */
i++;
}
@@ -197,7 +197,7 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op,
index_map = MEM_callocN(sizeof(int) * (*index_map_length), "index_map");
/*element type argument doesn't do anything here*/
- BMO_ITER (v, &oiter, bm, &find_op, "targetmapout", 0) {
+ BMO_ITER (v, &oiter, find_op.slots_out, "targetmap.out", 0) {
v2 = BMO_iter_map_value_p(&oiter);
index_map[BM_elem_index_get(v)] = BM_elem_index_get(v2) + 1;
@@ -218,9 +218,10 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op,
static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4],
const ArrayModifierData *amd,
BMOperator *dupe_op,
- const char *dupe_slot_name,
+ BMOpSlot dupe_op_slot_args[BMO_OP_MAX_SLOTS], const char *dupe_slot_name,
BMOperator *weld_op)
{
+ const int is_input = (dupe_op->slots_in == dupe_op_slot_args);
BMVert *v, *v2, *v3;
BMIter iter;
@@ -234,14 +235,27 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4],
BMOIter oiter;
BMOperator find_op;
+ BMOpSlot *slot_targetmap;
BMO_op_initf(bm, &find_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
- "find_doubles verts=%Hv dist=%f keep_verts=%s",
+ is_input ? /* ugh */
+ "find_doubles verts=%Hv dist=%f keep_verts=%s" :
+ "find_doubles verts=%Hv dist=%f keep_verts=%S",
BM_ELEM_TAG, amd->merge_dist,
dupe_op, dupe_slot_name);
/* append the dupe's geom to the findop input verts */
- BMO_slot_buffer_append(&find_op, "verts", dupe_op, dupe_slot_name);
+ if (is_input) {
+ BMO_slot_buffer_append(&find_op, slots_in, "verts",
+ dupe_op, slots_in, dupe_slot_name);
+ }
+ else if (dupe_op->slots_out == dupe_op_slot_args) {
+ BMO_slot_buffer_append(&find_op, slots_in, "verts",
+ dupe_op, slots_out, dupe_slot_name);
+ }
+ else {
+ BLI_assert(0);
+ }
/* transform and tag verts */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
@@ -253,15 +267,17 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4],
BMO_op_exec(bm, &find_op);
+ slot_targetmap = BMO_slot_get(weld_op->slots_in, "targetmap");
+
/* add new merge targets to weld operator */
- BMO_ITER (v, &oiter, bm, &find_op, "targetmapout", 0) {
+ BMO_ITER (v, &oiter, find_op.slots_out, "targetmap.out", 0) {
v2 = BMO_iter_map_value_p(&oiter);
/* check in case the target vertex (v2) is already marked
* for merging */
- while ((v3 = BMO_slot_map_ptr_get(bm, weld_op, "targetmap", v2))) {
+ while ((v3 = BMO_slot_map_ptr_get(slot_targetmap, v2))) {
v2 = v3;
}
- BMO_slot_map_ptr_insert(bm, weld_op, "targetmap", v, v2);
+ BMO_slot_map_ptr_insert(weld_op, slot_targetmap, v, v2);
}
BMO_op_finish(bm, &find_op);
@@ -286,6 +302,7 @@ static void merge_first_last(BMesh *bm,
BMOperator find_op;
BMOIter oiter;
BMVert *v, *v2;
+ BMOpSlot *slot_targetmap;
BMO_op_initf(bm, &find_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"find_doubles verts=%s dist=%f keep_verts=%s",
@@ -293,14 +310,16 @@ static void merge_first_last(BMesh *bm,
dupe_first, "geom");
/* append the last dupe's geom to the findop input verts */
- BMO_slot_buffer_append(&find_op, "verts", dupe_last, "newout");
+ BMO_slot_buffer_append(&find_op, slots_in, "verts",
+ dupe_last, slots_out, "geom.out");
BMO_op_exec(bm, &find_op);
/* add new merge targets to weld operator */
- BMO_ITER (v, &oiter, bm, &find_op, "targetmapout", 0) {
+ slot_targetmap = BMO_slot_get(weld_op->slots_in, "targetmap");
+ BMO_ITER (v, &oiter, find_op.slots_out, "targetmap.out", 0) {
v2 = BMO_iter_map_value_p(&oiter);
- BMO_slot_map_ptr_insert(bm, weld_op, "targetmap", v, v2);
+ BMO_slot_map_ptr_insert(weld_op, slot_targetmap, v, v2);
}
BMO_op_finish(bm, &find_op);
@@ -325,6 +344,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
int *indexMap = NULL;
DerivedMesh *start_cap = NULL, *end_cap = NULL;
MVert *src_mvert;
+ BMOpSlot *slot_targetmap = NULL; /* for weldop */
/* need to avoid infinite recursion here */
if (amd->start_cap && amd->start_cap != ob)
@@ -408,13 +428,17 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
* cleaner way to do this. One possibility: a "mirror" BMOp would
* certainly help by compressing it all into one top-level BMOp that
* executes a lot of second-level BMOps. */
+ BM_mesh_elem_toolflags_ensure(bm);
BMO_push(bm, NULL);
bmesh_edit_begin(bm, 0);
- if (amd->flags & MOD_ARR_MERGE)
+ if (amd->flags & MOD_ARR_MERGE) {
BMO_op_init(bm, &weld_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"weld_verts");
+ slot_targetmap = BMO_slot_get(weld_op.slots_in, "targetmap");
+ }
+
BMO_op_initf(bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"duplicate geom=%avef");
first_dupe_op = dupe_op;
@@ -422,18 +446,18 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
for (j = 0; j < count - 1; j++) {
BMVert *v, *v2, *v3;
BMOpSlot *geom_slot;
- BMOpSlot *newout_slot;
+ BMOpSlot *geom_out_slot;
BMOIter oiter;
if (j != 0) {
BMO_op_initf(bm, &dupe_op,
(BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
- "duplicate geom=%s", &old_dupe_op, "newout");
+ "duplicate geom=%S", &old_dupe_op, "geom.out");
}
BMO_op_exec(bm, &dupe_op);
- geom_slot = BMO_slot_get(&dupe_op, "geom");
- newout_slot = BMO_slot_get(&dupe_op, "newout");
+ geom_slot = BMO_slot_get(dupe_op.slots_in, "geom");
+ geom_out_slot = BMO_slot_get(dupe_op.slots_out, "geom.out");
if ((amd->flags & MOD_ARR_MERGEFINAL) && j == 0) {
int first_geom_bytes = sizeof(BMVert *) * geom_slot->len;
@@ -445,7 +469,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
}
/* apply transformation matrix */
- BMO_ITER (v, &oiter, bm, &dupe_op, "newout", BM_VERT) {
+ BMO_ITER (v, &oiter, dupe_op.slots_out, "geom.out", BM_VERT) {
mul_m4_v3(offset, v->co);
}
@@ -464,17 +488,17 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
for (i = 0; i < index_len; i++) {
if (!indexMap[i]) continue;
- /* merge v (from 'newout') into v2 (from old 'geom') */
- v = _E(newout_slot, i - geom_slot->len);
+ /* merge v (from 'geom.out') into v2 (from old 'geom') */
+ v = _E(geom_out_slot, i - geom_slot->len);
v2 = _E(geom_slot, indexMap[i] - 1);
/* check in case the target vertex (v2) is already marked
* for merging */
- while ((v3 = BMO_slot_map_ptr_get(bm, &weld_op, "targetmap", v2))) {
+ while ((v3 = BMO_slot_map_ptr_get(slot_targetmap, v2))) {
v2 = v3;
}
- BMO_slot_map_ptr_insert(bm, &weld_op, "targetmap", v, v2);
+ BMO_slot_map_ptr_insert(&weld_op, slot_targetmap, v, v2);
}
#undef _E
@@ -510,14 +534,15 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
float startoffset[4][4];
invert_m4_m4(startoffset, offset);
bm_merge_dm_transform(bm, start_cap, startoffset, amd,
- &first_dupe_op, "geom", &weld_op);
+ &first_dupe_op, first_dupe_op.slots_in, "geom", &weld_op);
}
if (end_cap) {
float endoffset[4][4];
mult_m4_m4m4(endoffset, offset, final_offset);
bm_merge_dm_transform(bm, end_cap, endoffset, amd,
- &dupe_op, count == 1 ? "geom" : "newout", &weld_op);
+ &dupe_op, (count == 1) ? dupe_op.slots_in : dupe_op.slots_out,
+ (count == 1) ? "geom" : "geom.out", &weld_op);
}
}
/* done capping */
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 3e3bcb73491..59befe4db05 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -92,20 +92,15 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
#ifdef USE_BM_BEVEL_OP_AS_MOD
-#define EDGE_MARK 1
-
/* BMESH_TODO
*
- * this bevel calls the operator which is missing many of the options
- * which the bevel modifier in trunk has.
+ * this bevel calls the new bevel code (added since 2.64)
+ * which is missing many of the options which the bevel modifier from 2.4x has.
* - no vertex bevel
* - no weight bevel
*
* These will need to be added to the bmesh operator.
- * - campbell
- *
- * note: this code is very close to MOD_edgesplit.c.
- * note: if 0'd code from trunk included below.
+ * - campbell
*/
static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
DerivedMesh *dm,
@@ -116,22 +111,20 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
BMIter iter;
BMEdge *e;
BevelModifierData *bmd = (BevelModifierData *) md;
- float threshold = cos((bmd->bevel_angle + 0.00001f) * M_PI / 180.0f);
+ const float threshold = cosf((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f);
+ const int segments = 16; /* XXX */
bm = DM_to_bmesh(dm);
- BM_mesh_normals_update(bm, FALSE);
- BMO_push(bm, NULL);
-
if (bmd->lim_flags & BME_BEVEL_ANGLE) {
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
/* check for 1 edge having 2 face users */
- BMLoop *l1, *l2;
- if ((l1 = e->l) &&
- (l2 = e->l->radial_next) != l1)
- {
- if (dot_v3v3(l1->f->no, l2->f->no) < threshold) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ BMLoop *l_a, *l_b;
+ if (BM_edge_loop_pair(e, &l_a, &l_b)) {
+ if (dot_v3v3(l_a->f->no, l_b->f->no) < threshold) {
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
}
}
}
@@ -139,18 +132,23 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
else {
/* crummy, is there a way just to operator on all? - campbell */
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- BMO_elem_flag_enable(bm, e, EDGE_MARK);
+ if (BM_edge_is_manifold(e)) {
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
+ }
}
}
- BMO_op_callf(bm, BMO_FLAG_DEFAULTS,
- "bevel geom=%fe percent=%f use_even=%b use_dist=%b",
- EDGE_MARK, bmd->value, (bmd->flags & BME_BEVEL_EVEN) != 0, (bmd->flags & BME_BEVEL_DIST) != 0);
- BMO_pop(bm);
+ BM_mesh_bevel(bm, bmd->value, segments);
result = CDDM_from_bmesh(bm, TRUE);
+
+ BLI_assert(bm->toolflagpool == NULL); /* make sure we never alloc'd this */
BM_mesh_free(bm);
+ CDDM_calc_normals(result);
+
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index dc29e59d549..3f8eaa438c9 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -186,6 +186,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* update for display only */
dmd->face_count = bm->totface;
result = CDDM_from_bmesh(bm, FALSE);
+ BLI_assert(bm->toolflagpool == NULL); /* make sure we never alloc'd this */
BM_mesh_free(bm);
#ifdef USE_TIMEIT
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index 21717d07fef..ec81c5ce699 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -67,8 +67,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
float threshold = cosf((emd->split_angle + 0.00001f) * (float)M_PI / 180.0f);
bm = DM_to_bmesh(dm);
-
- BMO_push(bm, NULL);
+ BM_mesh_elem_toolflags_ensure(bm);
if (emd->flags & MOD_EDGESPLIT_FROMANGLE) {
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
@@ -103,8 +102,6 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
BMO_op_callf(bm, BMO_FLAG_DEFAULTS,
"split_edges edges=%fe", EDGE_MARK);
-
- BMO_pop(bm);
/* BM_mesh_validate(bm); */ /* for troubleshooting */
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 47523286229..13d409dc941 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -426,7 +426,11 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm,
FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
{
int displaymode = 0;
- int curFrame = framenr - 1 /*scene->r.sfra*/; /* start with 0 at start frame */
+
+ int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */
+ /* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway. (See physics_fluid.c for that. - DG */
+ /* If we start with frame 0, we need to remap all animation channels, too, because they will all be 1 frame late if using frame-1! - DG */
+
char targetFile[FILE_MAX];
FluidsimSettings *fss = fluidmd->fss;
DerivedMesh *dm = NULL;
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 6f6589d4d14..266226040a3 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -199,7 +199,7 @@ static void init_data(ModifierData *md)
smd->lambda = 0.00001f;
smd->lambda_border = 0.00005f;
smd->repeat = 1;
- smd->flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z | MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION;
+ smd->flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z | MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME;
smd->defgrp_name[0] = '\0';
}
@@ -511,7 +511,7 @@ static void validate_solution(LaplacianSystem *sys, short flag)
float leni, lene;
float vini, vend;
float *vi1, *vi2, ve1[3], ve2[3];
- if (flag & MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION) {
+ if (flag & MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME) {
vini = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces);
}
for (i = 0; i < sys->numEdges; i++) {
@@ -545,7 +545,7 @@ static void validate_solution(LaplacianSystem *sys, short flag)
}
}
}
- if (flag & MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION) {
+ if (flag & MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME) {
vend = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces);
volume_preservation(sys, vini, vend, flag);
}
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 38ec0e8bb4c..9f702957fa5 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -249,14 +249,14 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe)
}
/* Apply face attributes to hull output */
- BMO_ITER (f, &oiter, bm, &op, "geomout", BM_FACE) {
+ BMO_ITER (f, &oiter, op.slots_out, "geom.out", BM_FACE) {
if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING)
BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
f->mat_nr = so->mat_nr;
}
/* Mark interior frames */
- BMO_ITER (v, &oiter, bm, &op, "interior_geom", BM_VERT) {
+ BMO_ITER (v, &oiter, op.slots_out, "geom_interior.out", BM_VERT) {
for (i = 0; i < totframe; i++) {
Frame *frame = frames[i];
@@ -309,7 +309,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe)
/* Check if removing triangles above will create wire triangles,
* mark them too */
- BMO_ITER (e, &oiter, bm, &op, "geomout", BM_EDGE) {
+ BMO_ITER (e, &oiter, op.slots_out, "geom.out", BM_EDGE) {
int is_wire = TRUE;
BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
if (!BM_elem_flag_test(f, BM_ELEM_TAG)) {
@@ -537,6 +537,7 @@ static int connection_node_mat(float mat[3][3], int v, const MeshElemMap *emap,
/* Get axis and angle to rotate frame by */
angle = angle_normalized_v3v3(ine[0], oute[0]) / 2.0f;
cross_v3_v3v3(axis, ine[0], oute[0]);
+ normalize_v3(axis);
/* Build frame matrix (don't care about X axis here) */
copy_v3_v3(mat[0], ine[0]);
@@ -1079,17 +1080,20 @@ static BMFace *collapse_face_corners(BMesh *bm, BMFace *f, int n,
BMOperator op;
BMIter iter;
int i;
+ BMOpSlot *slot_targetmap;
shortest_edge = BM_face_find_shortest_loop(f)->e;
BMO_op_initf(bm, &op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "weld_verts");
+ slot_targetmap = BMO_slot_get(op.slots_in, "targetmap");
+
/* Note: could probably calculate merges in one go to be
* faster */
v_safe = shortest_edge->v1;
v_merge = shortest_edge->v2;
mid_v3_v3v3(v_safe->co, v_safe->co, v_merge->co);
- BMO_slot_map_ptr_insert(bm, &op, "targetmap", v_merge, v_safe);
+ BMO_slot_map_ptr_insert(&op, slot_targetmap, v_merge, v_safe);
BMO_op_exec(bm, &op);
BMO_op_finish(bm, &op);
@@ -1215,6 +1219,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f
BMOIter oiter;
BMOperator op;
int i, best_order[4];
+ BMOpSlot *slot_targetmap;
BLI_assert(split_face->len >= 3);
@@ -1228,7 +1233,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f
/* Update split face (should only be one new face created
* during extrusion) */
split_face = NULL;
- BMO_ITER (f, &oiter, bm, &op, "faceout", BM_FACE) {
+ BMO_ITER (f, &oiter, op.slots_out, "faces.out", BM_FACE) {
BLI_assert(!split_face);
split_face = f;
}
@@ -1246,7 +1251,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f
BM_elem_flag_enable(longest_edge, BM_ELEM_TAG);
BMO_op_callf(bm, BMO_FLAG_DEFAULTS,
- "subdivide_edges edges=%he numcuts=%i quadcornertype=%i",
+ "subdivide_edges edges=%he cuts=%i quad_corner_type=%i",
BM_ELEM_TAG, 1, SUBD_STRAIGHT_CUT);
}
else if (split_face->len > 4) {
@@ -1280,8 +1285,9 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f
BM_face_kill(bm, split_face);
BMO_op_init(bm, &op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"weld_verts");
+ slot_targetmap = BMO_slot_get(op.slots_in, "targetmap");
for (i = 0; i < 4; i++) {
- BMO_slot_map_ptr_insert(bm, &op, "targetmap",
+ BMO_slot_map_ptr_insert(&op, slot_targetmap,
verts[i], frame->verts[best_order[i]]);
}
BMO_op_exec(bm, &op);
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
new file mode 100644
index 00000000000..645fd5eb2cf
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -0,0 +1,144 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Antony Riakiotakis
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/modifiers/intern/MOD_triangulate.c
+ * \ingroup modifiers
+ */
+
+#include "DNA_object_types.h"
+
+#include "BLI_utildefines.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_modifier.h"
+#include "BKE_tessmesh.h"
+
+/* triangulation modifier, directly calls the bmesh operator */
+
+static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int flag)
+{
+ DerivedMesh *result;
+ BMesh *bm;
+ int total_edges, i;
+ MEdge *me;
+
+ 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",
+ (flag & MOD_TRIANGULATE_BEAUTY));
+ BMO_pop(bm);
+
+ result = CDDM_from_bmesh(bm, FALSE);
+ BM_mesh_free(bm);
+
+ total_edges = result->getNumEdges(result);
+ me = CDDM_get_edges(result);
+
+ /* force drawing of all edges (seems to be omitted in CDDM_from_bmesh) */
+ for (i = 0; i < total_edges; i++, me++)
+ me->flag |= ME_EDGEDRAW | ME_EDGERENDER;
+
+ CDDM_calc_normals(result);
+
+ return result;
+}
+
+
+static void initData(ModifierData *md)
+{
+ TriangulateModifierData *tmd = (TriangulateModifierData *)md;
+
+ /* Enable in editmode by default */
+ md->mode |= eModifierMode_Editmode;
+ tmd->flag = MOD_TRIANGULATE_BEAUTY;
+}
+
+
+static void copyData(ModifierData *md, ModifierData *target)
+{
+ TriangulateModifierData *smd = (TriangulateModifierData *) md;
+ TriangulateModifierData *tsmd = (TriangulateModifierData *) target;
+
+ *tsmd = *smd;
+}
+
+static DerivedMesh *applyModifierEM(ModifierData *md,
+ Object *UNUSED(ob),
+ struct BMEditMesh *UNUSED(em),
+ DerivedMesh *dm)
+{
+ TriangulateModifierData *tmd = (TriangulateModifierData *)md;
+ DerivedMesh *result;
+ if (!(result = triangulate_dm(dm, tmd->flag))) {
+ return dm;
+ }
+
+ return result;
+}
+
+static DerivedMesh *applyModifier(ModifierData *md,
+ Object *UNUSED(ob),
+ DerivedMesh *dm,
+ ModifierApplyFlag UNUSED(flag))
+{
+ TriangulateModifierData *tmd = (TriangulateModifierData *)md;
+ DerivedMesh *result;
+ if (!(result = triangulate_dm(dm, tmd->flag))) {
+ return dm;
+ }
+
+ return result;
+}
+
+ModifierTypeInfo modifierType_Triangulate = {
+ /* name */ "Triangulate",
+ /* structName */ "TriangulateModifierData",
+ /* structSize */ sizeof(TriangulateModifierData),
+ /* type */ eModifierTypeType_Constructive,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_SupportsEditmode |
+ eModifierTypeFlag_SupportsMapping |
+ eModifierTypeFlag_EnableInEditmode |
+ eModifierTypeFlag_AcceptsCVs,
+
+ /* copyData */ copyData,
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ applyModifier,
+ /* applyModifierEM */ applyModifierEM,
+ /* initData */ initData,
+ /* requiredDataMask */ NULL, //requiredDataMask,
+ /* freeData */ NULL,
+ /* isDisabled */ NULL,
+ /* updateDepgraph */ NULL,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
+ /* foreachObjectLink */ NULL,
+ /* foreachIDLink */ NULL,
+};
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 3b769a30994..a27d5e5e03b 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -278,5 +278,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(Remesh);
INIT_TYPE(Skin);
INIT_TYPE(LaplacianSmooth);
+ INIT_TYPE(Triangulate);
#undef INIT_TYPE
}