[Bf-blender-cvs] [9fbf7f11805] master: BVH Utils: Remove '_allocated' members from 'BVHTreeFromMesh'

Germano Cavalcante noreply at git.blender.org
Wed Apr 6 01:05:56 CEST 2022


Commit: 9fbf7f1180501fc868a38dccecfbc71f6747b4e9
Author: Germano Cavalcante
Date:   Tue Apr 5 19:49:30 2022 -0300
Branches: master
https://developer.blender.org/rB9fbf7f1180501fc868a38dccecfbc71f6747b4e9

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.

===================================================================

M	source/blender/blenkernel/BKE_bvhutils.h
M	source/blender/blenkernel/intern/bvhutils.cc
M	source/blender/blenkernel/intern/mesh_remap.c
M	source/blender/editors/transform/transform_snap_object.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index ec017dec2e4..c957465a654 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -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,
diff --git a/source/blender/blenkernel/intern/bvhutils.cc b/source/blender/blenkernel/intern/bvhutils.cc
index 85d3c778a6d..abbd4ced94b 100644
--- a/source/blender/blenkernel/intern/bvhutils.cc
+++ b/source/blender/blenkernel/intern/bvhutils.cc
@@ -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->fa

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list