26 bool operator==(
const Box2LL& other)
const {
return m_min == other.m_min && m_max == other.m_max; }
27 bool operator!=(
const Box2LL& other)
const {
return !operator==(other); }
36 bool IsValid()
const {
return CountX() >= 0LL && CountY() >= 0LL; }
38 void MakeZero() { m_min.Set(0, 0); m_max.Set(0, 0); }
40 void Set(
const Vec2LL& min_,
const Vec2LL& max_) { m_min = min_; m_max = max_; }
41 void SetMin(
const Vec2LL& min_) { m_min = min_; }
42 void SetMax(
const Vec2LL& max_) { m_max = max_; }
44 const Vec2LL& Min()
const {
return m_min; }
45 const Vec2LL& Max()
const {
return m_max; }
47 KyInt64 CountX()
const {
return m_max.x - m_min.x + 1; }
48 KyInt64 CountY()
const {
return m_max.y - m_min.y + 1; }
50 bool DoesContain(
const Vec2LL& pos)
const {
return pos.x >= m_min.x && pos.x <= m_max.x && pos.y >= m_min.y && pos.y <= m_max.y; }
52 bool DoesStrictlyContain(
const Vec2LL& pos)
const {
return pos.x > m_min.x && pos.x < m_max.x && pos.y > m_min.y && pos.y < m_max.y; }
54 void ExpandByPos(
const Vec2LL& pos)
56 m_min.x = Kaim::Min(m_min.x, pos.x);
57 m_max.x = Kaim::Max(m_max.x, pos.x);
58 m_min.y = Kaim::Min(m_min.y, pos.y);
59 m_max.y = Kaim::Max(m_max.y, pos.y);
62 void ExpandByBox(
const Box2LL& box)
64 m_min.x = Kaim::Min(m_min.x, box.m_min.x);
65 m_max.x = Kaim::Max(m_max.x, box.m_max.x);
66 m_min.y = Kaim::Min(m_min.y, box.m_min.y);
67 m_max.y = Kaim::Max(m_max.y, box.m_max.y);
70 void Enlarge(
KyInt64 enlargement)
72 Vec2LL e(enlargement, enlargement);
80 enlarged.Enlarge(enlargement);
86 m_min.x = Kaim::Max(m_min.x, box.m_min.x);
87 m_max.x = Kaim::Min(m_max.x, box.m_max.x);
88 m_min.y = Kaim::Max(m_min.y, box.m_min.y);
89 m_max.y = Kaim::Min(m_max.y, box.m_max.y);
96 m_min.x = Kaim::Max(box_1.m_min.x, box_2.m_min.x);
97 m_max.x = Kaim::Min(box_1.m_max.x, box_2.m_max.x);
98 m_min.y = Kaim::Max(box_1.m_min.y, box_2.m_min.y);
99 m_max.y = Kaim::Min(box_1.m_max.y, box_2.m_max.y);
109 template <
class OSTREAM>
110 inline OSTREAM& operator<<(OSTREAM& os,
const Box2LL&
self)
112 os <<
"{" <<
self.Min() <<
"," <<
self.Max() <<
"}";
bool IntersectWith(const Box2LL &box)
Set itself as its intersection with box, return true if itself and box do intersect.
Definition: box2ll.h:84
Box2LL()
Set { {+infinite, +infinite}, {-infinite, -infinite} }.
Definition: box2ll.h:22
2d vector using KyInt64
Definition: vec2ll.h:18
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
std::int64_t KyInt64
int64_t
Definition: types.h:25
void Clear()
Set { {+infinite, +infinite}, {-infinite, -infinite} }.
Definition: box2ll.h:30
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KyInt64MINVAL
KyInt64 min value
Definition: types.h:64
#define KyInt64MAXVAL
KyInt64 max value
Definition: types.h:63
bool SetAsIntersection(const Box2LL &box_1, const Box2LL &box_2)
Set itself as the intersection of box_1 and box_2, return true if box_1 and box_2 do intersect...
Definition: box2ll.h:94
2d axis aligned box of 64bits integers. Does not maintain m_countXY = m_max - m_min as a member...
Definition: box2ll.h:16