Cleanup: minor improvement to boundary check
Use a byte flag instead of counting polys using edges (technically a fix for edges with USHRT_MAX+2 users).
This commit is contained in:
@@ -130,25 +130,24 @@ static void mesh_get_boundaries(Mesh *mesh, float *smooth_weights)
|
|||||||
const MEdge *medge = BKE_mesh_edges(mesh);
|
const MEdge *medge = BKE_mesh_edges(mesh);
|
||||||
const MPoly *mpoly = BKE_mesh_polys(mesh);
|
const MPoly *mpoly = BKE_mesh_polys(mesh);
|
||||||
const MLoop *mloop = BKE_mesh_loops(mesh);
|
const MLoop *mloop = BKE_mesh_loops(mesh);
|
||||||
uint mpoly_num, medge_num, i;
|
|
||||||
ushort *boundaries;
|
|
||||||
|
|
||||||
mpoly_num = (uint)mesh->totpoly;
|
const uint mpoly_num = (uint)mesh->totpoly;
|
||||||
medge_num = (uint)mesh->totedge;
|
const uint medge_num = (uint)mesh->totedge;
|
||||||
|
|
||||||
boundaries = MEM_calloc_arrayN(medge_num, sizeof(*boundaries), __func__);
|
/* Flag boundary edges so only boundaries are set to 1. */
|
||||||
|
uint8_t *boundaries = MEM_calloc_arrayN(medge_num, sizeof(*boundaries), __func__);
|
||||||
|
|
||||||
/* count the number of adjacent faces */
|
for (uint i = 0; i < mpoly_num; i++) {
|
||||||
for (i = 0; i < mpoly_num; i++) {
|
|
||||||
const MPoly *p = &mpoly[i];
|
const MPoly *p = &mpoly[i];
|
||||||
const int totloop = p->totloop;
|
const int totloop = p->totloop;
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < totloop; j++) {
|
for (j = 0; j < totloop; j++) {
|
||||||
boundaries[mloop[p->loopstart + j].e]++;
|
uint8_t *e_value = &boundaries[mloop[p->loopstart + j].e];
|
||||||
|
*e_value |= (*e_value) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < medge_num; i++) {
|
for (uint i = 0; i < medge_num; i++) {
|
||||||
if (boundaries[i] == 1) {
|
if (boundaries[i] == 1) {
|
||||||
smooth_weights[medge[i].v1] = 0.0f;
|
smooth_weights[medge[i].v1] = 0.0f;
|
||||||
smooth_weights[medge[i].v2] = 0.0f;
|
smooth_weights[medge[i].v2] = 0.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user