diff options
author | aap <aap@papnet.eu> | 2020-07-16 13:36:25 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-07-16 13:36:25 +0200 |
commit | 4e3e1d0b87b88738741955fd2b673ee6ea4295ab (patch) | |
tree | 5c8df0e14777e604db1471a831e81d89437d2c5d /src/rw/RwHelper.cpp | |
parent | Merge branch 'master' into miami (diff) | |
download | re3-4e3e1d0b87b88738741955fd2b673ee6ea4295ab.tar re3-4e3e1d0b87b88738741955fd2b673ee6ea4295ab.tar.gz re3-4e3e1d0b87b88738741955fd2b673ee6ea4295ab.tar.bz2 re3-4e3e1d0b87b88738741955fd2b673ee6ea4295ab.tar.lz re3-4e3e1d0b87b88738741955fd2b673ee6ea4295ab.tar.xz re3-4e3e1d0b87b88738741955fd2b673ee6ea4295ab.tar.zst re3-4e3e1d0b87b88738741955fd2b673ee6ea4295ab.zip |
Diffstat (limited to 'src/rw/RwHelper.cpp')
-rw-r--r-- | src/rw/RwHelper.cpp | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 76c6c753..e8a85be6 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -212,7 +212,7 @@ isSkinnedCb(RpAtomic *atomic, void *data) RpAtomic **pAtomic = (RpAtomic**)data; if(*pAtomic) return nil; // already found one - if(RpSkinGeometryGetSkin(atomic->geometry)) + if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic))) *pAtomic = atomic; // we could just return nil here directly... return atomic; } @@ -621,3 +621,70 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer) WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); } WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); } #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 |