rework API

This commit is contained in:
ohyzha
2024-11-06 09:48:53 +02:00
parent e2df88ca22
commit 3521ddeb1d
21 changed files with 296 additions and 230 deletions

View File

@@ -13,14 +13,26 @@
namespace OpenVulkano::Scene
{
class Drawable;
class Node;
struct RayHit
{
Math::Vector3f point;
Math::Vector3f normal;
float distance;
bool operator==(const RayHit& other) const = default;
bool operator!=(const RayHit& other) const = default;
float distance2;
[[nodiscard]] float GetDistance() const
{
if (distance == -1)
{
distance = std::sqrt(distance2);
}
return distance;
}
bool operator==(const RayHit& other) const;
bool operator!=(const RayHit& other) const;
friend class Ray;
private:
mutable float distance = -1;
};
struct DrawableRayHit : RayHit
@@ -28,6 +40,7 @@ namespace OpenVulkano::Scene
DrawableRayHit() = default;
DrawableRayHit(const RayHit& hit) : RayHit(hit) {};
Drawable* drawable = nullptr;
Node* node = nullptr;
};
class Ray