Przeglądaj źródła

math: implement == and != for 2D and 3D box types.

legacy
Sam Hocevar sam 11 lat temu
rodzic
commit
e4d4f8df19
1 zmienionych plików z 24 dodań i 4 usunięć
  1. +24
    -4
      src/lol/math/geometry.h

+ 24
- 4
src/lol/math/geometry.h Wyświetl plik

@@ -61,7 +61,7 @@ template <typename T> struct Box2
B(bx, by)
{}

Box2<T> operator +(Vec2<T> const &v)
Box2<T> operator +(Vec2<T> const &v) const
{
return Box2<T>(A + v, B + v);
}
@@ -71,7 +71,7 @@ template <typename T> struct Box2
return *this = *this + v;
}

Box2<T> operator -(Vec2<T> const &v)
Box2<T> operator -(Vec2<T> const &v) const
{
return Box2<T>(A - v, B - v);
}
@@ -81,6 +81,16 @@ template <typename T> struct Box2
return *this = *this - v;
}

bool operator ==(Box2<T> const &box)
{
return A == box.A && B == box.B;
}

bool operator !=(Box2<T> const &box)
{
return A != box.A || B != box.B;
}

Vec2<T> A, B;
};

@@ -106,7 +116,7 @@ template <typename T> struct Box3
B(bx, by, bz)
{}

Box3<T> operator +(Vec3<T> const &v)
Box3<T> operator +(Vec3<T> const &v) const
{
return Box3<T>(A + v, B + v);
}
@@ -116,7 +126,7 @@ template <typename T> struct Box3
return *this = *this + v;
}

Box3<T> operator -(Vec3<T> const &v)
Box3<T> operator -(Vec3<T> const &v) const
{
return Box3<T>(A - v, B - v);
}
@@ -126,6 +136,16 @@ template <typename T> struct Box3
return *this = *this - v;
}

bool operator ==(Box3<T> const &box)
{
return A == box.A && B == box.B;
}

bool operator !=(Box3<T> const &box)
{
return A != box.A || B != box.B;
}

Vec3<T> A, B;
};



Ładowanie…
Anuluj
Zapisz