/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include "Base/ICloseable.hpp" #include "Scene/IRayIntersectable.hpp" #include "DrawEncoder.hpp" #include #include #ifdef _WIN32 # undef TRANSPARENT #endif namespace OpenVulkano::Scene { class Node; class Scene; class Shader; enum class DrawPhase { BACKGROUND = 0, MAIN, TRANSPARENT, POST }; class Drawable : public ICloseable, public IRayIntersectable { std::vector m_nodes; Scene* m_scene = nullptr; Shader* m_shader = nullptr; const DrawEncoder m_encoder; const DrawPhase m_drawPhase; bool m_isHittable = false; public: explicit Drawable(const DrawEncoder& encoder, const DrawPhase phase = DrawPhase::MAIN) : m_encoder(encoder), m_drawPhase(phase) {} ~Drawable() override {/* if (m_scene) Drawable::Close();*/ } void Close() override; void SetShader(Shader* shader) { m_shader = shader; } std::optional Intersect(const Ray& ray) const override { return {}; } void SetIsHittable(bool hittable) { m_isHittable = hittable; } bool IsHittable() const { return m_isHittable; } [[nodiscard]] Scene* GetScene() const { return m_scene; } [[nodiscard]] const auto& GetNodes() const { return m_nodes; } [[nodiscard]] const DrawEncoder& GetEncoder() const { return m_encoder; } [[nodiscard]] DrawPhase GetDrawPhase() const { return m_drawPhase; } [[nodiscard]] Shader* GetShader() const { return m_shader; } private: friend class Node; friend class Scene; void SetScene(Scene* scene); void AddNode(Node* node); void RemoveNode(Node* node); }; }