mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-12-03 14:34:14 +01:00
CVisibilityPlugins and CRenderer fixes; pulled MLO back in
This commit is contained in:
parent
7bacf3b6f4
commit
30061396e8
41
src/modelinfo/MloModelInfo.cpp
Normal file
41
src/modelinfo/MloModelInfo.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#include "VisibilityPlugins.h"
|
||||||
|
#include "ModelInfo.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
CMloModelInfo::ConstructClump()
|
||||||
|
{
|
||||||
|
m_clump = RpClumpCreate();
|
||||||
|
RwFrame *mainFrame = RwFrameCreate();
|
||||||
|
RwFrameSetIdentity(mainFrame);
|
||||||
|
RpClumpSetFrame(m_clump, mainFrame);
|
||||||
|
|
||||||
|
for (int i = firstInstance; i < lastInstance; i++) {
|
||||||
|
int modelId = CModelInfo::GetMloInstanceStore().store[i].m_modelIndex;
|
||||||
|
RwMatrix *attMat = CModelInfo::GetMloInstanceStore().store[i].GetMatrix().m_attachment;
|
||||||
|
CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(modelId);
|
||||||
|
|
||||||
|
if (minfo->m_atomics[0] != nil) {
|
||||||
|
RpAtomic *newAtomic = RpAtomicClone(minfo->m_atomics[0]);
|
||||||
|
RwFrame *newFrame = RwFrameCreate();
|
||||||
|
if (newAtomic != nil && newFrame != nil) {
|
||||||
|
*RwFrameGetMatrix(newFrame) = *attMat;
|
||||||
|
RpAtomicSetFrame(newAtomic, newFrame);
|
||||||
|
RwFrameAddChild(mainFrame, newFrame);
|
||||||
|
RpClumpAddAtomic(m_clump, newAtomic);
|
||||||
|
} else {
|
||||||
|
debug("Failed to allocate memory while creating template MLO.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RpClumpGetNumAtomics(m_clump) != 0) {
|
||||||
|
CVisibilityPlugins::SetClumpModelInfo(m_clump, this);
|
||||||
|
} else {
|
||||||
|
RpClumpDestroy(m_clump);
|
||||||
|
m_clump = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
14
src/modelinfo/MloModelInfo.h
Normal file
14
src/modelinfo/MloModelInfo.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ClumpModelInfo.h"
|
||||||
|
|
||||||
|
class CMloModelInfo : public CClumpModelInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float drawDist;
|
||||||
|
int firstInstance;
|
||||||
|
int lastInstance;
|
||||||
|
public:
|
||||||
|
CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {}
|
||||||
|
void ConstructClump();
|
||||||
|
};
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "2dEffect.h"
|
#include "2dEffect.h"
|
||||||
#include "SimpleModelInfo.h"
|
#include "SimpleModelInfo.h"
|
||||||
|
#include "MloModelInfo.h"
|
||||||
#include "TimeModelInfo.h"
|
#include "TimeModelInfo.h"
|
||||||
#include "WeaponModelInfo.h"
|
#include "WeaponModelInfo.h"
|
||||||
#include "ClumpModelInfo.h"
|
#include "ClumpModelInfo.h"
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
bool gbShowPedRoadGroups;
|
bool gbShowPedRoadGroups;
|
||||||
bool gbShowCarRoadGroups;
|
bool gbShowCarRoadGroups;
|
||||||
bool gbShowCollisionPolys;
|
bool gbShowCollisionPolys;
|
||||||
|
bool gbShowCollisionPolysReflections;
|
||||||
|
bool gbShowCollisionPolysNoShadows;
|
||||||
bool gbShowCollisionLines;
|
bool gbShowCollisionLines;
|
||||||
bool gbBigWhiteDebugLightSwitchedOn;
|
bool gbBigWhiteDebugLightSwitchedOn;
|
||||||
|
|
||||||
@ -126,11 +128,16 @@ CRenderer::PreRender(void)
|
|||||||
void
|
void
|
||||||
CRenderer::RenderOneRoad(CEntity *e)
|
CRenderer::RenderOneRoad(CEntity *e)
|
||||||
{
|
{
|
||||||
|
#ifndef FINAL
|
||||||
if(gbDontRenderBuildings)
|
if(gbDontRenderBuildings)
|
||||||
return;
|
return;
|
||||||
if(gbShowCollisionPolys)
|
#endif
|
||||||
|
#ifndef MASTER
|
||||||
|
if(gbShowCollisionPolys || gbShowCollisionPolysReflections || gbShowCollisionPolysNoShadows)
|
||||||
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
|
||||||
|
{
|
||||||
PUSH_RENDERGROUP(CModelInfo::GetModelInfo(e->GetModelIndex())->GetModelName());
|
PUSH_RENDERGROUP(CModelInfo::GetModelInfo(e->GetModelIndex())->GetModelName());
|
||||||
|
|
||||||
e->Render();
|
e->Render();
|
||||||
@ -148,12 +155,15 @@ CRenderer::RenderOneNonRoad(CEntity *e)
|
|||||||
bool resetLights;
|
bool resetLights;
|
||||||
|
|
||||||
#ifndef MASTER
|
#ifndef MASTER
|
||||||
if(gbShowCollisionPolys){
|
if(gbShowCollisionPolys || gbShowCollisionPolysReflections || gbShowCollisionPolysNoShadows){
|
||||||
if(!e->IsVehicle()){
|
if(!e->IsVehicle()){
|
||||||
CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
|
CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else if(e->IsBuilding()){
|
}else
|
||||||
|
#endif
|
||||||
|
#ifndef FINAL
|
||||||
|
if(e->IsBuilding()){
|
||||||
if(e->bIsBIGBuilding){
|
if(e->bIsBIGBuilding){
|
||||||
if(gbDontRenderBigBuildings)
|
if(gbDontRenderBigBuildings)
|
||||||
return;
|
return;
|
||||||
@ -164,7 +174,7 @@ CRenderer::RenderOneNonRoad(CEntity *e)
|
|||||||
}else
|
}else
|
||||||
#endif
|
#endif
|
||||||
if(e->IsPed()){
|
if(e->IsPed()){
|
||||||
#ifndef MASTER
|
#ifndef FINAL
|
||||||
if(gbDontRenderPeds)
|
if(gbDontRenderPeds)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@ -172,7 +182,7 @@ CRenderer::RenderOneNonRoad(CEntity *e)
|
|||||||
if(ped->m_nPedState == PED_DRIVING)
|
if(ped->m_nPedState == PED_DRIVING)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifndef MASTER
|
#ifndef FINAL
|
||||||
else if(e->IsObject() || e->IsDummy()){
|
else if(e->IsObject() || e->IsDummy()){
|
||||||
if(gbDontRenderObjects)
|
if(gbDontRenderObjects)
|
||||||
return;
|
return;
|
||||||
@ -665,8 +675,10 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
|
|||||||
ti->m_alpha = 255;
|
ti->m_alpha = 255;
|
||||||
}else{
|
}else{
|
||||||
// Hide if possible
|
// Hide if possible
|
||||||
if(CANTIMECULL)
|
if(CANTIMECULL){
|
||||||
|
ent->DeleteRwObject();
|
||||||
return VIS_INVISIBLE;
|
return VIS_INVISIBLE;
|
||||||
|
}
|
||||||
// can't cull, so we'll try to draw this one, but don't request
|
// can't cull, so we'll try to draw this one, but don't request
|
||||||
// it since what we really want is the other one.
|
// it since what we really want is the other one.
|
||||||
request = false;
|
request = false;
|
||||||
|
@ -51,7 +51,7 @@ CVisibilityPlugins::Initialise(void)
|
|||||||
m_alphaBoatAtomicList.tail.item.sort = 100000000.0f;
|
m_alphaBoatAtomicList.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);
|
||||||
@ -604,8 +604,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, DistToCameraSq))
|
||||||
if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq - 0.0001f))
|
|
||||||
RENDERCALLBACK(atomic);
|
RENDERCALLBACK(atomic);
|
||||||
}else{
|
}else{
|
||||||
if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot))
|
if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot))
|
||||||
@ -662,12 +661,14 @@ CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic)
|
|||||||
RpAtomic*
|
RpAtomic*
|
||||||
CVisibilityPlugins::RenderPedCB(RpAtomic *atomic)
|
CVisibilityPlugins::RenderPedCB(RpAtomic *atomic)
|
||||||
{
|
{
|
||||||
|
RpClump *clump;
|
||||||
|
float dist;
|
||||||
int32 alpha;
|
int32 alpha;
|
||||||
RwV3d cam2atm;
|
|
||||||
|
|
||||||
RwV3dSub(&cam2atm, &RwFrameGetLTM(RpAtomicGetFrame(atomic))->pos, ms_pCameraPosn);
|
clump = RpAtomicGetClump(atomic);
|
||||||
if(RwV3dDotProduct(&cam2atm, &cam2atm) < ms_pedLod1Dist){
|
dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump));
|
||||||
alpha = GetClumpAlpha(RpAtomicGetClump(atomic));
|
if(dist < ms_pedLod1Dist){
|
||||||
|
alpha = GetClumpAlpha(clump);
|
||||||
if(alpha == 255)
|
if(alpha == 255)
|
||||||
RENDERCALLBACK(atomic);
|
RENDERCALLBACK(atomic);
|
||||||
else
|
else
|
||||||
@ -755,12 +756,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
|
||||||
@ -854,6 +866,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)
|
||||||
{
|
{
|
||||||
@ -939,7 +957,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 ||
|
||||||
@ -953,6 +973,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)
|
||||||
{
|
{
|
||||||
@ -964,3 +990,9 @@ CVisibilityPlugins::GetClumpAlpha(RpClump *clump)
|
|||||||
{
|
{
|
||||||
return CLUMPEXT(clump)->alpha;
|
return CLUMPEXT(clump)->alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CVisibilityPlugins::IsClumpVisible(RpClump *clump)
|
||||||
|
{
|
||||||
|
return CLUMPEXT(clump)->visibilityCB(clump);
|
||||||
|
}
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
// All actually unused
|
// All actually unused
|
||||||
static bool DefaultVisibilityCB(RpClump *clump);
|
static bool DefaultVisibilityCB(RpClump *clump);
|
||||||
static bool FrustumSphereCB(RpClump *clump);
|
static bool FrustumSphereCB(RpClump *clump);
|
||||||
|
static bool MloVisibilityCB(RpClump *clump);
|
||||||
static bool VehicleVisibilityCB(RpClump *clump);
|
static bool VehicleVisibilityCB(RpClump *clump);
|
||||||
static bool VehicleVisibilityCB_BigVehicle(RpClump *clump);
|
static bool VehicleVisibilityCB_BigVehicle(RpClump *clump);
|
||||||
|
|
||||||
@ -104,6 +105,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);
|
||||||
|
|
||||||
@ -133,8 +135,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 New Issue
Block a user