Code/Editor

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-08-16 15:56:36 -07:00
parent e6b5342c07
commit 2963739288
51 changed files with 286 additions and 337 deletions
+23 -17
View File
@@ -284,7 +284,7 @@ void EditorViewportWidget::paintEvent([[maybe_unused]] QPaintEvent* event)
const char* kFontName = "Arial";
const QColor kTextColor(255, 255, 255);
const QColor kTextShadowColor(0, 0, 0);
const QFont font(kFontName, kFontSize / 10.0);
const QFont font(kFontName, static_cast<int>(kFontSize / 10.0f));
painter.setFont(font);
QString friendlyName = QFileInfo(GetIEditor()->GetLevelName()).fileName();
@@ -815,29 +815,35 @@ void EditorViewportWidget::UpdateSafeFrame()
float maxSafeFrameWidth = m_safeFrame.height() * targetAspectRatio;
float widthDifference = m_safeFrame.width() - maxSafeFrameWidth;
m_safeFrame.setLeft(m_safeFrame.left() + widthDifference * 0.5);
m_safeFrame.setRight(m_safeFrame.right() - widthDifference * 0.5);
m_safeFrame.setLeft(static_cast<int>(m_safeFrame.left() + widthDifference * 0.5f));
m_safeFrame.setRight(static_cast<int>(m_safeFrame.right() - widthDifference * 0.5f));
}
else
{
float maxSafeFrameHeight = m_safeFrame.width() / targetAspectRatio;
float heightDifference = m_safeFrame.height() - maxSafeFrameHeight;
m_safeFrame.setTop(m_safeFrame.top() + heightDifference * 0.5);
m_safeFrame.setBottom(m_safeFrame.bottom() - heightDifference * 0.5);
m_safeFrame.setTop(static_cast<int>(m_safeFrame.top() + heightDifference * 0.5f));
m_safeFrame.setBottom(static_cast<int>(m_safeFrame.bottom() - heightDifference * 0.5f));
}
m_safeFrame.adjust(0, 0, -1, -1); // <-- aesthetic improvement.
const float SAFE_ACTION_SCALE_FACTOR = 0.05f;
m_safeAction = m_safeFrame;
m_safeAction.adjust(m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR, m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR,
-m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR, -m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR);
m_safeAction.adjust(
static_cast<int>(m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR),
static_cast<int>(m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR),
static_cast<int>(-m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR),
static_cast<int>(-m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR));
const float SAFE_TITLE_SCALE_FACTOR = 0.1f;
m_safeTitle = m_safeFrame;
m_safeTitle.adjust(m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR, m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR,
-m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR, -m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR);
m_safeTitle.adjust(
static_cast<int>(m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR),
static_cast<int>(m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR),
static_cast<int>(-m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR),
static_cast<int>(-m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR));
}
//////////////////////////////////////////////////////////////////////////
@@ -856,8 +862,8 @@ void EditorViewportWidget::RenderSafeFrame(const QRect& frame, float r, float g,
const int LINE_WIDTH = 2;
for (int i = 0; i < LINE_WIDTH; i++)
{
AZ::Vector3 topLeft(frame.left() + i, frame.top() + i, 0);
AZ::Vector3 bottomRight(frame.right() - i, frame.bottom() - i, 0);
AZ::Vector3 topLeft(static_cast<float>(frame.left() + i), static_cast<float>(frame.top() + i), 0.0f);
AZ::Vector3 bottomRight(static_cast<float>(frame.right() - i), static_cast<float>(frame.bottom() - i), 0.0f);
m_debugDisplay->DrawWireBox(topLeft, bottomRight);
}
}
@@ -1936,8 +1942,8 @@ QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width
ProjectToScreen(wp.x, wp.y, wp.z, &x, &y, &z);
if (_finite(x) || _finite(y))
{
p.rx() = (x / 100) * width;
p.ry() = (y / 100) * height;
p.rx() = static_cast<int>((x / 100) * width);
p.ry() = static_cast<int>((y / 100) * height);
}
else
{
@@ -2091,8 +2097,8 @@ void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, flo
void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const
{
AzFramework::ScreenPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
*sx = screenPosition.m_x;
*sy = screenPosition.m_y;
*sx = static_cast<float>(screenPosition.m_x);
*sy = static_cast<float>(screenPosition.m_y);
*sz = 0.f;
}
@@ -2103,7 +2109,7 @@ void EditorViewportWidget::ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3&
Vec3 pos0, pos1;
float wx, wy, wz;
UnProjectFromScreen(vp.x(), rc.bottom() - vp.y(), 0, &wx, &wy, &wz);
UnProjectFromScreen(static_cast<float>(vp.x()), static_cast<float>(rc.bottom() - vp.y()), 0.0f, &wx, &wy, &wz);
if (!_finite(wx) || !_finite(wy) || !_finite(wz))
{
return;
@@ -2113,7 +2119,7 @@ void EditorViewportWidget::ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3&
return;
}
pos0(wx, wy, wz);
UnProjectFromScreen(vp.x(), rc.bottom() - vp.y(), 1, &wx, &wy, &wz);
UnProjectFromScreen(static_cast<float>(vp.x()), static_cast<float>(rc.bottom() - vp.y()), 1.0f, &wx, &wy, &wz);
if (!_finite(wx) || !_finite(wy) || !_finite(wz))
{
return;