Move Drawable draw call recording logic out of renderer
This commit is contained in:
@@ -7,53 +7,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "Base/ICloseable.hpp"
|
||||
#include "DrawEncoder.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace openVulkanoCpp::Scene
|
||||
{
|
||||
class Node;
|
||||
class Scene;
|
||||
class Geometry;
|
||||
class Material;
|
||||
|
||||
class Drawable : virtual public ICloseable
|
||||
class Drawable
|
||||
{
|
||||
std::vector<Node*> m_nodes;
|
||||
Scene* m_scene = nullptr;
|
||||
Geometry* m_mesh = nullptr;
|
||||
Material* m_material = nullptr;
|
||||
const DrawEncoder m_encoder;
|
||||
|
||||
public:
|
||||
Drawable() = default;
|
||||
explicit Drawable(const DrawEncoder& encoder) : m_encoder(encoder) {}
|
||||
|
||||
explicit Drawable(const Drawable* toCopy)
|
||||
{
|
||||
m_mesh = toCopy->m_mesh;
|
||||
m_material = toCopy->m_material;
|
||||
}
|
||||
~Drawable() { if (m_scene) Drawable::Close(); }
|
||||
|
||||
~Drawable() override
|
||||
{
|
||||
if (m_mesh) Drawable::Close();
|
||||
}
|
||||
void Close();
|
||||
|
||||
[[nodiscard]] Drawable* Copy() const
|
||||
{
|
||||
return new Drawable(this);
|
||||
}
|
||||
|
||||
void Init(Geometry* mesh, Material* material);
|
||||
|
||||
void Init(Drawable* drawable);
|
||||
|
||||
void Close() override;
|
||||
[[nodiscard]] virtual Drawable* Copy() = 0;
|
||||
|
||||
[[nodiscard]] Scene* GetScene() const { return m_scene; }
|
||||
|
||||
[[nodiscard]] Geometry* GetMesh() const { return m_mesh; }
|
||||
|
||||
[[nodiscard]] const auto& GetNodes() const { return m_nodes; }
|
||||
|
||||
[[nodiscard]] const DrawEncoder& GetEncoder() const { return m_encoder; }
|
||||
|
||||
private:
|
||||
friend class Node;
|
||||
friend class Scene;
|
||||
|
||||
Reference in New Issue
Block a user