summaryrefslogtreecommitdiff
path: root/indra/llmath/llrect.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath/llrect.h')
-rw-r--r--indra/llmath/llrect.h50
1 files changed, 26 insertions, 24 deletions
diff --git a/indra/llmath/llrect.h b/indra/llmath/llrect.h
index 9eb58dbbe9..c03a331aff 100644
--- a/indra/llmath/llrect.h
+++ b/indra/llmath/llrect.h
@@ -64,23 +64,17 @@ public:
mLeft(left), mTop(top), mRight(right), mBottom(bottom)
{}
- LLRectBase(const LLSD& sd)
+ explicit LLRectBase(const LLSD& sd)
{
setValue(sd);
}
- const LLRectBase& operator=(const LLSD& sd)
- {
- setValue(sd);
- return *this;
- }
-
void setValue(const LLSD& sd)
{
- mLeft = sd[0].asInteger();
- mTop = sd[1].asInteger();
- mRight = sd[2].asInteger();
- mBottom = sd[3].asInteger();
+ mLeft = (Type)sd[0].asInteger();
+ mTop = (Type)sd[1].asInteger();
+ mRight = (Type)sd[2].asInteger();
+ mBottom = (Type)sd[3].asInteger();
}
LLSD getValue() const
@@ -147,10 +141,20 @@ public:
// Note: Does NOT follow GL_QUAD conventions: the top and right edges ARE considered part of the rect
// returns TRUE if any part of rect is is inside this LLRect
- BOOL rectInRect(const LLRectBase* rect) const
+ BOOL overlaps(const LLRectBase& rect) const
+ {
+ return !(mLeft > rect.mRight
+ || mRight < rect.mLeft
+ || mBottom > rect.mTop
+ || mTop < rect.mBottom);
+ }
+
+ BOOL contains(const LLRectBase& rect) const
{
- return mLeft <= rect->mRight && rect->mLeft <= mRight &&
- mBottom <= rect->mTop && rect->mBottom <= mTop ;
+ return mLeft <= rect.mLeft
+ && mRight >= rect.mRight
+ && mBottom <= rect.mBottom
+ && mTop >= rect.mTop;
}
LLRectBase& set(Type left, Type top, Type right, Type bottom)
@@ -229,26 +233,25 @@ public:
return mLeft <= mRight && mBottom <= mTop;
}
- bool isNull() const
+ bool isEmpty() const
{
return mLeft == mRight || mBottom == mTop;
}
- bool notNull() const
+ bool notEmpty() const
{
- return !isNull();
+ return !isEmpty();
}
- LLRectBase& unionWith(const LLRectBase &other)
+ void unionWith(const LLRectBase &other)
{
mLeft = llmin(mLeft, other.mLeft);
mRight = llmax(mRight, other.mRight);
mBottom = llmin(mBottom, other.mBottom);
mTop = llmax(mTop, other.mTop);
- return *this;
}
- LLRectBase& intersectWith(const LLRectBase &other)
+ void intersectWith(const LLRectBase &other)
{
mLeft = llmax(mLeft, other.mLeft);
mRight = llmin(mRight, other.mRight);
@@ -262,7 +265,6 @@ public:
{
mBottom = mTop;
}
- return *this;
}
friend std::ostream &operator<<(std::ostream &s, const LLRectBase &rect)
@@ -271,8 +273,8 @@ public:
<< " W " << rect.getWidth() << " H " << rect.getHeight() << " }";
return s;
}
-
- bool operator==(const LLRectBase &b)
+
+ bool operator==(const LLRectBase &b) const
{
return ((mLeft == b.mLeft) &&
(mTop == b.mTop) &&
@@ -280,7 +282,7 @@ public:
(mBottom == b.mBottom));
}
- bool operator!=(const LLRectBase &b)
+ bool operator!=(const LLRectBase &b) const
{
return ((mLeft != b.mLeft) ||
(mTop != b.mTop) ||