# HG changeset patch # User Teemu Piippo # Date 1680991920 -10800 # Node ID 73b6c478378e0a9dcbf80f3ee9dc9ac00b719131 # Parent ef90ed0a572075646885a9fed0dc1329aa9fd8fa The renderer now centers on the grid origin, not the part origin diff -r ef90ed0a5720 -r 73b6c478378e src/gl/partrenderer.cpp --- a/src/gl/partrenderer.cpp Sun Apr 09 00:56:49 2023 +0300 +++ b/src/gl/partrenderer.cpp Sun Apr 09 01:12:00 2023 +0300 @@ -237,7 +237,7 @@ void PartRenderer::updateModelMatrix() { - this->modelMatrix = glm::mat4_cast(this->modelQuaternion); + this->modelMatrix = glm::translate(glm::mat4_cast(this->modelQuaternion), -this->modelViewOrigin); gl::setShaderUniformMatrix(&this->shaders, "modelMatrix", modelMatrix); Q_EMIT this->modelMatrixChanged(this->modelMatrix); this->update(); @@ -420,6 +420,12 @@ return lineFromPoints(p1, p2); } +void PartRenderer::setModelViewOrigin(const glm::vec3& newViewOrigin) +{ + this->modelViewOrigin = newViewOrigin; + this->updateModelMatrix(); +} + /** * @brief Unprojects the specified window coordinates to model coordinates * @param win Window coordinates to project. Z-coordinate indicates depth diff -r ef90ed0a5720 -r 73b6c478378e src/gl/partrenderer.h --- a/src/gl/partrenderer.h Sun Apr 09 00:56:49 2023 +0300 +++ b/src/gl/partrenderer.h Sun Apr 09 01:12:00 2023 +0300 @@ -20,6 +20,7 @@ glm::mat4 modelMatrix; glm::vec4 viewportVector; glm::quat modelQuaternion; + glm::vec3 modelViewOrigin = {0, 0, 0}; QPoint lastMousePosition; int totalMouseMove = 0; gl::RenderPreferences renderPreferences; @@ -48,6 +49,7 @@ void setSelection(const QSet& selectedIds); glm::vec3 cameraVector(const QPointF& point) const; Line<3> cameraLine(const QPointF& point) const; + Q_SLOT void setModelViewOrigin(const glm::vec3& newViewOrigin); Q_SIGNALS: void projectionMatrixChanged(const glm::mat4& newMatrix); void modelMatrixChanged(const glm::mat4& newMatrix); diff -r ef90ed0a5720 -r 73b6c478378e src/main.cpp --- a/src/main.cpp Sun Apr 09 00:56:49 2023 +0300 +++ b/src/main.cpp Sun Apr 09 01:12:00 2023 +0300 @@ -746,6 +746,7 @@ { data->gridLayer->setGridMatrix(newGridMatrix); data->tools->setGridMatrix(newGridMatrix); + data->canvas->setModelViewOrigin(newGridMatrix[3]); data->canvas->update(); } });