Renderer/DebugDrawer: Add support for Frustum
This commit is contained in:
committed by
Jérôme Leclercq
parent
f572d229d9
commit
a5d4b8f28d
@@ -10,6 +10,7 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Frustum.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
@@ -40,6 +41,7 @@ namespace Nz
|
||||
void Draw(CommandBufferBuilder& builder);
|
||||
|
||||
inline void DrawBox(const Boxf& box, const Color& color);
|
||||
inline void DrawFrustum(const Frustumf& frustum, const Color& color);
|
||||
inline void DrawLine(const Vector3f& start, const Vector3f& end, const Color& color);
|
||||
inline void DrawLine(const Vector3f& start, const Vector3f& end, const Color& startColor, const Color& endColor);
|
||||
void DrawSkeleton(const Skeleton& skeleton, const Color& color);
|
||||
|
||||
@@ -26,6 +26,26 @@ namespace Nz
|
||||
DrawLine({ max.x, min.y, min.z }, { max.x, min.y, max.z }, color);
|
||||
}
|
||||
|
||||
inline void DebugDrawer::DrawFrustum(const Frustumf& frustum, const Color& color)
|
||||
{
|
||||
std::array<Vector3f, BoxCornerCount> corners;
|
||||
for (std::size_t i = 0; i < BoxCornerCount; ++i)
|
||||
corners[i] = frustum.ComputeCorner(static_cast<BoxCorner>(i));
|
||||
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::NearLeftBottom)], corners[UnderlyingCast(BoxCorner::NearRightBottom)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::NearLeftBottom)], corners[UnderlyingCast(BoxCorner::NearLeftTop)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::NearLeftBottom)], corners[UnderlyingCast(BoxCorner::FarLeftBottom)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::FarRightTop)], corners[UnderlyingCast(BoxCorner::FarLeftTop)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::FarRightTop)], corners[UnderlyingCast(BoxCorner::FarRightBottom)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::FarRightTop)], corners[UnderlyingCast(BoxCorner::NearRightTop)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::FarLeftBottom)], corners[UnderlyingCast(BoxCorner::FarRightBottom)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::FarLeftBottom)], corners[UnderlyingCast(BoxCorner::FarLeftTop)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::NearLeftTop)], corners[UnderlyingCast(BoxCorner::NearRightTop)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::NearLeftTop)], corners[UnderlyingCast(BoxCorner::FarLeftTop)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::NearRightBottom)], corners[UnderlyingCast(BoxCorner::NearRightTop)], color);
|
||||
DrawLine(corners[UnderlyingCast(BoxCorner::NearRightBottom)], corners[UnderlyingCast(BoxCorner::FarRightBottom)], color);
|
||||
}
|
||||
|
||||
inline void DebugDrawer::DrawLine(const Vector3f& start, const Vector3f& end, const Color& color)
|
||||
{
|
||||
return DrawLine(start, end, color, color);
|
||||
|
||||
Reference in New Issue
Block a user