From fcfd3e1e3dc5449674aae2814d17c793a80dcbed Mon Sep 17 00:00:00 2001 From: aszabo314 Date: Wed, 27 Sep 2023 14:15:14 +0200 Subject: [PATCH] ### 5.2.27 - [LodTreeInstance] intersect view frustum depth range to -1 +1 --- RELEASE_NOTES.md | 3 ++ .../LodTreeInstance.fs | 42 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 2adb89b2..439c1f56 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +### 5.2.27 +- [LodTreeInstance] intersect view frustum depth range to -1 +1 + ### 5.2.26 - [LodTreeInstance] ShouldSplit vfc diff --git a/src/Aardvark.Rendering.PointSet/LodTreeInstance.fs b/src/Aardvark.Rendering.PointSet/LodTreeInstance.fs index db96ab8d..95df23dd 100644 --- a/src/Aardvark.Rendering.PointSet/LodTreeInstance.fs +++ b/src/Aardvark.Rendering.PointSet/LodTreeInstance.fs @@ -323,13 +323,51 @@ module LodTreeInstance = else 0.0 - + let intersectsFrustum (vp : M44d) (box : Box3d) = + let r0 = vp.R0 + let r1 = vp.R1 + let r2 = vp.R2 + let r3 = vp.R3 + let plane = r3 + r0 + let mutable min = V3d.Zero + let mutable max = V3d.Zero + box.GetMinMaxInDirection(plane.XYZ, &min, &max) + if max.Dot(plane.XYZ) + plane.W < 0 then + false + else + let plane = r3 - r0 + box.GetMinMaxInDirection(plane.XYZ, &min, &max) + if max.Dot(plane.XYZ) + plane.W < 0 then + false + else + let plane = r3 + r1 + box.GetMinMaxInDirection(plane.XYZ, &min, &max) + if max.Dot(plane.XYZ) + plane.W < 0 then + false + else + let plane = r3 - r1 + box.GetMinMaxInDirection(plane.XYZ, &min, &max) + if max.Dot(plane.XYZ) + plane.W < 0 then + false + else + let plane = r3 + r2 + box.GetMinMaxInDirection(plane.XYZ, &min, &max) + if max.Dot(plane.XYZ) + plane.W < 0 then + false + else + let plane = r3 - r2 + box.GetMinMaxInDirection(plane.XYZ, &min, &max) + if max.Dot(plane.XYZ) + plane.W < 0 then + false + else + true let fov (proj : Trafo3d) = 2.0 * atan(proj.Backward.M00) * Constant.DegreesPerRadian let equivalentAngle60 (view : Trafo3d) (proj : Trafo3d) = - if localCellBounds.IntersectsFrustum((view * proj).Forward) then + let vp = (view * proj).Forward + if intersectsFrustum vp localCellBounds then if isOrtho proj then let width = proj.Backward.M00 * 2.0