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.cpp66
1 files changed, 63 insertions, 3 deletions
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 754c8778..ffd7b18a 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -96,6 +96,10 @@ CVisibilityPlugins::InitAlphaEntityList(void)
bool
CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist)
{
+#ifdef FIX_BUGS
+ if (!e->m_rwObject) return true;
+#endif
+
AlphaObjectInfo item;
item.entity = e;
item.sort = dist;
@@ -229,7 +233,9 @@ CVisibilityPlugins::RenderFadingEntities(CLinkList<AlphaObjectInfo> &list)
DeActivateDirectional();
SetAmbientColours();
e->bImBeingRendered = true;
+ PUSH_RENDERGROUP(mi->GetModelName());
RenderFadingAtomic((RpAtomic*)e->m_rwObject, node->item.sort);
+ POP_RENDERGROUP();
e->bImBeingRendered = false;
}else
CRenderer::RenderOneNonRoad(e);
@@ -821,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
@@ -833,6 +839,7 @@ void*
CVisibilityPlugins::AtomicConstructor(void *object, int32, int32)
{
ATOMICEXT(object)->modelInfo = nil;
+ ATOMICEXT(object)->distanceAlpha = 255;
return object;
}
@@ -985,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);
+}