dyn-topo: maintain materials for new faces.
also minor optimization for BM_edge_in_face(), check edges radial loops rather then the faces edges since normally there are 0-2 faces attached to an edge compared to 3+ edges in a face.
This commit is contained in:
@@ -294,7 +294,7 @@ static BMVert *pbvh_bmesh_vert_create(PBVH *bvh, int node_index,
|
||||
|
||||
static BMFace *pbvh_bmesh_face_create(PBVH *bvh, int node_index,
|
||||
BMVert *v_tri[3], BMEdge *e_tri[3],
|
||||
const BMFace *UNUSED(example))
|
||||
const BMFace *f_example)
|
||||
{
|
||||
BMFace *f;
|
||||
void *val = SET_INT_IN_POINTER(node_index);
|
||||
@@ -302,9 +302,10 @@ static BMFace *pbvh_bmesh_face_create(PBVH *bvh, int node_index,
|
||||
/* ensure we never add existing face */
|
||||
BLI_assert(BM_face_exists(v_tri, 3, NULL) == false);
|
||||
|
||||
/* Note: passing NULL for the 'example' parameter, profiling shows
|
||||
* a small performance bump */
|
||||
f = BM_face_create(bvh->bm, v_tri, e_tri, 3, 0);
|
||||
// BM_elem_attrs_copy(bvh->bm, bvh->bm, f_example, f);
|
||||
f->mat_nr = f_example->mat_nr;
|
||||
|
||||
if (!BLI_ghash_haskey(bvh->bm_face_to_node, f)) {
|
||||
|
||||
BLI_ghash_insert(bvh->nodes[node_index].bm_faces, f, NULL);
|
||||
|
||||
@@ -338,16 +338,16 @@ bool BM_verts_in_face(BMFace *f, BMVert **varr, int len)
|
||||
*/
|
||||
bool BM_edge_in_face(BMFace *f, BMEdge *e)
|
||||
{
|
||||
BMLoop *l_iter;
|
||||
BMLoop *l_first;
|
||||
if (e->l) {
|
||||
BMLoop *l_iter, *l_first;
|
||||
|
||||
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
|
||||
|
||||
do {
|
||||
if (l_iter->e == e) {
|
||||
return true;
|
||||
}
|
||||
} while ((l_iter = l_iter->next) != l_first);
|
||||
l_iter = l_first = e->l;
|
||||
do {
|
||||
if (l_iter->f == f) {
|
||||
return true;
|
||||
}
|
||||
} while ((l_iter = l_iter->radial_next) != l_first);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user