From 38584e55ddd929d72e847344ddff51cc48942d31 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 30 Sep 2020 23:14:10 +0100 Subject: [PATCH] Don't process an invalid window position This is used for computing a vector index, so it can't be negative. --- 3d-viewer/3d_rendering/ccamera.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/3d-viewer/3d_rendering/ccamera.cpp b/3d-viewer/3d_rendering/ccamera.cpp index c7467c4441..6cc779c200 100644 --- a/3d-viewer/3d_rendering/ccamera.cpp +++ b/3d-viewer/3d_rendering/ccamera.cpp @@ -383,10 +383,11 @@ void CCAMERA::MakeRayAtCurrrentMousePosition( SFVEC3F &aOutOrigin, const SFVEC2I windowPos = SFVEC2I( m_lastPosition.x, m_windowSize.y - m_lastPosition.y ); - if( ( windowPos.x < m_windowSize.x ) && - ( windowPos.y < m_windowSize.y ) ) - MakeRay( windowPos, - aOutOrigin, aOutDirection ); + if( ( 0 < windowPos.x ) && ( windowPos.x < m_windowSize.x ) && + ( 0 < windowPos.y ) && ( windowPos.y < m_windowSize.y ) ) + { + MakeRay( windowPos, aOutOrigin, aOutDirection ); + } }