Cleanup: Use proper type for subdiv CCG faces

This commit is contained in:
Hans Goudey
2023-11-29 08:47:49 -05:00
parent 7c1a0e57ca
commit aa2cdf283a
5 changed files with 27 additions and 21 deletions

View File

@@ -43,6 +43,7 @@ struct PBVHNode;
struct PBVHBatches;
struct PBVH_GPU_Args;
struct SculptSession;
struct SubdivCCGFace;
struct SubdivCCG;
struct TaskParallelSettings;
struct Image;
@@ -457,7 +458,10 @@ void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flags);
void BKE_pbvh_update_visibility(PBVH *pbvh);
void BKE_pbvh_update_normals(PBVH *pbvh, SubdivCCG *subdiv_ccg);
void BKE_pbvh_redraw_BB(PBVH *pbvh, float bb_min[3], float bb_max[3]);
void BKE_pbvh_get_grid_updates(PBVH *pbvh, bool clear, void ***r_gridfaces, int *r_totface);
void BKE_pbvh_get_grid_updates(PBVH *pbvh,
bool clear,
SubdivCCGFace ***r_gridfaces,
int *r_totface);
void BKE_pbvh_grids_update(PBVH *pbvh,
CCGElem **grids,
blender::Span<int> grid_to_face_map,

View File

@@ -237,7 +237,7 @@ void BKE_subdiv_ccg_recalc_normals(SubdivCCG *subdiv_ccg);
/* Update normals of affected faces. */
void BKE_subdiv_ccg_update_normals(SubdivCCG *subdiv_ccg,
CCGFace **effected_faces,
SubdivCCGFace **effected_faces,
int num_effected_faces);
/* Average grid coordinates and normals along the grid boundaries. */
@@ -245,7 +245,7 @@ void BKE_subdiv_ccg_average_grids(SubdivCCG *subdiv_ccg);
/* Similar to above, but only updates given faces. */
void BKE_subdiv_ccg_average_stitch_faces(SubdivCCG *subdiv_ccg,
CCGFace **effected_faces,
SubdivCCGFace **effected_faces,
int num_effected_faces);
/* Get geometry counters at the current subdivision level. */

View File

@@ -1216,9 +1216,9 @@ void multires_stitch_grids(Object *ob)
/* NOTE: Currently CCG does not keep track of faces, making it impossible
* to use BKE_pbvh_get_grid_updates().
*/
CCGFace **faces;
SubdivCCGFace **faces;
int num_faces;
BKE_pbvh_get_grid_updates(pbvh, false, (void ***)&faces, &num_faces);
BKE_pbvh_get_grid_updates(pbvh, false, &faces, &num_faces);
if (num_faces) {
BKE_subdiv_ccg_average_stitch_faces(subdiv_ccg, faces, num_faces);
MEM_freeN(faces);

View File

@@ -1712,7 +1712,10 @@ void BKE_pbvh_redraw_BB(PBVH *pbvh, float bb_min[3], float bb_max[3])
copy_v3_v3(bb_max, bb.bmax);
}
void BKE_pbvh_get_grid_updates(PBVH *pbvh, bool clear, void ***r_gridfaces, int *r_totface)
void BKE_pbvh_get_grid_updates(PBVH *pbvh,
bool clear,
SubdivCCGFace ***r_gridfaces,
int *r_totface)
{
if (pbvh->nodes.is_empty()) {
return;
@@ -1747,12 +1750,13 @@ void BKE_pbvh_get_grid_updates(PBVH *pbvh, bool clear, void ***r_gridfaces, int
return;
}
void **faces = static_cast<void **>(MEM_mallocN(sizeof(*faces) * tot, __func__));
SubdivCCGFace **faces = static_cast<SubdivCCGFace **>(
MEM_mallocN(sizeof(*faces) * tot, __func__));
GSetIterator gs_iter;
int i;
GSET_ITER_INDEX (gs_iter, face_set, i) {
faces[i] = BLI_gsetIterator_getKey(&gs_iter);
faces[i] = static_cast<SubdivCCGFace *>(BLI_gsetIterator_getKey(&gs_iter));
}
BLI_gset_free(face_set, nullptr);
@@ -2872,9 +2876,9 @@ void BKE_pbvh_update_normals(PBVH *pbvh, SubdivCCG *subdiv_ccg)
pbvh_faces_update_normals(pbvh, nodes, *pbvh->mesh);
}
else if (pbvh->header.type == PBVH_GRIDS) {
CCGFace **faces;
SubdivCCGFace **faces;
int num_faces;
BKE_pbvh_get_grid_updates(pbvh, true, (void ***)&faces, &num_faces);
BKE_pbvh_get_grid_updates(pbvh, true, &faces, &num_faces);
if (num_faces > 0) {
BKE_subdiv_ccg_update_normals(subdiv_ccg, faces, num_faces);
MEM_freeN(faces);

View File

@@ -43,7 +43,7 @@ static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg,
void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
CCGKey *key,
CCGFace **effected_faces,
SubdivCCGFace **effected_faces,
int num_effected_faces);
/** \} */
@@ -807,7 +807,7 @@ static void subdiv_ccg_recalc_modified_inner_normal_free(const void *__restrict
}
static void subdiv_ccg_recalc_modified_inner_grid_normals(SubdivCCG *subdiv_ccg,
CCGFace **effected_faces,
SubdivCCGFace **effected_faces,
int num_effected_faces)
{
CCGKey key;
@@ -830,7 +830,7 @@ static void subdiv_ccg_recalc_modified_inner_grid_normals(SubdivCCG *subdiv_ccg,
}
void BKE_subdiv_ccg_update_normals(SubdivCCG *subdiv_ccg,
CCGFace **effected_faces,
SubdivCCGFace **effected_faces,
int num_effected_faces)
{
if (!subdiv_ccg->has_normal) {
@@ -1181,7 +1181,7 @@ void BKE_subdiv_ccg_average_grids(SubdivCCG *subdiv_ccg)
}
static void subdiv_ccg_affected_face_adjacency(SubdivCCG *subdiv_ccg,
CCGFace **effected_faces,
SubdivCCGFace **effected_faces,
int num_effected_faces,
GSet *r_adjacent_vertices,
GSet *r_adjacent_edges)
@@ -1193,7 +1193,7 @@ static void subdiv_ccg_affected_face_adjacency(SubdivCCG *subdiv_ccg,
Vector<int, 64> face_edges;
for (int i = 0; i < num_effected_faces; i++) {
SubdivCCGFace *face = (SubdivCCGFace *)effected_faces[i];
SubdivCCGFace *face = effected_faces[i];
int face_index = face - subdiv_ccg->faces;
const int num_face_grids = face->num_grids;
face_vertices.reinitialize(num_face_grids);
@@ -1221,7 +1221,7 @@ static void subdiv_ccg_affected_face_adjacency(SubdivCCG *subdiv_ccg,
void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
CCGKey *key,
CCGFace **effected_faces,
SubdivCCGFace **effected_faces,
int num_effected_faces)
{
GSet *adjacent_vertices = BLI_gset_ptr_new(__func__);
@@ -1260,7 +1260,7 @@ void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
struct StitchFacesInnerGridsData {
SubdivCCG *subdiv_ccg;
CCGKey *key;
CCGFace **effected_ccg_faces;
SubdivCCGFace **effected_ccg_faces;
};
static void subdiv_ccg_stitch_face_inner_grids_task(void *__restrict userdata_v,
@@ -1270,14 +1270,12 @@ static void subdiv_ccg_stitch_face_inner_grids_task(void *__restrict userdata_v,
StitchFacesInnerGridsData *data = static_cast<StitchFacesInnerGridsData *>(userdata_v);
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
CCGKey *key = data->key;
CCGFace **effected_ccg_faces = data->effected_ccg_faces;
CCGFace *effected_ccg_face = effected_ccg_faces[face_index];
SubdivCCGFace *face = (SubdivCCGFace *)effected_ccg_face;
SubdivCCGFace *face = data->effected_ccg_faces[face_index];
subdiv_ccg_average_inner_face_grids(subdiv_ccg, key, face);
}
void BKE_subdiv_ccg_average_stitch_faces(SubdivCCG *subdiv_ccg,
CCGFace **effected_faces,
SubdivCCGFace **effected_faces,
int num_effected_faces)
{
CCGKey key;