From 3d84a147f0ae781a71f74d9d7ad0b07f9b1ccb43 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Fri, 14 Jun 2024 08:06:31 +0200 Subject: #1611 Regression in anti-flipping mechanism for mouselook camera --- indra/llmath/llcoordframe.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'indra/llmath/llcoordframe.cpp') diff --git a/indra/llmath/llcoordframe.cpp b/indra/llmath/llcoordframe.cpp index 4d6276b2cd..7e1f350ab5 100644 --- a/indra/llmath/llcoordframe.cpp +++ b/indra/llmath/llcoordframe.cpp @@ -329,28 +329,30 @@ void LLCoordFrame::rotate(const LLMatrix3 &rotation_matrix) } +// Rotate 2 normalized orthogonal vectors in direction from `source` to `target` +static void rotate2(LLVector3& source, LLVector3& target, F32 angle) +{ + double sx = source[VX], sy = source[VY], sz = source[VZ]; + double tx = target[VX], ty = target[VY], tz = target[VZ]; + double c = cos(angle), s = sin(angle); + + source.set(sx * c + tx * s, sy * c + ty * s, sz * c + tz * s); + target.set(tx * c - sx * s, ty * c - sy * s, tz * c - sz * s); +} + void LLCoordFrame::roll(F32 angle) { - LLQuaternion q(angle, mXAxis); - LLMatrix3 rotation_matrix(q); - rotate(rotation_matrix); - CHECK_FINITE_OBJ(); + rotate2(mYAxis, mZAxis, angle); } void LLCoordFrame::pitch(F32 angle) { - LLQuaternion q(angle, mYAxis); - LLMatrix3 rotation_matrix(q); - rotate(rotation_matrix); - CHECK_FINITE_OBJ(); + rotate2(mZAxis, mXAxis, angle); } void LLCoordFrame::yaw(F32 angle) { - LLQuaternion q(angle, mZAxis); - LLMatrix3 rotation_matrix(q); - rotate(rotation_matrix); - CHECK_FINITE_OBJ(); + rotate2(mXAxis, mYAxis, angle); } // get*() routines -- cgit v1.2.3 From 4c6afbbb75076e9fd34ee5707a02195c4e2f7223 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 17 Apr 2025 19:50:30 +0200 Subject: Restore llmath improvements from archived develop branch: * Make eligible functions constexpr * Use constants for vector indices where applicable * Reformat to match actual coding conventions --- indra/llmath/llcoordframe.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llmath/llcoordframe.cpp') diff --git a/indra/llmath/llcoordframe.cpp b/indra/llmath/llcoordframe.cpp index 4d6276b2cd..15c9f6ff3f 100644 --- a/indra/llmath/llcoordframe.cpp +++ b/indra/llmath/llcoordframe.cpp @@ -26,7 +26,6 @@ #include "linden_common.h" -//#include "vmath.h" #include "v3math.h" #include "m3math.h" #include "v4math.h" -- cgit v1.2.3