Sun, 09 Apr 2023 01:12:00 +0300
The renderer now centers on the grid origin, not the part origin
src/gl/partrenderer.cpp | file | annotate | diff | comparison | revisions | |
src/gl/partrenderer.h | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions |
--- 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
--- 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<std::int32_t>& 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);