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/v2math.h | 102 ++++++++++++++++---------------------------------- 1 file changed, 32 insertions(+), 70 deletions(-) (limited to 'indra/llmath/v2math.h') diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index 5c756a7f84..978d14ece8 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -107,13 +107,14 @@ class LLVector2 friend LLVector2 operator-(const LLVector2 &a); // Return vector -a - friend std::ostream& operator<<(std::ostream& s, const LLVector2 &a); // Stream a + friend std::ostream& operator<<(std::ostream& s, const LLVector2 &a); // Stream a }; // Non-member functions F32 angle_between(const LLVector2 &a, const LLVector2 &b); // Returns angle (radians) between a and b +F32 signed_angle_between(const LLVector2& a, const LLVector2& b); // Returns signed angle (radians) between a and b BOOL are_parallel(const LLVector2 &a, const LLVector2 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns TRUE if a and b are very close to parallel F32 dist_vec(const LLVector2 &a, const LLVector2 &b); // Returns distance between a and b F32 dist_vec_squared(const LLVector2 &a, const LLVector2 &b);// Returns distance squared between a and b @@ -124,26 +125,22 @@ LLVector2 lerp(const LLVector2 &a, const LLVector2 &b, F32 u); // Returns a vect inline LLVector2::LLVector2(void) { - mV[VX] = 0.f; - mV[VY] = 0.f; + clear(); } inline LLVector2::LLVector2(F32 x, F32 y) { - mV[VX] = x; - mV[VY] = y; + set(x, y); } inline LLVector2::LLVector2(const F32 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; + set(vec); } inline LLVector2::LLVector2(const LLVector3 &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; + set(vec.mV); } inline LLVector2::LLVector2(const LLSD &sd) @@ -155,28 +152,24 @@ inline LLVector2::LLVector2(const LLSD &sd) inline void LLVector2::clear(void) { - mV[VX] = 0.f; - mV[VY] = 0.f; + mV[VX] = mV[VY] = 0.f; } inline void LLVector2::setZero(void) { - mV[VX] = 0.f; - mV[VY] = 0.f; + clear(); } // deprecated inline void LLVector2::clearVec(void) { - mV[VX] = 0.f; - mV[VY] = 0.f; + clear(); } // deprecated inline void LLVector2::zeroVec(void) { - mV[VX] = 0.f; - mV[VY] = 0.f; + clear(); } inline void LLVector2::set(F32 x, F32 y) @@ -187,36 +180,31 @@ inline void LLVector2::set(F32 x, F32 y) inline void LLVector2::set(const LLVector2 &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; + set(vec.mV); } inline void LLVector2::set(const F32 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; + set(vec[VX], vec[VY]); } // deprecated inline void LLVector2::setVec(F32 x, F32 y) { - mV[VX] = x; - mV[VY] = y; + set(x, y); } // deprecated inline void LLVector2::setVec(const LLVector2 &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; + set(vec); } // deprecated inline void LLVector2::setVec(const F32 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; + set(vec); } @@ -224,7 +212,7 @@ inline void LLVector2::setVec(const F32 *vec) inline F32 LLVector2::length(void) const { - return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); + return (F32) sqrt(lengthSquared()); } inline F32 LLVector2::lengthSquared(void) const @@ -232,63 +220,44 @@ inline F32 LLVector2::lengthSquared(void) const return mV[0]*mV[0] + mV[1]*mV[1]; } -inline F32 LLVector2::normalize(void) +inline F32 LLVector2::normalize(void) { - F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); - F32 oomag; + F32 mag = length(); if (mag > FP_MAG_THRESHOLD) { - oomag = 1.f/mag; - mV[0] *= oomag; - mV[1] *= oomag; + *this /= mag; } else { - mV[0] = 0.f; - mV[1] = 0.f; + clear(); mag = 0; } - return (mag); + return mag; } // checker inline bool LLVector2::isFinite() const { - return (llfinite(mV[VX]) && llfinite(mV[VY])); + return llfinite(mV[VX]) && llfinite(mV[VY]); } // deprecated -inline F32 LLVector2::magVec(void) const +inline F32 LLVector2::magVec(void) const { - return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); + return length(); } // deprecated -inline F32 LLVector2::magVecSquared(void) const +inline F32 LLVector2::magVecSquared(void) const { - return mV[0]*mV[0] + mV[1]*mV[1]; + return lengthSquared(); } // deprecated -inline F32 LLVector2::normVec(void) +inline F32 LLVector2::normVec(void) { - F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); - F32 oomag; - - if (mag > FP_MAG_THRESHOLD) - { - oomag = 1.f/mag; - mV[0] *= oomag; - mV[1] *= oomag; - } - else - { - mV[0] = 0.f; - mV[1] = 0.f; - mag = 0; - } - return (mag); + return normalize(); } inline const LLVector2& LLVector2::scaleVec(const LLVector2& vec) @@ -301,11 +270,7 @@ inline const LLVector2& LLVector2::scaleVec(const LLVector2& vec) inline BOOL LLVector2::isNull() { - if ( F_APPROXIMATELY_ZERO > mV[VX]*mV[VX] + mV[VY]*mV[VY] ) - { - return TRUE; - } - return FALSE; + return F_APPROXIMATELY_ZERO > mV[VX]*mV[VX] + mV[VY]*mV[VY]; } @@ -337,9 +302,9 @@ inline LLVector2 operator-(const LLVector2 &a, const LLVector2 &b) return c -= b; } -inline F32 operator*(const LLVector2 &a, const LLVector2 &b) +inline F32 operator*(const LLVector2 &a, const LLVector2 &b) { - return (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1]); + return a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1]; } inline LLVector2 operator%(const LLVector2 &a, const LLVector2 &b) @@ -405,10 +370,7 @@ inline const LLVector2& operator*=(LLVector2 &a, F32 k) inline const LLVector2& operator/=(LLVector2 &a, F32 k) { - F32 t = 1.f / k; - a.mV[0] *= t; - a.mV[1] *= t; - return a; + return a *= 1.f / k; } inline LLVector2 operator-(const LLVector2 &a) -- cgit v1.2.3 From 19347f7094c9448e02a021ae2d571b5fe8bfcc2e Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 15 Oct 2024 22:35:38 +0200 Subject: Fix merge issues: * Restore changes from 21947778baaca205615a71a97ac8f563c998fdd3 to llwindow/llwindowwin32.cpp * Restore changes from 3758618949684641fc94b5c9478d9002706213cc to newview/llinspecttexture.cpp * Fix apparent merge error in LLInventoryPanel::itemChanged * Restore changes from 1eeecfa1a8bf43a8980217ce34e3b5f4458483e0 in newview/llpaneloutfitsinventory.h * Restore changes from b9633c17e373bfe55b29228996e8473eb041466d in newview/llpaneloutfitsinventory.h & newview/llpanelwearing.cpp * Restore changes from f660f1f0fda4d2363d351fa550b4f8818b46c2c3 in newview/llviewertexture.cpp * Restore changes from b9633c17e373bfe55b29228996e8473eb041466d & 98f7d73d46fdc045759023eda6409e8c791f5cb2 in newview/lloutfitgallery.cpp and newview/lloutfitslist.cpp * Replace changes from 23729442aab7130f3368d433e8a5a9dd45ff6b98 with current implementation in develop branch * Fix more broken changes in LLViewerTexture::saveRawImage * Restore the changes in LLMath both from develop and maint-c * Fix all kind of other merge errors # Conflicts: # indra/llmath/v2math.h # indra/llmath/v3math.h # indra/llui/llfolderviewitem.cpp # indra/llwindow/llwindowwin32.cpp # indra/newview/llfloaterobjectweights.h # indra/newview/lloutfitgallery.cpp # indra/newview/lloutfitslist.cpp # indra/newview/llsidepaneliteminfo.cpp # indra/newview/llvoavatar.cpp --- indra/llmath/v2math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmath/v2math.h') diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index 6e3a2933bf..8e366485e7 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -212,7 +212,7 @@ inline void LLVector2::setVec(const F32 *vec) inline F32 LLVector2::length(void) const { - return (F32) sqrt(lengthSquared()); + return sqrt(lengthSquared()); } inline F32 LLVector2::lengthSquared(void) const -- cgit v1.2.3 From 74a71e30e76862d59a240a1592c4094ff82f3bf6 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Fri, 18 Apr 2025 22:15:47 +0200 Subject: Restore llmath fixes that got lost during merge (#3948) --- indra/llmath/v2math.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llmath/v2math.h') diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index d9fb70e191..6b9d37535b 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -243,19 +243,19 @@ inline bool LLVector2::isFinite() const } // deprecated -inline F32 LLVector2::magVec(void) const +inline F32 LLVector2::magVec() const { return length(); } // deprecated -inline F32 LLVector2::magVecSquared(void) const +inline F32 LLVector2::magVecSquared() const { return lengthSquared(); } // deprecated -inline F32 LLVector2::normVec(void) +inline F32 LLVector2::normVec() { return normalize(); } -- cgit v1.2.3