Skip to content

Commit

Permalink
Making modelViewProjectionMatrix internal
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardodoria committed Nov 14, 2024
1 parent 3e05878 commit a27a3d6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions engine/core/component/Transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace Supernova{

Matrix4 modelMatrix;
Matrix4 normalMatrix;

// internal use only, it depends of camera (same scene can have multiple cameras)
Matrix4 modelViewProjectionMatrix;

bool staticObject = false;
Expand Down
15 changes: 15 additions & 0 deletions engine/core/object/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ Vector3 Camera::getWorldRight() const{
return camera.worldRight;
}

Matrix4 Camera::getViewMatrix() const{
CameraComponent& camera = getComponent<CameraComponent>();
return camera.viewMatrix;
}

Matrix4 Camera::getProjectionMatrix() const{
CameraComponent& camera = getComponent<CameraComponent>();
return camera.projectionMatrix;
}

Matrix4 Camera::getViewProjectionMatrix() const{
CameraComponent& camera = getComponent<CameraComponent>();
return camera.viewProjectionMatrix;
}

void Camera::rotateView(float angle){
if (angle != 0){
CameraComponent& camera = getComponent<CameraComponent>();
Expand Down
4 changes: 4 additions & 0 deletions engine/core/object/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ namespace Supernova{
Vector3 getWorldUp() const;
Vector3 getWorldRight() const;

Matrix4 getViewMatrix() const;
Matrix4 getProjectionMatrix() const;
Matrix4 getViewProjectionMatrix() const;

void rotateView(float angle);
void rotatePosition(float angle);

Expand Down
5 changes: 0 additions & 5 deletions engine/core/object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ Matrix4 Object::getNormalMatrix() const{
return transform.normalMatrix;
}

Matrix4 Object::getModelViewProjectionMatrix() const{
Transform& transform = getComponent<Transform>();
return transform.modelViewProjectionMatrix;
}

void Object::addChild(Object* child){
scene->addEntityChild(this->entity, child->entity, false);
}
Expand Down
1 change: 0 additions & 1 deletion engine/core/object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ namespace Supernova{

Matrix4 getModelMatrix() const;
Matrix4 getNormalMatrix() const;
Matrix4 getModelViewProjectionMatrix() const;

void updateTransform();

Expand Down
4 changes: 3 additions & 1 deletion engine/core/script/binding/ObjectClassesLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ void LuaBinding::registerObjectClasses(lua_State *L){
.addProperty("localMatrix", &Object::getLocalMatrix, &Object::setLocalMatrix)
.addProperty("modelMatrix", &Object::getModelMatrix)
.addProperty("normalMatrix", &Object::getNormalMatrix)
.addProperty("modelViewProjectionMatrix", &Object::getModelViewProjectionMatrix)
.addFunction("updateTransform", &Object::updateTransform)
.addFunction("getBody2D", &Object::getBody2D)
.addFunction("removeBody2D", &Object::removeBody2D)
Expand Down Expand Up @@ -237,6 +236,9 @@ void LuaBinding::registerObjectClasses(lua_State *L){
.addFunction("getWorldDirection", &Camera::getWorldDirection)
.addFunction("getWorldUp", &Camera::getWorldUp)
.addFunction("getWorldRight", &Camera::getWorldRight)
.addFunction("getViewMatrix", &Camera::getViewMatrix)
.addFunction("getProjectionMatrix", &Camera::getProjectionMatrix)
.addFunction("getViewProjectionMatrix", &Camera::getViewProjectionMatrix)
.addFunction("rotateView", &Camera::rotateView)
.addFunction("rotatePosition", &Camera::rotatePosition)
.addFunction("elevateView", &Camera::elevateView)
Expand Down

0 comments on commit a27a3d6

Please sign in to comment.