diff --git a/Source/Contents/Actors/SpriteDrawingPolicy.h b/Source/Contents/Actors/SpriteDrawingPolicy.h index f3f5aa3..356bdbd 100644 --- a/Source/Contents/Actors/SpriteDrawingPolicy.h +++ b/Source/Contents/Actors/SpriteDrawingPolicy.h @@ -24,6 +24,7 @@ struct SpriteDrawingPolicy { int unused, int layer, float scale, const SpriteFrameCell& cell, float x, float y, const float* position, float shift, float& bottomDepth, float& topDepth, const SpriteRleImage& image, SpriteCellQuad& quad, tagRECT& bounds, SpriteColor& color, int offsetX, int offsetY, int flags ) const; + void OffsetLayerDepth(int layer, SpriteCellQuad& quad, float bottomDepth, float topDepth) const; }; #endif diff --git a/Source/Contents/Camera/Camera.h b/Source/Contents/Camera/Camera.h index bdf0271..04f6178 100644 --- a/Source/Contents/Camera/Camera.h +++ b/Source/Contents/Camera/Camera.h @@ -8,6 +8,8 @@ struct WorldScene; +extern float g_cameraDistance; + class CView { public: /* 0000 */ void* vtable; diff --git a/Source/Contents/SpriteLayerDepth.cpp b/Source/Contents/SpriteLayerDepth.cpp new file mode 100644 index 0000000..14a1eb1 --- /dev/null +++ b/Source/Contents/SpriteLayerDepth.cpp @@ -0,0 +1,41 @@ +#include "Contents/Actors/SpriteDrawingPolicy.h" +#include "Contents/Camera/Camera.h" +#include "Render/SpriteGeometry.h" + +constexpr float robeTopLayerThreshold = 320.0f; + +// GLOBAL: gl_24739 +float g_cameraDistance = 300.0f; + +// OFFSET: 0x0080DAA0 +// FUNCTION: fn_10103 +void SpriteDrawingPolicy::OffsetLayerDepth(int layer, SpriteCellQuad& quad, float bottomDepth, float topDepth) const { + switch (layer) { + case 2: + if (g_cameraDistance < robeTopLayerThreshold) { + quad.bottomDepth = bottomDepth + 0.000027f; + quad.topDepth = topDepth + 0.000027f; + } else { + quad.bottomDepth = bottomDepth; + quad.topDepth = topDepth; + } + break; + case 3: + if (g_cameraDistance < robeTopLayerThreshold) { + quad.bottomDepth = bottomDepth + 0.00004f; + quad.topDepth = 0.0001f + topDepth; + } else { + quad.bottomDepth = bottomDepth; + quad.topDepth = 0.000045f + topDepth; + } + break; + case 4: + if (g_cameraDistance < robeTopLayerThreshold) { + bottomDepth += 0.00003f; + topDepth += 0.00003f; + } + quad.bottomDepth = bottomDepth; + quad.topDepth = topDepth; + break; + } +} diff --git a/data/compile.json b/data/compile.json index ee6f112..40e10fb 100644 --- a/data/compile.json +++ b/data/compile.json @@ -428,6 +428,7 @@ "Source/Contents/Sound/SoundMgr.cpp": 4, "Source/Contents/SpriteFrameSynchronization.cpp": 4, "Source/Contents/SpriteJob.cpp": 4, + "Source/Contents/SpriteLayerDepth.cpp": 4, "Source/Contents/SpriteLayerOrder.cpp": 4, "Source/Contents/SpriteRidingPolicy.cpp": 4, "Source/Contents/Store/MCStoreInfoBackup.cpp": 4,