Cleanup: Use C++ BitVector for sculpt boundary info

This commit is contained in:
Hans Goudey 2023-11-19 12:53:25 -05:00
parent 323259a7da
commit ee9265710a
3 changed files with 9 additions and 9 deletions

View File

@ -9,6 +9,7 @@
*/
#include "BLI_array.hh"
#include "BLI_bit_vector.hh"
#include "BLI_bitmap.h"
#include "BLI_compiler_compat.h"
#include "BLI_math_matrix_types.hh"
@ -388,7 +389,7 @@ struct SculptPersistentBase {
struct SculptVertexInfo {
/* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
BLI_bitmap *boundary;
blender::BitVector<> boundary;
};
struct SculptBoundaryEditInfo {

View File

@ -1460,7 +1460,7 @@ static void sculptsession_free_pbvh(Object *object)
MEM_SAFE_FREE(ss->preview_vert_list);
ss->preview_vert_count = 0;
MEM_SAFE_FREE(ss->vertex_info.boundary);
ss->vertex_info.boundary.clear_and_shrink();
MEM_SAFE_FREE(ss->fake_neighbors.fake_neighbor_index);
}

View File

@ -986,8 +986,7 @@ void SCULPT_vertex_neighbors_get(SculptSession *ss,
static bool sculpt_check_boundary_vertex_in_base_mesh(const SculptSession *ss, const int index)
{
BLI_assert(ss->vertex_info.boundary);
return BLI_BITMAP_TEST(ss->vertex_info.boundary, index);
return ss->vertex_info.boundary[index];
}
bool SCULPT_vertex_is_boundary(const SculptSession *ss, const PBVHVertRef vertex)
@ -3411,7 +3410,7 @@ static void sculpt_topology_update(Sculpt *sd,
/* Free index based vertex info as it will become invalid after modifying the topology during the
* stroke. */
MEM_SAFE_FREE(ss->vertex_info.boundary);
ss->vertex_info.boundary.clear();
PBVHTopologyUpdateMode mode = PBVHTopologyUpdateMode(0);
float location[3];
@ -6099,13 +6098,13 @@ void SCULPT_boundary_info_ensure(Object *object)
{
using namespace blender;
SculptSession *ss = object->sculpt;
if (ss->vertex_info.boundary) {
if (!ss->vertex_info.boundary.is_empty()) {
return;
}
Mesh *base_mesh = BKE_mesh_from_object(object);
ss->vertex_info.boundary = BLI_BITMAP_NEW(base_mesh->totvert, "Boundary info");
ss->vertex_info.boundary.resize(base_mesh->totvert);
Array<int> adjacent_faces_edge_count(base_mesh->totedge, 0);
array_utils::count_indices(base_mesh->corner_edges(), adjacent_faces_edge_count);
@ -6113,8 +6112,8 @@ void SCULPT_boundary_info_ensure(Object *object)
for (const int e : edges.index_range()) {
if (adjacent_faces_edge_count[e] < 2) {
const int2 &edge = edges[e];
BLI_BITMAP_SET(ss->vertex_info.boundary, edge[0], true);
BLI_BITMAP_SET(ss->vertex_info.boundary, edge[1], true);
ss->vertex_info.boundary[edge[0]].set();
ss->vertex_info.boundary[edge[1]].set();
}
}
}