Cleanup: Sculpt: Remove PBVH frustum plane and related calculation

The recent refactor of sculpt mode drawing (d601bf7e) removed usage of
the update frustum planes. This makes storage of this data inside the
PBVH also unnecessary. If this feature needs to be reimplemented in the
future, the storage of the planes should be outside of the PBVH `struct`

Pull Request: https://projects.blender.org/blender/blender/pulls/129649
This commit is contained in:
Sean Kim
2024-10-31 21:10:31 +01:00
committed by Sean Kim
parent 77a7671f54
commit 3ff2733279
4 changed files with 0 additions and 56 deletions

View File

@@ -235,10 +235,6 @@ class Tree {
*/
BitVector<> visibility_dirty_;
/** \todo Remove and store elsewhere. */
float planes_[6][4];
int num_planes_ = 0;
pixels::PBVHData *pixels_ = nullptr;
std::unique_ptr<DrawCache> draw_data;
@@ -395,10 +391,6 @@ bool find_nearest_to_ray_node(Tree &pbvh,
float *depth,
float *dist_sq);
/* Drawing */
void set_frustum_planes(Tree &pbvh, PBVHFrustumPlanes *planes);
void get_frustum_planes(const Tree &pbvh, PBVHFrustumPlanes *planes);
/**
* Get the Tree root's bounding box.
*/

View File

@@ -2405,22 +2405,6 @@ void BKE_pbvh_vert_coords_apply(blender::bke::pbvh::Tree &pbvh,
namespace blender::bke::pbvh {
void set_frustum_planes(Tree &pbvh, PBVHFrustumPlanes *planes)
{
pbvh.num_planes_ = planes->num_planes;
for (int i = 0; i < pbvh.num_planes_; i++) {
copy_v4_v4(pbvh.planes_[i], planes->planes[i]);
}
}
void get_frustum_planes(const Tree &pbvh, PBVHFrustumPlanes *planes)
{
planes->num_planes = pbvh.num_planes_;
for (int i = 0; i < planes->num_planes; i++) {
copy_v4_v4(planes->planes[i], pbvh.planes_[i]);
}
}
static Span<float3> vert_positions_eval(const Object &object_orig, const Object &object_eval)
{
const SculptSession &ss = *object_orig.sculpt;

View File

@@ -1330,7 +1330,6 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
const DRWContextState *drwctx = DRW_context_state_get();
RegionView3D *rv3d = drwctx->rv3d;
const bool navigating = rv3d && (rv3d->rflag & RV3D_NAVIGATING);
Paint *paint = nullptr;
if (drwctx->evil_C != nullptr) {
@@ -1338,28 +1337,9 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
}
/* Frustum planes to show only visible pbvh::Tree nodes. */
float update_planes[6][4];
float draw_planes[6][4];
PBVHFrustumPlanes update_frustum;
PBVHFrustumPlanes draw_frustum;
if (paint && (paint->flags & PAINT_SCULPT_DELAY_UPDATES)) {
update_frustum.planes = update_planes;
update_frustum.num_planes = 6;
bke::pbvh::get_frustum_planes(*pbvh, &update_frustum);
if (!navigating) {
drw_sculpt_get_frustum_planes(scd->ob, update_planes);
update_frustum.planes = update_planes;
update_frustum.num_planes = 6;
bke::pbvh::set_frustum_planes(*pbvh, &update_frustum);
}
}
else {
drw_sculpt_get_frustum_planes(scd->ob, update_planes);
update_frustum.planes = update_planes;
update_frustum.num_planes = 6;
}
drw_sculpt_get_frustum_planes(scd->ob, draw_planes);
draw_frustum.planes = draw_planes;
draw_frustum.num_planes = 6;

View File

@@ -59,8 +59,6 @@ static Vector<SculptBatch> sculpt_batches_get_ex(const Object *ob,
/* Frustum planes to show only visible pbvh::Tree nodes. */
float4 draw_planes[6];
PBVHFrustumPlanes draw_frustum = {reinterpret_cast<float(*)[4]>(draw_planes), 6};
float4 update_planes[6];
PBVHFrustumPlanes update_frustum = {reinterpret_cast<float(*)[4]>(update_planes), 6};
/* TODO: take into account partial redraw for clipping planes. */
DRW_view_frustum_planes_get(DRW_view_default_get(), draw_frustum.planes);
@@ -70,16 +68,6 @@ static Vector<SculptBatch> sculpt_batches_get_ex(const Object *ob,
float4x4 tmat = math::transpose(ob->object_to_world());
for (int i : IndexRange(6)) {
draw_planes[i] = tmat * draw_planes[i];
update_planes[i] = draw_planes[i];
}
if (paint && (paint->flags & PAINT_SCULPT_DELAY_UPDATES)) {
if (navigating) {
bke::pbvh::get_frustum_planes(*pbvh, &update_frustum);
}
else {
bke::pbvh::set_frustum_planes(*pbvh, &update_frustum);
}
}
/* Fast mode to show low poly multires while navigating. */