Sculpt: Remove old connected component API in favor of new island API
This commit is contained in:
parent
da21e035d3
commit
fcb0425f64
|
@ -392,9 +392,6 @@ typedef struct SculptPersistentBase {
|
|||
} SculptPersistentBase;
|
||||
|
||||
typedef struct SculptVertexInfo {
|
||||
/* Indexed by vertex, stores and ID of its topologically connected component. */
|
||||
int *connected_component;
|
||||
|
||||
/* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
|
||||
BLI_bitmap *boundary;
|
||||
} SculptVertexInfo;
|
||||
|
|
|
@ -1454,7 +1454,6 @@ 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.connected_component);
|
||||
MEM_SAFE_FREE(ss->vertex_info.boundary);
|
||||
|
||||
MEM_SAFE_FREE(ss->fake_neighbors.fake_neighbor_index);
|
||||
|
|
|
@ -3351,7 +3351,6 @@ 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);
|
||||
MEM_SAFE_FREE(ss->vertex_info.connected_component);
|
||||
|
||||
PBVHTopologyUpdateMode mode = PBVHTopologyUpdateMode(0);
|
||||
float location[3];
|
||||
|
@ -5928,14 +5927,6 @@ enum {
|
|||
SCULPT_TOPOLOGY_ID_DEFAULT,
|
||||
};
|
||||
|
||||
static int SCULPT_vertex_get_connected_component(SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
if (ss->vertex_info.connected_component) {
|
||||
return ss->vertex_info.connected_component[vertex.i];
|
||||
}
|
||||
return SCULPT_TOPOLOGY_ID_DEFAULT;
|
||||
}
|
||||
|
||||
static void SCULPT_fake_neighbor_init(SculptSession *ss, const float max_dist)
|
||||
{
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
@ -5981,7 +5972,7 @@ static void do_fake_neighbor_search_task_cb(void *__restrict userdata,
|
|||
PBVHVertexIter vd;
|
||||
|
||||
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
|
||||
int vd_topology_id = SCULPT_vertex_get_connected_component(ss, vd.vertex);
|
||||
int vd_topology_id = SCULPT_vertex_island_get(ss, vd.vertex);
|
||||
if (vd_topology_id != nvtd->current_topology_id &&
|
||||
ss->fake_neighbors.fake_neighbor_index[vd.index] == FAKE_NEIGHBOR_NONE) {
|
||||
float distance_squared = len_squared_v3v3(vd.co, data->nearest_vertex_search_co);
|
||||
|
@ -6044,7 +6035,7 @@ static PBVHVertRef SCULPT_fake_neighbor_search(Sculpt *sd,
|
|||
NearestVertexFakeNeighborTLSData nvtd;
|
||||
nvtd.nearest_vertex.i = -1;
|
||||
nvtd.nearest_vertex_distance_squared = FLT_MAX;
|
||||
nvtd.current_topology_id = SCULPT_vertex_get_connected_component(ss, vertex);
|
||||
nvtd.current_topology_id = SCULPT_vertex_island_get(ss, vertex);
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BKE_pbvh_parallel_range_settings(&settings, true, totnode);
|
||||
|
@ -6062,55 +6053,6 @@ struct SculptTopologyIDFloodFillData {
|
|||
int next_id;
|
||||
};
|
||||
|
||||
static bool SCULPT_connected_components_floodfill_cb(
|
||||
SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool /*is_duplicate*/, void *userdata)
|
||||
{
|
||||
SculptTopologyIDFloodFillData *data = static_cast<SculptTopologyIDFloodFillData *>(userdata);
|
||||
|
||||
int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
|
||||
int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
|
||||
ss->vertex_info.connected_component[from_v_i] = data->next_id;
|
||||
ss->vertex_info.connected_component[to_v_i] = data->next_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SCULPT_connected_components_ensure(Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
/* Topology IDs already initialized. They only need to be recalculated when the PBVH is
|
||||
* rebuild.
|
||||
*/
|
||||
if (ss->vertex_info.connected_component) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
ss->vertex_info.connected_component = static_cast<int *>(
|
||||
MEM_malloc_arrayN(totvert, sizeof(int), "topology ID"));
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
ss->vertex_info.connected_component[i] = SCULPT_TOPOLOGY_ID_NONE;
|
||||
}
|
||||
|
||||
int next_id = 0;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (ss->vertex_info.connected_component[i] == SCULPT_TOPOLOGY_ID_NONE) {
|
||||
SculptFloodFill flood;
|
||||
SCULPT_floodfill_init(ss, &flood);
|
||||
SCULPT_floodfill_add_initial(&flood, vertex);
|
||||
SculptTopologyIDFloodFillData data;
|
||||
data.next_id = next_id;
|
||||
SCULPT_floodfill_execute(ss, &flood, SCULPT_connected_components_floodfill_cb, &data);
|
||||
SCULPT_floodfill_free(&flood);
|
||||
next_id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SCULPT_boundary_info_ensure(Object *object)
|
||||
{
|
||||
SculptSession *ss = object->sculpt;
|
||||
|
@ -6159,7 +6101,7 @@ void SCULPT_fake_neighbors_ensure(Sculpt *sd, Object *ob, const float max_dist)
|
|||
return;
|
||||
}
|
||||
|
||||
SCULPT_connected_components_ensure(ob);
|
||||
SCULPT_topology_islands_ensure(ob);
|
||||
SCULPT_fake_neighbor_init(ss, max_dist);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
|
|
|
@ -133,10 +133,8 @@ static bool sculpt_expand_is_vert_in_active_component(SculptSession *ss,
|
|||
ExpandCache *expand_cache,
|
||||
const PBVHVertRef v)
|
||||
{
|
||||
int v_i = BKE_pbvh_vertex_to_index(ss->pbvh, v);
|
||||
|
||||
for (int i = 0; i < EXPAND_SYMM_AREAS; i++) {
|
||||
if (ss->vertex_info.connected_component[v_i] == expand_cache->active_connected_components[i]) {
|
||||
if (SCULPT_vertex_island_get(ss, v) == expand_cache->active_connected_islands[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -403,8 +401,6 @@ static void sculpt_expand_check_topology_islands(Object *ob)
|
|||
|
||||
if (ss->expand_cache->check_islands) {
|
||||
SCULPT_topology_islands_ensure(ob);
|
||||
ss->expand_cache->initial_island_key = SCULPT_vertex_island_get(
|
||||
ss, ss->expand_cache->initial_active_vertex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1269,7 +1265,7 @@ static void sculpt_expand_mask_update_task_cb(void *__restrict userdata,
|
|||
const bool enabled = sculpt_expand_state_get(ss, expand_cache, vd.vertex);
|
||||
|
||||
if (expand_cache->check_islands &&
|
||||
SCULPT_vertex_island_get(ss, vd.vertex) != expand_cache->initial_island_key) {
|
||||
!sculpt_expand_is_vert_in_active_component(ss, expand_cache, vd.vertex)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1632,7 +1628,7 @@ static void sculpt_expand_find_active_connected_components_from_vert(
|
|||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
for (int i = 0; i < EXPAND_SYMM_AREAS; i++) {
|
||||
expand_cache->active_connected_components[i] = EXPAND_ACTIVE_COMPONENT_NONE;
|
||||
expand_cache->active_connected_islands[i] = EXPAND_ACTIVE_COMPONENT_NONE;
|
||||
}
|
||||
|
||||
const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
|
||||
|
@ -1644,10 +1640,8 @@ static void sculpt_expand_find_active_connected_components_from_vert(
|
|||
const PBVHVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
ob, symm_it, initial_vertex);
|
||||
|
||||
int symm_vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, symm_vertex);
|
||||
|
||||
expand_cache->active_connected_components[(int)symm_it] =
|
||||
ss->vertex_info.connected_component[symm_vertex_i];
|
||||
expand_cache->active_connected_islands[(int)symm_it] = SCULPT_vertex_island_get(
|
||||
ss, symm_vertex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1727,8 +1721,8 @@ static void sculpt_expand_move_propagation_origin(bContext *C,
|
|||
static void sculpt_expand_ensure_sculptsession_data(Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SCULPT_topology_islands_ensure(ob);
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
SCULPT_connected_components_ensure(ob);
|
||||
SCULPT_boundary_info_ensure(ob);
|
||||
if (!ss->tex_pool) {
|
||||
ss->tex_pool = BKE_image_pool_new();
|
||||
|
|
|
@ -744,11 +744,11 @@ typedef struct ExpandCache {
|
|||
* initial position of Expand. */
|
||||
float original_mouse_move[2];
|
||||
|
||||
/* Active components checks. */
|
||||
/* Indexed by symmetry pass index, contains the connected component ID found in
|
||||
* SculptSession->vertex_info.connected_component. Other connected components not found in this
|
||||
/* Active island checks. */
|
||||
/* Indexed by symmetry pass index, contains the connected island ID for that
|
||||
* symmetry pass. Other connected island IDs not found in this
|
||||
* array will be ignored by Expand. */
|
||||
int active_connected_components[EXPAND_SYMM_AREAS];
|
||||
int active_connected_islands[EXPAND_SYMM_AREAS];
|
||||
|
||||
/* Snapping. */
|
||||
/* GSet containing all Face Sets IDs that Expand will use to snap the new data. */
|
||||
|
@ -819,7 +819,6 @@ typedef struct ExpandCache {
|
|||
int *original_face_sets;
|
||||
float (*original_colors)[4];
|
||||
|
||||
int initial_island_key;
|
||||
bool check_islands;
|
||||
} ExpandCache;
|
||||
/** \} */
|
||||
|
@ -1028,8 +1027,6 @@ void SCULPT_boundary_info_ensure(Object *object);
|
|||
/* Boundary Info needs to be initialized in order to use this function. */
|
||||
bool SCULPT_vertex_is_boundary(const SculptSession *ss, PBVHVertRef vertex);
|
||||
|
||||
void SCULPT_connected_components_ensure(Object *ob);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
|
@ -95,7 +95,7 @@ static void mask_init_task_cb(void *__restrict userdata,
|
|||
break;
|
||||
}
|
||||
case SCULPT_MASK_INIT_RANDOM_PER_LOOSE_PART:
|
||||
*vd.mask = BLI_hash_int_01(ss->vertex_info.connected_component[vd.index] + seed);
|
||||
*vd.mask = BLI_hash_int_01(SCULPT_vertex_island_get(ss, vd.vertex) + seed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static int sculpt_mask_init_exec(bContext *C, wmOperator *op)
|
|||
SCULPT_undo_push_begin(ob, op);
|
||||
|
||||
if (mode == SCULPT_MASK_INIT_RANDOM_PER_LOOSE_PART) {
|
||||
SCULPT_connected_components_ensure(ob);
|
||||
SCULPT_topology_islands_ensure(ob);
|
||||
}
|
||||
|
||||
SculptThreadedTaskData data = {
|
||||
|
|
Loading…
Reference in New Issue