Optimize physics shapes debug drawing for large scenes by using culling for colliders

This commit is contained in:
Wojtek Figat
2021-11-04 15:59:41 +01:00
parent 6dfedd219b
commit 568c70f2f7
5 changed files with 10 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ void BoxCollider::SetSize(const Vector3& value)
void BoxCollider::DrawPhysicsDebug(RenderView& view)
{
if (!view.CullingFrustum.Intersects(_sphere))
return;
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
DebugDraw::DrawBox(_bounds, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
else

View File

@@ -41,6 +41,8 @@ void CapsuleCollider::SetHeight(const float value)
void CapsuleCollider::DrawPhysicsDebug(RenderView& view)
{
if (!view.CullingFrustum.Intersects(_sphere))
return;
Quaternion rot;
Quaternion::Multiply(_transform.Orientation, Quaternion::Euler(0, 90, 0), rot);
const float scaling = _cachedScale.GetAbsolute().MaxValue();

View File

@@ -69,6 +69,8 @@ void MeshCollider::DrawPhysicsDebug(RenderView& view)
{
if (CollisionData && CollisionData->IsLoaded())
{
if (!view.CullingFrustum.Intersects(_sphere))
return;
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
{
Array<Vector3>* vertexBuffer;

View File

@@ -29,6 +29,8 @@ void SphereCollider::SetRadius(const float value)
void SphereCollider::DrawPhysicsDebug(RenderView& view)
{
if (!view.CullingFrustum.Intersects(_sphere))
return;
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
DebugDraw::DrawSphere(_sphere, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
else

View File

@@ -90,6 +90,8 @@ bool SplineCollider::CanBeTrigger() const
void SplineCollider::DrawPhysicsDebug(RenderView& view)
{
if (!view.CullingFrustum.Intersects(_sphere))
return;
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
DebugDraw::DrawTriangles(_vertexBuffer, _indexBuffer, Color::CornflowerBlue, 0, true);
else