@@ -73,9 +73,9 @@ CVector g_vecBulletFireEndPosition;
7373#define DOUBLECLICK_TIMEOUT 330
7474#define DOUBLECLICK_MOVE_THRESHOLD 10 .0f
7575
76- // Ray casting constants for marker click detection
77- constexpr float MARKER_CLICK_RAY_DEPTH = 300 .0f ; // Screen-to-world ray projection depth
78- constexpr float MARKER_CLICK_MAX_DISTANCE = 99999 . 9f ; // Maximum distance for closest marker comparison
76+ // Ray casting constants for click detection
77+ constexpr float CLICK_RAY_DEPTH = 300 .0f ; // Screen-to-world ray projection depth
78+ constexpr float MAX_CLICK_DISTANCE = 6000 . 0f ; // Maximum distance for closest marker comparison
7979
8080static constexpr long long TIME_DISCORD_UPDATE_RATE = 15000 ;
8181
@@ -2329,55 +2329,55 @@ void CClientGame::ProcessServerControlBind(CControlFunctionBind* pBind)
23292329 m_pNetAPI->RPC (KEY_BIND, bitStream.pBitStream );
23302330}
23312331
2332- CClientMarker* CClientGame::CheckMarkerClick (float fScreenX , float fScreenY , float & fDistance )
2332+ CClientMarker* CClientGame::CheckMarkerClick (float screenX , float screenY , float & distance) noexcept
23332333{
23342334 if (!m_pMarkerManager)
23352335 return nullptr ;
23362336
2337- CCamera* pCamera = g_pGame->GetCamera ();
2338- CMatrix matCamera ;
2339- pCamera ->GetMatrix (&matCamera );
2340- CVector vecOrigin = matCamera .vPos ;
2337+ CCamera* camera = g_pGame->GetCamera ();
2338+ CMatrix cameraMatrix ;
2339+ camera ->GetMatrix (&cameraMatrix );
2340+ CVector origin = cameraMatrix .vPos ;
23412341
2342- CVector vecTarget, vecScreen ( fScreenX , fScreenY , MARKER_CLICK_RAY_DEPTH );
2343- g_pCore->GetGraphics ()->CalcWorldCoors (&vecScreen , &vecTarget );
2342+ CVector target, screen (screenX, screenY, CLICK_RAY_DEPTH );
2343+ g_pCore->GetGraphics ()->CalcWorldCoors (&screen , &target );
23442344
2345- CVector vecRayDir = vecTarget - vecOrigin ;
2346- vecRayDir .Normalize ();
2345+ CVector rayDirection = target - origin ;
2346+ rayDirection .Normalize ();
23472347
2348- CClientMarker* pClosestMarker = nullptr ;
2349- float fClosestDist = MARKER_CLICK_MAX_DISTANCE ;
2348+ CClientMarker* closestMarker = nullptr ;
2349+ float closestDistance = MAX_CLICK_DISTANCE ;
23502350
2351- for (auto * pMarker : m_pMarkerManager->m_Markers )
2351+ for (auto * marker : m_pMarkerManager->m_Markers )
23522352 {
2353- if (!pMarker || !pMarker ->IsStreamedIn () || !pMarker ->IsVisible ())
2353+ if (!marker || !marker ->IsStreamedIn () || !marker ->IsVisible ())
23542354 continue ;
23552355
2356- if (!pMarker ->IsClientSideOnScreen ())
2356+ if (!marker ->IsClientSideOnScreen ())
23572357 continue ;
23582358
2359- CSphere boundingSphere = pMarker ->GetWorldBoundingSphere ();
2359+ CSphere boundingSphere = marker ->GetWorldBoundingSphere ();
23602360
2361- CVector vecToSphere = boundingSphere.vecPosition - vecOrigin ;
2362- float fProjection = vecToSphere .DotProduct (&vecRayDir );
2361+ CVector toSphere = boundingSphere.vecPosition - origin ;
2362+ float projection = toSphere .DotProduct (&rayDirection );
23632363
2364- if (fProjection <= 0 .0f )
2364+ if (projection <= 0 .0f )
23652365 continue ;
23662366
2367- CVector vecClosestPoint = vecOrigin + vecRayDir * fProjection ;
2368- float fDistanceToRay = (boundingSphere.vecPosition - vecClosestPoint ).Length ();
2367+ CVector closestPoint = origin + rayDirection * projection ;
2368+ float distanceToRay = (boundingSphere.vecPosition - closestPoint ).Length ();
23692369
2370- if (fDistanceToRay <= boundingSphere.fRadius && fProjection < fClosestDist )
2370+ if (distanceToRay <= boundingSphere.fRadius && projection < closestDistance )
23712371 {
2372- fClosestDist = fProjection ;
2373- pClosestMarker = pMarker ;
2372+ closestDistance = projection ;
2373+ closestMarker = marker ;
23742374 }
23752375 }
23762376
2377- if (pClosestMarker )
2378- fDistance = fClosestDist ;
2377+ if (closestMarker )
2378+ distance = closestDistance ;
23792379
2380- return pClosestMarker ;
2380+ return closestMarker ;
23812381}
23822382
23832383bool CClientGame::ProcessMessageForCursorEvents (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -2429,7 +2429,7 @@ bool CClientGame::ProcessMessageForCursorEvents(HWND hwnd, UINT uMsg, WPARAM wPa
24292429
24302430 CVector2D vecCursorPosition ((float )iX, (float )iY);
24312431
2432- CVector vecOrigin, vecTarget, vecScreen ((float )iX, (float )iY, 300 . 0f );
2432+ CVector vecOrigin, vecTarget, vecScreen ((float )iX, (float )iY, CLICK_RAY_DEPTH );
24332433 g_pCore->GetGraphics ()->CalcWorldCoors (&vecScreen, &vecTarget);
24342434
24352435 // Grab the camera position
@@ -2613,7 +2613,7 @@ bool CClientGame::ProcessMessageForCursorEvents(HWND hwnd, UINT uMsg, WPARAM wPa
26132613 CVector2D vecResolution = g_pCore->GetGUI ()->GetResolution ();
26142614 CVector2D vecCursorPosition (((float )iX) / vecResolution.fX , ((float )iY) / vecResolution.fY );
26152615
2616- CVector vecTarget, vecScreen ((float )iX, (float )iY, MARKER_CLICK_RAY_DEPTH );
2616+ CVector vecTarget, vecScreen ((float )iX, (float )iY, CLICK_RAY_DEPTH );
26172617 g_pCore->GetGraphics ()->CalcWorldCoors (&vecScreen, &vecTarget);
26182618
26192619 // Call the onClientCursorMove event
0 commit comments