Skip to content

Commit

Permalink
inline frustum_intersection_test function to prevent accidental perf …
Browse files Browse the repository at this point in the history
…footgun; disable debug-assertions in wgpu-types to prevent validation layers from being enable since gfx-rs/wgpu#4230
  • Loading branch information
Davidster committed Feb 19, 2024
1 parent 44f7ce9 commit d97f548
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ opt-level = 3
[profile.dev.package."wgpu-core"]
debug-assertions = false

[profile.dev.package."wgpu-types"]
debug-assertions = false

# [profile.dev.package."wgpu"]
# debug-assertions = false

Expand Down
12 changes: 1 addition & 11 deletions ikari/src/collisions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,7 @@ impl From<CameraFrustumDescriptor> for Frustum {
}

impl CameraFrustumDescriptor {
// TODO: this function is slow due to the calls to to_convex_polyhedron. should cache the convex polyhedra.
pub fn frustum_intersection_test(&self, other: &CameraFrustumDescriptor) -> bool {
rapier3d_f64::parry::query::intersection_test(
&rapier3d_f64::na::Isometry::identity(),
&self.to_convex_polyhedron(),
&rapier3d_f64::na::Isometry::identity(),
&other.to_convex_polyhedron(),
)
.unwrap()
}

/// this is not free. consider caching the result
pub fn to_convex_polyhedron(&self) -> ConvexPolyhedron {
let points: Vec<_> = self
.to_basic_mesh()
Expand Down
18 changes: 15 additions & 3 deletions ikari/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3334,8 +3334,14 @@ impl Renderer {
};
let debug_culling_frustum_mesh = debug_frustum_descriptor.to_basic_mesh();

let collision_based_color = if frustum_descriptor
.frustum_intersection_test(main_culling_frustum_desc)
let identity = rapier3d_f64::na::Isometry::identity();
let collision_based_color = if rapier3d_f64::parry::query::intersection_test(
&identity,
&frustum_descriptor.to_convex_polyhedron(),
&identity,
&main_culling_frustum_desc.to_convex_polyhedron(),
)
.unwrap()
{
Vec4::new(0.0, 1.0, 0.0, 0.1)
} else {
Expand Down Expand Up @@ -4038,7 +4044,13 @@ impl Renderer {
// that are inside the main view so we can completely skip the shadow map
// render pass for this light view
let is_light_view_culled = if USE_EXTRA_SHADOW_MAP_CULLING {
!desc.frustum_intersection_test(&culling_frustum_desc)
!rapier3d_f64::parry::query::intersection_test(
&rapier3d_f64::na::Isometry::identity(),
&desc.to_convex_polyhedron(),
&rapier3d_f64::na::Isometry::identity(),
&culling_frustum_desc.to_convex_polyhedron(),
)
.unwrap()
} else {
false
};
Expand Down

0 comments on commit d97f548

Please sign in to comment.