From 4732c0810c2b0ec8c19ae281e77e8f6e58d85a33 Mon Sep 17 00:00:00 2001 From: Linloir <3145078758@qq.com> Date: Sun, 18 Dec 2022 16:06:40 +0800 Subject: [PATCH] [CORE][ADD] Ray Class Implementation --- FinalProject/ray.cpp | 2 +- FinalProject/ray.h | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/FinalProject/ray.cpp b/FinalProject/ray.cpp index ffef4ad..2b4bb82 100644 --- a/FinalProject/ray.cpp +++ b/FinalProject/ray.cpp @@ -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); diff --git a/FinalProject/ray.h b/FinalProject/ray.h index a0c2ab7..17fc3db 100644 --- a/FinalProject/ray.h +++ b/FinalProject/ray.h @@ -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; }; \ No newline at end of file