81 lines
2.6 KiB
C++
81 lines
2.6 KiB
C++
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
#include <Atom/RHI.Reflect/Viewport.h>
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
|
|
namespace AZ
|
|
{
|
|
namespace RHI
|
|
{
|
|
void Viewport::Reflect(AZ::ReflectContext* context)
|
|
{
|
|
if (SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context))
|
|
{
|
|
serializeContext->Class<Viewport>()
|
|
->Version(1)
|
|
->Field("m_minX", &Viewport::m_minX)
|
|
->Field("m_maxX", &Viewport::m_maxX)
|
|
->Field("m_minY", &Viewport::m_minY)
|
|
->Field("m_maxY", &Viewport::m_maxY)
|
|
->Field("m_minZ", &Viewport::m_minZ)
|
|
->Field("m_maxZ", &Viewport::m_maxZ);
|
|
}
|
|
}
|
|
|
|
Viewport::Viewport(
|
|
float minX,
|
|
float maxX,
|
|
float minY,
|
|
float maxY,
|
|
float minZ,
|
|
float maxZ)
|
|
: m_minX(minX)
|
|
, m_maxX(maxX)
|
|
, m_minY(minY)
|
|
, m_maxY(maxY)
|
|
, m_minZ(minZ)
|
|
, m_maxZ(maxZ)
|
|
{}
|
|
|
|
Viewport Viewport::GetScaled(
|
|
float normalizedMinX,
|
|
float normalizedMaxX,
|
|
float normalizedMinY,
|
|
float normalizedMaxY,
|
|
float normalizedMinZ,
|
|
float normalizedMaxZ) const
|
|
{
|
|
Viewport viewport;
|
|
viewport.m_minX = Lerp(m_minX, m_maxX, normalizedMinX);
|
|
viewport.m_maxX = Lerp(m_minX, m_maxX, normalizedMaxX);
|
|
viewport.m_minY = Lerp(m_minY, m_maxY, normalizedMinY);
|
|
viewport.m_maxY = Lerp(m_minY, m_maxY, normalizedMaxY);
|
|
viewport.m_minZ = Lerp(m_minZ, m_maxZ, normalizedMinZ);
|
|
viewport.m_maxZ = Lerp(m_minZ, m_maxZ, normalizedMaxZ);
|
|
return viewport;
|
|
}
|
|
|
|
Viewport Viewport::CreateNull()
|
|
{
|
|
return Viewport{0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
|
|
}
|
|
|
|
bool Viewport::IsNull() const
|
|
{
|
|
return ((m_minX >= m_maxX) ||
|
|
(m_minY >= m_maxY) ||
|
|
(m_minZ >= m_maxZ));
|
|
}
|
|
|
|
} // namespace RHI
|
|
} // namespace AZ
|