summaryrefslogtreecommitdiff
path: root/src/modelinfo
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-05-05 13:02:42 +0200
committeraap <aap@papnet.eu>2020-05-05 13:02:42 +0200
commitb44df26d3ea5fcdaf6d954016303f358d2c64b79 (patch)
tree2921c2c0e2883117f4ce9cec73865c1701f32cec /src/modelinfo
parent84c9484e55874c57c1c017cb2394e0c6b2f32303 (diff)
implemented most of streamed collisions and big buildings
Diffstat (limited to 'src/modelinfo')
-rw-r--r--src/modelinfo/BaseModelInfo.cpp6
-rw-r--r--src/modelinfo/BaseModelInfo.h14
-rw-r--r--src/modelinfo/ClumpModelInfo.h2
-rw-r--r--src/modelinfo/ModelInfo.cpp16
-rw-r--r--src/modelinfo/ModelInfo.h3
-rw-r--r--src/modelinfo/SimpleModelInfo.cpp16
-rw-r--r--src/modelinfo/SimpleModelInfo.h7
7 files changed, 50 insertions, 14 deletions
diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp
index e8d2601f..a2779107 100644
--- a/src/modelinfo/BaseModelInfo.cpp
+++ b/src/modelinfo/BaseModelInfo.cpp
@@ -6,7 +6,7 @@
#include "BaseModelInfo.h"
-CBaseModelInfo::CBaseModelInfo(ModeInfoType type)
+CBaseModelInfo::CBaseModelInfo(ModelInfoType type)
{
m_colModel = nil;
m_twodEffects = nil;
@@ -15,7 +15,7 @@ CBaseModelInfo::CBaseModelInfo(ModeInfoType type)
m_txdSlot = -1;
m_type = type;
m_num2dEffects = 0;
- m_freeCol = false;
+ m_bOwnsColModel = false;
}
void
@@ -31,7 +31,7 @@ CBaseModelInfo::Shutdown(void)
void
CBaseModelInfo::DeleteCollisionModel(void)
{
- if(m_colModel && m_freeCol){
+ if(m_colModel && m_bOwnsColModel){
if(m_colModel)
delete m_colModel;
m_colModel = nil;
diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h
index 0c4bf934..44f4c47a 100644
--- a/src/modelinfo/BaseModelInfo.h
+++ b/src/modelinfo/BaseModelInfo.h
@@ -4,7 +4,7 @@
#define MAX_MODEL_NAME (24)
-enum ModeInfoType : uint8
+enum ModelInfoType : uint8
{
MITYPE_NA = 0,
MITYPE_SIMPLE = 1,
@@ -15,7 +15,7 @@ enum ModeInfoType : uint8
MITYPE_PED = 6,
MITYPE_XTRACOMPS = 7,
};
-static_assert(sizeof(ModeInfoType) == 1, "ModeInfoType: error");
+static_assert(sizeof(ModelInfoType) == 1, "ModeInfoType: error");
class C2dEffect;
@@ -30,11 +30,11 @@ protected:
public:
uint16 m_refCount;
int16 m_txdSlot;
- ModeInfoType m_type;
+ ModelInfoType m_type;
uint8 m_num2dEffects;
- bool m_freeCol;
+ bool m_bOwnsColModel;
- CBaseModelInfo(ModeInfoType type);
+ CBaseModelInfo(ModelInfoType type);
virtual ~CBaseModelInfo() {}
virtual void Shutdown(void);
virtual void DeleteRwObject(void) = 0;
@@ -48,8 +48,8 @@ public:
}
char *GetName(void) { return m_name; }
void SetName(const char *name) { strncpy(m_name, name, 24); }
- void SetColModel(CColModel *col, bool free = false){
- m_colModel = col; m_freeCol = free; }
+ void SetColModel(CColModel *col, bool owns = false){
+ m_colModel = col; m_bOwnsColModel = owns; }
CColModel *GetColModel(void) { return m_colModel; }
void DeleteCollisionModel(void);
void ClearTexDictionary(void) { m_txdSlot = -1; }
diff --git a/src/modelinfo/ClumpModelInfo.h b/src/modelinfo/ClumpModelInfo.h
index 100aa30b..c37a468a 100644
--- a/src/modelinfo/ClumpModelInfo.h
+++ b/src/modelinfo/ClumpModelInfo.h
@@ -32,7 +32,7 @@ public:
RpClump *m_clump;
CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) {}
- CClumpModelInfo(ModeInfoType id) : CBaseModelInfo(id) {}
+ CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) {}
~CClumpModelInfo() {}
void DeleteRwObject(void);
RwObject *CreateInstance(void);
diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp
index c1ae692f..812a8749 100644
--- a/src/modelinfo/ModelInfo.cpp
+++ b/src/modelinfo/ModelInfo.cpp
@@ -200,6 +200,20 @@ CModelInfo::GetModelInfo(const char *name, int *id)
return nil;
}
+#ifdef MIAMI
+CBaseModelInfo*
+CModelInfo::GetModelInfo(const char *name, int minIndex, int maxIndex)
+{
+ CBaseModelInfo *modelinfo;
+ for(int i = minIndex; i <= maxIndex; i++){
+ modelinfo = CModelInfo::ms_modelInfoPtrs[i];
+ if(modelinfo && !CGeneral::faststricmp(modelinfo->GetName(), name))
+ return modelinfo;
+ }
+ return nil;
+}
+#endif
+
bool
CModelInfo::IsBoatModel(int32 id)
{
@@ -214,6 +228,7 @@ CModelInfo::IsBikeModel(int32 id)
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE;
}
+#ifndef MIAMI
void
CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
{
@@ -230,6 +245,7 @@ CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
}
}
}
+#endif
void
CModelInfo::ConstructMloClumps()
diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h
index 65cfa4e7..dadc8f8b 100644
--- a/src/modelinfo/ModelInfo.h
+++ b/src/modelinfo/ModelInfo.h
@@ -42,6 +42,9 @@ public:
static CBaseModelInfo *GetModelInfo(int id){
return ms_modelInfoPtrs[id];
}
+#ifdef MIAMI
+ static CBaseModelInfo *GetModelInfo(const char *name, int minIndex, int maxIndex);
+#endif
static bool IsBoatModel(int32 id);
static bool IsBikeModel(int32 id);
diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp
index 2fb2adeb..424fb0e5 100644
--- a/src/modelinfo/SimpleModelInfo.cpp
+++ b/src/modelinfo/SimpleModelInfo.cpp
@@ -95,6 +95,12 @@ CSimpleModelInfo::IncreaseAlpha(void)
}
float
+CSimpleModelInfo::GetLodDistance(int i)
+{
+ return m_lodDistances[i] * TheCamera.LODDistMultiplier;
+}
+
+float
CSimpleModelInfo::GetNearDistance(void)
{
return m_lodDistances[2] * TheCamera.LODDistMultiplier;
@@ -119,11 +125,19 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist)
if(m_isDamaged)
i = m_firstDamaged;
for(; i < m_numAtomics; i++)
- if(dist < m_lodDistances[i] *TheCamera.LODDistMultiplier)
+ if(dist < m_lodDistances[i] * TheCamera.LODDistMultiplier)
return m_atomics[i];
return nil;
}
+RpAtomic*
+CSimpleModelInfo::GetFirstAtomicFromDistance(float dist)
+{
+ if(dist < m_lodDistances[0] * TheCamera.LODDistMultiplier)
+ return m_atomics[0];
+ return nil;
+}
+
void
CSimpleModelInfo::FindRelatedModel(void)
{
diff --git a/src/modelinfo/SimpleModelInfo.h b/src/modelinfo/SimpleModelInfo.h
index 35d48669..451a9c00 100644
--- a/src/modelinfo/SimpleModelInfo.h
+++ b/src/modelinfo/SimpleModelInfo.h
@@ -25,7 +25,7 @@ public:
uint16 m_noZwrite : 1;
CSimpleModelInfo(void) : CBaseModelInfo(MITYPE_SIMPLE) {}
- CSimpleModelInfo(ModeInfoType id) : CBaseModelInfo(id) {}
+ CSimpleModelInfo(ModelInfoType id) : CBaseModelInfo(id) {}
~CSimpleModelInfo() {}
void DeleteRwObject(void);
RwObject *CreateInstance(void);
@@ -36,10 +36,13 @@ public:
void IncreaseAlpha(void);
void SetAtomic(int n, RpAtomic *atomic);
void SetLodDistances(float *dist);
- float GetLodDistance(int i) { return m_lodDistances[i]; }
+ float GetLodDistance(int i);
float GetNearDistance(void);
float GetLargestLodDistance(void);
RpAtomic *GetAtomicFromDistance(float dist);
+#ifdef MIAMI
+ RpAtomic *GetFirstAtomicFromDistance(float dist); // inline
+#endif
void FindRelatedModel(void);
void SetupBigBuilding(void);