diff --git a/src/main.cpp b/src/main.cpp index ea8bfcf..6e94f6f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -108,12 +108,15 @@ void processInput(GLFWwindow* window) { shiftFactor *= deltaTime; if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) { parts.back().rotation.x += shiftFactor; + syncPartPhysics(parts.back()); } if (glfwGetKey(window, GLFW_KEY_Y) == GLFW_PRESS) { parts.back().rotation.y += shiftFactor; + syncPartPhysics(parts.back()); } if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) { parts.back().rotation.z += shiftFactor; + syncPartPhysics(parts.back()); } } } @@ -165,22 +168,28 @@ void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods if (mode == 0) { if (key == GLFW_KEY_X && action == GLFW_PRESS) { parts.back().position.x += shiftFactor; + syncPartPhysics(parts.back()); } if (key == GLFW_KEY_Y && action == GLFW_PRESS) { parts.back().position.y += shiftFactor; + syncPartPhysics(parts.back()); } if (key == GLFW_KEY_Z && action == GLFW_PRESS) { parts.back().position.z += shiftFactor; + syncPartPhysics(parts.back()); } } else if (mode == 1) { if (key == GLFW_KEY_X && action == GLFW_PRESS) { parts.back().scale.x += shiftFactor; + syncPartPhysics(parts.back()); } if (key == GLFW_KEY_Y && action == GLFW_PRESS) { parts.back().scale.y += shiftFactor; + syncPartPhysics(parts.back()); } if (key == GLFW_KEY_Z && action == GLFW_PRESS) { parts.back().scale.z += shiftFactor; + syncPartPhysics(parts.back()); } } diff --git a/src/rendering/renderer.cpp b/src/rendering/renderer.cpp index 195a99f..c23abc7 100644 --- a/src/rendering/renderer.cpp +++ b/src/rendering/renderer.cpp @@ -75,10 +75,10 @@ void render(GLFWwindow* window) { for (Part part : parts) { glm::mat4 model = glm::mat4(1.0f); model = glm::translate(model, part.position); - model = glm::scale(model, part.scale); model = glm::rotate(model, part.rotation.x, glm::vec3(1., 0., 0.)); model = glm::rotate(model, part.rotation.y, glm::vec3(0., 1., 0.)); model = glm::rotate(model, part.rotation.z, glm::vec3(0., 0., 1.)); + model = glm::scale(model, part.scale); shader->set("model", model); glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(model))); shader->set("normalMatrix", normalMatrix);