1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-26 18:15:27 +00:00

make game load all platform dffs

This commit is contained in:
aap 2020-07-16 13:36:25 +02:00
parent d0f5464200
commit 4e3e1d0b87
4 changed files with 89 additions and 3 deletions

View file

@ -393,6 +393,16 @@ CFileLoader::FindRelatedModelInfoCB(RpAtomic *atomic, void *data)
return atomic; return atomic;
} }
#ifdef LIBRW
void
InitClump(RpClump *clump)
{
RpClumpForAllAtomics(clump, ConvertPlatformAtomic, nil);
}
#else
#define InitClump(clump)
#endif
void void
CFileLoader::LoadModelFile(const char *filename) CFileLoader::LoadModelFile(const char *filename)
{ {
@ -404,6 +414,7 @@ CFileLoader::LoadModelFile(const char *filename)
if(RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)){ if(RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)){
clump = RpClumpStreamRead(stream); clump = RpClumpStreamRead(stream);
if(clump){ if(clump){
InitClump(clump);
RpClumpForAllAtomics(clump, FindRelatedModelInfoCB, clump); RpClumpForAllAtomics(clump, FindRelatedModelInfoCB, clump);
RpClumpDestroy(clump); RpClumpDestroy(clump);
} }
@ -429,6 +440,7 @@ CFileLoader::LoadClumpFile(const char *filename)
GetNameAndLOD(nodename, name, &n); GetNameAndLOD(nodename, name, &n);
mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(name, nil); mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(name, nil);
if(mi){ if(mi){
InitClump(clump);
assert(mi->IsClump()); assert(mi->IsClump());
mi->SetClump(clump); mi->SetClump(clump);
}else }else
@ -449,6 +461,7 @@ CFileLoader::LoadClumpFile(RwStream *stream, uint32 id)
clump = RpClumpStreamRead(stream); clump = RpClumpStreamRead(stream);
if(clump == nil) if(clump == nil)
return false; return false;
InitClump(clump);
mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(id); mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(id);
mi->SetClump(clump); mi->SetClump(clump);
return true; return true;
@ -476,6 +489,7 @@ CFileLoader::FinishLoadClumpFile(RwStream *stream, uint32 id)
clump = RpClumpGtaStreamRead2(stream); clump = RpClumpGtaStreamRead2(stream);
if(clump){ if(clump){
InitClump(clump);
mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(id); mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(id);
mi->SetClump(clump); mi->SetClump(clump);
return true; return true;
@ -496,6 +510,7 @@ CFileLoader::LoadAtomicFile(RwStream *stream, uint32 id)
clump = RpClumpStreamRead(stream); clump = RpClumpStreamRead(stream);
if(clump == nil) if(clump == nil)
return false; return false;
InitClump(clump);
gpRelatedModelInfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(id); gpRelatedModelInfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(id);
RpClumpForAllAtomics(clump, SetRelatedModelInfoCB, clump); RpClumpForAllAtomics(clump, SetRelatedModelInfoCB, clump);
RpClumpDestroy(clump); RpClumpDestroy(clump);
@ -531,6 +546,8 @@ CFileLoader::LoadAtomicFile2Return(const char *filename)
stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, filename); stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, filename);
if(RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)) if(RwStreamFindChunk(stream, rwID_CLUMP, nil, nil))
clump = RpClumpStreamRead(stream); clump = RpClumpStreamRead(stream);
if(clump)
InitClump(clump);
RwStreamClose(stream, nil); RwStreamClose(stream, nil);
return clump; return clump;
} }

View file

@ -1091,7 +1091,7 @@ CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data)
RpGeometry *geo; RpGeometry *geo;
geo = RpAtomicGetGeometry(atomic); geo = RpAtomicGetGeometry(atomic);
fx = 0; fx = rpMATFXEFFECTNULL;
RpGeometryForAllMaterials(geo, GetMatFXEffectMaterialCB, &fx); RpGeometryForAllMaterials(geo, GetMatFXEffectMaterialCB, &fx);
if(fx != rpMATFXEFFECTNULL){ if(fx != rpMATFXEFFECTNULL){
RpMatFXAtomicEnableEffects(atomic); RpMatFXAtomicEnableEffects(atomic);

View file

@ -212,7 +212,7 @@ isSkinnedCb(RpAtomic *atomic, void *data)
RpAtomic **pAtomic = (RpAtomic**)data; RpAtomic **pAtomic = (RpAtomic**)data;
if(*pAtomic) if(*pAtomic)
return nil; // already found one return nil; // already found one
if(RpSkinGeometryGetSkin(atomic->geometry)) if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic)))
*pAtomic = atomic; // we could just return nil here directly... *pAtomic = atomic; // we could just return nil here directly...
return atomic; return atomic;
} }
@ -621,3 +621,70 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer)
WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); } WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); }
WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); } WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); }
#endif #endif
#ifdef LIBRW
#include <rpmatfx.h>
#include "VehicleModelInfo.h"
int32
findPlatform(rw::Atomic *a)
{
rw::Geometry *g = a->geometry;
if(g->instData)
return g->instData->platform;
return 0;
}
// Game doesn't read atomic extensions so we never get any other than the default pipe,
// but we need it for uninstancing
void
attachPipe(rw::Atomic *atomic)
{
if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic)))
atomic->pipeline = rw::skinGlobals.pipelines[rw::platform];
else{
int fx = rpMATFXEFFECTNULL;
RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), CVehicleModelInfo::GetMatFXEffectMaterialCB, &fx);
if(fx != rpMATFXEFFECTNULL)
RpMatFXAtomicEnableEffects(atomic);
}
}
// Attach pipes for the platform we have native data for so we can uninstance
void
switchPipes(rw::Atomic *a, int32 platform)
{
if(a->pipeline && a->pipeline->platform != platform){
uint32 plgid = a->pipeline->pluginID;
switch(plgid){
// assume default pipe won't be attached explicitly
case rw::ID_SKIN:
a->pipeline = rw::skinGlobals.pipelines[platform];
break;
case rw::ID_MATFX:
a->pipeline = rw::matFXGlobals.pipelines[platform];
break;
}
}
}
RpAtomic*
ConvertPlatformAtomic(RpAtomic *atomic, void *data)
{
int32 driver = rw::platform;
int32 platform = findPlatform(atomic);
if(platform != 0 && platform != driver){
attachPipe(atomic); // kludge
rw::ObjPipeline *origPipe = atomic->pipeline;
rw::platform = platform;
switchPipes(atomic, rw::platform);
if(atomic->geometry->flags & rw::Geometry::NATIVE)
atomic->uninstance();
// no ADC in this game
//rw::ps2::unconvertADC(atomic->geometry);
rw::platform = driver;
atomic->pipeline = origPipe;
}
return atomic;
}
#endif

View file

@ -54,4 +54,6 @@ RwCamera *CameraCreate(RwInt32 width,
void _TexturePoolsInitialise(); void _TexturePoolsInitialise();
void _TexturePoolsShutdown(); void _TexturePoolsShutdown();
RpAtomic *ConvertPlatformAtomic(RpAtomic *atomic, void *data);