introduce intersectable interface

This commit is contained in:
ohyzha
2024-11-04 18:20:32 +02:00
parent 4f3336014a
commit 4956884d5f
6 changed files with 95 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
#pragma once
#include "Base/ICloseable.hpp"
#include "Scene/IRayIntersectable.hpp"
#include "DrawEncoder.hpp"
#include <memory>
#include <vector>
@@ -26,13 +27,14 @@ namespace OpenVulkano::Scene
BACKGROUND = 0, MAIN, TRANSPARENT, POST
};
class Drawable : public ICloseable
class Drawable : public ICloseable, public IRayIntersectable
{
std::vector<Node*> 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,
@@ -45,6 +47,12 @@ namespace OpenVulkano::Scene
void SetShader(Shader* shader) { m_shader = shader; }
std::optional<RayHit> 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; }