Move Drawable draw call recording logic out of renderer
This commit is contained in:
@@ -10,19 +10,24 @@
|
||||
|
||||
namespace openVulkanoCpp::Scene
|
||||
{
|
||||
void Drawable::Close()
|
||||
{
|
||||
if (!m_nodes.empty()) throw std::runtime_error("Drawable is still being used!!!");
|
||||
m_scene = nullptr;
|
||||
}
|
||||
|
||||
void Drawable::SetScene(Scene* scene)
|
||||
{
|
||||
if (m_scene == scene) return;
|
||||
if (scene && m_scene) throw std::runtime_error("Drawable has been associated with a scene already!");
|
||||
const auto oldScene = m_scene;
|
||||
m_scene = scene;
|
||||
if(scene) scene->RegisterDrawable(this);
|
||||
if (scene) scene->RegisterDrawable(this);
|
||||
else if (oldScene) oldScene->RemoveDrawable(this);
|
||||
}
|
||||
|
||||
void Drawable::AddNode(Node* node)
|
||||
{
|
||||
if (!m_mesh) throw std::runtime_error("Drawable is not initialized.");
|
||||
if (Utils::Contains(m_nodes, node)) throw std::runtime_error("A drawable must not use the same node more than once.");
|
||||
m_nodes.push_back(node);
|
||||
}
|
||||
@@ -36,25 +41,4 @@ namespace openVulkanoCpp::Scene
|
||||
m_scene = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Drawable::Init(Geometry* mesh, Material* material)
|
||||
{
|
||||
if (m_mesh || m_material) throw std::runtime_error("Drawable is already initialized.");
|
||||
m_mesh = mesh;
|
||||
m_material = material;
|
||||
}
|
||||
|
||||
void Drawable::Init(Drawable* drawable)
|
||||
{
|
||||
if (m_mesh || m_material) throw std::runtime_error("Drawable is already initialized.");
|
||||
m_mesh = drawable->m_mesh;
|
||||
m_material = drawable->m_material;
|
||||
}
|
||||
|
||||
void Drawable::Close()
|
||||
{
|
||||
if (!m_nodes.empty()) throw std::runtime_error("Drawable is still being used!!!");
|
||||
m_mesh = nullptr;
|
||||
m_material = nullptr;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user