Gems/LyShine
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
|
||||
QColor InterpolateColor(const QColor& c1, const QColor& c2, float fraction)
|
||||
{
|
||||
const int r = (c2.red() - c1.red()) * fraction + c1.red();
|
||||
const int g = (c2.green() - c1.green()) * fraction + c1.green();
|
||||
const int b = (c2.blue() - c1.blue()) * fraction + c1.blue();
|
||||
const int r = static_cast<int>(static_cast<float>(c2.red() - c1.red()) * fraction + c1.red());
|
||||
const int g = static_cast<int>(static_cast<float>(c2.green() - c1.green()) * fraction + c1.green());
|
||||
const int b = static_cast<int>(static_cast<float>(c2.blue() - c1.blue()) * fraction + c1.blue());
|
||||
return QColor(r, g, b);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ float TimelineWidget::SnapTime(float time)
|
||||
{
|
||||
double t = floor((double)time * m_ticksStep + 0.5);
|
||||
t = t / m_ticksStep;
|
||||
return t;
|
||||
return static_cast<float>(t);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -147,10 +147,10 @@ void TimelineWidget::DrawTicks(QPainter* painter)
|
||||
painter->setPen(redpen);
|
||||
int x = TimeToClient(m_fTimeMarker);
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawRect(QRect(QPoint(x - 3, rc.top()), QPoint(x + 4, rc.bottom())));
|
||||
painter->drawRect(QRect(QPoint(x - 3, static_cast<int>(rc.top())), QPoint(x + 4, static_cast<int>(rc.bottom()))));
|
||||
|
||||
painter->setPen(redpen);
|
||||
painter->drawLine(x, rc.top(), x, rc.bottom());
|
||||
painter->drawLine(x, static_cast<int>(rc.top()), x, static_cast<int>(rc.bottom()));
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
|
||||
// Draw vertical line showing current time.
|
||||
@@ -184,7 +184,7 @@ void TimelineWidget::DrawTicks(QPainter* painter)
|
||||
float keyTime = (m_pKeyTimeSet ? m_pKeyTimeSet->GetKeyTime(keyTimeIndex) : 0.0f);
|
||||
|
||||
int x2 = TimeToClient(keyTime);
|
||||
painter->drawRect(QRect(QPoint(x2 - 2, rc.top()), QPoint(x2 + 3, rc.bottom())));
|
||||
painter->drawRect(QRect(QPoint(x2 - 2, static_cast<int>(rc.top())), QPoint(x2 + 3, static_cast<int>(rc.bottom()))));
|
||||
}
|
||||
|
||||
painter->setPen(pOldPen);
|
||||
|
||||
@@ -320,7 +320,7 @@ bool CUiAVCustomizeTrackColorsDlg::Import(const QString& fullPath)
|
||||
{
|
||||
return entry.paramType == paramType;
|
||||
});
|
||||
int entryIndex = pEntry - g_trackEntries;
|
||||
int entryIndex = static_cast<int>(pEntry - g_trackEntries);
|
||||
if (entryIndex >= arraysize(g_trackEntries)) // If not found, skip this.
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -1470,7 +1470,7 @@ void CUiAnimViewDialog::OnSnapFPS()
|
||||
if (ok)
|
||||
{
|
||||
m_wndDopeSheet->SetSnapFPS(fps);
|
||||
m_wndCurveEditor->SetFPS(fps);
|
||||
m_wndCurveEditor->SetFPS(static_cast<float>(fps));
|
||||
|
||||
SetCursorPosText(m_animationContext->GetTime());
|
||||
}
|
||||
@@ -1541,7 +1541,7 @@ void CUiAnimViewDialog::ReadMiscSettings()
|
||||
|
||||
if (settings.contains(s_kFrameSnappingFPSEntry))
|
||||
{
|
||||
float fps = settings.value(s_kFrameSnappingFPSEntry).toDouble();
|
||||
float fps = settings.value(s_kFrameSnappingFPSEntry).toFloat();
|
||||
m_wndDopeSheet->SetSnapFPS(FloatToIntRet(fps));
|
||||
m_wndCurveEditor->SetFPS(fps);
|
||||
}
|
||||
|
||||
@@ -139,8 +139,7 @@ CUiAnimViewDopeSheetBase::~CUiAnimViewDopeSheetBase()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CUiAnimViewDopeSheetBase::TimeToClient(float time) const
|
||||
{
|
||||
int x = m_leftOffset - m_scrollOffset.x() + (time * m_timeScale);
|
||||
return x;
|
||||
return static_cast<int>(m_leftOffset - m_scrollOffset.x() + (time * m_timeScale));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -186,7 +185,7 @@ void CUiAnimViewDopeSheetBase::SetTimeRange(float start, float end)
|
||||
|
||||
m_timeRange.Set(start, end);
|
||||
|
||||
SetHorizontalExtent(-m_leftOffset, m_timeRange.end * m_timeScale - m_leftOffset);
|
||||
SetHorizontalExtent(-m_leftOffset, static_cast<int>(m_timeRange.end * m_timeScale - m_leftOffset));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -255,7 +254,7 @@ void CUiAnimViewDopeSheetBase::SetTimeScale(float timeScale, float fAnchorTime)
|
||||
|
||||
update();
|
||||
|
||||
SetHorizontalExtent(-m_leftOffset, m_timeRange.end * m_timeScale);
|
||||
SetHorizontalExtent(-m_leftOffset, static_cast<int>(m_timeRange.end * m_timeScale));
|
||||
|
||||
ComputeFrameSteps(GetVisibleRange());
|
||||
}
|
||||
@@ -346,15 +345,15 @@ float CUiAnimViewDopeSheetBase::TickSnap(float time) const
|
||||
double tickTime = GetTickTime();
|
||||
double t = floor(((double)time / tickTime) + 0.5);
|
||||
t *= tickTime;
|
||||
return t;
|
||||
return static_cast<float>(t);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float CUiAnimViewDopeSheetBase::TimeFromPoint(const QPoint& point) const
|
||||
{
|
||||
int x = point.x() - m_leftOffset + m_scrollOffset.x();
|
||||
double t = (double)x / m_timeScale;
|
||||
return (float)TickSnap(t);
|
||||
float t = static_cast<float>(x) / m_timeScale;
|
||||
return TickSnap(t);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -362,7 +361,7 @@ float CUiAnimViewDopeSheetBase::TimeFromPointUnsnapped(const QPoint& point) cons
|
||||
{
|
||||
int x = point.x() - m_leftOffset + m_scrollOffset.x();
|
||||
double t = (double)x / m_timeScale;
|
||||
return t;
|
||||
return static_cast<float>(t);
|
||||
}
|
||||
|
||||
void CUiAnimViewDopeSheetBase::mousePressEvent(QMouseEvent* event)
|
||||
@@ -1651,7 +1650,7 @@ float CUiAnimViewDopeSheetBase::FrameSnap(float time) const
|
||||
{
|
||||
double t = floor((double)time / m_snapFrameTime + 0.5);
|
||||
t = t * m_snapFrameTime;
|
||||
return t;
|
||||
return static_cast<float>(t);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1755,9 +1754,10 @@ bool CUiAnimViewDopeSheetBase::CreateColorKey(CUiAnimViewTrack* pTrack, float ke
|
||||
Vec3 vColor(0, 0, 0);
|
||||
pTrack->GetValue(keyTime, vColor);
|
||||
|
||||
const AZ::Color defaultColor = AZ::Color::CreateFromRgba(clamp_tpl(FloatToIntRet(vColor.x), 0, 255),
|
||||
clamp_tpl(FloatToIntRet(vColor.y), 0, 255),
|
||||
clamp_tpl(FloatToIntRet(vColor.z), 0, 255), 255);
|
||||
const AZ::Color defaultColor = AZ::Color::CreateFromRgba(
|
||||
clamp_tpl(static_cast<AZ::u8>(FloatToIntRet(vColor.x)), AZ::u8(0), AZ::u8(255)),
|
||||
clamp_tpl(static_cast<AZ::u8>(FloatToIntRet(vColor.y)), AZ::u8(0), AZ::u8(255)),
|
||||
clamp_tpl(static_cast<AZ::u8>(FloatToIntRet(vColor.z)), AZ::u8(0), AZ::u8(255)), 255);
|
||||
AzQtComponents::ColorPicker dlg(AzQtComponents::ColorPicker::Configuration::RGB, tr("Select Color"), this);
|
||||
dlg.setCurrentColor(defaultColor);
|
||||
dlg.setSelectedColor(defaultColor);
|
||||
@@ -1997,12 +1997,12 @@ void CUiAnimViewDopeSheetBase::DrawTicks(QPainter* painter, const QRect& rc, Ran
|
||||
nNumberTicks = 8;
|
||||
}
|
||||
|
||||
double start = TickSnap(timeRange.start);
|
||||
double step = 1.0 / m_ticksStep;
|
||||
float start = TickSnap(timeRange.start);
|
||||
float step = 1.0f / static_cast<float>(m_ticksStep);
|
||||
|
||||
for (double t = 0.0f; t <= timeRange.end + step; t += step)
|
||||
for (float t = 0.0f; t <= timeRange.end + step; t += step)
|
||||
{
|
||||
double st = TickSnap(t);
|
||||
float st = TickSnap(t);
|
||||
if (st > timeRange.end)
|
||||
{
|
||||
st = timeRange.end;
|
||||
@@ -2021,7 +2021,7 @@ void CUiAnimViewDopeSheetBase::DrawTicks(QPainter* painter, const QRect& rc, Ran
|
||||
continue;
|
||||
}
|
||||
|
||||
int k = RoundFloatToInt(st * m_ticksStep);
|
||||
int k = RoundFloatToInt(st * static_cast<float>(m_ticksStep));
|
||||
if (k % nNumberTicks == 0)
|
||||
{
|
||||
if (st >= start)
|
||||
@@ -2743,7 +2743,7 @@ void CUiAnimViewDopeSheetBase::ComputeFrameSteps(const Range& visRange)
|
||||
float nBIntermediateTicks = 5;
|
||||
m_fFrameLabelStep = fFact * afStepTable[nStepIdx];
|
||||
|
||||
if (TimeToClient(m_fFrameLabelStep) - TimeToClient(0) > 1300)
|
||||
if (TimeToClient(static_cast<float>(m_fFrameLabelStep)) - TimeToClient(0) > 1300)
|
||||
{
|
||||
nBIntermediateTicks = 10;
|
||||
}
|
||||
@@ -2755,7 +2755,7 @@ void CUiAnimViewDopeSheetBase::ComputeFrameSteps(const Range& visRange)
|
||||
void CUiAnimViewDopeSheetBase::DrawTimeLineInFrames(QPainter* painter, const QRect& rc, [[maybe_unused]] const QColor& lineCol, const QColor& textCol, [[maybe_unused]] double step)
|
||||
{
|
||||
float fFramesPerSec = 1.0f / m_snapFrameTime;
|
||||
float fInvFrameLabelStep = 1.0f / m_fFrameLabelStep;
|
||||
float fInvFrameLabelStep = 1.0f / static_cast<float>(m_fFrameLabelStep);
|
||||
Range VisRange = GetVisibleRange();
|
||||
|
||||
const Range& timeRange = m_timeRange;
|
||||
@@ -2763,9 +2763,9 @@ void CUiAnimViewDopeSheetBase::DrawTimeLineInFrames(QPainter* painter, const QRe
|
||||
const QPen ltgray(QColor(90, 90, 90));
|
||||
const QPen black(textCol);
|
||||
|
||||
for (double t = TickSnap(timeRange.start); t <= timeRange.end + m_fFrameTickStep; t += m_fFrameTickStep)
|
||||
for (float t = TickSnap(timeRange.start); t <= timeRange.end + static_cast<float>(m_fFrameTickStep); t += static_cast<float>(m_fFrameTickStep))
|
||||
{
|
||||
double st = t;
|
||||
float st = t;
|
||||
if (st > timeRange.end)
|
||||
{
|
||||
st = timeRange.end;
|
||||
@@ -2810,9 +2810,9 @@ void CUiAnimViewDopeSheetBase::DrawTimeLineInSeconds(QPainter* painter, const QR
|
||||
const QPen ltgray(QColor(90, 90, 90));
|
||||
const QPen black(textCol);
|
||||
|
||||
for (double t = TickSnap(timeRange.start); t <= timeRange.end + step; t += step)
|
||||
for (float t = TickSnap(timeRange.start); t <= timeRange.end + static_cast<float>(step); t += static_cast<float>(step))
|
||||
{
|
||||
double st = TickSnap(t);
|
||||
float st = TickSnap(t);
|
||||
if (st > timeRange.end)
|
||||
{
|
||||
st = timeRange.end;
|
||||
@@ -2831,7 +2831,7 @@ void CUiAnimViewDopeSheetBase::DrawTimeLineInSeconds(QPainter* painter, const QR
|
||||
}
|
||||
int x = TimeToClient(st);
|
||||
|
||||
int k = RoundFloatToInt(st * m_ticksStep);
|
||||
int k = RoundFloatToInt(st * static_cast<float>(m_ticksStep));
|
||||
if (k % nNumberTicks == 0)
|
||||
{
|
||||
painter->setPen(black);
|
||||
|
||||
@@ -95,88 +95,88 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void dragMoveEvent(QDragMoveEvent* event)
|
||||
void dragMoveEvent([[maybe_unused]] QDragMoveEvent* event)
|
||||
{
|
||||
// For now we do not support any drag and drop in the Nodes pane
|
||||
return;
|
||||
|
||||
CUiAnimViewNodesCtrl::CRecord* pRecord = (CUiAnimViewNodesCtrl::CRecord*) itemAt(event->pos());
|
||||
if (!pRecord)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CUiAnimViewNode* pTargetNode = pRecord->GetNode();
|
||||
|
||||
QTreeWidget::dragMoveEvent(event);
|
||||
if (!event->isAccepted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (pTargetNode && pTargetNode->IsGroupNode() /*&& !m_draggedNodes.DoesContain(pTargetNode)*/)
|
||||
{
|
||||
CUiAnimViewAnimNode* pDragTarget = static_cast<CUiAnimViewAnimNode*>(pTargetNode);
|
||||
bool bAllValidReparenting = true;
|
||||
QList<CUiAnimViewAnimNode*> nodes = draggedNodes(event);
|
||||
Q_FOREACH(CUiAnimViewAnimNode * pDraggedNode, nodes)
|
||||
{
|
||||
if (!pDraggedNode->IsValidReparentingTo(pDragTarget))
|
||||
{
|
||||
bAllValidReparenting = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAllValidReparenting)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
//CUiAnimViewNodesCtrl::CRecord* pRecord = (CUiAnimViewNodesCtrl::CRecord*) itemAt(event->pos());
|
||||
//if (!pRecord)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//CUiAnimViewNode* pTargetNode = pRecord->GetNode();
|
||||
//
|
||||
//QTreeWidget::dragMoveEvent(event);
|
||||
//if (!event->isAccepted())
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//
|
||||
//if (pTargetNode && pTargetNode->IsGroupNode() /*&& !m_draggedNodes.DoesContain(pTargetNode)*/)
|
||||
//{
|
||||
// CUiAnimViewAnimNode* pDragTarget = static_cast<CUiAnimViewAnimNode*>(pTargetNode);
|
||||
// bool bAllValidReparenting = true;
|
||||
// QList<CUiAnimViewAnimNode*> nodes = draggedNodes(event);
|
||||
// Q_FOREACH(CUiAnimViewAnimNode * pDraggedNode, nodes)
|
||||
// {
|
||||
// if (!pDraggedNode->IsValidReparentingTo(pDragTarget))
|
||||
// {
|
||||
// bAllValidReparenting = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!bAllValidReparenting)
|
||||
// {
|
||||
// event->ignore();
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
//}
|
||||
}
|
||||
|
||||
void dropEvent(QDropEvent* event)
|
||||
void dropEvent([[maybe_unused]] QDropEvent* event)
|
||||
{
|
||||
// For now we do not support any drag and drop in the Nodes pane
|
||||
return;
|
||||
|
||||
CUiAnimViewNodesCtrl::CRecord* pRecord = (CUiAnimViewNodesCtrl::CRecord*) itemAt(event->pos());
|
||||
if (!pRecord)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CUiAnimViewNode* pTargetNode = pRecord->GetNode();
|
||||
|
||||
QTreeWidget::dropEvent(event);
|
||||
if (!event->isAccepted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (pTargetNode && pTargetNode->IsGroupNode() /*&& !m_draggedNodes.DoesContain(pTargetNode)*/)
|
||||
{
|
||||
CUiAnimViewAnimNode* pDragTarget = static_cast<CUiAnimViewAnimNode*>(pTargetNode);
|
||||
bool bAllValidReparenting = true;
|
||||
QList<CUiAnimViewAnimNode*> nodes = draggedNodes(event);
|
||||
Q_FOREACH(CUiAnimViewAnimNode * pDraggedNode, nodes)
|
||||
{
|
||||
if (!pDraggedNode->IsValidReparentingTo(pDragTarget))
|
||||
{
|
||||
bAllValidReparenting = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bAllValidReparenting)
|
||||
{
|
||||
UiAnimUndo undo("Drag and Drop UiAnimView Nodes");
|
||||
Q_FOREACH(CUiAnimViewAnimNode * pDraggedNode, nodes)
|
||||
{
|
||||
pDraggedNode->SetNewParent(pDragTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
//CUiAnimViewNodesCtrl::CRecord* pRecord = (CUiAnimViewNodesCtrl::CRecord*) itemAt(event->pos());
|
||||
//if (!pRecord)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//CUiAnimViewNode* pTargetNode = pRecord->GetNode();
|
||||
//
|
||||
//QTreeWidget::dropEvent(event);
|
||||
//if (!event->isAccepted())
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//
|
||||
//if (pTargetNode && pTargetNode->IsGroupNode() /*&& !m_draggedNodes.DoesContain(pTargetNode)*/)
|
||||
//{
|
||||
// CUiAnimViewAnimNode* pDragTarget = static_cast<CUiAnimViewAnimNode*>(pTargetNode);
|
||||
// bool bAllValidReparenting = true;
|
||||
// QList<CUiAnimViewAnimNode*> nodes = draggedNodes(event);
|
||||
// Q_FOREACH(CUiAnimViewAnimNode * pDraggedNode, nodes)
|
||||
// {
|
||||
// if (!pDraggedNode->IsValidReparentingTo(pDragTarget))
|
||||
// {
|
||||
// bAllValidReparenting = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (bAllValidReparenting)
|
||||
// {
|
||||
// UiAnimUndo undo("Drag and Drop UiAnimView Nodes");
|
||||
// Q_FOREACH(CUiAnimViewAnimNode * pDraggedNode, nodes)
|
||||
// {
|
||||
// pDraggedNode->SetNewParent(pDragTarget);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
void keyPressEvent(QKeyEvent* event)
|
||||
|
||||
@@ -32,8 +32,7 @@ namespace QtHelpers
|
||||
|
||||
float GetHighDpiScaleFactor(const QWidget& widget)
|
||||
{
|
||||
float dpiScale = QHighDpiScaling::factor(widget.windowHandle()->screen());
|
||||
return dpiScale;
|
||||
return static_cast<float>(QHighDpiScaling::factor(widget.windowHandle()->screen()));
|
||||
}
|
||||
|
||||
QSize GetDpiScaledViewportSize(const QWidget& widget)
|
||||
@@ -41,7 +40,7 @@ namespace QtHelpers
|
||||
float dpiScale = GetHighDpiScaleFactor(widget);
|
||||
float width = ceilf(widget.size().width() * dpiScale);
|
||||
float height = ceilf(widget.size().height() * dpiScale);
|
||||
return QSize(width, height);
|
||||
return QSize(static_cast<int>(width), static_cast<int>(height));
|
||||
}
|
||||
|
||||
} // namespace QtHelpers
|
||||
|
||||
@@ -27,7 +27,7 @@ AZ::Vector2 ViewportIcon::GetTextureSize() const
|
||||
if (m_image)
|
||||
{
|
||||
AZ::RHI::Size size = m_image->GetDescriptor().m_size;
|
||||
AZ::Vector2 scaledSize(size.m_width, size.m_height);
|
||||
AZ::Vector2 scaledSize(static_cast<float>(size.m_width), static_cast<float>(size.m_height));
|
||||
if (m_applyDpiScaleFactorToSize)
|
||||
{
|
||||
scaledSize *= m_dpiScaleFactor;
|
||||
|
||||
@@ -1001,7 +1001,7 @@ void ViewportWidget::RenderEditMode()
|
||||
|
||||
// Render this canvas
|
||||
QSize scaledViewportSize = QtHelpers::GetDpiScaledViewportSize(*this);
|
||||
AZ::Vector2 viewportSize(scaledViewportSize.width(), scaledViewportSize.height());
|
||||
AZ::Vector2 viewportSize(static_cast<float>(scaledViewportSize.width()), static_cast<float>(scaledViewportSize.height()));
|
||||
EBUS_EVENT_ID(canvasEntityId, UiEditorCanvasBus, RenderCanvasInEditorViewport, false, viewportSize);
|
||||
|
||||
m_draw2d->SetSortKey(topLayerKey);
|
||||
@@ -1111,7 +1111,7 @@ void ViewportWidget::UpdatePreviewMode(float deltaTime)
|
||||
if (canvasEntityId.IsValid())
|
||||
{
|
||||
QSize scaledViewportSize = QtHelpers::GetDpiScaledViewportSize(*this);
|
||||
AZ::Vector2 viewportSize(scaledViewportSize.width(), scaledViewportSize.height());
|
||||
AZ::Vector2 viewportSize(static_cast<float>(scaledViewportSize.width()), static_cast<float>(scaledViewportSize.height()));
|
||||
|
||||
// Get the canvas size
|
||||
AZ::Vector2 canvasSize = m_editorWindow->GetPreviewCanvasSize();
|
||||
@@ -1153,7 +1153,7 @@ void ViewportWidget::RenderPreviewMode()
|
||||
if (canvasEntityId.IsValid())
|
||||
{
|
||||
QSize scaledViewportSize = QtHelpers::GetDpiScaledViewportSize(*this);
|
||||
AZ::Vector2 viewportSize(scaledViewportSize.width(), scaledViewportSize.height());
|
||||
AZ::Vector2 viewportSize(static_cast<float>(scaledViewportSize.width()), static_cast<float>(scaledViewportSize.height()));
|
||||
|
||||
// Get the canvas size
|
||||
AZ::Vector2 canvasSize = m_editorWindow->GetPreviewCanvasSize();
|
||||
@@ -1239,7 +1239,7 @@ void ViewportWidget::RenderViewportBackground()
|
||||
|
||||
Draw2dHelper draw2d(m_draw2d.get());
|
||||
draw2d.SetImageColor(backgroundColor.GetAsVector3());
|
||||
draw2d.DrawImage(image, AZ::Vector2(0.0f, 0.0f), AZ::Vector2(viewportSize.width(), viewportSize.height()));
|
||||
draw2d.DrawImage(image, AZ::Vector2(0.0f, 0.0f), AZ::Vector2(static_cast<float>(viewportSize.width()), static_cast<float>(viewportSize.height())));
|
||||
}
|
||||
|
||||
void ViewportWidget::SetupShortcuts()
|
||||
|
||||
@@ -808,7 +808,7 @@ UiCanvasComponent* UiCanvasManager::FindEditorCanvasComponentByPathname(const AZ
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool UiCanvasManager::HandleInputEventForInWorldCanvases(const AzFramework::InputChannel::Snapshot& inputSnapshot, const AZ::Vector2& viewportPos)
|
||||
bool UiCanvasManager::HandleInputEventForInWorldCanvases([[maybe_unused]] const AzFramework::InputChannel::Snapshot& inputSnapshot, [[maybe_unused]] const AZ::Vector2& viewportPos)
|
||||
{
|
||||
// First we need to construct a ray from the either the center of the screen or the mouse position.
|
||||
// This requires knowledge of the camera
|
||||
@@ -816,86 +816,86 @@ bool UiCanvasManager::HandleInputEventForInWorldCanvases(const AzFramework::Inpu
|
||||
|
||||
// ToDo: Re-implement by getting the camera from Atom. LYN-3680
|
||||
return false;
|
||||
const CCamera cam;
|
||||
|
||||
// construct a ray from the camera position in the view direction of the camera
|
||||
const float rayLength = 5000.0f;
|
||||
Vec3 rayOrigin(cam.GetPosition());
|
||||
Vec3 rayDirection = cam.GetViewdir() * rayLength;
|
||||
|
||||
// If the mouse cursor is visible we will assume that the ray should be in the direction of the
|
||||
// mouse pointer. This is a temporary solution. A better solution is to be able to configure the
|
||||
// LyShine system to say how ray input should be handled.
|
||||
bool isCursorVisible = false;
|
||||
UiCursorBus::BroadcastResult(isCursorVisible, &UiCursorInterface::IsUiCursorVisible);
|
||||
if (isCursorVisible)
|
||||
{
|
||||
// for some reason Unproject seems to work when given the viewport pos with (0,0) at the
|
||||
// bottom left as opposed to the top left - even though that function specifically sets top left
|
||||
// to (0,0).
|
||||
const float viewportYInverted = cam.GetViewSurfaceZ() - viewportPos.GetY();
|
||||
|
||||
// Unproject to get the screen position in world space, use arbitrary Z that is within the depth range
|
||||
Vec3 flippedViewportRayOrigin(viewportPos.GetX(), viewportYInverted, 0.f);
|
||||
Vec3 flippedViewportRayForward(viewportPos.GetX(), viewportYInverted, 1.f);
|
||||
|
||||
cam.Unproject(flippedViewportRayOrigin, rayOrigin);
|
||||
|
||||
Vec3 unprojectedPosForward;
|
||||
cam.Unproject(flippedViewportRayForward, unprojectedPosForward);
|
||||
|
||||
// We want a vector relative to the camera origin
|
||||
Vec3 rayVec = unprojectedPosForward - rayOrigin;
|
||||
|
||||
// we want to ensure that the ray is a certain length so normalize it and scale it
|
||||
rayVec.NormalizeSafe();
|
||||
rayDirection = rayVec * rayLength;
|
||||
}
|
||||
|
||||
|
||||
AzFramework::EntityContextId gameContextId;
|
||||
AzFramework::GameEntityContextRequestBus::BroadcastResult(gameContextId,
|
||||
&AzFramework::GameEntityContextRequests::GetGameEntityContextId);
|
||||
|
||||
AzFramework::RenderGeometry::RayRequest request;
|
||||
request.m_startWorldPosition = LYVec3ToAZVec3(rayOrigin);
|
||||
request.m_endWorldPosition = LYVec3ToAZVec3(rayOrigin + rayDirection);
|
||||
|
||||
AzFramework::RenderGeometry::RayResult rayResult;
|
||||
AzFramework::RenderGeometry::IntersectorBus::EventResult(rayResult, gameContextId,
|
||||
&AzFramework::RenderGeometry::IntersectorInterface::RayIntersect, request);
|
||||
|
||||
if (rayResult)
|
||||
{
|
||||
AZ::EntityId hitEntity = rayResult.m_entityAndComponent.GetEntityId();
|
||||
if (hitEntity.IsValid())
|
||||
{
|
||||
AZ::EntityId canvasEntityId;
|
||||
UiCanvasRefBus::EventResult(canvasEntityId, hitEntity, &UiCanvasRefInterface::GetCanvas);
|
||||
if (canvasEntityId.IsValid())
|
||||
{
|
||||
// Checkif the UI canvas referenced by the hit entity supports automatic input
|
||||
bool doesCanvasSupportInput = false;
|
||||
UiCanvasBus::EventResult(doesCanvasSupportInput, canvasEntityId, &UiCanvasInterface::GetIsPositionalInputSupported);
|
||||
|
||||
if (doesCanvasSupportInput)
|
||||
{
|
||||
// set the hit details to the hit entity, it will convert into canvas coords and send to canvas
|
||||
bool handled = false;
|
||||
UiCanvasOnMeshBus::EventResult(handled, hitEntity,
|
||||
&UiCanvasOnMeshInterface::ProcessHitInputEvent, inputSnapshot, rayResult);
|
||||
|
||||
if (handled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
//const CCamera cam;
|
||||
//
|
||||
//// construct a ray from the camera position in the view direction of the camera
|
||||
//const float rayLength = 5000.0f;
|
||||
//Vec3 rayOrigin(cam.GetPosition());
|
||||
//Vec3 rayDirection = cam.GetViewdir() * rayLength;
|
||||
//
|
||||
//// If the mouse cursor is visible we will assume that the ray should be in the direction of the
|
||||
//// mouse pointer. This is a temporary solution. A better solution is to be able to configure the
|
||||
//// LyShine system to say how ray input should be handled.
|
||||
//bool isCursorVisible = false;
|
||||
//UiCursorBus::BroadcastResult(isCursorVisible, &UiCursorInterface::IsUiCursorVisible);
|
||||
//if (isCursorVisible)
|
||||
//{
|
||||
// // for some reason Unproject seems to work when given the viewport pos with (0,0) at the
|
||||
// // bottom left as opposed to the top left - even though that function specifically sets top left
|
||||
// // to (0,0).
|
||||
// const float viewportYInverted = cam.GetViewSurfaceZ() - viewportPos.GetY();
|
||||
//
|
||||
// // Unproject to get the screen position in world space, use arbitrary Z that is within the depth range
|
||||
// Vec3 flippedViewportRayOrigin(viewportPos.GetX(), viewportYInverted, 0.f);
|
||||
// Vec3 flippedViewportRayForward(viewportPos.GetX(), viewportYInverted, 1.f);
|
||||
//
|
||||
// cam.Unproject(flippedViewportRayOrigin, rayOrigin);
|
||||
//
|
||||
// Vec3 unprojectedPosForward;
|
||||
// cam.Unproject(flippedViewportRayForward, unprojectedPosForward);
|
||||
//
|
||||
// // We want a vector relative to the camera origin
|
||||
// Vec3 rayVec = unprojectedPosForward - rayOrigin;
|
||||
//
|
||||
// // we want to ensure that the ray is a certain length so normalize it and scale it
|
||||
// rayVec.NormalizeSafe();
|
||||
// rayDirection = rayVec * rayLength;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//AzFramework::EntityContextId gameContextId;
|
||||
//AzFramework::GameEntityContextRequestBus::BroadcastResult(gameContextId,
|
||||
// &AzFramework::GameEntityContextRequests::GetGameEntityContextId);
|
||||
//
|
||||
//AzFramework::RenderGeometry::RayRequest request;
|
||||
//request.m_startWorldPosition = LYVec3ToAZVec3(rayOrigin);
|
||||
//request.m_endWorldPosition = LYVec3ToAZVec3(rayOrigin + rayDirection);
|
||||
//
|
||||
//AzFramework::RenderGeometry::RayResult rayResult;
|
||||
//AzFramework::RenderGeometry::IntersectorBus::EventResult(rayResult, gameContextId,
|
||||
// &AzFramework::RenderGeometry::IntersectorInterface::RayIntersect, request);
|
||||
//
|
||||
//if (rayResult)
|
||||
//{
|
||||
// AZ::EntityId hitEntity = rayResult.m_entityAndComponent.GetEntityId();
|
||||
// if (hitEntity.IsValid())
|
||||
// {
|
||||
// AZ::EntityId canvasEntityId;
|
||||
// UiCanvasRefBus::EventResult(canvasEntityId, hitEntity, &UiCanvasRefInterface::GetCanvas);
|
||||
// if (canvasEntityId.IsValid())
|
||||
// {
|
||||
// // Checkif the UI canvas referenced by the hit entity supports automatic input
|
||||
// bool doesCanvasSupportInput = false;
|
||||
// UiCanvasBus::EventResult(doesCanvasSupportInput, canvasEntityId, &UiCanvasInterface::GetIsPositionalInputSupported);
|
||||
//
|
||||
// if (doesCanvasSupportInput)
|
||||
// {
|
||||
// // set the hit details to the hit entity, it will convert into canvas coords and send to canvas
|
||||
// bool handled = false;
|
||||
// UiCanvasOnMeshBus::EventResult(handled, hitEntity,
|
||||
// &UiCanvasOnMeshInterface::ProcessHitInputEvent, inputSnapshot, rayResult);
|
||||
//
|
||||
// if (handled)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//
|
||||
//return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user