feat: add line renderer / visualisations for box collidors as a test
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#ifndef DESTRUM_LINERENDERINGMANAGER_H
|
||||
#define DESTRUM_LINERENDERINGMANAGER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
|
||||
#include <destrum/Singleton.h>
|
||||
|
||||
struct Line {
|
||||
glm::vec3 start{};
|
||||
glm::vec3 end{};
|
||||
glm::vec4 color{1.0f};
|
||||
};
|
||||
|
||||
class LineRenderingManager final : public Singleton<LineRenderingManager> {
|
||||
public:
|
||||
friend class Singleton<LineRenderingManager>;
|
||||
|
||||
void SubmitLine(const Line& line);
|
||||
void SubmitLine(
|
||||
const glm::vec3& start,
|
||||
const glm::vec3& end,
|
||||
const glm::vec4& color = glm::vec4{1.0f});
|
||||
|
||||
[[nodiscard]] const std::vector<Line>& GetLines() const { return lines; }
|
||||
|
||||
void ClearLines();
|
||||
|
||||
private:
|
||||
LineRenderingManager() = default;
|
||||
|
||||
std::vector<Line> lines;
|
||||
};
|
||||
|
||||
#endif // DESTRUM_LINERENDERINGMANAGER_H
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef DESTRUM_LINERENDERINGPASS_H
|
||||
#define DESTRUM_LINERENDERINGPASS_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include <destrum/Graphics/Managers/LineRenderingManager.h>
|
||||
#include <destrum/Graphics/Resources/NBuffer.h>
|
||||
|
||||
class Camera;
|
||||
class GfxDevice;
|
||||
struct GPUImage;
|
||||
class Pipeline;
|
||||
|
||||
class LineRenderingPass final {
|
||||
public:
|
||||
void init(GfxDevice& gfxDevice, VkFormat drawImageFormat);
|
||||
void draw(
|
||||
VkCommandBuffer cmd,
|
||||
GfxDevice& gfxDevice,
|
||||
const GPUImage& target,
|
||||
const Camera& camera,
|
||||
LineRenderingManager& lineManager);
|
||||
void cleanup(GfxDevice& gfxDevice);
|
||||
|
||||
private:
|
||||
struct LineVertex {
|
||||
glm::vec4 position;
|
||||
glm::vec4 color;
|
||||
};
|
||||
|
||||
void ensureVertexCapacity(GfxDevice& gfxDevice, std::size_t requiredVertices);
|
||||
|
||||
VkPipelineLayout pipelineLayout{VK_NULL_HANDLE};
|
||||
std::unique_ptr<Pipeline> pipeline;
|
||||
NBuffer vertexBuffer;
|
||||
std::size_t vertexCapacity{0};
|
||||
};
|
||||
|
||||
#endif // DESTRUM_LINERENDERINGPASS_H
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include <destrum/Graphics/Camera.h>
|
||||
#include <destrum/Graphics/Pipelines/LineRenderingPass.h>
|
||||
#include <destrum/Graphics/Pipelines/MeshPipeline.h>
|
||||
#include <destrum/Graphics/ids.h>
|
||||
#include <destrum/Graphics/MeshDrawCommand.h>
|
||||
@@ -111,6 +112,7 @@ private:
|
||||
|
||||
std::unique_ptr<MeshPipeline> meshPipeline;
|
||||
std::unique_ptr<SkyboxPipeline> skyboxPipeline;
|
||||
std::unique_ptr<LineRenderingPass> lineRenderingPass;
|
||||
|
||||
std::unique_ptr<SkinningPipeline> skinningPipeline;
|
||||
bool initialized{false};
|
||||
|
||||
Reference in New Issue
Block a user