diff options
author | aap <aap@papnet.eu> | 2021-07-29 19:43:06 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2021-07-29 19:43:06 +0200 |
commit | 30061396e8fb5afb003cb686e3b2d8665145c76f (patch) | |
tree | fa0a77c84311f196518a67f4e695384465abbff0 /src/rw | |
parent | Reverse unused audio functions (diff) | |
download | re3-30061396e8fb5afb003cb686e3b2d8665145c76f.tar re3-30061396e8fb5afb003cb686e3b2d8665145c76f.tar.gz re3-30061396e8fb5afb003cb686e3b2d8665145c76f.tar.bz2 re3-30061396e8fb5afb003cb686e3b2d8665145c76f.tar.lz re3-30061396e8fb5afb003cb686e3b2d8665145c76f.tar.xz re3-30061396e8fb5afb003cb686e3b2d8665145c76f.tar.zst re3-30061396e8fb5afb003cb686e3b2d8665145c76f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/rw/VisibilityPlugins.cpp | 54 | ||||
-rw-r--r-- | src/rw/VisibilityPlugins.h | 4 |
2 files changed, 47 insertions, 11 deletions
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 01db546c..01f2c8e7 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -51,7 +51,7 @@ CVisibilityPlugins::Initialise(void) m_alphaBoatAtomicList.tail.item.sort = 100000000.0f; #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); #else m_alphaEntityList.Init(NUMALPHAENTITYLIST); @@ -604,8 +604,7 @@ CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic) return atomic; if(flags & ATOMIC_FLAG_DRAWLAST){ - // sort before clump - if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq - 0.0001f)) + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq)) RENDERCALLBACK(atomic); }else{ if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot)) @@ -662,12 +661,14 @@ CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic) RpAtomic* CVisibilityPlugins::RenderPedCB(RpAtomic *atomic) { + RpClump *clump; + float dist; int32 alpha; - RwV3d cam2atm; - RwV3dSub(&cam2atm, &RwFrameGetLTM(RpAtomicGetFrame(atomic))->pos, ms_pCameraPosn); - if(RwV3dDotProduct(&cam2atm, &cam2atm) < ms_pedLod1Dist){ - alpha = GetClumpAlpha(RpAtomicGetClump(atomic)); + clump = RpAtomicGetClump(atomic); + dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); + if(dist < ms_pedLod1Dist){ + alpha = GetClumpAlpha(clump); if(alpha == 255) RENDERCALLBACK(atomic); else @@ -756,11 +757,22 @@ CVisibilityPlugins::FrustumSphereCB(RpClump *clump) } 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 CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump) { - if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist) - return FrustumSphereCB(clump); - return false; + RwFrame *frame = RpClumpGetFrame(clump); + if (ms_vehicleLod1Dist < GetDistanceSquaredFromCamera(frame)) + return false; + return FrustumSphereCB(clump); } bool @@ -854,6 +866,12 @@ CVisibilityPlugins::ClearAtomicFlag(RpAtomic *atomic, int f) ATOMICEXT(atomic)->flags &= ~f; } +void +CVisibilityPlugins::SetAtomicId(RpAtomic *atomic, int id) +{ + ATOMICEXT(atomic)->flags = id; +} + int CVisibilityPlugins::GetAtomicId(RpAtomic *atomic) { @@ -939,7 +957,9 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo // Unused switch (modelInfo->GetModelType()) { - // ignore MLO + case MITYPE_MLO: + CLUMPEXT(clump)->visibilityCB = MloVisibilityCB; + break; case MITYPE_VEHICLE: vmi = (CVehicleModelInfo*)modelInfo; 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 CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha) { @@ -964,3 +990,9 @@ CVisibilityPlugins::GetClumpAlpha(RpClump *clump) { return CLUMPEXT(clump)->alpha; } + +bool +CVisibilityPlugins::IsClumpVisible(RpClump *clump) +{ + return CLUMPEXT(clump)->visibilityCB(clump); +} diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index d375044b..90afc0f5 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -84,6 +84,7 @@ public: // All actually unused static bool DefaultVisibilityCB(RpClump *clump); static bool FrustumSphereCB(RpClump *clump); + static bool MloVisibilityCB(RpClump *clump); static bool VehicleVisibilityCB(RpClump *clump); static bool VehicleVisibilityCB_BigVehicle(RpClump *clump); @@ -104,6 +105,7 @@ public: static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic); static void SetAtomicFlag(RpAtomic*, int); static void ClearAtomicFlag(RpAtomic*, int); + static void SetAtomicId(RpAtomic *atomic, int); static int GetAtomicId(RpAtomic *atomic); static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender); @@ -133,8 +135,10 @@ public: int alpha; }; static void SetClumpModelInfo(RpClump*, CClumpModelInfo*); + static CClumpModelInfo *GetClumpModelInfo(RpClump*); static void SetClumpAlpha(RpClump*, int); static int GetClumpAlpha(RpClump*); + static bool IsClumpVisible(RpClump*); static void *ClumpConstructor(void *object, int32 offset, int32 len); static void *ClumpDestructor(void *object, int32 offset, int32 len); |