Re3/src/rw/VisibilityPlugins.h

137 lines
4.7 KiB
C
Raw Normal View History

2019-05-15 10:52:37 -04:00
#pragma once
#include "templates.h"
class CEntity;
class CSimpleModelInfo;
class CClumpModelInfo;
typedef bool (*ClumpVisibilityCB)(RpClump*);
class CVisibilityPlugins
{
public:
struct AlphaObjectInfo
{
union {
CEntity *entity;
RpAtomic *atomic;
};
float sort;
};
2020-04-16 04:50:45 -04:00
static CLinkList<AlphaObjectInfo> m_alphaList;
static CLinkList<AlphaObjectInfo> m_alphaEntityList;
static RwCamera *ms_pCamera;
static RwV3d *ms_pCameraPosn;
static float ms_cullCompsDist;
static float ms_vehicleLod0Dist;
static float ms_vehicleLod1Dist;
static float ms_vehicleFadeDist;
static float ms_bigVehicleLod0Dist;
static float ms_bigVehicleLod1Dist;
static float ms_pedLod0Dist;
static float ms_pedLod1Dist;
static float ms_pedFadeDist;
2019-05-15 10:52:37 -04:00
static void Initialise(void);
2019-06-13 06:25:55 -04:00
static void Shutdown(void);
2019-05-15 10:52:37 -04:00
static void InitAlphaEntityList(void);
static bool InsertEntityIntoSortedList(CEntity *e, float dist);
static void InitAlphaAtomicList(void);
static bool InsertAtomicIntoSortedList(RpAtomic *a, float dist);
2019-05-31 05:44:43 -04:00
static void SetRenderWareCamera(RwCamera *camera);
2019-05-15 10:52:37 -04:00
static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic);
static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic);
static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha);
static RpAtomic *RenderFadingAtomic(RpAtomic *atm, float dist);
static RpAtomic *RenderVehicleHiDetailCB(RpAtomic *atomic);
static RpAtomic *RenderVehicleHiDetailAlphaCB(RpAtomic *atomic);
static RpAtomic *RenderVehicleHiDetailCB_BigVehicle(RpAtomic *atomic);
static RpAtomic *RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic);
static RpAtomic *RenderVehicleHiDetailCB_Boat(RpAtomic *atomic);
static RpAtomic *RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic);
static RpAtomic *RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic);
static RpAtomic *RenderVehicleReallyLowDetailCB(RpAtomic *atomic);
static RpAtomic *RenderVehicleReallyLowDetailCB_BigVehicle(RpAtomic *atomic);
static RpAtomic *RenderTrainHiDetailCB(RpAtomic *atomic);
static RpAtomic *RenderTrainHiDetailAlphaCB(RpAtomic *atomic);
static RpAtomic *RenderPlayerCB(RpAtomic *atomic);
static RpAtomic *RenderPedLowDetailCB(RpAtomic *atomic);
static RpAtomic *RenderPedHiDetailCB(RpAtomic *atomic);
static RpAtomic *RenderPedCB(RpAtomic *atomic); // for skinned models with only one clump
2019-05-15 10:52:37 -04:00
static void RenderAlphaAtomics(void);
static void RenderFadingEntities(void);
// All actually unused
static bool DefaultVisibilityCB(RpClump *clump);
static bool FrustumSphereCB(RpClump *clump);
2020-04-16 04:50:45 -04:00
static bool MloVisibilityCB(RpClump *clump);
2019-05-15 10:52:37 -04:00
static bool VehicleVisibilityCB(RpClump *clump);
static bool VehicleVisibilityCB_BigVehicle(RpClump *clump);
static float GetDistanceSquaredFromCamera(RwFrame *frame);
static float GetDotProductWithCameraVector(RwMatrix *atomicMat, RwMatrix *clumpMat, uint32 flags);
//
// RW Plugins
//
union AtomicExt
{
CSimpleModelInfo *modelInfo; // used by SimpleModelInfo
int flags; // used by ClumpModelInfo
};
static void SetAtomicModelInfo(RpAtomic*, CSimpleModelInfo*);
static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic);
static void SetAtomicFlag(RpAtomic*, int);
static void ClearAtomicFlag(RpAtomic*, int);
static int GetAtomicId(RpAtomic *atomic);
static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender);
static void *AtomicConstructor(void *object, int32 offset, int32 len);
static void *AtomicDestructor(void *object, int32 offset, int32 len);
static void *AtomicCopyConstructor(void *dst, const void *src,
int32 offset, int32 len);
2020-04-16 04:50:45 -04:00
static int32 ms_atomicPluginOffset;
2019-05-15 10:52:37 -04:00
struct FrameExt
{
// BUG: this is abused to hold a pointer by SetClumpModelInfo
2020-07-22 07:56:28 -04:00
uintptr id;
2019-05-15 10:52:37 -04:00
};
2020-07-22 07:56:28 -04:00
static void SetFrameHierarchyId(RwFrame *frame, uintptr id);
static uintptr GetFrameHierarchyId(RwFrame *frame);
2019-05-15 10:52:37 -04:00
static void *FrameConstructor(void *object, int32 offset, int32 len);
static void *FrameDestructor(void *object, int32 offset, int32 len);
static void *FrameCopyConstructor(void *dst, const void *src,
int32 offset, int32 len);
2020-04-16 04:50:45 -04:00
static int32 ms_framePluginOffset;
2019-05-15 10:52:37 -04:00
// Not actually used
struct ClumpExt
{
ClumpVisibilityCB visibilityCB;
int alpha;
};
static void SetClumpModelInfo(RpClump*, CClumpModelInfo*);
static void SetClumpAlpha(RpClump*, int);
static int GetClumpAlpha(RpClump*);
static void *ClumpConstructor(void *object, int32 offset, int32 len);
static void *ClumpDestructor(void *object, int32 offset, int32 len);
static void *ClumpCopyConstructor(void *dst, const void *src,
int32 offset, int32 len);
2020-04-16 04:50:45 -04:00
static int32 ms_clumpPluginOffset;
2019-05-15 10:52:37 -04:00
static bool PluginAttach(void);
};
RpMaterial *SetAlphaCB(RpMaterial *material, void *data);