Fixing gestures gem warnings when gEnv/pTimer is null

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
monroegm-disable-blank-issue-2
Guthrie Adams 4 years ago
parent f2e6c2dc2b
commit 3ad3e557e5

@ -73,12 +73,12 @@ inline Gestures::RecognizerClickOrTap::~RecognizerClickOrTap()
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerClickOrTap::OnPressedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerClickOrTap::OnPressedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
const CTimeValue currentTime = gEnv->pTimer->GetFrameStartTime(); const CTimeValue currentTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime() : CTimeValue();
switch (m_currentState) switch (m_currentState)
{ {
case State::Idle: case State::Idle:
@ -120,7 +120,7 @@ inline bool Gestures::RecognizerClickOrTap::OnPressedEvent(const AZ::Vector2& sc
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerClickOrTap::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerClickOrTap::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -129,7 +129,7 @@ inline bool Gestures::RecognizerClickOrTap::OnDownEvent(const AZ::Vector2& scree
{ {
case State::Pressed: case State::Pressed:
{ {
const CTimeValue currentTime = gEnv->pTimer->GetFrameStartTime(); const CTimeValue currentTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime() : CTimeValue();
if ((currentTime.GetDifferenceInSeconds(m_timeOfLastEvent) > m_config.maxSecondsHeld) || if ((currentTime.GetDifferenceInSeconds(m_timeOfLastEvent) > m_config.maxSecondsHeld) ||
(screenPosition.GetDistance(m_positionOfLastEvent) > m_config.maxPixelsMoved)) (screenPosition.GetDistance(m_positionOfLastEvent) > m_config.maxPixelsMoved))
{ {
@ -159,7 +159,7 @@ inline bool Gestures::RecognizerClickOrTap::OnDownEvent(const AZ::Vector2& scree
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerClickOrTap::OnReleasedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerClickOrTap::OnReleasedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -168,7 +168,7 @@ inline bool Gestures::RecognizerClickOrTap::OnReleasedEvent(const AZ::Vector2& s
{ {
case State::Pressed: case State::Pressed:
{ {
const CTimeValue currentTime = gEnv->pTimer->GetFrameStartTime(); const CTimeValue currentTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime() : CTimeValue();
if ((currentTime.GetDifferenceInSeconds(m_timeOfLastEvent) > m_config.maxSecondsHeld) || if ((currentTime.GetDifferenceInSeconds(m_timeOfLastEvent) > m_config.maxSecondsHeld) ||
(screenPosition.GetDistance(m_positionOfLastEvent) > m_config.maxPixelsMoved)) (screenPosition.GetDistance(m_positionOfLastEvent) > m_config.maxPixelsMoved))
{ {

@ -59,7 +59,7 @@ inline Gestures::RecognizerDrag::~RecognizerDrag()
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerDrag::OnPressedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerDrag::OnPressedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -68,7 +68,7 @@ inline bool Gestures::RecognizerDrag::OnPressedEvent(const AZ::Vector2& screenPo
{ {
case State::Idle: case State::Idle:
{ {
m_startTime = gEnv->pTimer->GetFrameStartTime().GetValue(); m_startTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime().GetValue() : 0;
m_startPosition = screenPosition; m_startPosition = screenPosition;
m_currentPosition = screenPosition; m_currentPosition = screenPosition;
m_currentState = State::Pressed; m_currentState = State::Pressed;
@ -90,7 +90,7 @@ inline bool Gestures::RecognizerDrag::OnPressedEvent(const AZ::Vector2& screenPo
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerDrag::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerDrag::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -101,7 +101,7 @@ inline bool Gestures::RecognizerDrag::OnDownEvent(const AZ::Vector2& screenPosit
{ {
case State::Pressed: case State::Pressed:
{ {
const CTimeValue currentTime = gEnv->pTimer->GetFrameStartTime(); const CTimeValue currentTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime() : CTimeValue();
if ((currentTime.GetDifferenceInSeconds(m_startTime) >= m_config.minSecondsHeld) && if ((currentTime.GetDifferenceInSeconds(m_startTime) >= m_config.minSecondsHeld) &&
(GetDistance() >= m_config.minPixelsMoved)) (GetDistance() >= m_config.minPixelsMoved))
{ {

@ -59,7 +59,7 @@ inline Gestures::RecognizerHold::~RecognizerHold()
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerHold::OnPressedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerHold::OnPressedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -68,7 +68,7 @@ inline bool Gestures::RecognizerHold::OnPressedEvent(const AZ::Vector2& screenPo
{ {
case State::Idle: case State::Idle:
{ {
m_startTime = gEnv->pTimer->GetFrameStartTime().GetValue(); m_startTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime().GetValue() : 0;
m_startPosition = screenPosition; m_startPosition = screenPosition;
m_currentPosition = screenPosition; m_currentPosition = screenPosition;
m_currentState = State::Pressed; m_currentState = State::Pressed;
@ -90,7 +90,7 @@ inline bool Gestures::RecognizerHold::OnPressedEvent(const AZ::Vector2& screenPo
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerHold::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerHold::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -101,7 +101,7 @@ inline bool Gestures::RecognizerHold::OnDownEvent(const AZ::Vector2& screenPosit
{ {
case State::Pressed: case State::Pressed:
{ {
const CTimeValue currentTime = gEnv->pTimer->GetFrameStartTime(); const CTimeValue currentTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime() : CTimeValue();
if (screenPosition.GetDistance(m_startPosition) > m_config.maxPixelsMoved) if (screenPosition.GetDistance(m_startPosition) > m_config.maxPixelsMoved)
{ {
// Hold recognition failed. // Hold recognition failed.

@ -106,13 +106,13 @@ inline float AngleInDegreesBetweenVectors(const AZ::Vector2& vec0, const AZ::Vec
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerPinch::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerPinch::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex > s_maxPinchPointerIndex) if (pointerIndex > s_maxPinchPointerIndex)
{ {
return false; return false;
} }
m_currentPositions[pointerIndex] = screenPosition; m_currentPositions[pointerIndex] = screenPosition;
m_lastUpdateTimes[pointerIndex] = gEnv->pTimer->GetFrameStartTime().GetValue(); m_lastUpdateTimes[pointerIndex] = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime().GetValue() : 0;
if (m_lastUpdateTimes[0] != m_lastUpdateTimes[1]) if (m_lastUpdateTimes[0] != m_lastUpdateTimes[1])
{ {
// We need to wait until both touches have been updated this frame. // We need to wait until both touches have been updated this frame.

@ -95,13 +95,13 @@ inline bool Gestures::RecognizerRotate::OnPressedEvent(const AZ::Vector2& screen
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerRotate::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerRotate::OnDownEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex > s_maxRotatePointerIndex) if (pointerIndex > s_maxRotatePointerIndex)
{ {
return false; return false;
} }
m_currentPositions[pointerIndex] = screenPosition; m_currentPositions[pointerIndex] = screenPosition;
m_lastUpdateTimes[pointerIndex] = gEnv->pTimer->GetFrameStartTime().GetValue(); m_lastUpdateTimes[pointerIndex] = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime().GetValue() : 0;
if (m_lastUpdateTimes[0] != m_lastUpdateTimes[1]) if (m_lastUpdateTimes[0] != m_lastUpdateTimes[1])
{ {
// We need to wait until both touches have been updated this frame. // We need to wait until both touches have been updated this frame.

@ -59,7 +59,7 @@ inline Gestures::RecognizerSwipe::~RecognizerSwipe()
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerSwipe::OnPressedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerSwipe::OnPressedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -68,7 +68,7 @@ inline bool Gestures::RecognizerSwipe::OnPressedEvent(const AZ::Vector2& screenP
{ {
case State::Idle: case State::Idle:
{ {
m_startTime = gEnv->pTimer->GetFrameStartTime().GetValue(); m_startTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime().GetValue() : 0;
m_startPosition = screenPosition; m_startPosition = screenPosition;
m_endPosition = screenPosition; m_endPosition = screenPosition;
m_currentState = State::Pressed; m_currentState = State::Pressed;
@ -89,7 +89,7 @@ inline bool Gestures::RecognizerSwipe::OnPressedEvent(const AZ::Vector2& screenP
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerSwipe::OnDownEvent([[maybe_unused]] const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerSwipe::OnDownEvent([[maybe_unused]] const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -98,7 +98,7 @@ inline bool Gestures::RecognizerSwipe::OnDownEvent([[maybe_unused]] const AZ::Ve
{ {
case State::Pressed: case State::Pressed:
{ {
const CTimeValue currentTime = gEnv->pTimer->GetFrameStartTime(); const CTimeValue currentTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime() : CTimeValue();
if (currentTime.GetDifferenceInSeconds(m_startTime) > m_config.maxSecondsHeld) if (currentTime.GetDifferenceInSeconds(m_startTime) > m_config.maxSecondsHeld)
{ {
// Swipe recognition failed because we took too long. // Swipe recognition failed because we took too long.
@ -125,7 +125,7 @@ inline bool Gestures::RecognizerSwipe::OnDownEvent([[maybe_unused]] const AZ::Ve
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool Gestures::RecognizerSwipe::OnReleasedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex) inline bool Gestures::RecognizerSwipe::OnReleasedEvent(const AZ::Vector2& screenPosition, uint32_t pointerIndex)
{ {
if (!gEnv || !gEnv->pTimer || pointerIndex != m_config.pointerIndex) if (pointerIndex != m_config.pointerIndex)
{ {
return false; return false;
} }
@ -134,7 +134,7 @@ inline bool Gestures::RecognizerSwipe::OnReleasedEvent(const AZ::Vector2& screen
{ {
case State::Pressed: case State::Pressed:
{ {
const CTimeValue currentTime = gEnv->pTimer->GetFrameStartTime(); const CTimeValue currentTime = (gEnv && gEnv->pTimer) ? gEnv->pTimer->GetFrameStartTime() : CTimeValue();
if ((currentTime.GetDifferenceInSeconds(m_startTime) <= m_config.maxSecondsHeld) && if ((currentTime.GetDifferenceInSeconds(m_startTime) <= m_config.maxSecondsHeld) &&
(screenPosition.GetDistance(m_startPosition) >= m_config.minPixelsMoved)) (screenPosition.GetDistance(m_startPosition) >= m_config.minPixelsMoved))
{ {

Loading…
Cancel
Save