Small optimization, no having to recompute a matrix for all objects
This commit is contained in:
@@ -60,8 +60,10 @@ void initRenderer(GLFWwindow* window, CommandLineOptions options) {
|
||||
|
||||
// traverses and updates matricies
|
||||
void updateNodeTransformations(SceneNode* node, mat4 transformationThusFar, mat4 const& V, mat4 const& P) {
|
||||
mat4 transformationMatrix
|
||||
= glm::translate(mat4(1.0), node->position)
|
||||
mat4 M = (node->has_no_transforms())
|
||||
? transformationThusFar
|
||||
: transformationThusFar
|
||||
* glm::translate(mat4(1.0), node->position)
|
||||
* glm::translate(mat4(1.0), node->referencePoint)
|
||||
* glm::rotate(mat4(1.0), node->rotation.z, vec3(0,0,1))
|
||||
* glm::rotate(mat4(1.0), node->rotation.y, vec3(0,1,0))
|
||||
@@ -69,8 +71,6 @@ void updateNodeTransformations(SceneNode* node, mat4 transformationThusFar, mat4
|
||||
* glm::scale(mat4(1.0), node->scale)
|
||||
* glm::translate(mat4(1.0), -node->referencePoint);
|
||||
|
||||
mat4 M = transformationThusFar * transformationMatrix;
|
||||
|
||||
node->MV = V*M;
|
||||
node->MVP = P*node->MV;
|
||||
node->MVnormal = glm::inverse(glm::transpose(node->MV));
|
||||
|
||||
Reference in New Issue
Block a user