Add Physics Colliders debug view mode to display physical world shapes (solid)

This commit is contained in:
Wojtek Figat
2021-07-14 14:49:41 +02:00
parent 151b478a97
commit 04c6ecc963
13 changed files with 69 additions and 18 deletions

View File

@@ -63,13 +63,23 @@ bool MeshCollider::CanBeTrigger() const
#if USE_EDITOR
#include "Engine/Debug/DebugDraw.h"
#include "Engine/Graphics/RenderView.h"
void MeshCollider::DrawPhysicsDebug(RenderView& view)
{
if (CollisionData && CollisionData->IsLoaded())
{
const auto& debugLines = CollisionData->GetDebugLines();
DEBUG_DRAW_LINES(Span<Vector3>(debugLines.Get(), debugLines.Count()), _transform.GetWorld(), Color::GreenYellow * 0.8f, 0, true);
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
{
Array<Vector3>* vertexBuffer;
Array<int32>* indexBuffer;
CollisionData->GetDebugTriangles(vertexBuffer, indexBuffer);
DebugDraw::DrawTriangles(*vertexBuffer, *indexBuffer, _transform.GetWorld(), _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
}
else
{
DebugDraw::DrawLines(CollisionData->GetDebugLines(), _transform.GetWorld(), Color::GreenYellow * 0.8f, 0, true);
}
}
}