Cleanup: Use C++ BitVector for sculpt boundary info
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BLI_array.hh"
|
#include "BLI_array.hh"
|
||||||
|
#include "BLI_bit_vector.hh"
|
||||||
#include "BLI_bitmap.h"
|
#include "BLI_bitmap.h"
|
||||||
#include "BLI_compiler_compat.h"
|
#include "BLI_compiler_compat.h"
|
||||||
#include "BLI_math_matrix_types.hh"
|
#include "BLI_math_matrix_types.hh"
|
||||||
@@ -388,7 +389,7 @@ struct SculptPersistentBase {
|
|||||||
|
|
||||||
struct SculptVertexInfo {
|
struct SculptVertexInfo {
|
||||||
/* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
|
/* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
|
||||||
BLI_bitmap *boundary;
|
blender::BitVector<> boundary;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SculptBoundaryEditInfo {
|
struct SculptBoundaryEditInfo {
|
||||||
|
|||||||
@@ -1460,7 +1460,7 @@ static void sculptsession_free_pbvh(Object *object)
|
|||||||
MEM_SAFE_FREE(ss->preview_vert_list);
|
MEM_SAFE_FREE(ss->preview_vert_list);
|
||||||
ss->preview_vert_count = 0;
|
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);
|
MEM_SAFE_FREE(ss->fake_neighbors.fake_neighbor_index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
static bool sculpt_check_boundary_vertex_in_base_mesh(const SculptSession *ss, const int index)
|
||||||
{
|
{
|
||||||
BLI_assert(ss->vertex_info.boundary);
|
return ss->vertex_info.boundary[index];
|
||||||
return BLI_BITMAP_TEST(ss->vertex_info.boundary, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SCULPT_vertex_is_boundary(const SculptSession *ss, const PBVHVertRef vertex)
|
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
|
/* Free index based vertex info as it will become invalid after modifying the topology during the
|
||||||
* stroke. */
|
* stroke. */
|
||||||
MEM_SAFE_FREE(ss->vertex_info.boundary);
|
ss->vertex_info.boundary.clear();
|
||||||
|
|
||||||
PBVHTopologyUpdateMode mode = PBVHTopologyUpdateMode(0);
|
PBVHTopologyUpdateMode mode = PBVHTopologyUpdateMode(0);
|
||||||
float location[3];
|
float location[3];
|
||||||
@@ -6099,13 +6098,13 @@ void SCULPT_boundary_info_ensure(Object *object)
|
|||||||
{
|
{
|
||||||
using namespace blender;
|
using namespace blender;
|
||||||
SculptSession *ss = object->sculpt;
|
SculptSession *ss = object->sculpt;
|
||||||
if (ss->vertex_info.boundary) {
|
if (!ss->vertex_info.boundary.is_empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh *base_mesh = BKE_mesh_from_object(object);
|
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<int> adjacent_faces_edge_count(base_mesh->totedge, 0);
|
||||||
array_utils::count_indices(base_mesh->corner_edges(), adjacent_faces_edge_count);
|
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()) {
|
for (const int e : edges.index_range()) {
|
||||||
if (adjacent_faces_edge_count[e] < 2) {
|
if (adjacent_faces_edge_count[e] < 2) {
|
||||||
const int2 &edge = edges[e];
|
const int2 &edge = edges[e];
|
||||||
BLI_BITMAP_SET(ss->vertex_info.boundary, edge[0], true);
|
ss->vertex_info.boundary[edge[0]].set();
|
||||||
BLI_BITMAP_SET(ss->vertex_info.boundary, edge[1], true);
|
ss->vertex_info.boundary[edge[1]].set();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user