Add light support (WIP)

This commit is contained in:
Jérôme Leclercq
2022-02-02 12:55:39 +01:00
parent e6951d54a5
commit 8a3a8547dc
44 changed files with 1700 additions and 253 deletions

View File

@@ -34,6 +34,8 @@ namespace Nz
BoundingVolume& ExtendTo(const BoundingVolume& volume);
bool Intersect(const Box<T>& box) const;
bool IsFinite() const;
bool IsInfinite() const;
bool IsNull() const;

View File

@@ -169,11 +169,28 @@ namespace Nz
return *this;
}
template<typename T>
bool BoundingVolume<T>::Intersect(const Box<T>& box) const
{
switch (extend)
{
case Extend::Infinite:
return true;
case Extend::Finite:
return aabb.Intersect(box);
case Extend::Null:
return false;
}
return false;
}
/*!
* \brief Checks whether the volume is finite
* \return true if extend is Extend::Finite
*/
template<typename T>
bool BoundingVolume<T>::IsFinite() const
{

View File

@@ -459,17 +459,12 @@ namespace Nz
{
T left = std::max(x, box.x);
T right = std::min(x + width, box.x + box.width);
if (left >= right)
return false;
T top = std::max(y, box.y);
T bottom = std::min(y + height, box.y + box.height);
if (top >= bottom)
return false;
T up = std::max(z, box.z);
T down = std::min(z + depth, box.z + box.depth);
if (up >= down)
if (left >= right || top >= bottom || up >= down)
return false;
if (intersection)