2019-05-15 10:52:37 -04:00
|
|
|
#include "common.h"
|
2020-04-17 09:31:11 -04:00
|
|
|
|
2019-10-29 19:12:58 -04:00
|
|
|
#include "General.h"
|
2019-06-17 04:30:02 -04:00
|
|
|
#include "TempColModels.h"
|
|
|
|
#include "ModelIndices.h"
|
2019-05-15 10:52:37 -04:00
|
|
|
#include "ModelInfo.h"
|
2020-08-16 10:26:44 -04:00
|
|
|
#include "Frontend.h"
|
2019-05-15 10:52:37 -04:00
|
|
|
|
2020-04-17 01:54:14 -04:00
|
|
|
CBaseModelInfo *CModelInfo::ms_modelInfoPtrs[MODELINFOSIZE];
|
2019-05-15 10:52:37 -04:00
|
|
|
|
|
|
|
CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore;
|
2020-01-20 15:41:41 -05:00
|
|
|
CStore<CMloModelInfo, MLOMODELSIZE> CModelInfo::ms_mloModelStore;
|
|
|
|
CStore<CInstance, MLOINSTANCESIZE> CModelInfo::ms_mloInstanceStore;
|
2019-05-15 10:52:37 -04:00
|
|
|
CStore<CTimeModelInfo, TIMEMODELSIZE> CModelInfo::ms_timeModelStore;
|
|
|
|
CStore<CClumpModelInfo, CLUMPMODELSIZE> CModelInfo::ms_clumpModelStore;
|
|
|
|
CStore<CPedModelInfo, PEDMODELSIZE> CModelInfo::ms_pedModelStore;
|
|
|
|
CStore<CVehicleModelInfo, VEHICLEMODELSIZE> CModelInfo::ms_vehicleModelStore;
|
2020-01-20 15:41:41 -05:00
|
|
|
CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> CModelInfo::ms_xtraCompsModelStore;
|
2019-05-15 10:52:37 -04:00
|
|
|
CStore<C2dEffect, TWODFXSIZE> CModelInfo::ms_2dEffectStore;
|
|
|
|
|
|
|
|
void
|
|
|
|
CModelInfo::Initialise(void)
|
|
|
|
{
|
|
|
|
int i;
|
2019-06-17 04:30:02 -04:00
|
|
|
CSimpleModelInfo *m;
|
|
|
|
|
2019-05-15 10:52:37 -04:00
|
|
|
for(i = 0; i < MODELINFOSIZE; i++)
|
|
|
|
ms_modelInfoPtrs[i] = nil;
|
|
|
|
ms_2dEffectStore.clear();
|
2020-01-20 15:41:41 -05:00
|
|
|
ms_mloInstanceStore.clear();
|
|
|
|
ms_xtraCompsModelStore.clear();
|
2019-05-15 10:52:37 -04:00
|
|
|
ms_simpleModelStore.clear();
|
|
|
|
ms_timeModelStore.clear();
|
2020-01-20 15:41:41 -05:00
|
|
|
ms_mloModelStore.clear();
|
2019-05-15 10:52:37 -04:00
|
|
|
ms_clumpModelStore.clear();
|
|
|
|
ms_pedModelStore.clear();
|
|
|
|
ms_vehicleModelStore.clear();
|
2019-06-17 04:30:02 -04:00
|
|
|
|
|
|
|
m = AddSimpleModel(MI_CAR_DOOR);
|
|
|
|
m->SetColModel(&CTempColModels::ms_colModelDoor1);
|
|
|
|
m->SetTexDictionary("generic");
|
|
|
|
m->SetNumAtomics(1);
|
|
|
|
m->m_lodDistances[0] = 80.0f;
|
|
|
|
|
|
|
|
m = AddSimpleModel(MI_CAR_BUMPER);
|
|
|
|
m->SetColModel(&CTempColModels::ms_colModelBumper1);
|
|
|
|
m->SetTexDictionary("generic");
|
|
|
|
m->SetNumAtomics(1);
|
|
|
|
m->m_lodDistances[0] = 80.0f;
|
|
|
|
|
|
|
|
m = AddSimpleModel(MI_CAR_PANEL);
|
|
|
|
m->SetColModel(&CTempColModels::ms_colModelPanel1);
|
|
|
|
m->SetTexDictionary("generic");
|
|
|
|
m->SetNumAtomics(1);
|
|
|
|
m->m_lodDistances[0] = 80.0f;
|
|
|
|
|
|
|
|
m = AddSimpleModel(MI_CAR_BONNET);
|
|
|
|
m->SetColModel(&CTempColModels::ms_colModelBonnet1);
|
|
|
|
m->SetTexDictionary("generic");
|
|
|
|
m->SetNumAtomics(1);
|
|
|
|
m->m_lodDistances[0] = 80.0f;
|
|
|
|
|
|
|
|
m = AddSimpleModel(MI_CAR_BOOT);
|
|
|
|
m->SetColModel(&CTempColModels::ms_colModelBoot1);
|
|
|
|
m->SetTexDictionary("generic");
|
|
|
|
m->SetNumAtomics(1);
|
|
|
|
m->m_lodDistances[0] = 80.0f;
|
|
|
|
|
|
|
|
m = AddSimpleModel(MI_CAR_WHEEL);
|
|
|
|
m->SetColModel(&CTempColModels::ms_colModelWheel1);
|
|
|
|
m->SetTexDictionary("generic");
|
|
|
|
m->SetNumAtomics(1);
|
|
|
|
m->m_lodDistances[0] = 80.0f;
|
|
|
|
|
|
|
|
m = AddSimpleModel(MI_BODYPARTA);
|
|
|
|
m->SetColModel(&CTempColModels::ms_colModelBodyPart1);
|
|
|
|
m->SetTexDictionary("generic");
|
|
|
|
m->SetNumAtomics(1);
|
|
|
|
m->m_lodDistances[0] = 80.0f;
|
|
|
|
|
|
|
|
m = AddSimpleModel(MI_BODYPARTB);
|
|
|
|
m->SetColModel(&CTempColModels::ms_colModelBodyPart2);
|
|
|
|
m->SetTexDictionary("generic");
|
|
|
|
m->SetNumAtomics(1);
|
|
|
|
m->m_lodDistances[0] = 80.0f;
|
2019-05-15 10:52:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-06-17 04:30:02 -04:00
|
|
|
CModelInfo::ShutDown(void)
|
2019-05-15 10:52:37 -04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < ms_simpleModelStore.allocPtr; i++)
|
|
|
|
ms_simpleModelStore.store[i].Shutdown();
|
2020-01-23 13:08:42 -05:00
|
|
|
for(i = 0; i < ms_mloInstanceStore.allocPtr; i++)
|
|
|
|
ms_mloInstanceStore.store[i].Shutdown();
|
2019-05-15 10:52:37 -04:00
|
|
|
for(i = 0; i < ms_timeModelStore.allocPtr; i++)
|
|
|
|
ms_timeModelStore.store[i].Shutdown();
|
|
|
|
for(i = 0; i < ms_clumpModelStore.allocPtr; i++)
|
|
|
|
ms_clumpModelStore.store[i].Shutdown();
|
|
|
|
for(i = 0; i < ms_vehicleModelStore.allocPtr; i++)
|
|
|
|
ms_vehicleModelStore.store[i].Shutdown();
|
2020-01-23 13:08:42 -05:00
|
|
|
for(i = 0; i < ms_pedModelStore.allocPtr; i++)
|
|
|
|
ms_pedModelStore.store[i].Shutdown();
|
|
|
|
for(i = 0; i < ms_xtraCompsModelStore.allocPtr; i++)
|
|
|
|
ms_xtraCompsModelStore.store[i].Shutdown();
|
|
|
|
for(i = 0; i < ms_mloInstanceStore.allocPtr; i++)
|
|
|
|
ms_mloInstanceStore.store[i].Shutdown();
|
2019-06-17 04:30:02 -04:00
|
|
|
for(i = 0; i < ms_2dEffectStore.allocPtr; i++)
|
|
|
|
ms_2dEffectStore.store[i].Shutdown();
|
2020-01-23 13:08:42 -05:00
|
|
|
|
|
|
|
ms_2dEffectStore.clear();
|
|
|
|
ms_simpleModelStore.clear();
|
|
|
|
ms_mloInstanceStore.clear();
|
|
|
|
ms_mloModelStore.clear();
|
|
|
|
ms_xtraCompsModelStore.clear();
|
|
|
|
ms_timeModelStore.clear();
|
|
|
|
ms_pedModelStore.clear();
|
|
|
|
ms_clumpModelStore.clear();
|
|
|
|
ms_vehicleModelStore.clear();
|
2019-05-15 10:52:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CSimpleModelInfo*
|
|
|
|
CModelInfo::AddSimpleModel(int id)
|
|
|
|
{
|
|
|
|
CSimpleModelInfo *modelinfo;
|
|
|
|
modelinfo = CModelInfo::ms_simpleModelStore.alloc();
|
|
|
|
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
|
|
|
|
modelinfo->Init();
|
|
|
|
return modelinfo;
|
|
|
|
}
|
|
|
|
|
2020-01-20 15:41:41 -05:00
|
|
|
CMloModelInfo *
|
|
|
|
CModelInfo::AddMloModel(int id)
|
|
|
|
{
|
|
|
|
CMloModelInfo *modelinfo;
|
|
|
|
modelinfo = CModelInfo::ms_mloModelStore.alloc();
|
|
|
|
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
|
2020-01-21 02:47:24 -05:00
|
|
|
modelinfo->m_clump = nil;
|
2020-01-20 15:41:41 -05:00
|
|
|
modelinfo->firstInstance = 0;
|
|
|
|
modelinfo->lastInstance = 0;
|
|
|
|
return modelinfo;
|
|
|
|
}
|
|
|
|
|
2019-05-15 10:52:37 -04:00
|
|
|
CTimeModelInfo*
|
|
|
|
CModelInfo::AddTimeModel(int id)
|
|
|
|
{
|
|
|
|
CTimeModelInfo *modelinfo;
|
|
|
|
modelinfo = CModelInfo::ms_timeModelStore.alloc();
|
|
|
|
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
|
|
|
|
modelinfo->Init();
|
|
|
|
return modelinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
CClumpModelInfo*
|
|
|
|
CModelInfo::AddClumpModel(int id)
|
|
|
|
{
|
|
|
|
CClumpModelInfo *modelinfo;
|
|
|
|
modelinfo = CModelInfo::ms_clumpModelStore.alloc();
|
|
|
|
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
|
|
|
|
modelinfo->m_clump = nil;
|
|
|
|
return modelinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
CPedModelInfo*
|
|
|
|
CModelInfo::AddPedModel(int id)
|
|
|
|
{
|
|
|
|
CPedModelInfo *modelinfo;
|
|
|
|
modelinfo = CModelInfo::ms_pedModelStore.alloc();
|
|
|
|
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
|
|
|
|
modelinfo->m_clump = nil;
|
|
|
|
return modelinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
CVehicleModelInfo*
|
|
|
|
CModelInfo::AddVehicleModel(int id)
|
|
|
|
{
|
|
|
|
CVehicleModelInfo *modelinfo;
|
|
|
|
modelinfo = CModelInfo::ms_vehicleModelStore.alloc();
|
|
|
|
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
|
|
|
|
modelinfo->m_clump = nil;
|
|
|
|
modelinfo->m_vehicleType = -1;
|
|
|
|
modelinfo->m_wheelId = -1;
|
|
|
|
modelinfo->m_materials1[0] = nil;
|
|
|
|
modelinfo->m_materials2[0] = nil;
|
|
|
|
modelinfo->m_bikeSteerAngle = 999.99f;
|
|
|
|
return modelinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseModelInfo*
|
|
|
|
CModelInfo::GetModelInfo(const char *name, int *id)
|
|
|
|
{
|
|
|
|
CBaseModelInfo *modelinfo;
|
|
|
|
for(int i = 0; i < MODELINFOSIZE; i++){
|
|
|
|
modelinfo = CModelInfo::ms_modelInfoPtrs[i];
|
2019-10-29 19:12:58 -04:00
|
|
|
if(modelinfo && !CGeneral::faststricmp(modelinfo->GetName(), name)){
|
2019-05-15 10:52:37 -04:00
|
|
|
if(id)
|
|
|
|
*id = i;
|
|
|
|
return modelinfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2019-06-27 04:58:51 -04:00
|
|
|
bool
|
|
|
|
CModelInfo::IsBoatModel(int32 id)
|
|
|
|
{
|
2020-05-05 08:06:55 -04:00
|
|
|
return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
|
2019-06-27 04:58:51 -04:00
|
|
|
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT;
|
|
|
|
}
|
|
|
|
|
2019-07-14 05:49:03 -04:00
|
|
|
bool
|
|
|
|
CModelInfo::IsBikeModel(int32 id)
|
|
|
|
{
|
2020-05-05 08:06:55 -04:00
|
|
|
return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
|
2019-07-14 05:49:03 -04:00
|
|
|
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE;
|
|
|
|
}
|
|
|
|
|
2019-06-28 13:23:28 -04:00
|
|
|
void
|
|
|
|
CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
|
|
|
|
{
|
2020-08-16 10:26:44 -04:00
|
|
|
#ifdef NO_ISLAND_LOADING
|
|
|
|
if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
CBaseModelInfo *mi;
|
|
|
|
CColModel *colmodel;
|
|
|
|
|
|
|
|
for (i = 0; i < MODELINFOSIZE; i++) {
|
|
|
|
mi = GetModelInfo(i);
|
|
|
|
if (mi) {
|
|
|
|
colmodel = mi->GetColModel();
|
|
|
|
if (colmodel && colmodel->level != LEVEL_GENERIC && colmodel->level != level)
|
|
|
|
colmodel->RemoveCollisionVolumes();
|
|
|
|
}
|
2019-06-28 13:23:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-21 02:47:24 -05:00
|
|
|
void
|
|
|
|
CModelInfo::ConstructMloClumps()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < ms_mloModelStore.allocPtr; i++)
|
|
|
|
ms_mloModelStore.store[i].ConstructClump();
|
|
|
|
}
|
|
|
|
|
2020-04-12 22:32:11 -04:00
|
|
|
void
|
|
|
|
CModelInfo::ReInit2dEffects()
|
|
|
|
{
|
|
|
|
ms_2dEffectStore.clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < MODELINFOSIZE; i++) {
|
|
|
|
if (ms_modelInfoPtrs[i])
|
|
|
|
ms_modelInfoPtrs[i]->Init2dEffects();
|
|
|
|
}
|
|
|
|
}
|