Added [Cube/Rect]::Get[Negative/Positive]Vertex
Former-commit-id: 66e4851be7751402077ea67df0554a51f3d28df2
This commit is contained in:
parent
4a11ff269f
commit
ee7a9c572b
|
|
@ -34,7 +34,9 @@ class NzCube
|
|||
|
||||
NzVector3<T> GetCorner(nzCorner corner) const;
|
||||
NzVector3<T> GetCenter() const;
|
||||
NzVector3<T> GetNegativeVertex(const NzVector3<T>& normal) const;
|
||||
NzVector3<T> GetPosition() const;
|
||||
NzVector3<T> GetPositiveVertex(const NzVector3<T>& normal) const;
|
||||
NzVector3<T> GetSize() const;
|
||||
|
||||
bool Intersect(const NzCube& cube, NzCube* intersection = nullptr) const;
|
||||
|
|
|
|||
|
|
@ -138,12 +138,46 @@ NzVector3<T> NzCube<T>::GetCenter() const
|
|||
return NzVector3<T>(x + width/F(2.0), y + height/F(2.0), z + depth/F(2.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetNegativeVertex(const NzVector3<T>& normal) const
|
||||
{
|
||||
NzVector3<T> neg(GetPosition());
|
||||
|
||||
if (normal.x < F(0.0))
|
||||
neg.x += width;
|
||||
|
||||
if (normal.y < F(0.0))
|
||||
neg.y += height;
|
||||
|
||||
if (normal.z < F(0.0))
|
||||
neg.z += depth;
|
||||
|
||||
return neg;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetPosition() const
|
||||
{
|
||||
return NzVector3<T>(x, y, z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetPositiveVertex(const NzVector3<T>& normal) const
|
||||
{
|
||||
NzVector3<T> pos(GetPosition());
|
||||
|
||||
if (normal.x > F(0.0))
|
||||
pos.x += width;
|
||||
|
||||
if (normal.y > F(0.0))
|
||||
pos.y += height;
|
||||
|
||||
if (normal.z > F(0.0))
|
||||
pos.z += depth;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetSize() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ class NzRect
|
|||
NzRect& ExtendTo(const NzRect& rect);
|
||||
|
||||
NzVector2<T> GetCenter() const;
|
||||
NzVector2<T> GetNegativeVertex(const NzVector2<T>& normal) const;
|
||||
NzVector2<T> GetPosition() const;
|
||||
NzVector2<T> GetPositiveVertex(const NzVector2<T>& normal) const;
|
||||
NzVector2<T> GetSize() const;
|
||||
|
||||
bool Intersect(const NzRect& rect, NzRect* intersection = nullptr) const;
|
||||
|
|
|
|||
|
|
@ -91,12 +91,40 @@ NzVector2<T> NzRect<T>::GetCenter() const
|
|||
return NzVector2<T>(x + width/F(2.0), y + height/F(2.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetNegativeVertex(const NzVector2<T>& normal) const
|
||||
{
|
||||
NzVector2<T> neg(GetPosition());
|
||||
|
||||
if (normal.x < F(0.0))
|
||||
neg.x += width;
|
||||
|
||||
if (normal.y < F(0.0))
|
||||
neg.y += height;
|
||||
|
||||
return neg;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetPosition() const
|
||||
{
|
||||
return NzVector2<T>(x, y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetPositiveVertex(const NzVector2<T>& normal) const
|
||||
{
|
||||
NzVector2<T> pos(GetPosition());
|
||||
|
||||
if (normal.x > F(0.0))
|
||||
pos.x += width;
|
||||
|
||||
if (normal.y > F(0.0))
|
||||
pos.y += height;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetSize() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue