mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-29 05:33:45 +00:00
CVisibilityPlugins and CRenderer fixes
This commit is contained in:
parent
6cea1de9e6
commit
3c5bae164f
6 changed files with 50 additions and 23 deletions
|
@ -1135,12 +1135,12 @@ CFileLoader::LoadMLO(const char *line)
|
||||||
char smth[8];
|
char smth[8];
|
||||||
char name[24];
|
char name[24];
|
||||||
int modelIndex;
|
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);
|
CMloModelInfo *minfo = CModelInfo::AddMloModel(modelIndex);
|
||||||
minfo->SetModelName(name);
|
minfo->SetModelName(name);
|
||||||
minfo->field_34 = someFloat;
|
minfo->drawDist = drawDist;
|
||||||
int instId = CModelInfo::GetMloInstanceStore().allocPtr;
|
int instId = CModelInfo::GetMloInstanceStore().allocPtr;
|
||||||
minfo->firstInstance = instId;
|
minfo->firstInstance = instId;
|
||||||
minfo->lastInstance = instId;
|
minfo->lastInstance = instId;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
class CMloModelInfo : public CClumpModelInfo
|
class CMloModelInfo : public CClumpModelInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
float field_34; // draw distance?
|
float drawDist;
|
||||||
int firstInstance;
|
int firstInstance;
|
||||||
int lastInstance;
|
int lastInstance;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -7,6 +7,7 @@ class CXtraCompsModelInfo : public CClumpModelInfo
|
||||||
int field_34;
|
int field_34;
|
||||||
public:
|
public:
|
||||||
CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; }
|
CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; }
|
||||||
void SetClump(RpClump*) {};
|
|
||||||
void Shutdown(void) {};
|
void Shutdown(void) {};
|
||||||
|
RwObject *CreateInstance(void) { return nil; }
|
||||||
|
void SetClump(RpClump*) {};
|
||||||
};
|
};
|
|
@ -154,11 +154,14 @@ CRenderer::PreRender(void)
|
||||||
void
|
void
|
||||||
CRenderer::RenderOneRoad(CEntity *e)
|
CRenderer::RenderOneRoad(CEntity *e)
|
||||||
{
|
{
|
||||||
|
#ifndef MASTER
|
||||||
if(gbDontRenderBuildings)
|
if(gbDontRenderBuildings)
|
||||||
return;
|
return;
|
||||||
if(gbShowCollisionPolys)
|
if(gbShowCollisionPolys)
|
||||||
CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
|
CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
|
||||||
else{
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
#ifdef EXTENDED_PIPELINES
|
#ifdef EXTENDED_PIPELINES
|
||||||
CustomPipes::AttachGlossPipe(e->GetAtomic());
|
CustomPipes::AttachGlossPipe(e->GetAtomic());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -155,7 +155,7 @@ CVisibilityPlugins::Initialise(void)
|
||||||
m_alphaList.head.item.sort = 0.0f;
|
m_alphaList.head.item.sort = 0.0f;
|
||||||
m_alphaList.tail.item.sort = 100000000.0f;
|
m_alphaList.tail.item.sort = 100000000.0f;
|
||||||
#ifdef ASPECT_RATIO_SCALE
|
#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);
|
m_alphaEntityList.Init(NUMALPHAENTITYLIST * 3);
|
||||||
#else
|
#else
|
||||||
m_alphaEntityList.Init(NUMALPHAENTITYLIST);
|
m_alphaEntityList.Init(NUMALPHAENTITYLIST);
|
||||||
|
@ -658,8 +658,7 @@ CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic)
|
||||||
return atomic;
|
return atomic;
|
||||||
|
|
||||||
if(flags & ATOMIC_FLAG_DRAWLAST){
|
if(flags & ATOMIC_FLAG_DRAWLAST){
|
||||||
// sort before clump
|
if(!InsertAtomicIntoSortedList(atomic, distsq))
|
||||||
if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f))
|
|
||||||
RENDERCALLBACK(atomic);
|
RENDERCALLBACK(atomic);
|
||||||
}else{
|
}else{
|
||||||
if(!InsertAtomicIntoSortedList(atomic, distsq + dot))
|
if(!InsertAtomicIntoSortedList(atomic, distsq + dot))
|
||||||
|
@ -791,16 +790,6 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
bool
|
||||||
CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
|
CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
|
||||||
{
|
{
|
||||||
|
@ -816,12 +805,23 @@ CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
|
||||||
return RwCameraFrustumTestSphere(ms_pCamera, &sphere) != rwSPHEREOUTSIDE;
|
return RwCameraFrustumTestSphere(ms_pCamera, &sphere) != rwSPHEREOUTSIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
bool
|
||||||
CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump)
|
CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump)
|
||||||
{
|
{
|
||||||
if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist)
|
RwFrame *frame = RpClumpGetFrame(clump);
|
||||||
return FrustumSphereCB(clump);
|
if (ms_vehicleLod1Dist < GetDistanceSquaredFromCamera(frame))
|
||||||
return false;
|
return false;
|
||||||
|
return FrustumSphereCB(clump);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -927,6 +927,12 @@ CVisibilityPlugins::ClearAtomicFlag(RpAtomic *atomic, int f)
|
||||||
ATOMICEXT(atomic)->flags &= ~f;
|
ATOMICEXT(atomic)->flags &= ~f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CVisibilityPlugins::SetAtomicId(RpAtomic *atomic, int id)
|
||||||
|
{
|
||||||
|
ATOMICEXT(atomic)->flags = id;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CVisibilityPlugins::GetAtomicId(RpAtomic *atomic)
|
CVisibilityPlugins::GetAtomicId(RpAtomic *atomic)
|
||||||
{
|
{
|
||||||
|
@ -1012,7 +1018,9 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo
|
||||||
|
|
||||||
// Unused
|
// Unused
|
||||||
switch (modelInfo->GetModelType()) {
|
switch (modelInfo->GetModelType()) {
|
||||||
// ignore MLO
|
case MITYPE_MLO:
|
||||||
|
CLUMPEXT(clump)->visibilityCB = MloVisibilityCB;
|
||||||
|
break;
|
||||||
case MITYPE_VEHICLE:
|
case MITYPE_VEHICLE:
|
||||||
vmi = (CVehicleModelInfo*)modelInfo;
|
vmi = (CVehicleModelInfo*)modelInfo;
|
||||||
if(vmi->m_vehicleType == VEHICLE_TYPE_TRAIN ||
|
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
|
void
|
||||||
CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha)
|
CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha)
|
||||||
{
|
{
|
||||||
|
@ -1037,3 +1051,9 @@ CVisibilityPlugins::GetClumpAlpha(RpClump *clump)
|
||||||
{
|
{
|
||||||
return CLUMPEXT(clump)->alpha;
|
return CLUMPEXT(clump)->alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CVisibilityPlugins::IsClumpVisible(RpClump *clump)
|
||||||
|
{
|
||||||
|
return CLUMPEXT(clump)->visibilityCB(clump);
|
||||||
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ public:
|
||||||
static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic);
|
static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic);
|
||||||
static void SetAtomicFlag(RpAtomic*, int);
|
static void SetAtomicFlag(RpAtomic*, int);
|
||||||
static void ClearAtomicFlag(RpAtomic*, int);
|
static void ClearAtomicFlag(RpAtomic*, int);
|
||||||
|
static void SetAtomicId(RpAtomic *atomic, int);
|
||||||
static int GetAtomicId(RpAtomic *atomic);
|
static int GetAtomicId(RpAtomic *atomic);
|
||||||
static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender);
|
static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender);
|
||||||
|
|
||||||
|
@ -123,8 +124,10 @@ public:
|
||||||
int alpha;
|
int alpha;
|
||||||
};
|
};
|
||||||
static void SetClumpModelInfo(RpClump*, CClumpModelInfo*);
|
static void SetClumpModelInfo(RpClump*, CClumpModelInfo*);
|
||||||
|
static CClumpModelInfo *GetClumpModelInfo(RpClump*);
|
||||||
static void SetClumpAlpha(RpClump*, int);
|
static void SetClumpAlpha(RpClump*, int);
|
||||||
static int GetClumpAlpha(RpClump*);
|
static int GetClumpAlpha(RpClump*);
|
||||||
|
static bool IsClumpVisible(RpClump*);
|
||||||
|
|
||||||
static void *ClumpConstructor(void *object, int32 offset, int32 len);
|
static void *ClumpConstructor(void *object, int32 offset, int32 len);
|
||||||
static void *ClumpDestructor(void *object, int32 offset, int32 len);
|
static void *ClumpDestructor(void *object, int32 offset, int32 len);
|
||||||
|
|
Loading…
Reference in a new issue