Commit acfd51dc authored by Bastian Krayer's avatar Bastian Krayer

small cvk changes to unify some getters and setters

parent 50f1b4c0
......@@ -72,7 +72,7 @@ void charCallback(GLFWwindow* window, unsigned int key) {
void resizeCallback(GLFWwindow* window, int w, int h) {
cam_trackball->setWidthHeight(w, h);
cam_trackball->getProjection()->updateRatio(w / (float)h);
cam_trackball->getProjection().updateRatio(w / (float)h);
glViewport(0, 0, w, h);
}
......
......@@ -36,7 +36,7 @@ class Camera {
* @brief Getter for the view matrix
* @return a pointer to the view matrix
*/
glm::mat4* getView();
const glm::mat4& getView() const;
/**
* Returns the view matrix corresponding to this Camera as pointer
* arguments.
......@@ -88,7 +88,8 @@ class Camera {
* @brief Getter for the projection matrix
* @return the projection matrix as pointer
*/
CVK::Projection* getProjection() const;
CVK::Projection& getProjection();
const CVK::Projection& getProjection() const;
protected:
GLFWwindow* m_window =
......
......@@ -6,8 +6,6 @@ Camera::Camera(GLFWwindow* window) : m_window(window) {}
Camera::~Camera() = default;
glm::mat4* Camera::getView() { return &m_viewmatrix; }
void Camera::getView(glm::vec3* x, glm::vec3* y, glm::vec3* z,
glm::vec3* pos) const {
*x = glm::vec3(glm::row(m_viewmatrix, 0));
......@@ -39,6 +37,8 @@ void Camera::setProjection(Projection* projection) {
m_projection = projection;
}
Projection* Camera::getProjection() const { return m_projection; }
Projection& Camera::getProjection() { return *m_projection; }
const CVK::Projection& Camera::getProjection() const { return *m_projection; }
const glm::mat4& Camera::getView() const { return m_viewmatrix; }
} // namespace CVK
\ No newline at end of file
......@@ -19,11 +19,7 @@ Node::Node(const std::string& name, const std::string& path) {
load(path);
}
Node::~Node() {
for (auto& c : m_children) {
delete c;
}
}
Node::~Node() = default;
void Node::init() {
m_name = "";
......
......@@ -19,8 +19,8 @@ void ShaderMinimal::update() {
glm::mat4 projection, viewmatrix;
if (cam != nullptr) {
viewmatrix = *cam->getView();
projection = cam->getProjection()->getProjMatrix();
viewmatrix = cam->getView();
projection = cam->getProjection().getProjMatrix();
}
glUniformMatrix4fv(m_viewMatrixID, 1, GL_FALSE, glm::value_ptr(viewmatrix));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment