3#include <glm/gtc/quaternion.hpp>
4#include <glm/gtc/matrix_transform.hpp>
48 const std::string&
getName()
const {
return objectName; }
50 void setName(std::string name) { objectName = std::move(name); }
53 using PosMap = std::unordered_map<Physics::PhysicsBody*, glm::vec3>;
56 std::lock_guard<std::mutex> lk(posMapMutex);
61 std::lock_guard<std::mutex> lk(posMapMutex);
62 renderOrigin = origin;
65 std::lock_guard<std::mutex> lk(posMapMutex);
69 std::lock_guard<std::mutex> lk(posMapMutex);
70 return glm::translate(glm::mat4(1.0f), -renderOrigin);
74 inline static std::mutex posMapMutex;
75 inline static PosMap posMap{};
76 inline static glm::vec3 renderOrigin{0.0f};
84 std::unique_ptr<Physics::PhysicsBody> physicsBody =
nullptr;
87 glm::vec3 position {0.0f};
88 glm::vec3 rotation {0.0f};
89 glm::quat orientation {1.0f, 0.0f, 0.0f, 0.0f};
90 glm::vec3 scale {1.0f};
92 bool isHovered =
false;
95 std::string objectName;
97 glm::mat4 getRenderModelMatrix()
const;
98 glm::mat4 buildModelMatrix(
bool relativeToRenderOrigin)
const;
100 std::optional<float> intersectsAABB(
const Math::Ray& ray)
const;
101 std::optional<float> intersectsMesh(
const Math::Ray& ray)
const;
Core interfaces for the rendering system supporting both instanced and custom drawing.
Interface for objects that support mouse-based selection and interaction.
std::variant< ObjectOptions, PointMassOptions, RigidBodyOptions > CreationOptions
Interface for objects that support GPU instanced rendering.
Abstract interface for objects that can be selected and interacted with using the mouse.
GPU mesh representation with support for instanced rendering.
void setHovered(bool hovered) override
Sets the hover state of this object.
static glm::mat4 worldToRenderMatrix()
glm::mat4 getModelMatrix() const override
Gets the model transformation matrix for this instance.
CreationOptions getCreationOptions() const
glm::vec3 getRotation() const
void setScale(const glm::vec3 &scl)
glm::vec3 getPosition() const
glm::vec3 getScale() const
static glm::vec3 getRenderOrigin()
void handleClick(const Math::Ray &ray, float distance) override
Handles a mouse click on this object.
Rendering::InstanceData getInstanceData() const override
Gets the complete per-instance data for GPU upload.
void setRotation(const glm::vec3 &rot)
void setRotationQuat(const glm::quat &q)
const std::string & getMeshName() const
std::unordered_map< Physics::PhysicsBody *, glm::vec3 > PosMap
glm::quat getRotationQuat() const
Shader * getShader() const override
Gets the shader used to render this object.
Physics::PhysicsBody * getPhysicsBody() const
const std::string & getName() const
static void setPhysicsPosMap(const PosMap &m)
static void setRenderOrigin(const glm::vec3 &origin)
uint32_t getObjectID() const override
Gets the unique identifier for this object.
void setName(std::string name)
Mesh * getMesh() const override
Gets the mesh geometry for this object.
void setPosition(const glm::vec3 &pos)
std::optional< float > intersectsRay(const Math::Ray &ray) const override
Tests if a ray intersects this object's geometry.
bool getHovered() const override
Gets the current hover state of this object.
Represents a ray in 3D space.
Per-instance data for instanced rendering.