mirror of
https://github.com/halpz/re3.git
synced 2025-07-17 09:28:16 +00:00
@ -51,7 +51,7 @@ RwInt32
|
||||
NodeNameStreamGetSize(const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject)
|
||||
{
|
||||
// game checks for null pointer on node name extension but that really happen
|
||||
return rwstrlen(NODENAMEEXT(object));
|
||||
return (RwInt32)rwstrlen(NODENAMEEXT(object));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -108,7 +108,7 @@ DefinedState(void)
|
||||
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
|
||||
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
|
||||
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
|
||||
RwRenderStateSet(rwRENDERSTATEALPHAPRIMITIVEBUFFER, (void*)FALSE);
|
||||
//RwRenderStateSet(rwRENDERSTATEALPHAPRIMITIVEBUFFER, (void*)FALSE);
|
||||
RwRenderStateSet(rwRENDERSTATEBORDERCOLOR, (void*)RWRGBALONG(0, 0, 0, 255));
|
||||
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
|
||||
RwRenderStateSet(rwRENDERSTATEFOGCOLOR,
|
||||
@ -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;
|
||||
}
|
||||
@ -358,9 +358,9 @@ AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data)
|
||||
hier->interpolator->currentAnim = nil;
|
||||
}
|
||||
#else
|
||||
if(hier && hier->pCurrentAnim){
|
||||
RpHAnimAnimationDestroy(hier->pCurrentAnim);
|
||||
hier->pCurrentAnim = nil;
|
||||
if(hier && hier->currentAnim){
|
||||
RpHAnimAnimationDestroy(hier->currentAnim->pCurrentAnim);
|
||||
hier->currentAnim = nil;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -740,3 +740,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
|
||||
|
@ -57,4 +57,6 @@ RwCamera *CameraCreate(RwInt32 width,
|
||||
|
||||
|
||||
void _TexturePoolsInitialise();
|
||||
void _TexturePoolsShutdown();
|
||||
void _TexturePoolsShutdown();
|
||||
|
||||
RpAtomic *ConvertPlatformAtomic(RpAtomic *atomic, void *data);
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
#define WITHD3D
|
||||
#include "common.h"
|
||||
#ifdef RWLIBS
|
||||
#include "patcher.h"
|
||||
#endif
|
||||
#include "rwcore.h"
|
||||
#include "rpmatfx.h"
|
||||
|
||||
struct MatFXNothing { int pad[5]; int effect; };
|
||||
|
||||
@ -47,16 +46,16 @@ struct MatFX
|
||||
int effects;
|
||||
};
|
||||
|
||||
#ifdef RWLIBS
|
||||
extern "C" {
|
||||
extern int MatFXMaterialDataOffset;
|
||||
extern int MatFXAtomicDataOffset;
|
||||
|
||||
void _rpMatFXD3D8AtomicMatFXEnvRender(RxD3D8InstanceData* inst, int flags, int sel, RwTexture* texture, RwTexture* envMap);
|
||||
void _rpMatFXD3D8AtomicMatFXRenderBlack(RxD3D8InstanceData *inst);
|
||||
void _rpMatFXD3D8AtomicMatFXBumpMapRender(RxD3D8InstanceData *inst, int flags, RwTexture *texture, RwTexture *bumpMap, RwTexture *envMap);
|
||||
void _rpMatFXD3D8AtomicMatFXDualPassRender(RxD3D8InstanceData *inst, int flags, RwTexture *texture, RwTexture *dualTexture);
|
||||
}
|
||||
#else
|
||||
int &MatFXMaterialDataOffset = *(int*)0x66188C;
|
||||
int &MatFXAtomicDataOffset = *(int*)0x66189C;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PS2_MATFX
|
||||
|
||||
@ -218,12 +217,96 @@ _rpMatFXD3D8AtomicMatFXEnvRender_ps2(RxD3D8InstanceData *inst, int flags, int se
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
|
||||
}
|
||||
|
||||
#ifdef RWLIBS
|
||||
STARTPATCHES
|
||||
InjectHook((uintptr)&_rpMatFXD3D8AtomicMatFXEnvRender, _rpMatFXD3D8AtomicMatFXEnvRender_ps2, PATCH_JUMP);
|
||||
ENDPATCHES
|
||||
#endif
|
||||
void
|
||||
_rwD3D8EnableClippingIfNeeded(void *object, RwUInt8 type)
|
||||
{
|
||||
int clip;
|
||||
if (type == rpATOMIC)
|
||||
clip = !RwD3D8CameraIsSphereFullyInsideFrustum(RwCameraGetCurrentCameraMacro(), RpAtomicGetWorldBoundingSphere((RpAtomic *)object));
|
||||
else
|
||||
clip = !RwD3D8CameraIsBBoxFullyInsideFrustum(RwCameraGetCurrentCameraMacro(), &((RpWorldSector *)object)->tightBoundingBox);
|
||||
RwD3D8SetRenderState(D3DRS_CLIPPING, clip);
|
||||
}
|
||||
|
||||
#endif
|
||||
void
|
||||
_rwD3D8AtomicMatFXRenderCallback(RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt32 flags)
|
||||
{
|
||||
RwBool lighting;
|
||||
RwBool forceBlack;
|
||||
RxD3D8ResEntryHeader *header;
|
||||
RxD3D8InstanceData *inst;
|
||||
RwInt32 i;
|
||||
|
||||
#endif
|
||||
if (flags & rpGEOMETRYPRELIT) {
|
||||
RwD3D8SetRenderState(D3DRS_COLORVERTEX, 1);
|
||||
RwD3D8SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
} else {
|
||||
RwD3D8SetRenderState(D3DRS_COLORVERTEX, 0);
|
||||
RwD3D8SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
}
|
||||
|
||||
_rwD3D8EnableClippingIfNeeded(object, type);
|
||||
|
||||
RwD3D8GetRenderState(D3DRS_LIGHTING, &lighting);
|
||||
if (lighting || flags & rpGEOMETRYPRELIT) {
|
||||
forceBlack = FALSE;
|
||||
} else {
|
||||
forceBlack = TRUE;
|
||||
RwD3D8SetTexture(nil, 0);
|
||||
RwD3D8SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(0, 0, 0, 255));
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
|
||||
}
|
||||
|
||||
header = (RxD3D8ResEntryHeader *)(repEntry + 1);
|
||||
inst = (RxD3D8InstanceData *)(header + 1);
|
||||
for (i = 0; i < header->numMeshes; i++) {
|
||||
if (forceBlack)
|
||||
_rpMatFXD3D8AtomicMatFXRenderBlack(inst);
|
||||
else {
|
||||
if (lighting)
|
||||
RwD3D8SetSurfaceProperties(&inst->material->color, &inst->material->surfaceProps, flags & rpGEOMETRYMODULATEMATERIALCOLOR);
|
||||
MatFX *matfx = *RWPLUGINOFFSET(MatFX *, inst->material, MatFXMaterialDataOffset);
|
||||
int effect = matfx ? matfx->effects : rpMATFXEFFECTNULL;
|
||||
switch (effect) {
|
||||
case rpMATFXEFFECTNULL:
|
||||
default:
|
||||
_rpMatFXD3D8AtomicMatFXDefaultRender(inst, flags, inst->material->texture);
|
||||
break;
|
||||
case rpMATFXEFFECTBUMPMAP:
|
||||
_rpMatFXD3D8AtomicMatFXBumpMapRender(inst, flags, inst->material->texture, matfx->fx[0].b.bumpedTex, nil);
|
||||
break;
|
||||
case rpMATFXEFFECTENVMAP:
|
||||
{
|
||||
// TODO: matfx switch in the settings
|
||||
//_rpMatFXD3D8AtomicMatFXEnvRender(inst, flags, 0, inst->material->texture, matfx->fx[0].e.envTex);
|
||||
_rpMatFXD3D8AtomicMatFXEnvRender_ps2(inst, flags, 0, inst->material->texture, matfx->fx[0].e.envTex);
|
||||
break;
|
||||
}
|
||||
case rpMATFXEFFECTBUMPENVMAP:
|
||||
_rpMatFXD3D8AtomicMatFXBumpMapRender(inst, flags, inst->material->texture, matfx->fx[0].b.bumpedTex, matfx->fx[1].e.envTex);
|
||||
break;
|
||||
case rpMATFXEFFECTDUAL:
|
||||
_rpMatFXD3D8AtomicMatFXDualPassRender(inst, flags, inst->material->texture, matfx->fx[0].d.dualTex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
inst++;
|
||||
}
|
||||
|
||||
if (forceBlack) {
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ReplaceMatFxCallback()
|
||||
{
|
||||
RxD3D8AllInOneSetRenderCallBack(
|
||||
RxPipelineFindNodeByName(RpMatFXGetD3D8Pipeline(rpMATFXD3D8ATOMICPIPELINE), RxNodeDefinitionGetD3D8AtomicAllInOne()->name, nil, nil),
|
||||
_rwD3D8AtomicMatFXRenderCallback);
|
||||
}
|
||||
#endif // PS2_MATFX
|
||||
|
||||
#endif // !LIBRW
|
||||
|
@ -625,6 +625,14 @@ CVisibilityPlugins::RenderPedCB(RpAtomic *atomic)
|
||||
return atomic;
|
||||
}
|
||||
|
||||
float
|
||||
CVisibilityPlugins::GetDistanceSquaredFromCamera(RwV3d *pos)
|
||||
{
|
||||
RwV3d dist;
|
||||
RwV3dSub(&dist, pos, ms_pCameraPosn);
|
||||
return RwV3dDotProduct(&dist, &dist);
|
||||
}
|
||||
|
||||
float
|
||||
CVisibilityPlugins::GetDistanceSquaredFromCamera(RwFrame *frame)
|
||||
{
|
||||
@ -835,12 +843,12 @@ CVisibilityPlugins::FrameCopyConstructor(void *dst, const void *src, int32, int3
|
||||
}
|
||||
|
||||
void
|
||||
CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, int32 id)
|
||||
CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, uintptr id)
|
||||
{
|
||||
FRAMEEXT(frame)->id = id;
|
||||
}
|
||||
|
||||
int32
|
||||
uintptr
|
||||
CVisibilityPlugins::GetFrameHierarchyId(RwFrame *frame)
|
||||
{
|
||||
return FRAMEEXT(frame)->id;
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
static bool VehicleVisibilityCB(RpClump *clump);
|
||||
static bool VehicleVisibilityCB_BigVehicle(RpClump *clump);
|
||||
|
||||
static float GetDistanceSquaredFromCamera(RwV3d *pos);
|
||||
static float GetDistanceSquaredFromCamera(RwFrame *frame);
|
||||
static float GetDotProductWithCameraVector(RwMatrix *atomicMat, RwMatrix *clumpMat, uint32 flags);
|
||||
|
||||
@ -111,10 +112,10 @@ public:
|
||||
struct FrameExt
|
||||
{
|
||||
// BUG: this is abused to hold a pointer by SetClumpModelInfo
|
||||
int32 id;
|
||||
uintptr id;
|
||||
};
|
||||
static void SetFrameHierarchyId(RwFrame *frame, int32 id);
|
||||
static int32 GetFrameHierarchyId(RwFrame *frame);
|
||||
static void SetFrameHierarchyId(RwFrame *frame, uintptr id);
|
||||
static uintptr GetFrameHierarchyId(RwFrame *frame);
|
||||
|
||||
static void *FrameConstructor(void *object, int32 offset, int32 len);
|
||||
static void *FrameDestructor(void *object, int32 offset, int32 len);
|
||||
|
Reference in New Issue
Block a user