summaryrefslogtreecommitdiff
path: root/indra/llmath/llcoord.h
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2012-05-26 16:12:33 -0400
committerOz Linden <oz@lindenlab.com>2012-05-26 16:12:33 -0400
commitdbac37dcb50bf44255c2b622d418bb4339f1afca (patch)
treeacffbcb5984696e507243f939f6b9c5a951b755b /indra/llmath/llcoord.h
parent790dfda43472da75d17a848eb91e2dcecb2b96e7 (diff)
parentb2b446aed7f7f32151bc152ba25d44253ebf864f (diff)
merge latest viewer-release
Diffstat (limited to 'indra/llmath/llcoord.h')
-rw-r--r--indra/llmath/llcoord.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h
index 1f617e649e..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<typename> class LLCoord;
+struct LL_COORD_TYPE_GL;
+struct LL_COORD_TYPE_WINDOW;
+struct LL_COORD_TYPE_SCREEN;
+
+typedef LLCoord<LL_COORD_TYPE_GL> LLCoordGL;
+typedef LLCoord<LL_COORD_TYPE_WINDOW> LLCoordWindow;
+typedef LLCoord<LL_COORD_TYPE_SCREEN> LLCoordScreen;
+
struct LLCoordCommon
{
LLCoordCommon(S32 x, S32 y) : mX(x), mY(y) {}
@@ -45,7 +54,7 @@ public:
LLCoord(): mX(0), mY(0)
{}
- LLCoord(S32 x, S32 y): mX(x), mY(y)
+ LLCoord(typename COORD_FRAME::value_t x, typename COORD_FRAME::value_t y): mX(x), mY(y)
{}
LLCoord(const LLCoordCommon& other)
@@ -58,10 +67,12 @@ 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); }
+ static const self_t& getTypedCoords(const COORD_FRAME& self) { return static_cast<const self_t&>(self); }
+ static self_t& getTypedCoords(COORD_FRAME& self) { return static_cast<self_t&>(self); }
};
struct LL_COORD_TYPE_GL
@@ -70,13 +81,13 @@ struct LL_COORD_TYPE_GL
LLCoordCommon convertToCommon() const
{
- const LLCoord<LL_COORD_TYPE_GL>& self = static_cast<const LLCoord<LL_COORD_TYPE_GL>&>(*this);
+ const LLCoordGL& self = LLCoordGL::getTypedCoords(*this);
return LLCoordCommon(self.mX, self.mY);
}
void convertFromCommon(const LLCoordCommon& from)
{
- LLCoord<LL_COORD_TYPE_GL>& self = static_cast<LLCoord<LL_COORD_TYPE_GL>&>(*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<LL_COORD_TYPE_GL> LLCoordGL;
-typedef LLCoord<LL_COORD_TYPE_WINDOW> LLCoordWindow;
-typedef LLCoord<LL_COORD_TYPE_SCREEN> LLCoordScreen;
-
#endif