Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/utils/modelinfomgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "pch.h"

#include <CCamera.h>
#include <CPools.h>
#include <CTxdStore.h>
#include <NodeName.h>
#include <RenderWare.h>
Expand All @@ -19,6 +20,7 @@
#include "defines.h"
#include "utils/meevents.h"
#include "utils/texmgr.h"
#include "utils/mathutil.h"

using namespace plugin;

Expand Down Expand Up @@ -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<RwFrame *>(pVeh->m_pRwClump->object.parent));
data.nFrameCount++;
} else {
data.nFrameCount++;
}
}
};
}

void ModelInfoMgr::RegisterRender(const RenderCallback_t &render) {
Expand Down