summaryrefslogtreecommitdiffstats
path: root/src/modelinfo
diff options
context:
space:
mode:
Diffstat (limited to 'src/modelinfo')
-rw-r--r--src/modelinfo/BaseModelInfo.cpp4
-rw-r--r--src/modelinfo/BaseModelInfo.h19
-rw-r--r--src/modelinfo/ClumpModelInfo.cpp4
-rw-r--r--src/modelinfo/ModelInfo.cpp52
-rw-r--r--src/modelinfo/ModelInfo.h1
-rw-r--r--src/modelinfo/PedModelInfo.cpp6
-rw-r--r--src/modelinfo/PedModelInfo.h1
-rw-r--r--src/modelinfo/SimpleModelInfo.cpp5
-rw-r--r--src/modelinfo/SimpleModelInfo.h12
-rw-r--r--src/modelinfo/TimeModelInfo.cpp5
-rw-r--r--src/modelinfo/VehicleModelInfo.cpp31
11 files changed, 80 insertions, 60 deletions
diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp
index a2779107..7137c604 100644
--- a/src/modelinfo/BaseModelInfo.cpp
+++ b/src/modelinfo/BaseModelInfo.cpp
@@ -4,7 +4,7 @@
#include "TxdStore.h"
#include "2dEffect.h"
#include "BaseModelInfo.h"
-
+#include "ColModel.h"
CBaseModelInfo::CBaseModelInfo(ModelInfoType type)
{
@@ -56,7 +56,7 @@ void
CBaseModelInfo::SetTexDictionary(const char *name)
{
int slot = CTxdStore::FindTxdSlot(name);
- if(slot < 0)
+ if(slot == -1)
slot = CTxdStore::AddTxdSlot(name);
m_txdSlot = slot;
}
diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h
index 2505967b..f46cea84 100644
--- a/src/modelinfo/BaseModelInfo.h
+++ b/src/modelinfo/BaseModelInfo.h
@@ -1,10 +1,10 @@
#pragma once
-#include "Collision.h"
+struct CColModel;
#define MAX_MODEL_NAME (24)
-enum ModelInfoType : uint8
+enum ModelInfoType
{
MITYPE_NA = 0,
MITYPE_SIMPLE = 1,
@@ -15,7 +15,6 @@ enum ModelInfoType : uint8
MITYPE_PED = 6,
MITYPE_XTRACOMPS = 7,
};
-VALIDATE_SIZE(ModelInfoType, 1);
class C2dEffect;
@@ -28,7 +27,7 @@ protected:
int16 m_objectId;
uint16 m_refCount;
int16 m_txdSlot;
- ModelInfoType m_type;
+ uint8 m_type;
uint8 m_num2dEffects;
bool m_bOwnsColModel;
#ifdef EXTRA_MODEL_FLAGS
@@ -45,27 +44,27 @@ public:
virtual ~CBaseModelInfo() {}
virtual void Shutdown(void);
virtual void DeleteRwObject(void) = 0;
- virtual RwObject *CreateInstance(RwMatrix *) = 0;
virtual RwObject *CreateInstance(void) = 0;
+ virtual RwObject *CreateInstance(RwMatrix *) = 0;
virtual RwObject *GetRwObject(void) = 0;
// one day it becomes virtual
- ModelInfoType GetModelType() const { return m_type; }
+ uint8 GetModelType() const { return m_type; }
bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; }
bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE ||
m_type == MITYPE_MLO || m_type == MITYPE_XTRACOMPS; // unused but what the heck
}
- char *GetName(void) { return m_name; }
- void SetName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); }
+ char *GetModelName(void) { return m_name; }
+ void SetModelName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); }
void SetColModel(CColModel *col, bool owns = false){
m_colModel = col; m_bOwnsColModel = owns; }
CColModel *GetColModel(void) { return m_colModel; }
bool DoesOwnColModel(void) { return m_bOwnsColModel; }
void DeleteCollisionModel(void);
void ClearTexDictionary(void) { m_txdSlot = -1; }
- short GetObjectID(void) { return m_objectId; }
+ int16 GetObjectID(void) { return m_objectId; }
void SetObjectID(int16 id) { m_objectId = id; }
- short GetTxdSlot(void) { return m_txdSlot; }
+ int16 GetTxdSlot(void) { return m_txdSlot; }
void AddRef(void);
void RemoveRef(void);
void SetTexDictionary(const char *name);
diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp
index 1ae936a7..44a62afb 100644
--- a/src/modelinfo/ClumpModelInfo.cpp
+++ b/src/modelinfo/ClumpModelInfo.cpp
@@ -112,7 +112,7 @@ CClumpModelInfo::SetClump(RpClump *clump)
}
RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
}
- if(strncmp(GetName(), "playerh", 8) == 0){
+ if(strcmp(GetModelName(), "playerh") == 0){
// playerh is incompatible with the xbox player skin
// so check if player model is skinned and only apply skin to head if it isn't
CPedModelInfo *body = (CPedModelInfo*)CModelInfo::GetModelInfo(MI_PLAYER);
@@ -120,7 +120,7 @@ CClumpModelInfo::SetClump(RpClump *clump)
RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
}
#else
- if(strncmp(GetName(), "playerh", 8) == 0){
+ if(strcmp(GetModelName(), "playerh") == 0)
RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
#endif
}
diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp
index 4ee8e72b..7aa5fc8b 100644
--- a/src/modelinfo/ModelInfo.cpp
+++ b/src/modelinfo/ModelInfo.cpp
@@ -26,15 +26,15 @@ CModelInfo::Initialise(void)
for(i = 0; i < MODELINFOSIZE; i++)
ms_modelInfoPtrs[i] = nil;
- ms_2dEffectStore.clear();
- ms_mloInstanceStore.clear();
- ms_xtraCompsModelStore.clear();
- ms_simpleModelStore.clear();
- ms_timeModelStore.clear();
- ms_mloModelStore.clear();
- ms_clumpModelStore.clear();
- ms_pedModelStore.clear();
- ms_vehicleModelStore.clear();
+ ms_2dEffectStore.Clear();
+ ms_mloInstanceStore.Clear();
+ ms_xtraCompsModelStore.Clear();
+ ms_simpleModelStore.Clear();
+ ms_timeModelStore.Clear();
+ ms_mloModelStore.Clear();
+ ms_clumpModelStore.Clear();
+ ms_pedModelStore.Clear();
+ ms_vehicleModelStore.Clear();
m = AddSimpleModel(MI_CAR_DOOR);
m->SetColModel(&CTempColModels::ms_colModelDoor1);
@@ -108,22 +108,22 @@ CModelInfo::ShutDown(void)
for(i = 0; i < ms_2dEffectStore.allocPtr; i++)
ms_2dEffectStore.store[i].Shutdown();
- 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();
+ 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();
}
CSimpleModelInfo*
CModelInfo::AddSimpleModel(int id)
{
CSimpleModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_simpleModelStore.alloc();
+ modelinfo = CModelInfo::ms_simpleModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->Init();
return modelinfo;
@@ -133,7 +133,7 @@ CMloModelInfo *
CModelInfo::AddMloModel(int id)
{
CMloModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_mloModelStore.alloc();
+ modelinfo = CModelInfo::ms_mloModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
modelinfo->firstInstance = 0;
@@ -145,7 +145,7 @@ CTimeModelInfo*
CModelInfo::AddTimeModel(int id)
{
CTimeModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_timeModelStore.alloc();
+ modelinfo = CModelInfo::ms_timeModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->Init();
return modelinfo;
@@ -155,7 +155,7 @@ CClumpModelInfo*
CModelInfo::AddClumpModel(int id)
{
CClumpModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_clumpModelStore.alloc();
+ modelinfo = CModelInfo::ms_clumpModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
return modelinfo;
@@ -165,7 +165,7 @@ CPedModelInfo*
CModelInfo::AddPedModel(int id)
{
CPedModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_pedModelStore.alloc();
+ modelinfo = CModelInfo::ms_pedModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
return modelinfo;
@@ -175,7 +175,7 @@ CVehicleModelInfo*
CModelInfo::AddVehicleModel(int id)
{
CVehicleModelInfo *modelinfo;
- modelinfo = CModelInfo::ms_vehicleModelStore.alloc();
+ modelinfo = CModelInfo::ms_vehicleModelStore.Alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
modelinfo->m_vehicleType = -1;
@@ -192,7 +192,7 @@ CModelInfo::GetModelInfo(const char *name, int *id)
CBaseModelInfo *modelinfo;
for(int i = 0; i < MODELINFOSIZE; i++){
modelinfo = CModelInfo::ms_modelInfoPtrs[i];
- if(modelinfo && !CGeneral::faststricmp(modelinfo->GetName(), name)){
+ if(modelinfo && !CGeneral::faststricmp(modelinfo->GetModelName(), name)){
if(id)
*id = i;
return modelinfo;
@@ -245,7 +245,7 @@ CModelInfo::ConstructMloClumps()
void
CModelInfo::ReInit2dEffects()
{
- ms_2dEffectStore.clear();
+ ms_2dEffectStore.Clear();
for (int i = 0; i < MODELINFOSIZE; i++) {
if (ms_modelInfoPtrs[i])
diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h
index 65cfa4e7..4fe1ebb0 100644
--- a/src/modelinfo/ModelInfo.h
+++ b/src/modelinfo/ModelInfo.h
@@ -10,6 +10,7 @@
#include "VehicleModelInfo.h"
#include "XtraCompsModelInfo.h"
#include "Instance.h"
+#include "Game.h"
class CModelInfo
{
diff --git a/src/modelinfo/PedModelInfo.cpp b/src/modelinfo/PedModelInfo.cpp
index b77cccda..d0816467 100644
--- a/src/modelinfo/PedModelInfo.cpp
+++ b/src/modelinfo/PedModelInfo.cpp
@@ -97,7 +97,7 @@ CPedModelInfo::SetClump(RpClump *clump)
#endif
#ifdef PED_SKIN
// CB has to be set here before atomics are detached from clump
- if(strncmp(GetName(), "player", 7) == 0)
+ if(strcmp(GetModelName(), "player") == 0)
RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
if(IsClumpSkinned(clump)){
LimbCBarg limbs = { this, clump, { 0, 0, 0 } };
@@ -108,7 +108,7 @@ CPedModelInfo::SetClump(RpClump *clump)
if(m_hitColModel == nil && !IsClumpSkinned(clump))
CreateHitColModel();
// And again because CClumpModelInfo resets it
- if(strncmp(GetName(), "player", 7) == 0)
+ if(strcmp(GetModelName(), "player") == 0)
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
else if(IsClumpSkinned(clump))
// skinned peds have no low detail version, so they don't have the right render Cb
@@ -118,7 +118,7 @@ CPedModelInfo::SetClump(RpClump *clump)
SetFrameIds(m_pPedIds);
if(m_hitColModel == nil)
CreateHitColModel();
- if(strncmp(GetName(), "player", 7) == 0)
+ if(strcmp(GetModelName(), "player") == 0)
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
#endif
}
diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h
index f467fe8a..26ab3c3f 100644
--- a/src/modelinfo/PedModelInfo.h
+++ b/src/modelinfo/PedModelInfo.h
@@ -1,6 +1,7 @@
#pragma once
#include "ClumpModelInfo.h"
+#include "ColModel.h"
#include "PedType.h"
enum PedNode {
diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp
index 416bdad5..9fc0dd6e 100644
--- a/src/modelinfo/SimpleModelInfo.cpp
+++ b/src/modelinfo/SimpleModelInfo.cpp
@@ -2,11 +2,10 @@
#include "General.h"
#include "Camera.h"
+#include "Renderer.h"
#include "ModelInfo.h"
#include "custompipes.h"
-#define LOD_DISTANCE (300.0f)
-
void
CSimpleModelInfo::DeleteRwObject(void)
{
@@ -143,7 +142,7 @@ CSimpleModelInfo::FindRelatedModel(void)
for(i = 0; i < MODELINFOSIZE; i++){
mi = CModelInfo::GetModelInfo(i);
if(mi && mi != this &&
- !CGeneral::faststrcmp(GetName()+3, mi->GetName()+3)){
+ !CGeneral::faststrcmp(GetModelName()+3, mi->GetModelName()+3)){
assert(mi->IsSimple());
this->SetRelatedModel((CSimpleModelInfo*)mi);
return;
diff --git a/src/modelinfo/SimpleModelInfo.h b/src/modelinfo/SimpleModelInfo.h
index ee63f24b..94e55a2f 100644
--- a/src/modelinfo/SimpleModelInfo.h
+++ b/src/modelinfo/SimpleModelInfo.h
@@ -11,6 +11,18 @@ public:
float m_lodDistances[3];
uint8 m_numAtomics;
uint8 m_alpha;
+ /* // For reference, PS2 has:
+ uint8 m_firstDamaged;
+ uint8 m_normalCull : 1;
+ uint8 m_isDamaged : 1;
+ uint8 m_isBigBuilding : 1;
+ uint8 m_noFade : 1;
+ uint8 m_drawLast : 1;
+ uint8 m_additive : 1;
+ uint8 m_isSubway : 1;
+ uint8 m_ignoreLight : 1;
+ // m_noZwrite is missing because not needed
+ */
uint16 m_firstDamaged : 2; // 0: no damage model
// 1: 1 and 2 are damage models
// 2: 2 is damage model
diff --git a/src/modelinfo/TimeModelInfo.cpp b/src/modelinfo/TimeModelInfo.cpp
index d4f92293..0db5fb78 100644
--- a/src/modelinfo/TimeModelInfo.cpp
+++ b/src/modelinfo/TimeModelInfo.cpp
@@ -2,6 +2,7 @@
#include "Camera.h"
#include "ModelInfo.h"
+#include "General.h"
CTimeModelInfo*
CTimeModelInfo::FindOtherTimeModel(void)
@@ -10,7 +11,7 @@ CTimeModelInfo::FindOtherTimeModel(void)
char *p;
int i;
- strcpy(name, GetName());
+ strcpy(name, GetModelName());
// change _nt to _dy
if(p = strstr(name, "_nt"))
strncpy(p, "_dy", 4);
@@ -23,7 +24,7 @@ CTimeModelInfo::FindOtherTimeModel(void)
for(i = 0; i < MODELINFOSIZE; i++){
CBaseModelInfo *mi = CModelInfo::GetModelInfo(i);
if (mi && mi->GetModelType() == MITYPE_TIME &&
- strncmp(name, mi->GetName(), 24) == 0){
+ !CGeneral::faststrncmp(name, mi->GetModelName(), MAX_MODEL_NAME)){
m_otherTimeModelID = i;
return (CTimeModelInfo*)mi;
}
diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp
index 5b212f62..685b6ef6 100644
--- a/src/modelinfo/VehicleModelInfo.cpp
+++ b/src/modelinfo/VehicleModelInfo.cpp
@@ -293,7 +293,7 @@ CVehicleModelInfo::SetAtomicRendererCB(RpAtomic *atomic, void *data)
name = GetFrameNodeName(RpAtomicGetFrame(atomic));
alpha = false;
RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), HasAlphaMaterialCB, &alpha);
- if(strstr(name, "_hi") || strncmp(name, "extra", 5) == 0){
+ if(strstr(name, "_hi") || !CGeneral::faststrncmp(name, "extra", 5)) {
if(alpha || strncmp(name, "windscreen", 10) == 0)
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB);
else
@@ -319,7 +319,7 @@ CVehicleModelInfo::SetAtomicRendererCB_BigVehicle(RpAtomic *atomic, void *data)
name = GetFrameNodeName(RpAtomicGetFrame(atomic));
alpha = false;
RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), HasAlphaMaterialCB, &alpha);
- if(strstr(name, "_hi") || strncmp(name, "extra", 5) == 0){
+ if(strstr(name, "_hi") || !CGeneral::faststrncmp(name, "extra", 5)) {
if(alpha)
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle);
else
@@ -367,7 +367,7 @@ CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data)
clump = (RpClump*)data;
name = GetFrameNodeName(RpAtomicGetFrame(atomic));
- if(strcmp(name, "boat_hi") == 0 || strncmp(name, "extra", 5) == 0)
+ if(strcmp(name, "boat_hi") == 0 || !CGeneral::faststrncmp(name, "extra", 5))
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB_Boat);
else if(strstr(name, "_hi"))
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB);
@@ -471,7 +471,7 @@ CVehicleModelInfo::PreprocessHierarchy(void)
if(desc[i].flags & VEHICLE_FLAG_POS){
f = assoc.frame;
- rwvec = (RwV3d*)&m_positions[desc[i].hierId];
+ rwvec = &m_positions[desc[i].hierId];
*rwvec = *RwMatrixGetPos(RwFrameGetMatrix(f));
for(f = RwFrameGetParent(f); f; f = RwFrameGetParent(f))
RwV3dTransformPoints(rwvec, rwvec, 1, RwFrameGetMatrix(f));
@@ -553,9 +553,9 @@ CVehicleModelInfo::SetVehicleComponentFlags(RwFrame *frame, uint32 flags)
SETFLAGS(ATOMIC_FLAG_FRONT);
else if(flags & VEHICLE_FLAG_REAR && (handling->Flags & HANDLING_IS_VAN || (flags & (VEHICLE_FLAG_LEFT|VEHICLE_FLAG_RIGHT)) == 0))
SETFLAGS(ATOMIC_FLAG_REAR);
- if(flags & VEHICLE_FLAG_LEFT)
+ else if(flags & VEHICLE_FLAG_LEFT)
SETFLAGS(ATOMIC_FLAG_LEFT);
- if(flags & VEHICLE_FLAG_RIGHT)
+ else if(flags & VEHICLE_FLAG_RIGHT)
SETFLAGS(ATOMIC_FLAG_RIGHT);
if(flags & VEHICLE_FLAG_REARDOOR)
@@ -709,7 +709,7 @@ struct editableMatCBData
RpMaterial*
CVehicleModelInfo::GetEditableMaterialListCB(RpMaterial *material, void *data)
{
- static RwRGBA white = { 255, 255, 255, 255 };
+ RwRGBA white = { 255, 255, 255, 255 };
const RwRGBA *col;
editableMatCBData *cbdata;
@@ -914,11 +914,11 @@ CVehicleModelInfo::LoadVehicleColours(void)
continue;
if(section == NONE){
- if(strncmp(&line[start], "col", 3) == 0)
+ if(line[start] == 'c' && line[start + 1] == 'o' && line[start + 2] == 'l')
section = COLOURS;
- else if(strncmp(&line[start], "car", 3) == 0)
+ else if(line[start] == 'c' && line[start + 1] == 'a' && line[start + 2] == 'r')
section = CARS;
- }else if(strncmp(&line[start], "end", 3) == 0){
+ }else if(line[start] == 'e' && line[start + 1] == 'n' && line[start + 2] == 'd'){
section = NONE;
}else if(section == COLOURS){
sscanf(&line[start], // BUG: games doesn't add start
@@ -962,7 +962,7 @@ CVehicleModelInfo::DeleteVehicleColourTextures(void)
for(i = 0; i < 256; i++){
if(ms_colourTextureTable[i]){
RwTextureDestroy(ms_colourTextureTable[i]);
-#ifdef GTA3_1_1_PATCH
+#if GTA_VERSION >= GTA3_PC_11
ms_colourTextureTable[i] = nil;
#endif
}
@@ -998,6 +998,8 @@ CVehicleModelInfo::SetEnvironmentMapCB(RpMaterial *material, void *data)
return material;
}
+bool initialised;
+
RpAtomic*
CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data)
{
@@ -1011,7 +1013,12 @@ CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data)
RpGeometryForAllMaterials(geo, SetEnvironmentMapCB, data);
RpGeometrySetFlags(geo, RpGeometryGetFlags(geo) | rpGEOMETRYMODULATEMATERIALCOLOR);
RpMatFXAtomicEnableEffects(atomic);
- // PS2 sets of PS2Manager lighting CB here
+#ifdef GTA_PS2
+ if(!initialised){
+ SetupPS2ManagerLightingCallback(RpAtomicGetInstancePipeline(atomic));
+ initialised = true;
+ }
+#endif
}
return atomic;
}