1
1

BMesh: triangulate & poke - multires data support

This commit is contained in:
2015-11-05 17:40:33 +11:00
parent ce49c70956
commit 23344bca6c
2 changed files with 37 additions and 3 deletions

View File

@@ -42,6 +42,8 @@
#include "bmesh.h"
#include "bmesh_tools.h"
#include "BKE_customdata.h"
#include "intern/bmesh_private.h"
/**
@@ -785,11 +787,13 @@ void BM_face_triangulate(
/* use for MOD_TRIANGULATE_NGON_BEAUTY only! */
struct Heap *pf_heap, struct EdgeHash *pf_ehash)
{
const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
const bool use_beauty = (ngon_method == MOD_TRIANGULATE_NGON_BEAUTY);
BMLoop *l_iter, *l_first, *l_new;
BMFace *f_new;
int nf_i = 0;
int ne_i = 0;
bool use_beauty = (ngon_method == MOD_TRIANGULATE_NGON_BEAUTY);
BLI_assert(BM_face_is_normal_valid(f));
@@ -804,6 +808,8 @@ void BM_face_triangulate(
const int totfilltri = f->len - 2;
const int last_tri = f->len - 3;
int i;
/* for mdisps */
float f_center[3];
if (f->len == 4) {
/* even though we're not using BLI_polyfill, fill in 'tris' and 'loops'
@@ -901,6 +907,10 @@ void BM_face_triangulate(
BLI_memarena_clear(pf_arena);
}
if (cd_loop_mdisp_offset != -1) {
BM_face_calc_center_mean(f, f_center);
}
/* loop over calculated triangles and create new geometry */
for (i = 0; i < totfilltri; i++) {
/* the order is reverse, otherwise the normal is flipped */
@@ -954,6 +964,12 @@ void BM_face_triangulate(
/* note, never disable tag's */
} while ((l_iter = l_iter->next) != l_first);
}
if (cd_loop_mdisp_offset != -1) {
float f_new_center[3];
BM_face_calc_center_mean(f_new, f_new_center);
BM_face_interp_multires_ex(bm, f_new, f, f_new_center, f_center, cd_loop_mdisp_offset);
}
}
{

View File

@@ -34,6 +34,8 @@
#include "intern/bmesh_operators_private.h" /* own include */
#include "BKE_customdata.h"
#define ELE_NEW 1
/**
@@ -45,6 +47,7 @@
*/
void bmo_poke_exec(BMesh *bm, BMOperator *op)
{
const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
BMOIter oiter;
BMFace *f;
@@ -70,7 +73,7 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
BMFace *f_new;
float f_center[3];
float f_center[3], f_center_mean[3];
BMVert *v_center = NULL;
BMLoop *l_iter, *l_first;
/* only interpolate the central loop from the face once,
@@ -86,6 +89,15 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
v_center = BM_vert_create(bm, f_center, NULL, BM_CREATE_NOP);
BMO_elem_flag_enable(bm, v_center, ELE_NEW);
if (cd_loop_mdisp_offset != -1) {
if (center_mode == BMOP_POKE_MEAN) {
copy_v3_v3(f_center_mean, f_center);
}
else {
BM_face_calc_center_mean(f, f_center_mean);
}
}
/* handled by BM_loop_interp_from_face */
// BM_vert_interp_from_face(bm, v_center, f);
@@ -106,7 +118,7 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
if (i == 0) {
l_center_example = l_new->prev;
BM_loop_interp_from_face(bm, l_center_example, f, true, true);
BM_loop_interp_from_face(bm, l_center_example, f, true, false);
}
else {
BM_elem_attrs_copy(bm, bm, l_center_example, l_new->prev);
@@ -118,6 +130,12 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
BMO_elem_flag_enable(bm, f_new, ELE_NEW);
if (cd_loop_mdisp_offset != -1) {
float f_new_center[3];
BM_face_calc_center_mean(f_new, f_new_center);
BM_face_interp_multires_ex(bm, f_new, f, f_new_center, f_center, cd_loop_mdisp_offset);
}
if (use_relative_offset) {
offset_fac += len_v3v3(f_center, l_iter->v->co);
}