summaryrefslogtreecommitdiffstats
path: root/src/rw
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2021-05-23 17:55:55 +0200
committerSergeanur <s.anureev@yandex.ua>2021-06-24 20:45:21 +0200
commite014bb5359ae464f14a413dd5ee98f0b5a385f67 (patch)
tree0a687f497f318c4a849e7054f05851a73f2f0c0c /src/rw
parentUndef PS2_AUDIO_CHANNELS for SQUEEZE_PERFORMANCE and VANILLA_DEFINES (diff)
downloadre3-e014bb5359ae464f14a413dd5ee98f0b5a385f67.tar
re3-e014bb5359ae464f14a413dd5ee98f0b5a385f67.tar.gz
re3-e014bb5359ae464f14a413dd5ee98f0b5a385f67.tar.bz2
re3-e014bb5359ae464f14a413dd5ee98f0b5a385f67.tar.lz
re3-e014bb5359ae464f14a413dd5ee98f0b5a385f67.tar.xz
re3-e014bb5359ae464f14a413dd5ee98f0b5a385f67.tar.zst
re3-e014bb5359ae464f14a413dd5ee98f0b5a385f67.zip
Diffstat (limited to 'src/rw')
-rw-r--r--src/rw/VisibilityPlugins.cpp60
-rw-r--r--src/rw/VisibilityPlugins.h15
2 files changed, 68 insertions, 7 deletions
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index eebbb93b..ffd7b18a 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -827,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
@@ -839,6 +839,7 @@ void*
CVisibilityPlugins::AtomicConstructor(void *object, int32, int32)
{
ATOMICEXT(object)->modelInfo = nil;
+ ATOMICEXT(object)->distanceAlpha = 255;
return object;
}
@@ -991,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);
+}
diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h
index f188096c..3a3e555b 100644
--- a/src/rw/VisibilityPlugins.h
+++ b/src/rw/VisibilityPlugins.h
@@ -97,10 +97,13 @@ public:
// RW Plugins
//
- union AtomicExt
+ struct AtomicExt
{
- CSimpleModelInfo *modelInfo; // used by SimpleModelInfo
- int flags; // used by ClumpModelInfo
+ union {
+ CSimpleModelInfo *modelInfo; // used by SimpleModelInfo
+ int flags; // used by ClumpModelInfo
+ };
+ int distanceAlpha; // not sure where this is in PS2/PSP LCS
};
static void SetAtomicModelInfo(RpAtomic*, CSimpleModelInfo*);
static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic);
@@ -129,7 +132,6 @@ public:
int32 offset, int32 len);
static int32 ms_framePluginOffset;
- // Not actually used
struct ClumpExt
{
ClumpVisibilityCB visibilityCB;
@@ -138,6 +140,8 @@ public:
static void SetClumpModelInfo(RpClump*, CClumpModelInfo*);
static void SetClumpAlpha(RpClump*, int);
static int GetClumpAlpha(RpClump*);
+ static void SetClumpDistanceAlpha(RpClump*, int);
+ static int GetClumpDistanceAlpha(RpClump*);
static void *ClumpConstructor(void *object, int32 offset, int32 len);
static void *ClumpDestructor(void *object, int32 offset, int32 len);
@@ -145,6 +149,9 @@ public:
int32 offset, int32 len);
static int32 ms_clumpPluginOffset;
+ static void SetObjectDistanceAlpha(RwObject *object, int alpha);
+ static int GetObjectDistanceAlpha(RwObject *object);
+
static bool PluginAttach(void);
};