summaryrefslogtreecommitdiff
path: root/src/update_objects.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/update_objects.c')
-rw-r--r--src/update_objects.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/update_objects.c b/src/update_objects.c
index 73d0dcfdc..15541a239 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 };
@@ -2088,8 +2090,6 @@ void init_smoke_particles(s32 arg0) {
}
}
-
-
void init_object_leaf_particle(s32 objectIndex, Vec3f arg1, s32 num) {
UNUSED s32 stackPadding1;
UNUSED u16 stackPadding0;
@@ -2104,19 +2104,19 @@ void init_object_leaf_particle(s32 objectIndex, Vec3f arg1, s32 num) {
gObjectList[objectIndex].sizeScaling = 0.1f;
gObjectList[objectIndex].surfaceHeight = arg1[1];
- if (GetCourse() == GetMarioRaceway()) {
+ if (IsMarioRaceway()) {
object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 25.0, arg1[2], 0x14, 0x1E, 0x14);
gObjectList[objectIndex].unk_034 = 1.5f;
gObjectList[objectIndex].velocity[1] = 1.5f;
- } else if (GetCourse() == GetYoshiValley()) {
+ } else if (IsYoshiValley()) {
object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 25.0, arg1[2], 0x14, 0x1E, 0x14);
gObjectList[objectIndex].unk_034 = 2.0f;
gObjectList[objectIndex].velocity[1] = 2.0f;
- } else if (GetCourse() == GetRoyalRaceway()) {
+ } else if (IsRoyalRaceway()) {
object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 30.0, arg1[2], 0x10, 0x28, 0x10);
gObjectList[objectIndex].unk_034 = 2.0f;
gObjectList[objectIndex].velocity[1] = 2.0f;
- } else if (GetCourse() == GetLuigiRaceway()) {
+ } else if (IsLuigiRaceway()) {
object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 25.0, arg1[2], 0x14, 0x1E, 0x14);
gObjectList[objectIndex].unk_034 = 1.5f;
gObjectList[objectIndex].velocity[1] = 1.0f;
@@ -2454,21 +2454,30 @@ void update_snowflakes(void) {
}
}
+// This function adjusted to place clouds in the sky correctly
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 the cloud'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) {
@@ -2601,7 +2610,6 @@ void func_80078C70(s32 arg0) {
}
}
-
void func_8007ABFC(s32 playerId, bool arg1) {
s32 itemWindow;
@@ -3448,7 +3456,7 @@ void func_8007BB9C(s32 arg0) {
}
void wrapper_update_boos(void) {
- //update_boos();
+ // update_boos();
}
// Updates the display status on an object based on its relative direction to the camera
@@ -3476,7 +3484,6 @@ void func_8007C420(s32 objectIndex, Player* player, Camera* camera) {
func_8007C360(objectIndex, camera);
}
-
void func_8007CE0C(s32 objectIndex) {
Object* object;
@@ -3873,8 +3880,6 @@ void func_800842C8(void) {
}
}
-
-
void func_80085BB4(s32 objectIndex) {
gObjectList[objectIndex].sizeScaling = 8.0f;
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);