normalize rotation when using gizmos

This commit is contained in:
T1ti
2023-07-05 09:29:01 +02:00
parent 66f1c06865
commit 126f44fdd6
3 changed files with 22 additions and 0 deletions

View File

@@ -279,6 +279,7 @@ public:
void randomizeShaderRotation();
void randomizeStampRotation();
void onSettingsSave();
void updateRotationEditor() { _rotation_editor_need_update = true; };
[[nodiscard]]
Noggit::Ui::minimap_widget* getMinimapWidget() const { return _minimap; }

View File

@@ -65,6 +65,25 @@ void SceneObject::resetDirection()
recalcExtents();
}
void SceneObject::normalizeDirection()
{
//! [-180, 180)
while (dir.x >= 180.0f)
dir.x -= 360.0f;
while (dir.x < -180.0f)
dir.x += 360.0f;
while (dir.y >= 180.0f)
dir.y -= 360.0f;
while (dir.y < -180.0f)
dir.y += 360.0f;
while (dir.z >= 180.0f)
dir.z -= 360.0f;
while (dir.z < -180.0f)
dir.z += 360.0f;
}
void SceneObject::refTile(MapTile* tile)
{
auto it = std::find(_tiles.begin(), _tiles.end(), tile);

View File

@@ -47,6 +47,8 @@ public:
void resetDirection();
void normalizeDirection();
[[nodiscard]]
glm::mat4x4 transformMatrix() const { return _transform_mat; };