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) {