From b47c509b016353976d25460d9a5d7e2cfe312096 Mon Sep 17 00:00:00 2001 From: blenk13 Date: Tue, 27 Jan 2026 12:34:04 +0000 Subject: [PATCH 1/2] Added a stabilisation bool flag to NavMesh which sets rotation to zero if true --- maths | 2 +- mplot/NavMesh.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/maths b/maths index 534fc8a0..90f1c5f6 160000 --- a/maths +++ b/maths @@ -1 +1 @@ -Subproject commit 534fc8a07ab12374c0befcf280878f265b3b0203 +Subproject commit 90f1c5f6a85af3099b8c5521e2a171525e29a789 diff --git a/mplot/NavMesh.h b/mplot/NavMesh.h index 33951c78..4348142d 100644 --- a/mplot/NavMesh.h +++ b/mplot/NavMesh.h @@ -114,6 +114,11 @@ namespace mplot */ sm::vec tn0 = {}; + /*! + * Stabilisation flag: if true, no rotation is applied when moving over the navmesh + */ + bool stabilised = false; + /*! * Return index of this->vertex that is closest to scene_coord. Can use vertexidx_to_indices * to find the indices into vertexPositions and vertexNormals that this index in the @@ -1299,6 +1304,9 @@ namespace mplot // Compute the reorientation due to the requested movement. // Rotate by the angle between the normals. I think this is constrained to be <= pi float rotn_angle = this->tn0.angle (_tn, cd.tri_edge); + if (stabilised){ + rotn_angle = 0.0f; // no rotation for a 'stabilised' camera + } // If tn0 and _tn are identical, then rotn_angle will be NaN, but in that case we want no rotation if (std::isnan (rotn_angle)) { rotn_angle = 0.0f; } sm::mat44 reorient_model; // reorientation transformation in sf From b7a638fe83d86e979533878331cb6f8d2d1fcc70 Mon Sep 17 00:00:00 2001 From: Seb James Date: Wed, 28 Jan 2026 13:19:16 +0000 Subject: [PATCH 2/2] Comments, tweaks to code --- mplot/NavMesh.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mplot/NavMesh.h b/mplot/NavMesh.h index 4348142d..8ee81e9e 100644 --- a/mplot/NavMesh.h +++ b/mplot/NavMesh.h @@ -115,8 +115,10 @@ namespace mplot sm::vec tn0 = {}; /*! - * Stabilisation flag: if true, no rotation is applied when moving over the navmesh - */ + * Stabilisation flag: if true, no rotation is applied when moving over a triangle boundary + * in NavMesh::compute_mesh_movement. If false, then a rotation about the triangle boundary + * is made. + */ bool stabilised = false; /*! @@ -1302,11 +1304,9 @@ namespace mplot if (flags.test (cmm_fl::vertex_crossing)) { cd.tri_edge = this->tn0.cross (_tn); } // Compute the reorientation due to the requested movement. - // Rotate by the angle between the normals. I think this is constrained to be <= pi - float rotn_angle = this->tn0.angle (_tn, cd.tri_edge); - if (stabilised){ - rotn_angle = 0.0f; // no rotation for a 'stabilised' camera - } + float rotn_angle = 0.0f; + // Rotate by the angle between the normals (if stabilised is false). I think this is constrained to be <= pi + if (stabilised == false) { this->tn0.angle (_tn, cd.tri_edge); } // If tn0 and _tn are identical, then rotn_angle will be NaN, but in that case we want no rotation if (std::isnan (rotn_angle)) { rotn_angle = 0.0f; } sm::mat44 reorient_model; // reorientation transformation in sf