// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_RENDERER_DEBUGDRAWER_HPP #define NAZARA_RENDERER_DEBUGDRAWER_HPP #include #include #include #include #include #include #include #include #include #include namespace Nz { class CommandBufferBuilder; class RenderBuffer; class RenderFrame; class RenderDevice; class RenderPipeline; class RenderPipelineLayout; class ShaderBinding; class Skeleton; class NAZARA_RENDERER_API DebugDrawer { public: DebugDrawer(RenderDevice& renderDevice, std::size_t maxVertexPerDraw = DefaultVertexBlockSize); DebugDrawer(const DebugDrawer&) = delete; DebugDrawer(DebugDrawer&&) noexcept = default; ~DebugDrawer(); void Draw(CommandBufferBuilder& builder); inline void DrawBox(const Boxf& box, 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); void Prepare(RenderFrame& renderFrame); void Reset(RenderFrame& renderFrame); void SetViewerData(const Matrix4f& viewProjMatrix); DebugDrawer& operator=(const DebugDrawer&) = delete; DebugDrawer& operator=(DebugDrawer&&) = delete; static constexpr std::size_t DefaultVertexBlockSize = 4096; private: struct ViewerData { std::shared_ptr buffer; std::shared_ptr binding; }; struct DataPool { std::vector> vertexBuffers; std::vector viewerData; }; struct DrawCall { std::shared_ptr vertexBuffer; std::size_t vertexCount; }; struct PendingUpload { UploadPool::Allocation* allocation; RenderBuffer* vertexBuffer; }; std::shared_ptr m_dataPool; std::shared_ptr m_renderPipeline; std::shared_ptr m_renderPipelineLayout; std::size_t m_vertexPerBlock; std::vector m_drawCalls; std::vector m_pendingUploads; std::vector m_viewerData; std::vector m_lineVertices; RenderDevice& m_renderDevice; ViewerData m_currentViewerData; bool m_viewerDataUpdated; }; } #include #endif // NAZARA_RENDERER_DEBUGDRAWER_HPP