Cleanup: Sculpt: Simplify arguments to node debug drawing

These are either always a certain value or retrievable from the node.
This commit is contained in:
Hans Goudey
2024-11-01 15:00:03 +01:00
parent 7853f07ca3
commit 45f28ab599
4 changed files with 13 additions and 41 deletions

View File

@@ -602,11 +602,7 @@ Span<float3> face_normals_eval_from_eval(const Object &object_eval);
int BKE_pbvh_debug_draw_gen_get(blender::bke::pbvh::Node &node);
void BKE_pbvh_draw_debug_cb(blender::bke::pbvh::Tree &pbvh,
void (*draw_fn)(blender::bke::pbvh::Node *node,
void *user_data,
const float bmin[3],
const float bmax[3],
PBVHNodeFlags flag),
void (*draw_fn)(blender::bke::pbvh::Node *node, void *user_data),
void *user_data);
namespace blender::bke::pbvh {

View File

@@ -2365,11 +2365,7 @@ bool BKE_pbvh_node_frustum_exclude_AABB(const blender::bke::pbvh::Node *node,
}
void BKE_pbvh_draw_debug_cb(blender::bke::pbvh::Tree &pbvh,
void (*draw_fn)(blender::bke::pbvh::Node *node,
void *user_data,
const float bmin[3],
const float bmax[3],
PBVHNodeFlags flag),
void (*draw_fn)(blender::bke::pbvh::Node *node, void *user_data),
void *user_data)
{
PBVHNodeFlags flag = PBVH_Leaf;
@@ -2388,7 +2384,7 @@ void BKE_pbvh_draw_debug_cb(blender::bke::pbvh::Tree &pbvh,
continue;
}
draw_fn(&node, user_data, node.bounds_.min, node.bounds_.max, node.flag_);
draw_fn(&node, user_data);
}
},
pbvh.nodes_);

View File

@@ -81,7 +81,6 @@ struct DRW_MeshCDMask;
namespace blender::bke::pbvh {
class Node;
}
enum PBVHNodeFlags : uint32_t;
typedef struct DRWCallBuffer DRWCallBuffer;
typedef struct DRWInterface DRWInterface;
@@ -955,10 +954,6 @@ void DRW_mesh_batch_cache_get_attributes(Object *object,
blender::draw::DRW_Attributes **r_attrs,
blender::draw::DRW_MeshCDMask **r_cd_needed);
void DRW_sculpt_debug_cb(blender::bke::pbvh::Node *node,
void *user_data,
const float bmin[3],
const float bmax[3],
PBVHNodeFlags flag);
void DRW_sculpt_debug_cb(blender::bke::pbvh::Node *node, void *user_data);
bool DRW_is_viewport_compositor_enabled();

View File

@@ -1273,31 +1273,21 @@ static void draw_pbvh_nodes(const Object &object,
});
}
void DRW_sculpt_debug_cb(blender::bke::pbvh::Node *node,
void *user_data,
const float bmin[3],
const float bmax[3],
PBVHNodeFlags flag)
void DRW_sculpt_debug_cb(blender::bke::pbvh::Node *node, void *user_data)
{
int *debug_node_nr = (int *)user_data;
BoundBox bb;
BKE_boundbox_init_from_minmax(&bb, bmin, bmax);
BKE_boundbox_init_from_minmax(&bb, node->bounds_.min, node->bounds_.max);
#if 0 /* Nodes hierarchy. */
if (flag & PBVH_Leaf) {
DRW_debug_bbox(&bb, blender::float4{0.0f, 1.0f, 0.0f, 1.0f});
}
else {
DRW_debug_bbox(&bb, blender::float4{0.5f, 0.5f, 0.5f, 0.6f});
}
#else /* Color coded leaf bounds. */
if (flag & (PBVH_Leaf | PBVH_TexLeaf)) {
DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR((*debug_node_nr)++));
int color = (*debug_node_nr)++;
color += BKE_pbvh_debug_draw_gen_get(*node);
DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR(color));
}
#else /* Color coded leaf bounds. */
DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR((*debug_node_nr)++));
int color = (*debug_node_nr)++;
color += BKE_pbvh_debug_draw_gen_get(*node);
DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR(color));
#endif
}
@@ -1394,12 +1384,7 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
if (SCULPT_DEBUG_BUFFERS) {
int debug_node_nr = 0;
DRW_debug_modelmat(object.object_to_world().ptr());
BKE_pbvh_draw_debug_cb(
*pbvh,
(void (*)(
bke::pbvh::Node *n, void *d, const float min[3], const float max[3], PBVHNodeFlags f))
DRW_sculpt_debug_cb,
&debug_node_nr);
BKE_pbvh_draw_debug_cb(*pbvh, DRW_sculpt_debug_cb, &debug_node_nr);
}
}