[CORE][ADD] Ray Class Implementation

This commit is contained in:
Linloir 2022-12-18 16:06:40 +08:00
parent a924b4dd30
commit 4732c0810c
No known key found for this signature in database
GPG Key ID: 58EEB209A0F2C366
2 changed files with 4 additions and 7 deletions

View File

@ -1,6 +1,6 @@
#include "ray.h"
Ray Ray::toLocalSpace(glm::mat4 modelMatrix) {
Ray Ray::toLocalSpace(glm::mat4 modelMatrix) const {
// The model matrix is the matrix that transforms local space to world space
// Therefore the inverse of the model matrix transforms world space to local space
glm::mat4 inversedModelMatrix = glm::inverse(modelMatrix);

View File

@ -4,8 +4,8 @@
class Ray {
private:
glm::vec3 _origin;
glm::vec3 _direction;
glm::vec3 _origin = glm::vec3(0.0f);
glm::vec3 _direction = glm::vec3(0.0f, 0.0f, -1.0f);
public:
Ray() {}
@ -15,9 +15,6 @@ public:
inline glm::vec3 origin() const { return _origin; }
inline glm::vec3 direction() const { return _direction; }
inline void setOrigin(glm::vec3 origin) { _origin = origin; }
inline void setDirection(glm::vec3 direction) { _direction = direction; }
public:
Ray toLocalSpace(glm::mat4 modelMatrix);
Ray toLocalSpace(glm::mat4 modelMatrix) const;
};