diff options
| author | Sonic Dreamcaster <alejandro.asenjo88@gmail.com> | 2025-05-17 01:48:08 -0300 |
|---|---|---|
| committer | Sonic Dreamcaster <alejandro.asenjo88@gmail.com> | 2025-05-17 01:48:08 -0300 |
| commit | 3f33446669aadcedd622476df1f5c734fda1f9e6 (patch) | |
| tree | 26241ab733f43211bc20e5c7127f9e6f52b2fa93 | |
| parent | 1c5bcd821c828e432779b99e2e3c3e47dbdd2c3d (diff) | |
fix clouds
| -rw-r--r-- | src/update_objects.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/update_objects.c b/src/update_objects.c index 73d0dcfdc..6d2b8a77a 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -40,6 +40,8 @@ #include <assets/boo_frames.h> #include "port/Game.h" +float OTRGetAspectRatio(void); + //! @todo unused? f32 D_800E43B0[] = { 65536.0, 0.0, 1.0, 0.0, 0.0, 65536.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; @@ -2455,20 +2457,28 @@ void update_snowflakes(void) { } void func_800788F8(s32 objectIndex, u16 rot, Camera* camera) { - s16 temp_v0; + s16 cameraRot; + // Adjustable culling factor + const float cullingFactor = OTRGetAspectRatio(); - temp_v0 = camera->rot[1] + rot; - if ((temp_v0 >= D_8018D210) && (D_8018D208 >= temp_v0)) { - gObjectList[objectIndex].unk_09C = (D_8018D218 + (D_8018D1E8 * temp_v0)); - set_object_flag(objectIndex, 0x00000010); - return; - } - if (CVarGetInteger("gNoCulling", 0) == 1) { - gObjectList[objectIndex].unk_09C = (D_8018D218 + (D_8018D1E8 * temp_v0)); - set_object_flag(objectIndex, 0x00000010); - return; + // Calculate object's rotation relative to the camera + cameraRot = camera->rot[1] + rot; + + // Adjust bounds based on the culling factor + s16 adjustedLowerBound = (s16) (D_8018D210 * cullingFactor); + s16 adjustedUpperBound = (s16) (D_8018D208 * cullingFactor); + + // Check if the object is within the adjusted bounds + if ((cameraRot >= adjustedLowerBound) && (adjustedUpperBound >= cameraRot)) { + // Calculate and update the object's position + gObjectList[objectIndex].unk_09C = (D_8018D218 + (D_8018D1E8 * cameraRot)); + + // Mark the object as visible + set_object_flag(objectIndex, 0x10); + } else { + // If outside the bounds, mark the object as not visible + set_object_flag(objectIndex, 0x10); } - clear_object_flag(objectIndex, 0x00000010); } void update_clouds(s32 arg0, Camera* arg1, CloudData* cloudList) { |
