From 5a14a67e060e7f325025e924c83489cfa236e3dc Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 1 Feb 2012 13:03:46 -0800 Subject: converted a bunch of narrowing implicit conversions to explicit --- indra/llmath/llcalcparser.h | 2 +- indra/llmath/llvolume.cpp | 4 ++-- indra/llmath/m4math.cpp | 38 +++++++++++++++++++------------------- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcalcparser.h b/indra/llmath/llcalcparser.h index bd9c8c2519..3509bd289b 100644 --- a/indra/llmath/llcalcparser.h +++ b/indra/llmath/llcalcparser.h @@ -174,7 +174,7 @@ private: F32 _log(const F32& a) const { return log(a); } F32 _exp(const F32& a) const { return exp(a); } F32 _fabs(const F32& a) const { return fabs(a); } - F32 _floor(const F32& a) const { return llfloor(a); } + F32 _floor(const F32& a) const { return (F3)llfloor(a); } F32 _ceil(const F32& a) const { return llceil(a); } F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); } diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 0c6cf1dfae..f08657a75c 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -2903,7 +2903,7 @@ F32 LLVolume::sculptGetSurfaceArea() // compute the area of the quad by taking the length of the cross product of the two triangles LLVector3 cross1 = (p1 - p2) % (p1 - p3); LLVector3 cross2 = (p4 - p2) % (p4 - p3); - area += (cross1.magVec() + cross2.magVec()) / 2.0; + area += (cross1.magVec() + cross2.magVec()) / 2.f; } } @@ -5887,7 +5887,7 @@ F32 find_vertex_score(LLVCacheVertexData& data) } //bonus points for having low valence - F32 valence_boost = powf(data.mActiveTriangles, -FindVertexScore_ValenceBoostPower); + F32 valence_boost = powf((F32)data.mActiveTriangles, -FindVertexScore_ValenceBoostPower); score += FindVertexScore_ValenceBoostScale * valence_boost; return score; diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp index bad4deb4de..6a1b4143cf 100644 --- a/indra/llmath/m4math.cpp +++ b/indra/llmath/m4math.cpp @@ -858,25 +858,25 @@ LLSD LLMatrix4::getValue() const void LLMatrix4::setValue(const LLSD& data) { - mMatrix[0][0] = data[0].asReal(); - mMatrix[0][1] = data[1].asReal(); - mMatrix[0][2] = data[2].asReal(); - mMatrix[0][3] = data[3].asReal(); - - mMatrix[1][0] = data[4].asReal(); - mMatrix[1][1] = data[5].asReal(); - mMatrix[1][2] = data[6].asReal(); - mMatrix[1][3] = data[7].asReal(); - - mMatrix[2][0] = data[8].asReal(); - mMatrix[2][1] = data[9].asReal(); - mMatrix[2][2] = data[10].asReal(); - mMatrix[2][3] = data[11].asReal(); - - mMatrix[3][0] = data[12].asReal(); - mMatrix[3][1] = data[13].asReal(); - mMatrix[3][2] = data[14].asReal(); - mMatrix[3][3] = data[15].asReal(); + mMatrix[0][0] = (F32)data[0].asReal(); + mMatrix[0][1] = (F32)data[1].asReal(); + mMatrix[0][2] = (F32)data[2].asReal(); + mMatrix[0][3] = (F32)data[3].asReal(); + + mMatrix[1][0] = (F32)data[4].asReal(); + mMatrix[1][1] = (F32)data[5].asReal(); + mMatrix[1][2] = (F32)data[6].asReal(); + mMatrix[1][3] = (F32)data[7].asReal(); + + mMatrix[2][0] = (F32)data[8].asReal(); + mMatrix[2][1] = (F32)data[9].asReal(); + mMatrix[2][2] = (F32)data[10].asReal(); + mMatrix[2][3] = (F32)data[11].asReal(); + + mMatrix[3][0] = (F32)data[12].asReal(); + mMatrix[3][1] = (F32)data[13].asReal(); + mMatrix[3][2] = (F32)data[14].asReal(); + mMatrix[3][3] = (F32)data[15].asReal(); } -- cgit v1.2.3 From d32c1c28b4e2add4e51361d13356b6638c6f0817 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 1 Feb 2012 16:39:27 -0800 Subject: cleaned up linden_common.h, removing stuff that is mostly unused --- indra/llmath/llcalcparser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcalcparser.h b/indra/llmath/llcalcparser.h index 3509bd289b..e0ad270266 100644 --- a/indra/llmath/llcalcparser.h +++ b/indra/llmath/llcalcparser.h @@ -174,7 +174,7 @@ private: F32 _log(const F32& a) const { return log(a); } F32 _exp(const F32& a) const { return exp(a); } F32 _fabs(const F32& a) const { return fabs(a); } - F32 _floor(const F32& a) const { return (F3)llfloor(a); } + F32 _floor(const F32& a) const { return (F32)llfloor(a); } F32 _ceil(const F32& a) const { return llceil(a); } F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); } -- cgit v1.2.3 From d56be1f1751f66bff09f0d223ed4712974e69e09 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 7 Feb 2012 12:31:48 -0800 Subject: EXP-1181 WIP as a designer I would like to specify default floater positions using realtive coordinates refactored LLCoord code to be templated, ultimately to support arbitrary conversions --- indra/llmath/llcoord.h | 74 +++++++++----------------------------------------- 1 file changed, 13 insertions(+), 61 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h index 706ad92787..c0623e6d1f 100644 --- a/indra/llmath/llcoord.h +++ b/indra/llmath/llcoord.h @@ -27,79 +27,31 @@ #define LL_LLCOORD_H // A two-dimensional pixel value +template class LLCoord { public: - S32 mX; - S32 mY; + typedef LLCoord self_t; + VALUE_TYPE mX; + VALUE_TYPE mY; LLCoord(): mX(0), mY(0) {} LLCoord(S32 x, S32 y): mX(x), mY(y) {} - virtual ~LLCoord() - {} - - virtual void set(S32 x, S32 y) { mX = x; mY = y; } -}; + void set(S32 x, S32 y) { mX = x; mY = y;} + bool operator==(const self_t& other) const { return mX == other.mX && mY == other.mY; } + bool operator!=(const self_t& other) const { return !(*this == other); } -// GL coordinates start in the client region of a window, -// with left, bottom = 0, 0 -class LLCoordGL : public LLCoord -{ -public: - LLCoordGL() : LLCoord() - {} - LLCoordGL(S32 x, S32 y) : LLCoord(x, y) - {} - bool operator==(const LLCoordGL& other) const { return mX == other.mX && mY == other.mY; } - bool operator!=(const LLCoordGL& other) const { return !(*this == other); } }; -//bool operator ==(const LLCoordGL& a, const LLCoordGL& b); - -// Window coords include things like window borders, -// menu regions, etc. -class LLCoordWindow : public LLCoord -{ -public: - LLCoordWindow() : LLCoord() - {} - LLCoordWindow(S32 x, S32 y) : LLCoord(x, y) - {} - bool operator==(const LLCoordWindow& other) const { return mX == other.mX && mY == other.mY; } - bool operator!=(const LLCoordWindow& other) const { return !(*this == other); } -}; +struct LL_COORD_TYPE_GL {}; +struct LL_COORD_TYPE_WINDOW {}; +struct LL_COORD_TYPE_SCREEN {}; - -// Screen coords start at left, top = 0, 0 -class LLCoordScreen : public LLCoord -{ -public: - LLCoordScreen() : LLCoord() - {} - LLCoordScreen(S32 x, S32 y) : LLCoord(x, y) - {} - bool operator==(const LLCoordScreen& other) const { return mX == other.mX && mY == other.mY; } - bool operator!=(const LLCoordScreen& other) const { return !(*this == other); } -}; - -class LLCoordFont : public LLCoord -{ -public: - F32 mZ; - - LLCoordFont() : LLCoord(), mZ(0.f) - {} - LLCoordFont(S32 x, S32 y, F32 z = 0) : LLCoord(x,y), mZ(z) - {} - - void set(S32 x, S32 y) { LLCoord::set(x,y); mZ = 0.f; } - void set(S32 x, S32 y, F32 z) { mX = x; mY = y; mZ = z; } - bool operator==(const LLCoordFont& other) const { return mX == other.mX && mY == other.mY; } - bool operator!=(const LLCoordFont& other) const { return !(*this == other); } -}; - +typedef LLCoord LLCoordGL; +typedef LLCoord LLCoordWindow; +typedef LLCoord LLCoordScreen; #endif -- cgit v1.2.3 From 4e08461f8ad23fb75ca8587c781c2cf65351b1ab Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 7 Feb 2012 19:29:10 -0800 Subject: EXP-1181 WIP as a designer I would like to specify default floater positions using realtive coordinates changed over to new convert() method added LLCoordFloater --- indra/llmath/llcoord.h | 69 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 11 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h index c0623e6d1f..0b1d7e04f5 100644 --- a/indra/llmath/llcoord.h +++ b/indra/llmath/llcoord.h @@ -26,32 +26,79 @@ #ifndef LL_LLCOORD_H #define LL_LLCOORD_H +struct LL_COORD_TYPE_COMMON +{ + typedef S32 value_t; +}; + // A two-dimensional pixel value -template -class LLCoord +template +class LLCoord : protected COORD_FRAME { public: - typedef LLCoord self_t; - VALUE_TYPE mX; - VALUE_TYPE mY; + typedef LLCoord self_t; + typename COORD_FRAME::value_t mX; + typename COORD_FRAME::value_t mY; LLCoord(): mX(0), mY(0) {} LLCoord(S32 x, S32 y): mX(x), mY(y) {} + LLCoord(const LLCoord& other) + { + COORD_FRAME::convertFromCommon(other); + } + + LLCoord convert() const + { + return COORD_FRAME::convertToCommon(); + } + void set(S32 x, S32 y) { mX = x; mY = y;} bool operator==(const self_t& other) const { return mX == other.mX && mY == other.mY; } bool operator!=(const self_t& other) const { return !(*this == other); } }; -struct LL_COORD_TYPE_GL {}; -struct LL_COORD_TYPE_WINDOW {}; -struct LL_COORD_TYPE_SCREEN {}; +typedef LLCoord LLCoordCommon; + +struct LL_COORD_TYPE_GL +{ + typedef S32 value_t; + + LLCoordCommon convertToCommon() const + { + const LLCoord& self = static_cast&>(*this); + return LLCoordCommon(self.mX, self.mY); + } + + void convertFromCommon(const LLCoordCommon& from) + { + LLCoord& self = static_cast&>(*this); + self.mX = from.mX; + self.mY = from.mY; + } +}; + +struct LL_COORD_TYPE_WINDOW +{ + typedef S32 value_t; + + LLCoordCommon convertToCommon() const; + void convertFromCommon(const LLCoordCommon& from); +}; + +struct LL_COORD_TYPE_SCREEN +{ + typedef S32 value_t; + + LLCoordCommon convertToCommon() const; + void convertFromCommon(const LLCoordCommon& from); +}; -typedef LLCoord LLCoordGL; -typedef LLCoord LLCoordWindow; -typedef LLCoord LLCoordScreen; +typedef LLCoord LLCoordGL; +typedef LLCoord LLCoordWindow; +typedef LLCoord LLCoordScreen; #endif -- cgit v1.2.3 From f27ea1aff738f3222c782a7fac5b9172fc3cf67c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 7 Feb 2012 22:50:49 -0800 Subject: EXP-1181 WIP as a designer I would like to specify default floater positions using realtive coordinates fixed build moved conversion funcs to llwindow.cpp as they work on all platforms refactored translateintorect to take overlap as parameter --- indra/llmath/llcoord.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h index 0b1d7e04f5..1f617e649e 100644 --- a/indra/llmath/llcoord.h +++ b/indra/llmath/llcoord.h @@ -26,9 +26,12 @@ #ifndef LL_LLCOORD_H #define LL_LLCOORD_H -struct LL_COORD_TYPE_COMMON +struct LLCoordCommon { - typedef S32 value_t; + LLCoordCommon(S32 x, S32 y) : mX(x), mY(y) {} + LLCoordCommon() : mX(0), mY(0) {} + S32 mX; + S32 mY; }; // A two-dimensional pixel value @@ -45,12 +48,12 @@ public: LLCoord(S32 x, S32 y): mX(x), mY(y) {} - LLCoord(const LLCoord& other) + LLCoord(const LLCoordCommon& other) { COORD_FRAME::convertFromCommon(other); } - LLCoord convert() const + LLCoordCommon convert() const { return COORD_FRAME::convertToCommon(); } @@ -61,8 +64,6 @@ public: }; -typedef LLCoord LLCoordCommon; - struct LL_COORD_TYPE_GL { typedef S32 value_t; -- cgit v1.2.3 From e8b8be637bf63f4ff530c2ec6d0abb89da50035f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 Feb 2012 15:53:41 -0800 Subject: Fix Linux compile issue : make templated type casting explicit --- indra/llmath/llcoord.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h index 1f617e649e..533aa2978b 100644 --- a/indra/llmath/llcoord.h +++ b/indra/llmath/llcoord.h @@ -45,7 +45,7 @@ public: LLCoord(): mX(0), mY(0) {} - LLCoord(S32 x, S32 y): mX(x), mY(y) + LLCoord(S32 x, S32 y): mX((typename COORD_FRAME::value_t)(x)), mY((typename COORD_FRAME::value_t)(y)) {} LLCoord(const LLCoordCommon& other) -- cgit v1.2.3 From 5c8bcc4643e8f2e02c96847e3eeeced0d2b4157a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 Feb 2012 16:39:35 -0800 Subject: Fix Linux compile issue : make templated type casting explicit (2) --- indra/llmath/llcoord.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h index 533aa2978b..756e23dbdf 100644 --- a/indra/llmath/llcoord.h +++ b/indra/llmath/llcoord.h @@ -45,7 +45,7 @@ public: LLCoord(): mX(0), mY(0) {} - LLCoord(S32 x, S32 y): mX((typename COORD_FRAME::value_t)(x)), mY((typename COORD_FRAME::value_t)(y)) + LLCoord(typename COORD_FRAME::value_t x, typename COORD_FRAME::value_t y): mX(x), mY(y) {} LLCoord(const LLCoordCommon& other) @@ -58,7 +58,7 @@ public: return COORD_FRAME::convertToCommon(); } - void set(S32 x, S32 y) { mX = x; mY = y;} + void set(typename COORD_FRAME::value_t x, typename COORD_FRAME::value_t y) { mX = x; mY = y;} bool operator==(const self_t& other) const { return mX == other.mX && mY == other.mY; } bool operator!=(const self_t& other) const { return !(*this == other); } -- cgit v1.2.3 From a5e4b15b7d29a64781eb32ef71e557a5bb8dc870 Mon Sep 17 00:00:00 2001 From: Seth ProductEngine Date: Thu, 23 Feb 2012 21:02:46 +0200 Subject: Linux build fix. Moved type casts from protected base classes to derived LLCoord. --- indra/llmath/llcoord.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h index 756e23dbdf..9b76268afd 100644 --- a/indra/llmath/llcoord.h +++ b/indra/llmath/llcoord.h @@ -26,6 +26,15 @@ #ifndef LL_LLCOORD_H #define LL_LLCOORD_H +template class LLCoord; +struct LL_COORD_TYPE_GL; +struct LL_COORD_TYPE_WINDOW; +struct LL_COORD_TYPE_SCREEN; + +typedef LLCoord LLCoordGL; +typedef LLCoord LLCoordWindow; +typedef LLCoord LLCoordScreen; + struct LLCoordCommon { LLCoordCommon(S32 x, S32 y) : mX(x), mY(y) {} @@ -62,6 +71,8 @@ public: bool operator==(const self_t& other) const { return mX == other.mX && mY == other.mY; } bool operator!=(const self_t& other) const { return !(*this == other); } + static const self_t& getTypedCoords(const COORD_FRAME& self) { return static_cast(self); } + static self_t& getTypedCoords(COORD_FRAME& self) { return static_cast(self); } }; struct LL_COORD_TYPE_GL @@ -70,13 +81,13 @@ struct LL_COORD_TYPE_GL LLCoordCommon convertToCommon() const { - const LLCoord& self = static_cast&>(*this); + const LLCoordGL& self = LLCoordGL::getTypedCoords(*this); return LLCoordCommon(self.mX, self.mY); } void convertFromCommon(const LLCoordCommon& from) { - LLCoord& self = static_cast&>(*this); + LLCoordGL& self = LLCoordGL::getTypedCoords(*this); self.mX = from.mX; self.mY = from.mY; } @@ -98,8 +109,4 @@ struct LL_COORD_TYPE_SCREEN void convertFromCommon(const LLCoordCommon& from); }; -typedef LLCoord LLCoordGL; -typedef LLCoord LLCoordWindow; -typedef LLCoord LLCoordScreen; - #endif -- cgit v1.2.3