summaryrefslogtreecommitdiffstats
path: root/src/rw/VisibilityPlugins.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rw/VisibilityPlugins.cpp')
-rw-r--r--src/rw/VisibilityPlugins.cpp91
1 files changed, 86 insertions, 5 deletions
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 01db546c..ffd7b18a 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -267,6 +267,7 @@ CVisibilityPlugins::RenderWheelAtomicCB(RpAtomic *atomic)
mi = GetAtomicModelInfo(atomic);
len = Sqrt(DistToCameraSq);
+ len *= 0.5f; // HACK HACK, LOD wheels look shite
lodatm = mi->GetAtomicFromDistance(len * TheCamera.LODDistMultiplier / VEHICLE_LODDIST_MULTIPLIER);
if(lodatm){
if(RpAtomicGetGeometry(lodatm) != RpAtomicGetGeometry(atomic))
@@ -466,6 +467,14 @@ CVisibilityPlugins::RenderVehicleHiDetailCB_Boat(RpAtomic *atomic)
}
RpAtomic*
+CVisibilityPlugins::RenderVehicleHiDetailCB_Boat_Far(RpAtomic *atomic)
+{
+ if(DistToCameraSq < ms_bigVehicleLod1Dist)
+ RENDERCALLBACK(atomic);
+ return atomic;
+}
+
+RpAtomic*
CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic)
{
if(DistToCameraSq < ms_vehicleLod0Dist){
@@ -496,6 +505,23 @@ CVisibilityPlugins::RenderVehicleLoDetailCB_Boat(RpAtomic *atomic)
}
RpAtomic*
+CVisibilityPlugins::RenderVehicleLoDetailCB_Boat_Far(RpAtomic *atomic)
+{
+ RpClump *clump;
+ int32 alpha;
+
+ clump = RpAtomicGetClump(atomic);
+ if(DistToCameraSq >= ms_bigVehicleLod1Dist){
+ alpha = GetClumpAlpha(clump);
+ if(alpha == 255)
+ RENDERCALLBACK(atomic);
+ else
+ RenderAlphaAtomic(atomic, alpha);
+ }
+ return atomic;
+}
+
+RpAtomic*
CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic)
{
RwFrame *clumpframe;
@@ -653,8 +679,9 @@ CVisibilityPlugins::RenderVehicleTailRotorAlphaCB(RpAtomic *atomic)
RpAtomic*
CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic)
{
- if(CWorld::Players[0].m_pSkinTexture)
- RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture);
+// LCS: removed
+// if(CWorld::Players[0].m_pSkinTexture)
+// RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture);
RENDERCALLBACK(atomic);
return atomic;
}
@@ -800,9 +827,9 @@ CVisibilityPlugins::PluginAttach(void)
return ms_atomicPluginOffset != -1 && ms_clumpPluginOffset != -1;
}
-#define ATOMICEXT(o) (RWPLUGINOFFSET(AtomicExt, o, ms_atomicPluginOffset))
-#define FRAMEEXT(o) (RWPLUGINOFFSET(FrameExt, o, ms_framePluginOffset))
-#define CLUMPEXT(o) (RWPLUGINOFFSET(ClumpExt, o, ms_clumpPluginOffset))
+#define ATOMICEXT(o) (RWPLUGINOFFSET(CVisibilityPlugins::AtomicExt, o, CVisibilityPlugins::ms_atomicPluginOffset))
+#define FRAMEEXT(o) (RWPLUGINOFFSET(CVisibilityPlugins::FrameExt, o, CVisibilityPlugins::ms_framePluginOffset))
+#define CLUMPEXT(o) (RWPLUGINOFFSET(CVisibilityPlugins::ClumpExt, o, CVisibilityPlugins::ms_clumpPluginOffset))
//
// Atomic
@@ -812,6 +839,7 @@ void*
CVisibilityPlugins::AtomicConstructor(void *object, int32, int32)
{
ATOMICEXT(object)->modelInfo = nil;
+ ATOMICEXT(object)->distanceAlpha = 255;
return object;
}
@@ -964,3 +992,56 @@ CVisibilityPlugins::GetClumpAlpha(RpClump *clump)
{
return CLUMPEXT(clump)->alpha;
}
+
+// LCS walks the atomic list manually but we want to be compatible with both RW and librw,
+// so this code isn't quite original and uses callbacks instead.
+static RpAtomic*
+SetAtomicDistanceAlphaCB(RpAtomic *atomic, void *data)
+{
+ ATOMICEXT(atomic)->distanceAlpha = *(int*)data;
+ return atomic;
+}
+void
+CVisibilityPlugins::SetClumpDistanceAlpha(RpClump *clump, int alpha)
+{
+ RpClumpForAllAtomics(clump, SetAtomicDistanceAlphaCB, &alpha);
+}
+
+static RpAtomic*
+GetAtomicDistanceAlphaCB(RpAtomic *atomic, void *data)
+{
+ *(int*)data = ATOMICEXT(atomic)->distanceAlpha;
+ return atomic;
+}
+int
+CVisibilityPlugins::GetClumpDistanceAlpha(RpClump *clump)
+{
+ int alpha = 255;
+ RpClumpForAllAtomics(clump, GetAtomicDistanceAlphaCB, &alpha);
+ return alpha;
+}
+
+
+
+
+void
+CVisibilityPlugins::SetObjectDistanceAlpha(RwObject *object, int alpha)
+{
+ if(object == nil)
+ return;
+ if(RwObjectGetType(object) == rpATOMIC)
+ ATOMICEXT(object)->distanceAlpha = alpha;
+ else
+ SetClumpDistanceAlpha((RpClump*)object, alpha);
+}
+
+int
+CVisibilityPlugins::GetObjectDistanceAlpha(RwObject *object)
+{
+ if(object == nil)
+ return 255;
+ if(RwObjectGetType(object) == rpATOMIC)
+ return ATOMICEXT(object)->distanceAlpha;
+ else
+ return GetClumpDistanceAlpha((RpClump*)object);
+}