[GHI 2178] Vegetation Debugger info was sometimes getting culled (#2209)
* [GHI 2178] Fixed missing vegetation info The entity debug drawing culling system was removing it due to the level entity not having an AABB. Since this component can draw infinitely far, it just needed a max AABB. With the culling fixed, it made another culling problem evident - a bug in the font code where it wasn't culling 3D text rendered behind the camera. Now it is. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Fix problem with debug rendering not immediately showing up. When using FloatMax for the AABB, it causes math overflows with the initial camera frustrum. Changing to max/2.0f is sufficient to avoid the overflows. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Fixed normals on mesh raycasts. The normals needed to be normalized after transformation, and didn't need the non-uniform scale applied to them, since they're normals. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Fixed the bug that prevented max-size AABBs from working with ShapeIntersection::Overlap. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
This commit is contained in:
@@ -130,7 +130,11 @@ namespace AZ
|
||||
//So for each plane, we can test compare the center-to-plane distance to this interval to see which side of the plane the AABB is on.
|
||||
//The AABB is not overlapping if it is fully behind any of the planes, otherwise it is overlapping.
|
||||
const Vector3 center = aabb.GetCenter();
|
||||
const Vector3 extents = 0.5f * aabb.GetExtents();
|
||||
|
||||
//If the AABB contains FLT_MAX at either (or both) extremes, it would be easy to overflow here by using "0.5f * GetExtents()"
|
||||
//or "0.5f * (GetMax() - GetMin())". By separating into two separate multiplies before the subtraction, we can ensure
|
||||
//that we don't overflow.
|
||||
const Vector3 extents = (0.5f * aabb.GetMax()) - (0.5f * aabb.GetMin());
|
||||
|
||||
for (Frustum::PlaneId planeId = Frustum::PlaneId::Near; planeId < Frustum::PlaneId::MAX; ++planeId)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace UnitTest
|
||||
AZ::Aabb unitBox = AZ::Aabb::CreateCenterHalfExtents(AZ::Vector3::CreateZero(), AZ::Vector3(1.f, 1.f, 1.f));
|
||||
AZ::Aabb aabb = AZ::Aabb::CreateCenterHalfExtents(AZ::Vector3(10.f, 10.f, 10.f), AZ::Vector3(1.f, 1.f, 1.f));
|
||||
AZ::Aabb aabb1 = AZ::Aabb::CreateCenterHalfExtents(AZ::Vector3(10.f, 10.f, 10.f), AZ::Vector3(100.f, 100.f, 100.f));
|
||||
AZ::Aabb maxSizeAabb = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-AZ::Constants::FloatMax), AZ::Vector3(AZ::Constants::FloatMax));
|
||||
|
||||
AZ::Vector3 point(0.f, 0.f, 0.f);
|
||||
AZ::Vector3 point1(10.f, 10.f, 10.f);
|
||||
@@ -73,6 +74,10 @@ namespace UnitTest
|
||||
EXPECT_TRUE(AZ::ShapeIntersection::Overlaps(frustum, aabb1));
|
||||
EXPECT_TRUE(AZ::ShapeIntersection::Overlaps(sphere1, far_value));
|
||||
|
||||
// Verify that an AABB that covers the max floating point range successfully overlaps with a frustum and doesn't hit any
|
||||
// floating-point math overflows.
|
||||
EXPECT_TRUE(AZ::ShapeIntersection::Overlaps(frustum, maxSizeAabb));
|
||||
|
||||
EXPECT_FALSE(AZ::ShapeIntersection::Overlaps(frustum, aabb));
|
||||
EXPECT_FALSE(AZ::ShapeIntersection::Overlaps(unitSphere, aabb));
|
||||
EXPECT_FALSE(AZ::ShapeIntersection::Overlaps(unitSphere, sphere2));
|
||||
|
||||
Reference in New Issue
Block a user