Skip to content

Commit

Permalink
fixed culling by distance in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Mar 21, 2024
1 parent 9a02374 commit 5cd6e5c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/3d/render_instances.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,33 +114,34 @@ class DelayedRenderer {
bool update_visibility(std::shared_ptr<GeometryPoolCullingData> t_distance_data, bool _skip_expiration_check) {
// ZoneScoped;
if (_skip_expiration_check || !is_expired()) {
is_visible = false;
is_visible = true;

if (t_distance_data->m_max_distance > 0 && t_distance_data->m_camera_positions.size()) {
bool in_radius = false;
for (const auto &pos : t_distance_data->m_camera_positions) {
if (pos.distance_to(bounds.position) > t_distance_data->m_max_distance) {
is_visible = false;
return is_visible;
if (pos.distance_to(bounds.position) < t_distance_data->m_max_distance) {
is_visible = true;
in_radius = true;
break;
}
}
if (!in_radius)
return is_visible = false;
}

// TODO mb move to draw_* for instant draws
if (t_distance_data->m_frustums.size()) {
for (const auto &frustum : t_distance_data->m_frustums) {
if (MathUtils::is_bounds_partially_inside_convex_shape(bounds, frustum)) {
is_visible = true;
return is_visible;
return is_visible = true;
}
}
return false;
return is_visible = false;
} else {
is_visible = true;
return is_visible;
return is_visible = true;
}
}
is_visible = false;
return is_visible;
return is_visible = false;
}

void update_expiration(const double &_delta) {
Expand Down

0 comments on commit 5cd6e5c

Please sign in to comment.