summaryrefslogtreecommitdiffstats
path: root/src/render/VisibilityPlugins.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/VisibilityPlugins.cpp')
-rw-r--r--src/render/VisibilityPlugins.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/render/VisibilityPlugins.cpp b/src/render/VisibilityPlugins.cpp
index ac5ac826..bbaa08ce 100644
--- a/src/render/VisibilityPlugins.cpp
+++ b/src/render/VisibilityPlugins.cpp
@@ -7,6 +7,7 @@
#include "Renderer.h"
#include "Camera.h"
#include "VisibilityPlugins.h"
+#include "World.h"
#define FADE_DISTANCE 20.0f
@@ -498,14 +499,11 @@ CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic)
return atomic;
}
-// TODO: this is part of a struct
-static RwTexture *&playerskin = *(RwTexture**)0x941428;
-
RpAtomic*
CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic)
{
- if(playerskin)
- RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, playerskin);
+ if(CWorld::Players[0].m_pSkinTexture)
+ RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture);
AtomicDefaultRenderCallBack(atomic);
return atomic;
}
@@ -607,22 +605,30 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump)
bool
CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
{
- // TODO, but unused
- return true;
+ RwSphere sphere;
+ RwFrame *frame = RpClumpGetFrame(clump);
+
+ CClumpModelInfo *modelInfo = (CClumpModelInfo*)GetFrameHierarchyId(frame);
+ sphere.radius = modelInfo->GetColModel()->boundingSphere.radius;
+ sphere.center.x = modelInfo->GetColModel()->boundingSphere.center.x;
+ sphere.center.y = modelInfo->GetColModel()->boundingSphere.center.y;
+ sphere.center.z = modelInfo->GetColModel()->boundingSphere.center.z;
+ RwV3dTransformPoints(&sphere.center, &sphere.center, 1, RwFrameGetLTM(frame));
+ return RwCameraFrustumTestSphere(ms_pCamera, &sphere) != rwSPHEREOUTSIDE;
}
bool
CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump)
{
- // TODO, but unused
- return true;
+ if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist)
+ return FrustumSphereCB(clump);
+ return false;
}
bool
CVisibilityPlugins::VehicleVisibilityCB_BigVehicle(RpClump *clump)
{
- // TODO, but unused
- return true;
+ return FrustumSphereCB(clump);
}