summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/FileLoader.cpp6
-rw-r--r--src/modelinfo/MloModelInfo.h2
-rw-r--r--src/modelinfo/XtraCompsModelInfo.h3
-rw-r--r--src/renderer/Renderer.cpp5
-rw-r--r--src/rw/VisibilityPlugins.cpp54
-rw-r--r--src/rw/VisibilityPlugins.h3
6 files changed, 50 insertions, 23 deletions
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index cc2b402b..afa2a66f 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -1135,12 +1135,12 @@ CFileLoader::LoadMLO(const char *line)
char smth[8];
char name[24];
int modelIndex;
- float someFloat;
+ float drawDist;
- sscanf(line, "%s %s %d %f", smth, name, &modelIndex, &someFloat);
+ sscanf(line, "%s %s %d %f", smth, name, &modelIndex, &drawDist);
CMloModelInfo *minfo = CModelInfo::AddMloModel(modelIndex);
minfo->SetModelName(name);
- minfo->field_34 = someFloat;
+ minfo->drawDist = drawDist;
int instId = CModelInfo::GetMloInstanceStore().allocPtr;
minfo->firstInstance = instId;
minfo->lastInstance = instId;
diff --git a/src/modelinfo/MloModelInfo.h b/src/modelinfo/MloModelInfo.h
index d4344706..b1ae3298 100644
--- a/src/modelinfo/MloModelInfo.h
+++ b/src/modelinfo/MloModelInfo.h
@@ -5,7 +5,7 @@
class CMloModelInfo : public CClumpModelInfo
{
public:
- float field_34; // draw distance?
+ float drawDist;
int firstInstance;
int lastInstance;
public:
diff --git a/src/modelinfo/XtraCompsModelInfo.h b/src/modelinfo/XtraCompsModelInfo.h
index 9832399c..ab308a8a 100644
--- a/src/modelinfo/XtraCompsModelInfo.h
+++ b/src/modelinfo/XtraCompsModelInfo.h
@@ -7,6 +7,7 @@ class CXtraCompsModelInfo : public CClumpModelInfo
int field_34;
public:
CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; }
- void SetClump(RpClump*) {};
void Shutdown(void) {};
+ RwObject *CreateInstance(void) { return nil; }
+ void SetClump(RpClump*) {};
}; \ No newline at end of file
diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp
index 1c0bd445..25effc81 100644
--- a/src/renderer/Renderer.cpp
+++ b/src/renderer/Renderer.cpp
@@ -154,11 +154,14 @@ CRenderer::PreRender(void)
void
CRenderer::RenderOneRoad(CEntity *e)
{
+#ifndef MASTER
if(gbDontRenderBuildings)
return;
if(gbShowCollisionPolys)
CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
- else{
+ else
+#endif
+ {
#ifdef EXTENDED_PIPELINES
CustomPipes::AttachGlossPipe(e->GetAtomic());
#endif
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 7ff5c243..e6d4641d 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -155,7 +155,7 @@ CVisibilityPlugins::Initialise(void)
m_alphaList.head.item.sort = 0.0f;
m_alphaList.tail.item.sort = 100000000.0f;
#ifdef ASPECT_RATIO_SCALE
- // default 150 if not enough for bigger FOVs
+ // default 150 is not enough for bigger FOVs
m_alphaEntityList.Init(NUMALPHAENTITYLIST * 3);
#else
m_alphaEntityList.Init(NUMALPHAENTITYLIST);
@@ -658,8 +658,7 @@ CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic)
return atomic;
if(flags & ATOMIC_FLAG_DRAWLAST){
- // sort before clump
- if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f))
+ if(!InsertAtomicIntoSortedList(atomic, distsq))
RENDERCALLBACK(atomic);
}else{
if(!InsertAtomicIntoSortedList(atomic, distsq + dot))
@@ -792,16 +791,6 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump)
}
bool
-CVisibilityPlugins::MloVisibilityCB(RpClump *clump)
-{
- RwFrame *frame = RpClumpGetFrame(clump);
- CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame);
- if (sq(modelInfo->field_34) < GetDistanceSquaredFromCamera(frame))
- return false;
- return CVisibilityPlugins::FrustumSphereCB(clump);
-}
-
-bool
CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
{
RwSphere sphere;
@@ -817,11 +806,22 @@ CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
}
bool
+CVisibilityPlugins::MloVisibilityCB(RpClump *clump)
+{
+ RwFrame *frame = RpClumpGetFrame(clump);
+ CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame);
+ if (SQR(modelInfo->drawDist) < GetDistanceSquaredFromCamera(frame))
+ return false;
+ return CVisibilityPlugins::FrustumSphereCB(clump);
+}
+
+bool
CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump)
{
- if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist)
- return FrustumSphereCB(clump);
- return false;
+ RwFrame *frame = RpClumpGetFrame(clump);
+ if (ms_vehicleLod1Dist < GetDistanceSquaredFromCamera(frame))
+ return false;
+ return FrustumSphereCB(clump);
}
bool
@@ -927,6 +927,12 @@ CVisibilityPlugins::ClearAtomicFlag(RpAtomic *atomic, int f)
ATOMICEXT(atomic)->flags &= ~f;
}
+void
+CVisibilityPlugins::SetAtomicId(RpAtomic *atomic, int id)
+{
+ ATOMICEXT(atomic)->flags = id;
+}
+
int
CVisibilityPlugins::GetAtomicId(RpAtomic *atomic)
{
@@ -1012,7 +1018,9 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo
// Unused
switch (modelInfo->GetModelType()) {
- // ignore MLO
+ case MITYPE_MLO:
+ CLUMPEXT(clump)->visibilityCB = MloVisibilityCB;
+ break;
case MITYPE_VEHICLE:
vmi = (CVehicleModelInfo*)modelInfo;
if(vmi->m_vehicleType == VEHICLE_TYPE_TRAIN ||
@@ -1026,6 +1034,12 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo
}
}
+CClumpModelInfo*
+CVisibilityPlugins::GetClumpModelInfo(RpClump *clump)
+{
+ return (CClumpModelInfo*)GetFrameHierarchyId(RpClumpGetFrame(clump));
+}
+
void
CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha)
{
@@ -1037,3 +1051,9 @@ CVisibilityPlugins::GetClumpAlpha(RpClump *clump)
{
return CLUMPEXT(clump)->alpha;
}
+
+bool
+CVisibilityPlugins::IsClumpVisible(RpClump *clump)
+{
+ return CLUMPEXT(clump)->visibilityCB(clump);
+}
diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h
index 5fb87765..f97fd589 100644
--- a/src/rw/VisibilityPlugins.h
+++ b/src/rw/VisibilityPlugins.h
@@ -94,6 +94,7 @@ public:
static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic);
static void SetAtomicFlag(RpAtomic*, int);
static void ClearAtomicFlag(RpAtomic*, int);
+ static void SetAtomicId(RpAtomic *atomic, int);
static int GetAtomicId(RpAtomic *atomic);
static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender);
@@ -123,8 +124,10 @@ public:
int alpha;
};
static void SetClumpModelInfo(RpClump*, CClumpModelInfo*);
+ static CClumpModelInfo *GetClumpModelInfo(RpClump*);
static void SetClumpAlpha(RpClump*, int);
static int GetClumpAlpha(RpClump*);
+ static bool IsClumpVisible(RpClump*);
static void *ClumpConstructor(void *object, int32 offset, int32 len);
static void *ClumpDestructor(void *object, int32 offset, int32 len);