From 346fa1f512b0e16e5b4c9be5d0742bb01d7bd121 Mon Sep 17 00:00:00 2001 From: Caner Karaca Date: Thu, 24 Sep 2026 22:00:00 +0300 Subject: [PATCH] fix(render): render coronas and shadows for offscreen vehicles in drawingEvent --- src/utils/modelinfomgr.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/utils/modelinfomgr.cpp b/src/utils/modelinfomgr.cpp index 89b84c16..88e633e4 100755 --- a/src/utils/modelinfomgr.cpp +++ b/src/utils/modelinfomgr.cpp @@ -2,6 +2,7 @@ #include "pch.h" #include +#include #include #include #include @@ -19,6 +20,7 @@ #include "defines.h" #include "utils/meevents.h" #include "utils/texmgr.h" +#include "utils/mathutil.h" using namespace plugin; @@ -181,6 +183,33 @@ void ModelInfoMgr::Init() { } } }; + + Events::drawingEvent += []() { + for (CVehicle *pVeh : CPools::ms_pVehiclePool) { + if (!pVeh || pVeh->m_nType != ENTITY_TYPE_VEHICLE || !pVeh->m_pRwClump || pVeh->GetIsOnScreen()) { + continue; + } + + if (pVeh->m_nVehicleSubClass == VEHICLE_BMX || pVeh->m_nVehicleSubClass == VEHICLE_BOAT || pVeh->m_nVehicleSubClass == VEHICLE_TRAILER) { + continue; + } + + if (MathUtil::DistanceSquared(pVeh->GetPosition(), TheCamera.GetPosition()) > (120.0f * 120.0f)) { + continue; + } + + auto &data = m_VehData.Get(pVeh); + if (data.nFrameCount > 10) { + ModelInfoMgr::OnRender(pVeh); + } else if (data.nFrameCount == 10) { + ModelInfoMgr::FindDummies( + pVeh, reinterpret_cast(pVeh->m_pRwClump->object.parent)); + data.nFrameCount++; + } else { + data.nFrameCount++; + } + } + }; } void ModelInfoMgr::RegisterRender(const RenderCallback_t &render) {