453808eb90
* ClipmapBounds class - This class is built to keep track of textures for clipmap like structures where there is a virtual center point and the edges need to be updated as the camera moves around the world Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * Removing dead code Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * Updates from PR feedback. Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * comment update Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * Updates from review suggestions Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * More updates. Moved the snapped center point calculation out to a separate function so the constructor doesn't need to do unnecessary work. Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * Removing unused variable. Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * Fixing bug in unit test that was doing a comparison and throwing away the result instead of actually testing it. Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * Adding some comments and constifying some functions. Signed-off-by: Ken Pruiksma <pruiksma@amazon.com> * Fixing numeric casting issue on linux Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
73 lines
1.7 KiB
C++
73 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#include <TerrainRenderer/Aabb2i.h>
|
|
#include <AzCore/Math/MathUtils.h>
|
|
|
|
namespace Terrain
|
|
{
|
|
Aabb2i::Aabb2i(const Vector2i& min, const Vector2i& max)
|
|
: m_min(min)
|
|
, m_max(max)
|
|
{}
|
|
|
|
Aabb2i Aabb2i::operator+(const Vector2i& rhs) const
|
|
{
|
|
Aabb2i returnValue = *this;
|
|
returnValue += rhs;
|
|
return returnValue;
|
|
}
|
|
|
|
Aabb2i& Aabb2i::operator+=(const Vector2i& rhs)
|
|
{
|
|
m_min += rhs;
|
|
m_max += rhs;
|
|
return *this;
|
|
}
|
|
|
|
Aabb2i Aabb2i::operator-(const Vector2i& rhs) const
|
|
{
|
|
Aabb2i returnValue = *this;
|
|
returnValue -= rhs;
|
|
return returnValue;
|
|
}
|
|
|
|
Aabb2i& Aabb2i::operator-=(const Vector2i& rhs)
|
|
{
|
|
m_min -= rhs;
|
|
m_max -= rhs;
|
|
return *this;
|
|
}
|
|
|
|
bool Aabb2i::operator==(const Aabb2i& other) const
|
|
{
|
|
return m_min == other.m_min && m_max == other.m_max;
|
|
}
|
|
|
|
bool Aabb2i::operator!=(const Aabb2i& other) const
|
|
{
|
|
return !(*this == other);
|
|
}
|
|
|
|
Aabb2i Aabb2i::GetClamped(Aabb2i rhs) const
|
|
{
|
|
Aabb2i ret;
|
|
ret.m_min.m_x = AZ::GetMax(m_min.m_x, rhs.m_min.m_x);
|
|
ret.m_min.m_y = AZ::GetMax(m_min.m_y, rhs.m_min.m_y);
|
|
ret.m_max.m_x = AZ::GetMin(m_max.m_x, rhs.m_max.m_x);
|
|
ret.m_max.m_y = AZ::GetMin(m_max.m_y, rhs.m_max.m_y);
|
|
return ret;
|
|
}
|
|
|
|
bool Aabb2i::IsValid() const
|
|
{
|
|
// Intentionally strict, equal min/max not valid.
|
|
return m_min.m_x < m_max.m_x && m_min.m_y < m_max.m_y;
|
|
}
|
|
}
|