BVH Utils: Remove '_allocated' members from 'BVHTreeFromMesh'
The parameters indicating whether it is allocated are always `false` and it is up to the caller to free them. Also clang-format was triggered.
This commit is contained in:
parent
684b95804e
commit
9fbf7f1180
|
@ -56,15 +56,10 @@ typedef struct BVHTreeFromMesh {
|
|||
/* Vertex array, so that callbacks have instant access to data. */
|
||||
const struct MVert *vert;
|
||||
const float (*vert_normals)[3];
|
||||
const struct MEdge *edge; /* only used for #BVHTreeFromMeshEdges */
|
||||
const struct MEdge *edge;
|
||||
const struct MFace *face;
|
||||
const struct MLoop *loop;
|
||||
const struct MLoopTri *looptri;
|
||||
bool vert_allocated;
|
||||
bool edge_allocated;
|
||||
bool face_allocated;
|
||||
bool loop_allocated;
|
||||
bool looptri_allocated;
|
||||
|
||||
/* Private data */
|
||||
bool cached;
|
||||
|
@ -125,7 +120,6 @@ BVHTree *bvhtree_from_editmesh_verts_ex(BVHTreeFromEditMesh *data,
|
|||
BVHTree *bvhtree_from_mesh_verts_ex(struct BVHTreeFromMesh *data,
|
||||
const struct MVert *vert,
|
||||
int verts_num,
|
||||
bool vert_allocated,
|
||||
const BLI_bitmap *verts_mask,
|
||||
int verts_num_active,
|
||||
float epsilon,
|
||||
|
@ -158,10 +152,8 @@ BVHTree *bvhtree_from_editmesh_edges_ex(BVHTreeFromEditMesh *data,
|
|||
*/
|
||||
BVHTree *bvhtree_from_mesh_edges_ex(struct BVHTreeFromMesh *data,
|
||||
const struct MVert *vert,
|
||||
bool vert_allocated,
|
||||
const struct MEdge *edge,
|
||||
int edges_num,
|
||||
bool edge_allocated,
|
||||
const BLI_bitmap *edges_mask,
|
||||
int edges_num_active,
|
||||
float epsilon,
|
||||
|
@ -180,10 +172,8 @@ BVHTree *bvhtree_from_mesh_edges_ex(struct BVHTreeFromMesh *data,
|
|||
*/
|
||||
BVHTree *bvhtree_from_mesh_faces_ex(struct BVHTreeFromMesh *data,
|
||||
const struct MVert *vert,
|
||||
bool vert_allocated,
|
||||
const struct MFace *face,
|
||||
int numFaces,
|
||||
bool face_allocated,
|
||||
const BLI_bitmap *faces_mask,
|
||||
int faces_num_active,
|
||||
float epsilon,
|
||||
|
@ -213,12 +203,9 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(BVHTreeFromEditMesh *data,
|
|||
*/
|
||||
BVHTree *bvhtree_from_mesh_looptri_ex(struct BVHTreeFromMesh *data,
|
||||
const struct MVert *vert,
|
||||
bool vert_allocated,
|
||||
const struct MLoop *mloop,
|
||||
bool loop_allocated,
|
||||
const struct MLoopTri *looptri,
|
||||
int looptri_num,
|
||||
bool looptri_allocated,
|
||||
const BLI_bitmap *mask,
|
||||
int looptri_num_active,
|
||||
float epsilon,
|
||||
|
|
|
@ -759,7 +759,6 @@ BVHTree *bvhtree_from_editmesh_verts(
|
|||
BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
|
||||
const MVert *vert,
|
||||
const int verts_num,
|
||||
const bool vert_allocated,
|
||||
const BLI_bitmap *verts_mask,
|
||||
int verts_num_active,
|
||||
float epsilon,
|
||||
|
@ -777,7 +776,6 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
|
|||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_VERTS, vert, nullptr, nullptr, nullptr, nullptr, nullptr, data);
|
||||
data->vert_allocated = vert_allocated;
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -896,10 +894,8 @@ BVHTree *bvhtree_from_editmesh_edges(
|
|||
|
||||
BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
|
||||
const MVert *vert,
|
||||
const bool vert_allocated,
|
||||
const MEdge *edge,
|
||||
const int edges_num,
|
||||
const bool edge_allocated,
|
||||
const BLI_bitmap *edges_mask,
|
||||
int edges_num_active,
|
||||
float epsilon,
|
||||
|
@ -917,8 +913,6 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
|
|||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_EDGES, vert, edge, nullptr, nullptr, nullptr, nullptr, data);
|
||||
data->vert_allocated = vert_allocated;
|
||||
data->vert_allocated = edge_allocated;
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -979,10 +973,8 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(float epsilon,
|
|||
|
||||
BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
|
||||
const MVert *vert,
|
||||
const bool vert_allocated,
|
||||
const MFace *face,
|
||||
const int numFaces,
|
||||
const bool face_allocated,
|
||||
const BLI_bitmap *faces_mask,
|
||||
int faces_num_active,
|
||||
float epsilon,
|
||||
|
@ -1000,8 +992,6 @@ BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
|
|||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_FACES, vert, nullptr, face, nullptr, nullptr, nullptr, data);
|
||||
data->vert_allocated = vert_allocated;
|
||||
data->face_allocated = face_allocated;
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -1139,12 +1129,9 @@ BVHTree *bvhtree_from_editmesh_looptri(
|
|||
|
||||
BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
|
||||
const struct MVert *vert,
|
||||
const bool vert_allocated,
|
||||
const struct MLoop *mloop,
|
||||
const bool loop_allocated,
|
||||
const struct MLoopTri *looptri,
|
||||
const int looptri_num,
|
||||
const bool looptri_allocated,
|
||||
const BLI_bitmap *looptri_mask,
|
||||
int looptri_num_active,
|
||||
float epsilon,
|
||||
|
@ -1169,9 +1156,6 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
|
|||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_LOOPTRI, vert, nullptr, nullptr, mloop, looptri, nullptr, data);
|
||||
data->vert_allocated = vert_allocated;
|
||||
data->loop_allocated = loop_allocated;
|
||||
data->looptri_allocated = looptri_allocated;
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -1306,7 +1290,6 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
|
|||
data->tree = bvhtree_from_mesh_verts_ex(nullptr,
|
||||
mesh->mvert,
|
||||
verts_len,
|
||||
false,
|
||||
loose_verts_mask,
|
||||
loose_vert_len,
|
||||
0.0f,
|
||||
|
@ -1331,10 +1314,8 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
|
|||
|
||||
data->tree = bvhtree_from_mesh_edges_ex(nullptr,
|
||||
mesh->mvert,
|
||||
false,
|
||||
mesh->medge,
|
||||
edges_len,
|
||||
false,
|
||||
loose_edges_mask,
|
||||
loose_edges_len,
|
||||
0.0,
|
||||
|
@ -1353,10 +1334,8 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
|
|||
|
||||
data->tree = bvhtree_from_mesh_faces_ex(nullptr,
|
||||
mesh->mvert,
|
||||
false,
|
||||
mesh->mface,
|
||||
num_faces,
|
||||
false,
|
||||
nullptr,
|
||||
-1,
|
||||
0.0,
|
||||
|
@ -1378,12 +1357,9 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
|
|||
|
||||
data->tree = bvhtree_from_mesh_looptri_ex(nullptr,
|
||||
mesh->mvert,
|
||||
false,
|
||||
mesh->mloop,
|
||||
false,
|
||||
data->looptri,
|
||||
looptri_len,
|
||||
false,
|
||||
looptri_mask,
|
||||
looptri_mask_active_len,
|
||||
0.0,
|
||||
|
@ -1513,22 +1489,6 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
|
|||
BLI_bvhtree_free(data->tree);
|
||||
}
|
||||
|
||||
if (data->vert_allocated) {
|
||||
MEM_freeN((void *)data->vert);
|
||||
}
|
||||
if (data->edge_allocated) {
|
||||
MEM_freeN((void *)data->edge);
|
||||
}
|
||||
if (data->face_allocated) {
|
||||
MEM_freeN((void *)data->face);
|
||||
}
|
||||
if (data->loop_allocated) {
|
||||
MEM_freeN((void *)data->loop);
|
||||
}
|
||||
if (data->looptri_allocated) {
|
||||
MEM_freeN((void *)data->looptri);
|
||||
}
|
||||
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
|
||||
|
|
|
@ -1510,7 +1510,6 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
bvhtree_from_mesh_verts_ex(&treedata[tindex],
|
||||
verts_src,
|
||||
num_verts_src,
|
||||
false,
|
||||
verts_active,
|
||||
num_verts_active,
|
||||
0.0,
|
||||
|
@ -1547,12 +1546,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
}
|
||||
bvhtree_from_mesh_looptri_ex(&treedata[tindex],
|
||||
verts_src,
|
||||
false,
|
||||
loops_src,
|
||||
false,
|
||||
looptri_src,
|
||||
num_looptri_src,
|
||||
false,
|
||||
looptri_active,
|
||||
num_looptri_active,
|
||||
0.0,
|
||||
|
|
|
@ -275,17 +275,16 @@ static SnapObjectData *snap_object_data_mesh_get(SnapObjectContext *sctx,
|
|||
/* The tree is owned by the Mesh and may have been freed since we last used. */
|
||||
is_dirty = true;
|
||||
}
|
||||
else if (!sod->treedata_mesh.looptri_allocated &&
|
||||
sod->treedata_mesh.looptri != me_eval->runtime.looptris.array) {
|
||||
else if (sod->treedata_mesh.looptri != me_eval->runtime.looptris.array) {
|
||||
is_dirty = true;
|
||||
}
|
||||
else if (!sod->treedata_mesh.vert_allocated && sod->treedata_mesh.vert != me_eval->mvert) {
|
||||
else if (sod->treedata_mesh.vert != me_eval->mvert) {
|
||||
is_dirty = true;
|
||||
}
|
||||
else if (!sod->treedata_mesh.loop_allocated && sod->treedata_mesh.loop != me_eval->mloop) {
|
||||
else if (sod->treedata_mesh.loop != me_eval->mloop) {
|
||||
is_dirty = true;
|
||||
}
|
||||
else if (!sod->treedata_mesh.edge_allocated && sod->treedata_mesh.edge != me_eval->medge) {
|
||||
else if (sod->treedata_mesh.edge != me_eval->medge) {
|
||||
is_dirty = true;
|
||||
}
|
||||
else if (sod->poly != me_eval->mpoly) {
|
||||
|
@ -901,7 +900,8 @@ static bool raycastEditMesh(SnapObjectContext *sctx,
|
|||
sctx->callbacks.edit_mesh.test_face_fn,
|
||||
sctx->callbacks.edit_mesh.user_data);
|
||||
|
||||
bvhtree_from_editmesh_looptri_ex(treedata, em, elem_mask, looptri_num_active, 0.0f, 4, 6, false);
|
||||
bvhtree_from_editmesh_looptri_ex(
|
||||
treedata, em, elem_mask, looptri_num_active, 0.0f, 4, 6, false);
|
||||
|
||||
MEM_freeN(elem_mask);
|
||||
}
|
||||
|
@ -2364,12 +2364,6 @@ static short snapMesh(SnapObjectContext *sctx,
|
|||
sod->has_loose_edge = false;
|
||||
}
|
||||
sod->cached[0] = treedata_tmp.cached;
|
||||
BLI_assert(!ELEM(true,
|
||||
treedata_tmp.vert_allocated,
|
||||
treedata_tmp.edge_allocated,
|
||||
treedata_tmp.face_allocated,
|
||||
treedata_tmp.loop_allocated,
|
||||
treedata_tmp.looptri_allocated));
|
||||
}
|
||||
|
||||
if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX) {
|
||||
|
@ -2380,12 +2374,6 @@ static short snapMesh(SnapObjectContext *sctx,
|
|||
sod->has_loose_vert = false;
|
||||
}
|
||||
sod->cached[1] = treedata_tmp.cached;
|
||||
BLI_assert(!ELEM(true,
|
||||
treedata_tmp.vert_allocated,
|
||||
treedata_tmp.edge_allocated,
|
||||
treedata_tmp.face_allocated,
|
||||
treedata_tmp.loop_allocated,
|
||||
treedata_tmp.looptri_allocated));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -2565,7 +2553,8 @@ static short snapEditMesh(SnapObjectContext *sctx,
|
|||
(bool (*)(BMElem *, void *))sctx->callbacks.edit_mesh.test_vert_fn,
|
||||
sctx->callbacks.edit_mesh.user_data);
|
||||
|
||||
bvhtree_from_editmesh_verts_ex(&treedata, em, verts_mask, verts_num_active, 0.0f, 2, 6, false);
|
||||
bvhtree_from_editmesh_verts_ex(
|
||||
&treedata, em, verts_mask, verts_num_active, 0.0f, 2, 6, false);
|
||||
MEM_freeN(verts_mask);
|
||||
}
|
||||
else {
|
||||
|
@ -2597,7 +2586,8 @@ static short snapEditMesh(SnapObjectContext *sctx,
|
|||
(bool (*)(BMElem *, void *))sctx->callbacks.edit_mesh.test_edge_fn,
|
||||
sctx->callbacks.edit_mesh.user_data);
|
||||
|
||||
bvhtree_from_editmesh_edges_ex(&treedata, em, edges_mask, edges_num_active, 0.0f, 2, 6, false);
|
||||
bvhtree_from_editmesh_edges_ex(
|
||||
&treedata, em, edges_mask, edges_num_active, 0.0f, 2, 6, false);
|
||||
MEM_freeN(edges_mask);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue