From 3d7cdcee8aa324dd62606b37a259cd81c9a5a18d Mon Sep 17 00:00:00 2001 From: MegaMech Date: Wed, 26 Jun 2024 19:22:38 -0600 Subject: [PATCH] Collision Documentation (#640) * Collision related renames --- .../code_80005FD0/func_8000929C.s | 16 +- .../code_80005FD0/func_80009B60.s | 20 +- .../code_80005FD0/kart_ai_use_item_strategy.s | 6 +- enhancements/flycam.patch | 2 +- include/common_structs.h | 58 +- include/defines.h | 13 + include/objects.h | 6 +- include/vehicles.h | 11 + include/waypoints.h | 2 +- src/actors/banana/update.inc.c | 16 +- src/actors/blue_and_red_shells/update.inc.c | 40 +- src/actors/fake_item_box/update.inc.c | 2 +- src/actors/falling_rock/render.inc.c | 12 +- src/actors/falling_rock/update.inc.c | 32 +- src/actors/green_shell/update.inc.c | 30 +- src/actors/kiwano_fruit/update.inc.c | 4 +- src/audio/external.c | 38 +- src/camera.c | 36 +- src/camera.h | 2 +- src/code_800029B0.c | 4 +- src/code_800029B0.h | 4 +- src/code_80005FD0.c | 352 ++-- src/code_80005FD0.h | 8 +- src/code_8003DC40.c | 148 +- src/code_80057C60.c | 112 +- src/code_80057C60.h | 2 +- src/code_8006E9C0.c | 4 +- src/code_80086E70.c | 236 +-- src/code_80091440.c | 3 +- src/code_80091440.h | 2 +- src/effects.c | 16 +- src/main.c | 3 +- src/main.h | 10 +- src/math_util_2.c | 40 +- src/player_controller.c | 325 ++-- src/player_controller.h | 2 +- src/racing/actors.c | 32 +- src/racing/actors_extended.c | 58 +- src/racing/collision.c | 1349 ++++++++------- src/racing/collision.h | 24 +- src/racing/math_util.c | 18 +- src/racing/render_courses.c | 42 +- src/racing/render_courses.h | 2 +- src/render_objects.c | 136 +- src/render_player.c | 20 +- src/spawn_players.c | 102 +- src/update_objects.c | 1450 ++++++++--------- 47 files changed, 2435 insertions(+), 2415 deletions(-) diff --git a/asm/non_matchings/code_80005FD0/func_8000929C.s b/asm/non_matchings/code_80005FD0/func_8000929C.s index 934d47fbf..f31cb788f 100644 --- a/asm/non_matchings/code_80005FD0/func_8000929C.s +++ b/asm/non_matchings/code_80005FD0/func_8000929C.s @@ -38,8 +38,8 @@ glabel func_8000929C /* 009F04 80009304 E7AC004C */ swc1 $f12, 0x4c($sp) /* 009F08 80009308 0C003349 */ jal func_8000CD24 /* 009F0C 8000930C AFB80018 */ sw $t8, 0x18($sp) -/* 009F10 80009310 3C058016 */ lui $a1, %hi(D_80162FCE) # $a1, 0x8016 -/* 009F14 80009314 24A52FCE */ addiu $a1, %lo(D_80162FCE) # addiu $a1, $a1, 0x2fce +/* 009F10 80009310 3C058016 */ lui $a1, %hi(sSomeNearestWaypoint) # $a1, 0x8016 +/* 009F14 80009314 24A52FCE */ addiu $a1, %lo(sSomeNearestWaypoint) # addiu $a1, $a1, 0x2fce /* 009F18 80009318 A4A20000 */ sh $v0, ($a1) /* 009F1C 8000931C 84A70000 */ lh $a3, ($a1) /* 009F20 80009320 8FA80030 */ lw $t0, 0x30($sp) @@ -57,8 +57,8 @@ glabel func_8000929C /* 009F50 80009350 AFA40050 */ sw $a0, 0x50($sp) /* 009F54 80009354 0C0023CE */ jal func_80008F38 /* 009F58 80009358 E7AC004C */ swc1 $f12, 0x4c($sp) -/* 009F5C 8000935C 3C078016 */ lui $a3, %hi(D_80162FCE) # $a3, 0x8016 -/* 009F60 80009360 84E72FCE */ lh $a3, %lo(D_80162FCE)($a3) +/* 009F5C 8000935C 3C078016 */ lui $a3, %hi(sSomeNearestWaypoint) # $a3, 0x8016 +/* 009F60 80009360 84E72FCE */ lh $a3, %lo(sSomeNearestWaypoint)($a3) /* 009F64 80009364 8FA40050 */ lw $a0, 0x50($sp) /* 009F68 80009368 C7AC004C */ lwc1 $f12, 0x4c($sp) .L8000936C: @@ -321,7 +321,7 @@ glabel func_8000929C /* 00A328 80009728 8FAA0054 */ lw $t2, 0x54($sp) .L8000972C: /* 00A32C 8000972C 3C068016 */ lui $a2, %hi(D_80163448) # 0x8016 -/* 00A330 80009730 3C038016 */ lui $v1, %hi(D_80162FCE) # 0x8016 +/* 00A330 80009730 3C038016 */ lui $v1, %hi(sSomeNearestWaypoint) # 0x8016 /* 00A334 80009734 95420000 */ lhu $v0, ($t2) /* 00A338 80009738 304B4000 */ andi $t3, $v0, 0x4000 /* 00A33C 8000973C 11600020 */ beqz $t3, .L800097C0 @@ -335,7 +335,7 @@ glabel func_8000929C /* 00A35C 8000975C 8FA40050 */ lw $a0, 0x50($sp) /* 00A360 80009760 3C068016 */ lui $a2, %hi(D_80163448) # $a2, 0x8016 /* 00A364 80009764 15A00013 */ bnez $t5, .L800097B4 -/* 00A368 80009768 3C038016 */ lui $v1, %hi(D_80162FCE) # $v1, 0x8016 +/* 00A368 80009768 3C038016 */ lui $v1, %hi(sSomeNearestWaypoint) # $v1, 0x8016 /* 00A36C 8000976C 3C0E8019 */ lui $t6, %hi(gPlayerCount) # $t6, 0x8019 /* 00A370 80009770 81CEEDF3 */ lb $t6, %lo(gPlayerCount)($t6) /* 00A374 80009774 24010002 */ li $at, 2 @@ -358,10 +358,10 @@ glabel func_8000929C .L800097B4: /* 00A3B4 800097B4 8CC63448 */ lw $a2, %lo(D_80163448)($a2) /* 00A3B8 800097B8 10000003 */ b .L800097C8 -/* 00A3BC 800097BC 84632FCE */ lh $v1, %lo(D_80162FCE)($v1) +/* 00A3BC 800097BC 84632FCE */ lh $v1, %lo(sSomeNearestWaypoint)($v1) .L800097C0: /* 00A3C0 800097C0 8CC63448 */ lw $a2, %lo(D_80163448)($a2) # 0x3448($a2) -/* 00A3C4 800097C4 84632FCE */ lh $v1, %lo(D_80162FCE)($v1) +/* 00A3C4 800097C4 84632FCE */ lh $v1, %lo(sSomeNearestWaypoint)($v1) .L800097C8: /* 00A3C8 800097C8 0C002E57 */ jal func_8000B95C /* 00A3CC 800097CC 3065FFFF */ andi $a1, $v1, 0xffff diff --git a/asm/non_matchings/code_80005FD0/func_80009B60.s b/asm/non_matchings/code_80005FD0/func_80009B60.s index a33462131..87bb29360 100644 --- a/asm/non_matchings/code_80005FD0/func_80009B60.s +++ b/asm/non_matchings/code_80005FD0/func_80009B60.s @@ -514,8 +514,8 @@ glabel func_80009B60 /* 00AE78 8000A278 1000002C */ b .L8000A32C /* 00AE7C 8000A27C E4700004 */ swc1 $f16, 4($v1) .L8000A280: -/* 00AE80 8000A280 3C0F8016 */ lui $t7, %hi(D_80162FCE) # $t7, 0x8016 -/* 00AE84 8000A284 85EF2FCE */ lh $t7, %lo(D_80162FCE)($t7) +/* 00AE80 8000A280 3C0F8016 */ lui $t7, %hi(sSomeNearestWaypoint) # $t7, 0x8016 +/* 00AE84 8000A284 85EF2FCE */ lh $t7, %lo(sSomeNearestWaypoint)($t7) /* 00AE88 8000A288 3C0B8016 */ lui $t3, %hi(D_801645E0) # $t3, 0x8016 /* 00AE8C 8000A28C 8D6B45E0 */ lw $t3, %lo(D_801645E0)($t3) /* 00AE90 8000A290 000F7040 */ sll $t6, $t7, 1 @@ -560,7 +560,7 @@ glabel func_80009B60 /* 00AF28 8000A328 E5040000 */ swc1 $f4, ($t0) .L8000A32C: /* 00AF2C 8000A32C 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00AF30 8000A330 0C004C77 */ jal func_800131DC +/* 00AF30 8000A330 0C004C77 */ jal check_ai_crossing_distance /* 00AF34 8000A334 AFA8003C */ sw $t0, 0x3c($sp) /* 00AF38 8000A338 0C0034EE */ jal func_8000D3B8 /* 00AF3C 8000A33C 8FA400D0 */ lw $a0, 0xd0($sp) @@ -726,8 +726,8 @@ glabel func_80009B60 /* 00B18C 8000A58C 0002C823 */ negu $t9, $v0 /* 00B190 8000A590 01981821 */ addu $v1, $t4, $t8 /* 00B194 8000A594 A4790000 */ sh $t9, ($v1) -/* 00B198 8000A598 3C0F8016 */ lui $t7, %hi(D_80162FCE) # $t7, 0x8016 -/* 00B19C 8000A59C 85EF2FCE */ lh $t7, %lo(D_80162FCE)($t7) +/* 00B198 8000A598 3C0F8016 */ lui $t7, %hi(sSomeNearestWaypoint) # $t7, 0x8016 +/* 00B19C 8000A59C 85EF2FCE */ lh $t7, %lo(sSomeNearestWaypoint)($t7) /* 00B1A0 8000A5A0 3C0D8016 */ lui $t5, %hi(D_80164430) # $t5, 0x8016 /* 00B1A4 8000A5A4 95AD4430 */ lhu $t5, %lo(D_80164430)($t5) /* 00B1A8 8000A5A8 25EA0002 */ addiu $t2, $t7, 2 @@ -893,18 +893,18 @@ glabel func_80009B60 /* 00B3E8 8000A7E8 10000252 */ b .L8000B134 /* 00B3EC 8000A7EC 8FBF0014 */ lw $ra, 0x14($sp) .L8000A7F0: -/* 00B3F0 8000A7F0 3C058016 */ lui $a1, %hi(D_80162FCE) # $a1, 0x8016 +/* 00B3F0 8000A7F0 3C058016 */ lui $a1, %hi(sSomeNearestWaypoint) # $a1, 0x8016 /* 00B3F4 8000A7F4 254D0014 */ addiu $t5, $t2, 0x14 /* 00B3F8 8000A7F8 AFAD001C */ sw $t5, 0x1c($sp) /* 00B3FC 8000A7FC 0C002DF9 */ jal func_8000B7E4 -/* 00B400 8000A800 94A52FCE */ lhu $a1, %lo(D_80162FCE)($a1) +/* 00B400 8000A800 94A52FCE */ lhu $a1, %lo(sSomeNearestWaypoint)($a1) /* 00B404 8000A804 8FAF0038 */ lw $t7, 0x38($sp) /* 00B408 8000A808 3C0B8016 */ lui $t3, %hi(D_801630B8) # $t3, 0x8016 /* 00B40C 8000A80C 256B30B8 */ addiu $t3, %lo(D_801630B8) # addiu $t3, $t3, 0x30b8 /* 00B410 8000A810 01EB1821 */ addu $v1, $t7, $t3 /* 00B414 8000A814 AC620000 */ sw $v0, ($v1) -/* 00B418 8000A818 3C058016 */ lui $a1, %hi(D_80162FCE) # $a1, 0x8016 -/* 00B41C 8000A81C 94A52FCE */ lhu $a1, %lo(D_80162FCE)($a1) +/* 00B418 8000A818 3C058016 */ lui $a1, %hi(sSomeNearestWaypoint) # $a1, 0x8016 +/* 00B41C 8000A81C 94A52FCE */ lhu $a1, %lo(sSomeNearestWaypoint)($a1) /* 00B420 8000A820 AFA30028 */ sw $v1, 0x28($sp) /* 00B424 8000A824 0C00350E */ jal func_8000D438 /* 00B428 8000A828 8FA400D0 */ lw $a0, 0xd0($sp) @@ -1520,7 +1520,7 @@ glabel func_80009B60 /* 00BD08 8000B108 3C018016 */ lui $at, %hi(D_80163210) /* 00BD0C 8000B10C 002F0821 */ addu $at, $at, $t7 /* 00BD10 8000B110 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00BD14 8000B114 0C004C77 */ jal func_800131DC +/* 00BD14 8000B114 0C004C77 */ jal check_ai_crossing_distance /* 00BD18 8000B118 E4303210 */ swc1 $f16, %lo(D_80163210)($at) /* 00BD1C 8000B11C 3C058016 */ lui $a1, %hi(D_8016320C) # $a1, 0x8016 /* 00BD20 8000B120 8CA5320C */ lw $a1, %lo(D_8016320C)($a1) diff --git a/asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s b/asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s index e3eec8992..7a18f71db 100644 --- a/asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s +++ b/asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s @@ -330,7 +330,7 @@ glabel L8001AFD8 /* 01BC94 8001B094 46283280 */ add.d $f10, $f6, $f8 /* 01BC98 8001B098 8D86001C */ lw $a2, 0x1c($t4) /* 01BC9C 8001B09C AFA70028 */ sw $a3, 0x28($sp) -/* 01BCA0 8001B0A0 0C0AB870 */ jal func_802AE1C0 +/* 01BCA0 8001B0A0 0C0AB870 */ jal spawn_actor_on_surface /* 01BCA4 8001B0A4 462053A0 */ cvt.s.d $f14, $f10 /* 01BCA8 8001B0A8 8FA70028 */ lw $a3, 0x28($sp) /* 01BCAC 8001B0AC 3C013F80 */ li $at, 0x3F800000 # 1.000000 @@ -582,7 +582,7 @@ glabel L8001B3B4 /* 01C054 8001B454 E4E00028 */ swc1 $f0, 0x28($a3) /* 01C058 8001B458 E4E0002C */ swc1 $f0, 0x2c($a3) /* 01C05C 8001B45C AFA70028 */ sw $a3, 0x28($sp) -/* 01C060 8001B460 0C0AB870 */ jal func_802AE1C0 +/* 01C060 8001B460 0C0AB870 */ jal spawn_actor_on_surface /* 01C064 8001B464 462033A0 */ cvt.s.d $f14, $f6 /* 01C068 8001B468 8FA70028 */ lw $a3, 0x28($sp) /* 01C06C 8001B46C 3C013F80 */ li $at, 0x3F800000 # 1.000000 @@ -1122,7 +1122,7 @@ glabel L8001BB30 /* 01C7F4 8001BBF4 46249180 */ add.d $f6, $f18, $f4 /* 01C7F8 8001BBF8 8CE60020 */ lw $a2, 0x20($a3) /* 01C7FC 8001BBFC AFA70028 */ sw $a3, 0x28($sp) -/* 01C800 8001BC00 0C0AB870 */ jal func_802AE1C0 +/* 01C800 8001BC00 0C0AB870 */ jal spawn_actor_on_surface /* 01C804 8001BC04 462033A0 */ cvt.s.d $f14, $f6 /* 01C808 8001BC08 8FA70028 */ lw $a3, 0x28($sp) /* 01C80C 8001BC0C C4E8000C */ lwc1 $f8, 0xc($a3) diff --git a/enhancements/flycam.patch b/enhancements/flycam.patch index 8efaae248..50981012a 100644 --- a/enhancements/flycam.patch +++ b/enhancements/flycam.patch @@ -365,7 +365,7 @@ index 0000000..5569838 + f32 pitchChange = controller->rawStickY * SENSITIVITY_Y; + Vec3f forwardVector; + -+ func_802ADDC8(&camera->unk_54, 50, camera->pos[0], camera->pos[1], camera->pos[2]); ++ check_bounding_collision(&camera->collision, 50, camera->pos[0], camera->pos[1], camera->pos[2]); + + camera->rot[1] += (short)(yawChange * 65535.0f / (2 * M_PI)); // Convert radians to 0-65535 range + diff --git a/include/common_structs.h b/include/common_structs.h index ecf0287d1..616889954 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -139,11 +139,11 @@ typedef struct { /* 0x00 */ u16 unk30; /* 0x02 */ u16 unk32; /* 0x04 */ u16 unk34; - /* 0x06 */ u16 unk36; - /* 0x08 */ u16 unk38; + /* 0x06 */ u16 meshIndexYX; + /* 0x08 */ u16 meshIndexZY; // This may be an index to the tilemap? - /* 0x0A */ u16 unk3A; - /* 0x0C */ Vec3f unk3C; + /* 0x0A */ u16 meshIndexZX; + /* 0x0C */ Vec3f surfaceDistance; // Appears to be distance from actor to surface for zx, yx, and zy planes. /* 0x18 */ Vec3f unk48; /* 0x24 */ Vec3f unk54; /* 0x30 */ Vec3f orientationVector; @@ -185,7 +185,6 @@ typedef struct { s16 ob[3]; /* x, y, z */ s16 tc[2]; /* texture coord */ s8 ca[4]; /* color & alpha */ - } CourseVtx; /* @@ -214,44 +213,29 @@ typedef struct { /* 0x10 */ Vtx *vtx1; //pointer to the 3 vertices of this poly Vtx *vtx2; Vtx *vtx3; - //unsure why this exists along with a copy of two of the vertices. - //both are involved in hit detection. - /* 0x1C */ f32 height; - //normally 0; read at 0x802AB1A4. this value is added to the height Lakitu - //drops you at. changing it seems to make the surface intangible. - /* 0x20 */ f32 gravity; - //normally 1. The height Lakitu drops you off at is divided by this value - //(before adding the value at 0x1C), although if set to zero, he just tries - //to drop you at about the height of the finish line banner. Changing it - //has various unusual effects, making the polygon intangible or - //significantly reducing the gravity above it, probably depending on its Y - //position. - /* 0x24 */ f32 rotation; //normally about -0.001. no idea what this actually is. - /* 0x28 */ f32 height2; //changes Y position of all vertices (but not graphics or - //Lakitu drop position). Normally set to (track_height * -1) + about 6. + // Face normal. Should really be Vec3f normal + /* 0x1C */ f32 normalX; + /* 0x20 */ f32 normalY; + /* 0x24 */ f32 normalZ; + /* 0x28 */ f32 distance; } CollisionTriangle; // size = 0x2C typedef struct { - /* 0x00 */ Vec3f cornerPos; - // Type of surface the corner is above - /* 0x0C */ u8 surfaceType; - // Close to being a copy of the top byte of the CollisionTriangle "flags" member + /* 0x00 */ Vec3f pos; + /* 0x0C */ u8 surfaceType; // Surface type that the tyre is touching. /* 0x0D */ u8 surfaceFlags; - // Don't know if "tile" is right the right term - // gCollisionMesh is a pointer to an array of "tile" structs. This is an index to that array - /* 0x0E */ u16 collisionMeshIndex; - // cornerPos places the corner "in the air" as it were, this member indicates the Y position of the corner's "on the ground" sibling - // On flat ground this value should be cornerY - gKartBoundingBoxTable[characterId] - /* 0x10 */ f32 cornerGroundY; + /* 0x0E */ u16 collisionMeshIndex; // Index into gCollisionMesh + // Height of tyre attached to ground. When flying it floats with the kart. + /* 0x10 */ f32 baseHeight; // Something lighting related. 1 when in a shaded region, 2 when in a tree's shadow // 3 when getting crushed by a whomp, but curiously only the front left tyre will ever have this value /* 0x14 */ s32 unk_14; -} KartBoundingBoxCorner; // size = 0x18 +} KartTyre; // size = 0x18 -#define FRONT_LEFT_TYRE 0 -#define FRONT_RIGHT_TYRE 1 -#define BACK_LEFT_TYRE 2 -#define BACK_RIGHT_TYRE 3 +#define FRONT_LEFT 0 +#define FRONT_RIGHT 1 +#define BACK_LEFT 2 +#define BACK_RIGHT 3 struct UnkPlayerInner { /* 0xDB4 */ s16 unk0; @@ -345,10 +329,10 @@ typedef struct { /* 0x0108 */ f32 unk_108; /* 0x010C */ s16 unk_10C; /* 0x010E */ char unk_10E[0x2]; - /* 0x0110 */ Collision unk_110; + /* 0x0110 */ Collision collision; /* 0x0150 */ Mat3 unk_150; /* 0x0174 */ Mat3 orientationMatrix; - /* 0x0198 */ KartBoundingBoxCorner boundingBoxCorners[4]; + /* 0x0198 */ KartTyre tyres[4]; /* 0x01F8 */ f32 unk_1F8; /* 0x01FC */ f32 unk_1FC; /* 0x0200 */ u32 unk_200; // May be s32. but less casting required if u32 diff --git a/include/defines.h b/include/defines.h index c575ffb85..f62a07186 100644 --- a/include/defines.h +++ b/include/defines.h @@ -384,3 +384,16 @@ enum KART_AI_BEHAVIOURS { #define COLOR_BLACK GPACK_RGB888(0, 0, 0) #endif // DEFINES_H + + +/** + * + * Collision mesh flags + * +*/ + +#define GRID_SIZE 32 + +#define FACING_Y_AXIS 0x4000 +#define FACING_X_AXIS 0x8000 +#define FACING_Z_AXIS 0x2000 diff --git a/include/objects.h b/include/objects.h index 86fc2af02..91e5f4cb5 100644 --- a/include/objects.h +++ b/include/objects.h @@ -16,7 +16,7 @@ typedef struct /* 0x28 */ Vec3f offset; /* 0x34 */ f32 unk_034; /* 0x38 */ Vec3f velocity; // acceleration - /* 0x44 */ f32 unk_044; + /* 0x44 */ f32 surfaceHeight; /* 0x48 */ s32 unk_048; /* 0x4C */ s32 unk_04C; /* 0x50 */ s32 unk_050; @@ -79,9 +79,9 @@ typedef struct /* 0xDD */ u8 unk_0DD; /* 0xDE */ s8 unk_0DE; /* 0xDF */ u8 unk_0DF; -} Objects; // size = 0xE0 +} Object; // size = 0xE0 -extern Objects gObjectList[]; +extern Object gObjectList[]; typedef struct { diff --git a/include/vehicles.h b/include/vehicles.h index ff1fa3b35..17e80587e 100644 --- a/include/vehicles.h +++ b/include/vehicles.h @@ -10,6 +10,11 @@ #define NUM_TRAINS 2 #define LOCOMOTIVE_ONLY 0 +#define NUM_CROSSINGS 2 +// This allows karts to jump the train despite the crossing being activated. +// but still stop for the train once it's close +#define FRAMES_SINCE_CROSSING_ACTIVATED 240 + // It seems like there's room for 2 Ferries, but only 1 is ever active #define NUM_ACTIVE_PADDLE_BOATS 1 #define NUM_PADDLE_BOATS 2 @@ -24,6 +29,12 @@ #define NUM_TIME_TRIAL_TANKER_TRUCKS (NUM_RACE_TANKER_TRUCKS + 1) #define NUM_TIME_TRIAL_CARS (NUM_RACE_CARS + 1) +#define TRAIN_SMOKE_RENDER_DISTANCE 2000.0f +#define TRAIN_CROSSING_AI_DISTANCE 1000.0f +#define BOAT_SMOKE_RENDER_DISTANCE 2000.0f + +#define RENDER_VEHICLE 1 + typedef struct { /* 0x00 */ s16 isActive; // Only used for Tender and Passenger Cars, unused for Locomotives /* 0x02 */ s16 compilerPadding; diff --git a/include/waypoints.h b/include/waypoints.h index 7334a49c7..bc5ef3237 100644 --- a/include/waypoints.h +++ b/include/waypoints.h @@ -38,7 +38,7 @@ extern s16 *D_801645A0[]; * a given player is on, the specific value may change **/ // Shadows values from gNearestWaypointByPlayerId -extern s16 D_80162FCE; +extern s16 sSomeNearestWaypoint; // Shadows values from gPathIndexByPlayerId extern s32 D_80163448; // Shadows values from D_80164560 diff --git a/src/actors/banana/update.inc.c b/src/actors/banana/update.inc.c index bdede3011..9d31b1166 100644 --- a/src/actors/banana/update.inc.c +++ b/src/actors/banana/update.inc.c @@ -47,7 +47,7 @@ void update_actor_banana(struct BananaActor *banana) { banana->pos[1] = player->pos[1] - temp_f14 - 2.0f; banana->pos[2] = player->pos[2] - temp_f16; } - func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]); + check_bounding_collision(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]); func_802B4E30((struct Actor *) banana); if ((player->type & PLAYER_HUMAN) != 0) { if (gDemoMode) { @@ -99,15 +99,15 @@ void update_actor_banana(struct BananaActor *banana) { if ((banana->pos[2] < (f32) gCourseMinZ) || ((f32) gCourseMaxZ < banana->pos[2]) || (banana->pos[0] < (f32) gCourseMinX) || ((f32) gCourseMaxX < banana->pos[0]) || (banana->pos[1] < (f32) gCourseMinY)) { destroy_destructable_actor((struct Actor *) banana); } else { - func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]); + check_bounding_collision(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]); banana->unk30.unk34 = 1; - if ((banana->unk30.unk34 != 0) && (banana->unk30.unk3C[2] < 0.0f)) { + if ((banana->unk30.unk34 != 0) && (banana->unk30.surfaceDistance[2] < 0.0f)) { someOtherVelocity[0] = -banana->unk30.orientationVector[0]; someOtherVelocity[1] = -banana->unk30.orientationVector[1]; someOtherVelocity[2] = -banana->unk30.orientationVector[2]; - banana->pos[0] += someOtherVelocity[0] * banana->unk30.unk3C[2]; - banana->pos[1] += someOtherVelocity[1] * banana->unk30.unk3C[2]; - banana->pos[2] += someOtherVelocity[2] * banana->unk30.unk3C[2]; + banana->pos[0] += someOtherVelocity[0] * banana->unk30.surfaceDistance[2]; + banana->pos[1] += someOtherVelocity[1] * banana->unk30.surfaceDistance[2]; + banana->pos[2] += someOtherVelocity[2] * banana->unk30.surfaceDistance[2]; banana->flags &= ~0x1000; banana->state = 4; } @@ -137,7 +137,7 @@ void update_actor_banana(struct BananaActor *banana) { banana->pos[1] = unkY - temp_f14 - 2.0f; banana->pos[2] = unkZ - temp_f16; } - func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]); + check_bounding_collision(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]); func_802B4E30((struct Actor *) banana); break; case BANANA_BUNCH_BANANA: @@ -159,7 +159,7 @@ void update_actor_banana(struct BananaActor *banana) { banana->pos[2] = elderBanana->pos[2] - temp_f16; } var_f8 = banana->pos[2]; - func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]); + check_bounding_collision(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]); func_802B4E30((struct Actor *) banana); break; case DESTROYED_BANANA: diff --git a/src/actors/blue_and_red_shells/update.inc.c b/src/actors/blue_and_red_shells/update.inc.c index 37a3ad226..81bec3241 100644 --- a/src/actors/blue_and_red_shells/update.inc.c +++ b/src/actors/blue_and_red_shells/update.inc.c @@ -85,7 +85,7 @@ void func_802B3B44(struct ShellActor *shell) { shell->pos[0] += temp_f12_3; shell->pos[1] += temp_f14_2; shell->pos[2] += temp_f16_2; - func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], origPos[0], origPos[1], origPos[2]); + actor_terrain_collision(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], origPos[0], origPos[1], origPos[2]); func_802B4E30((struct Actor *) shell); } } else { @@ -142,7 +142,7 @@ void func_802B3E7C(struct ShellActor *shell, Player *player) { if (player->effects & BOO_EFFECT) { destroy_destructable_actor((struct Actor *) shell); } else { - func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], newPosition[0], newPosition[1], newPosition[2]); + actor_terrain_collision(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], newPosition[0], newPosition[1], newPosition[2]); func_802B4E30((struct Actor *) shell); func_802B4104(shell); } @@ -177,11 +177,11 @@ s16 func_802B3FD0(Player *owner, struct ShellActor *shell) { } void func_802B4104(struct ShellActor *shell) { - if ((shell->unk30.unk3C[0] < 0.0f) && ((shell->unk30.unk48[1] < 0.25f) || (shell->unk30.unk48[1] > -0.25f))) { + if ((shell->unk30.surfaceDistance[0] < 0.0f) && ((shell->unk30.unk48[1] < 0.25f) || (shell->unk30.unk48[1] > -0.25f))) { destroy_destructable_actor((struct Actor *) shell); func_800C98B8(shell->pos, shell->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x54)); shell->flags |= 0x80; - } else if ((shell->unk30.unk3C[1] < 0.0f) && ((shell->unk30.unk54[1] < 0.25f) || (shell->unk30.unk54[1] < -0.25f))) { + } else if ((shell->unk30.surfaceDistance[1] < 0.0f) && ((shell->unk30.unk54[1] < 0.25f) || (shell->unk30.unk54[1] < -0.25f))) { destroy_destructable_actor((struct Actor *) shell); func_800C98B8(shell->pos, shell->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x54)); shell->flags |= 0x80; @@ -196,7 +196,7 @@ void func_802B4104(struct ShellActor *shell) { void update_actor_red_blue_shell(struct ShellActor *shell) { UNUSED f32 pad9; Player *player; - f32 temp_f0; + f32 height; UNUSED f32 temp_f14; f32 temp_f2; s16 temp_v0; @@ -235,7 +235,7 @@ void update_actor_red_blue_shell(struct ShellActor *shell) { switch (shell->state) { case HELD_SHELL: player = &gPlayers[shell->playerId]; - copy_collision(&player->unk_110, &shell->unk30); + copy_collision(&player->collision, &shell->unk30); somePosVel[0] = 0.0f; somePosVel[1] = player->boundingBoxSize; somePosVel[2] = -(player->boundingBoxSize + shell->boundingBoxSize + 2.0f); @@ -243,11 +243,11 @@ void update_actor_red_blue_shell(struct ShellActor *shell) { shell->pos[0] = player->pos[0] + somePosVel[0]; pad7 = player->pos[1] - somePosVel[1]; shell->pos[2] = player->pos[2] + somePosVel[2]; - temp_f0 = func_802ABE30(shell->pos[0], pad7, shell->pos[2], player->unk_110.unk3A); - temp_f2 = pad7 - temp_f0; + height = calculate_surface_height(shell->pos[0], pad7, shell->pos[2], player->collision.meshIndexZX); + temp_f2 = pad7 - height; if ((temp_f2 < 5.0f) && (temp_f2 > -5.0f)) { - shell->pos[1] = shell->boundingBoxSize + temp_f0; + shell->pos[1] = shell->boundingBoxSize + height; } else { shell->pos[1] = pad7; } @@ -303,13 +303,13 @@ void update_actor_red_blue_shell(struct ShellActor *shell) { } if (shell->state == MOVING_SHELL) { shell->someTimer = 0x001E; - temp_f0 = 8.0f; + height = 8.0f; if (player->unk_094 > 8.0f) { - temp_f0 = player->unk_094 * 1.2f; + height = player->unk_094 * 1.2f; } somePosVel[0] = 0.0f; somePosVel[1] = 0.0f; - somePosVel[2] = temp_f0; + somePosVel[2] = height; func_802B64C4(somePosVel, (s16) (player->rotation[1] + player->unk_0C0)); shell->velocity[0] = somePosVel[0]; shell->velocity[1] = somePosVel[1]; @@ -385,7 +385,7 @@ void update_actor_red_blue_shell(struct ShellActor *shell) { shell->pos[0] += shell->velocity[0]; shell->pos[1] += shell->velocity[1]; shell->pos[2] += shell->velocity[2]; - func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], origPos[0], origPos[1], origPos[2]); + actor_terrain_collision(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], origPos[0], origPos[1], origPos[2]); func_802B4E30((struct Actor *) shell); func_802B4104(shell); break; @@ -405,11 +405,11 @@ void update_actor_red_blue_shell(struct ShellActor *shell) { case GREEN_SHELL_HIT_A_RACER: func_802B3B44(shell); player = &gPlayers[shell->targetPlayer]; - temp_f0 = player->pos[0]; - temp_f0 -= shell->pos[0]; + height = player->pos[0]; + height -= shell->pos[0]; temp_f2 = player->pos[2]; temp_f2 -= shell->pos[2]; - if (((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) < 40000.0f) { + if (((height * height) + (temp_f2 * temp_f2)) < 40000.0f) { shell->state = RED_SHELL_LOCK_ON; } break; @@ -430,7 +430,7 @@ void update_actor_red_blue_shell(struct ShellActor *shell) { shell->pos[0] = player->pos[0] + somePosVel[0]; shell->pos[1] = player->pos[1] + somePosVel[1]; shell->pos[2] = player->pos[2] + somePosVel[2]; - func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], origPos[0], origPos[1], origPos[2]); + actor_terrain_collision(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], origPos[0], origPos[1], origPos[2]); func_802B4E30((struct Actor *) shell); } break; @@ -450,11 +450,11 @@ void update_actor_red_blue_shell(struct ShellActor *shell) { func_802B3B44(shell); shell->targetPlayer = gPlayerPositionLUT[0]; player = &gPlayers[gPlayerPositionLUT[0]]; - temp_f0 = player->pos[0]; - temp_f0 -= shell->pos[0]; + height = player->pos[0]; + height -= shell->pos[0]; temp_f2 = player->pos[2]; temp_f2 -= shell->pos[2]; - if (((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) < 40000.0f) { + if (((height * height) + (temp_f2 * temp_f2)) < 40000.0f) { shell->state = BLUE_SHELL_TARGET_ELIMINATED; } break; diff --git a/src/actors/fake_item_box/update.inc.c b/src/actors/fake_item_box/update.inc.c index ad546120a..364992d9c 100644 --- a/src/actors/fake_item_box/update.inc.c +++ b/src/actors/fake_item_box/update.inc.c @@ -36,7 +36,7 @@ void update_actor_fake_item_box(struct FakeItemBox *fake_item_box) { fake_item_box->pos[0] = temp_v0_4->pos[0] - temp_f14; fake_item_box->pos[1] = (temp_v0_4->pos[1] - temp_f16) - 1.0f; fake_item_box->pos[2] = temp_v0_4->pos[2] - temp_f18; - func_802ADDC8(&fake_item_box->unk30, fake_item_box->boundingBoxSize, fake_item_box->pos[0], fake_item_box->pos[1], fake_item_box->pos[2]); + check_bounding_collision(&fake_item_box->unk30, fake_item_box->boundingBoxSize, fake_item_box->pos[0], fake_item_box->pos[1], fake_item_box->pos[2]); func_802B4E30((struct Actor *)fake_item_box); temp_v1_3 = &gControllers[temp_v1]; if ((temp_v0_4->type & 0x4000) != 0) { diff --git a/src/actors/falling_rock/render.inc.c b/src/actors/falling_rock/render.inc.c index 70854943b..66c4570df 100644 --- a/src/actors/falling_rock/render.inc.c +++ b/src/actors/falling_rock/render.inc.c @@ -13,25 +13,25 @@ void render_actor_falling_rock(Camera *camera, struct FallingRock *rock) { Vec3s sp98; Vec3f sp8C; Mat4 sp4C; - f32 temp_f0; + f32 height; UNUSED s32 pad[4]; if (rock->respawnTimer != 0) { return; } - temp_f0 = is_within_render_distance(camera->pos, rock->pos, camera->rot[1], 400.0f, gCameraZoom[camera - camera1], 4000000.0f); + height = is_within_render_distance(camera->pos, rock->pos, camera->rot[1], 400.0f, gCameraZoom[camera - camera1], 4000000.0f); - if (temp_f0 < 0.0f) { return; } + if (height < 0.0f) { return; } - if (temp_f0 < 250000.0f) { + if (height < 250000.0f) { if (rock->unk30.unk34 == 1) { sp8C[0] = rock->pos[0]; sp8C[2] = rock->pos[2]; - temp_f0 = func_802ABE30(sp8C[0], rock->pos[1], sp8C[2], rock->unk30.unk3A); + height = calculate_surface_height(sp8C[0], rock->pos[1], sp8C[2], rock->unk30.meshIndexZX); sp98[0] = 0; sp98[1] = 0; sp98[2] = 0; - sp8C[1] = temp_f0 + 2.0f; + sp8C[1] = height + 2.0f; mtxf_pos_rotation_xyz(sp4C, sp8C, sp98); if (render_set_position(sp4C, 0) == 0) { return; diff --git a/src/actors/falling_rock/update.inc.c b/src/actors/falling_rock/update.inc.c index b10a9b26f..d79ddc5b9 100644 --- a/src/actors/falling_rock/update.inc.c +++ b/src/actors/falling_rock/update.inc.c @@ -77,20 +77,20 @@ void update_actor_falling_rocks(struct FallingRock *rock) { rock->pos[1] += rock->velocity[1]; rock->pos[2] += rock->velocity[2]; pad1 = rock->velocity[1]; - func_802ADDC8(&rock->unk30, 10.0f, rock->pos[0], rock->pos[1], rock->pos[2]); - pad0 = rock->unk30.unk3C[2]; + check_bounding_collision(&rock->unk30, 10.0f, rock->pos[0], rock->pos[1], rock->pos[2]); + pad0 = rock->unk30.surfaceDistance[2]; if (pad0 < 0.0f) { unkVec[0] = -rock->unk30.orientationVector[0]; unkVec[1] = -rock->unk30.orientationVector[1]; unkVec[2] = -rock->unk30.orientationVector[2]; - rock->pos[0] += unkVec[0] * rock->unk30.unk3C[2]; - rock->pos[1] += unkVec[1] * rock->unk30.unk3C[2]; - rock->pos[2] += unkVec[2] * rock->unk30.unk3C[2]; - func_802AC114(unkVec, pad0, rock->velocity, 2.0f); + rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[2]; + rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[2]; + rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[2]; + adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f); rock->velocity[1] = -1.2f * pad1; func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F)); } - pad0 = rock->unk30.unk3C[0]; + pad0 = rock->unk30.surfaceDistance[0]; if (pad0 < 0.0f) { unkVec[1] = -rock->unk30.unk48[1]; if (unkVec[1] == 0.0f) { @@ -100,15 +100,15 @@ void update_actor_falling_rocks(struct FallingRock *rock) { else { unkVec[0] = -rock->unk30.unk48[0]; unkVec[2] = -rock->unk30.unk48[2]; - rock->pos[0] += unkVec[0] * rock->unk30.unk3C[0]; - rock->pos[1] += unkVec[1] * rock->unk30.unk3C[0]; - rock->pos[2] += unkVec[2] * rock->unk30.unk3C[0]; - func_802AC114(unkVec, pad0, rock->velocity, 2.0f); + rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[0]; + rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[0]; + rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[0]; + adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f); rock->velocity[1] = -1.2f * pad1; func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F)); } } - pad0 = rock->unk30.unk3C[1]; + pad0 = rock->unk30.surfaceDistance[1]; if (pad0 < 0.0f) { unkVec[1] = -rock->unk30.unk54[1]; if (unkVec[1] == 0.0f) { @@ -117,11 +117,11 @@ void update_actor_falling_rocks(struct FallingRock *rock) { else { unkVec[0] = -rock->unk30.unk54[0]; unkVec[2] = -rock->unk30.unk54[2]; - rock->pos[0] += unkVec[0] * rock->unk30.unk3C[1]; - rock->pos[1] += unkVec[1] * rock->unk30.unk3C[1]; - rock->pos[2] += unkVec[2] * rock->unk30.unk3C[1]; + rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[1]; + rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[1]; + rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[1]; pad1 = rock->velocity[1]; - func_802AC114(unkVec, pad0, rock->velocity, 2.0f); + adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f); rock->velocity[1] = -1.2f * pad1; func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F)); } diff --git a/src/actors/green_shell/update.inc.c b/src/actors/green_shell/update.inc.c index cae0c9470..36ee94505 100644 --- a/src/actors/green_shell/update.inc.c +++ b/src/actors/green_shell/update.inc.c @@ -18,27 +18,27 @@ void update_actor_green_shell(struct ShellActor *shell) { f32 var_f2; struct Controller *controller; TripleShellParent *parent; - UNUSED f32 pad0; - UNUSED f32 pad1; + f32 height; + f32 z; UNUSED f32 pad2; UNUSED f32 pad3; UNUSED f32 pad4; UNUSED f32 pad5; - UNUSED f32 pad6; + f32 y; UNUSED f32 pad7; UNUSED f32 pad8; - pad0 = shell->pos[0]; - pad6 = shell->pos[1]; - pad1 = shell->pos[2]; - if ((pad1 < gCourseMinZ) || (gCourseMaxZ < pad1) || (pad0 < gCourseMinX) || (gCourseMaxX < pad0) || (pad6 < gCourseMinY)) { + height = shell->pos[0]; + y = shell->pos[1]; + z = shell->pos[2]; + if ((z < gCourseMinZ) || (gCourseMaxZ < z) || (height < gCourseMinX) || (gCourseMaxX < height) || (y < gCourseMinY)) { destroy_destructable_actor((struct Actor *) shell); } shell->rotVelocity += 0x71C; switch (shell->state) { case HELD_SHELL: player = &gPlayers[shell->playerId]; - copy_collision(&player->unk_110, &shell->unk30); + copy_collision(&player->collision, &shell->unk30); somePosVel[0] = 0.0f; somePosVel[1] = player->boundingBoxSize; somePosVel[2] = -(player->boundingBoxSize + shell->boundingBoxSize + 2.0f); @@ -46,10 +46,10 @@ void update_actor_green_shell(struct ShellActor *shell) { shell->pos[0] = player->pos[0] + somePosVel[0]; pad2 = player->pos[1] - somePosVel[1]; shell->pos[2] = player->pos[2] + somePosVel[2]; - pad0 = func_802ABE30(shell->pos[0], pad2, shell->pos[2], player->unk_110.unk3A); - pad1 = pad2 - pad0; - if ((pad1 < 5.0f) && (pad1 > -5.0f)) { - shell->pos[1] = shell->boundingBoxSize + pad0; + height = calculate_surface_height(shell->pos[0], pad2, shell->pos[2], player->collision.meshIndexZX); + z = pad2 - height; + if ((z < 5.0f) && (z > -5.0f)) { + shell->pos[1] = shell->boundingBoxSize + height; } else { shell->pos[1] = pad2; } @@ -145,9 +145,9 @@ void update_actor_green_shell(struct ShellActor *shell) { shell->pos[0] += shell->velocity[0]; shell->pos[1] += shell->velocity[1]; shell->pos[2] += shell->velocity[2]; - func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], somePos2[0], somePos2[1], somePos2[2]); + actor_terrain_collision(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], somePos2[0], somePos2[1], somePos2[2]); func_802B4E30((struct Actor *) shell); - if ((shell->unk30.unk3C[0] < 0.0f) || (shell->unk30.unk3C[1] < 0.0f)) { + if ((shell->unk30.surfaceDistance[0] < 0.0f) || (shell->unk30.surfaceDistance[1] < 0.0f)) { shell_collision(&shell->unk30, shell->velocity); func_800C98B8(shell->pos, shell->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x54)); shell->flags |= 0x80; @@ -170,7 +170,7 @@ void update_actor_green_shell(struct ShellActor *shell) { shell->pos[0] = player->pos[0] + somePosVel[0]; shell->pos[1] = player->pos[1] + somePosVel[1]; shell->pos[2] = player->pos[2] + somePosVel[2]; - func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], somePos2[0], somePos2[1], somePos2[2]); + actor_terrain_collision(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], somePos2[0], somePos2[1], somePos2[2]); func_802B4E30((struct Actor *) shell); } break; diff --git a/src/actors/kiwano_fruit/update.inc.c b/src/actors/kiwano_fruit/update.inc.c index dd1ba9b31..ed2892b2a 100644 --- a/src/actors/kiwano_fruit/update.inc.c +++ b/src/actors/kiwano_fruit/update.inc.c @@ -18,13 +18,13 @@ void update_actor_kiwano_fruit(struct KiwanoFruit *fruit) { s32 nearestWaypoint; player = &gPlayers[fruit->targetPlayer]; - if (((player->type & PLAYER_KART_AI) != 0) || (player->unk_110.unk34 == 0)) { + if (((player->type & PLAYER_KART_AI) != 0) || (player->collision.unk34 == 0)) { fruit->state = 0; return; } switch (fruit->state) { /* irregular */ case 0: - if ((get_surface_type(player->unk_110.unk3A) & 0xFF) != GRASS) { + if ((get_surface_type(player->collision.meshIndexZX) & 0xFF) != GRASS) { return; } fruit->state = 1; diff --git a/src/audio/external.c b/src/audio/external.c index a46e63712..a3e8a5245 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -228,11 +228,11 @@ char external_unused_string_eu_03[] = "SE FADE OUT TIME %d\n"; #endif #ifdef VERSION_EU -#define AUDIO_LEFT_TYRE FRONT_LEFT_TYRE -#define AUDIO_RIGHT_TYRE FRONT_RIGHT_TYRE +#define AUDIO_LEFT_TYRE FRONT_LEFT +#define AUDIO_RIGHT_TYRE FRONT_RIGHT #else -#define AUDIO_LEFT_TYRE BACK_LEFT_TYRE -#define AUDIO_RIGHT_TYRE BACK_RIGHT_TYRE +#define AUDIO_LEFT_TYRE BACK_LEFT +#define AUDIO_RIGHT_TYRE BACK_RIGHT #endif // Requires void in the argument list to match properly. @@ -672,8 +672,8 @@ void func_800C2474(void) { D_800E9E74[var_v0] = 0; D_800E9E84[var_v0] = 0; D_800E9E94[var_v0] = 0; - gPlayers[var_v0].boundingBoxCorners[AUDIO_LEFT_TYRE ].surfaceType = 0; - gPlayers[var_v0].boundingBoxCorners[AUDIO_RIGHT_TYRE].surfaceType = 0; + gPlayers[var_v0].tyres[AUDIO_LEFT_TYRE ].surfaceType = 0; + gPlayers[var_v0].tyres[AUDIO_RIGHT_TYRE].surfaceType = 0; gPlayers[var_v0].effects = 0; gPlayers[var_v0].unk_20C = 0.0f; gPlayers[var_v0].unk_0C0 = 0; @@ -1930,15 +1930,15 @@ void func_800C5E38(u8 playerId) { } void func_800C6108(u8 playerId) { - Player *temp_v1; + Player *player; - temp_v1 = &gPlayers[playerId]; - D_800E9E64[playerId] = (temp_v1->unk_098 / D_800E9DC4[playerId]) + D_800E9DD4[playerId]; - if ((temp_v1->unk_098 < 1800.0f) && ((temp_v1->unk_044 & 0x20) != 0x20)) { - D_800E9E64[playerId] = (temp_v1->unk_098 / D_800E9F7C[playerId].unk_34) + D_800E9F7C[playerId].unk_28; + player = &gPlayers[playerId]; + D_800E9E64[playerId] = (player->unk_098 / D_800E9DC4[playerId]) + D_800E9DD4[playerId]; + if ((player->unk_098 < 1800.0f) && ((player->unk_044 & 0x20) != 0x20)) { + D_800E9E64[playerId] = (player->unk_098 / D_800E9F7C[playerId].unk_34) + D_800E9F7C[playerId].unk_28; if(D_800E9EC4){} // ? } - if (temp_v1->unk_094 > 4.75f) { + if (player->unk_094 > 4.75f) { if (D_800E9EB4[playerId] < (D_800E9F7C[playerId].unk_18 + 0.4f)) { D_800E9DE4[playerId] += 0.005f; } @@ -1946,11 +1946,11 @@ void func_800C6108(u8 playerId) { D_800E9DE4[playerId] = 0.0f; } if (gPlayers[playerId].unk_0C0 > 0) { - D_800E9E54[playerId] = (f32) temp_v1->unk_0C0; + D_800E9E54[playerId] = (f32) player->unk_0C0; } else { - D_800E9E54[playerId] = (f32) -temp_v1->unk_0C0; + D_800E9E54[playerId] = (f32) -player->unk_0C0; } - if ((temp_v1->effects & 0x10) == 0x10) { + if ((player->effects & 0x10) == 0x10) { D_800E9EB4[playerId] = D_800E9E64[playerId] + D_800E9DE4[playerId]; } else { D_800E9EB4[playerId] = D_800E9E64[playerId] + D_800E9DE4[playerId] - (D_800E9E54[playerId] / 12000.0f); @@ -2193,7 +2193,7 @@ void func_800C70A8(u8 playerId) { D_800E9E74[playerId] = 0; if ((D_800E9E54[playerId] > 3500.0f) || ((gPlayers[playerId].effects & 0x10) == 0x10)) { D_800E9E74[playerId] = 1; - switch (gPlayers[playerId].boundingBoxCorners[AUDIO_LEFT_TYRE].surfaceType) { + switch (gPlayers[playerId].tyres[AUDIO_LEFT_TYRE].surfaceType) { case DIRT: /* switch 1 */ D_800E9E74[playerId] = 0x0000000D; break; @@ -2225,7 +2225,7 @@ void func_800C70A8(u8 playerId) { } if ((gPlayers[playerId].effects & 0x10) == 0x10) { D_800E9E74[playerId] = 2; - switch (gPlayers[playerId].boundingBoxCorners[AUDIO_LEFT_TYRE].surfaceType) { /* switch 2 */ + switch (gPlayers[playerId].tyres[AUDIO_LEFT_TYRE].surfaceType) { /* switch 2 */ case DIRT: /* switch 2 */ D_800E9E74[playerId] = 0x0000000D; break; @@ -2255,7 +2255,7 @@ void func_800C70A8(u8 playerId) { break; } } - switch (gPlayers[playerId].boundingBoxCorners[AUDIO_LEFT_TYRE].surfaceType) { /* switch 3 */ + switch (gPlayers[playerId].tyres[AUDIO_LEFT_TYRE].surfaceType) { /* switch 3 */ case GRASS: /* switch 3 */ if (D_800E9E74[playerId] == 6) { D_800E9E74[playerId] = 4; @@ -2315,7 +2315,7 @@ void func_800C70A8(u8 playerId) { D_800E9E74[playerId] = 0x0000001B; break; } - switch (gPlayers[playerId].boundingBoxCorners[AUDIO_RIGHT_TYRE].surfaceType) { /* switch 4 */ + switch (gPlayers[playerId].tyres[AUDIO_RIGHT_TYRE].surfaceType) { /* switch 4 */ case GRASS: /* switch 4 */ if (D_800E9E74[playerId] == 5) { D_800E9E74[playerId] = 4; diff --git a/src/camera.c b/src/camera.c index 0ff40d9be..1d6f73b8e 100644 --- a/src/camera.c +++ b/src/camera.c @@ -641,23 +641,23 @@ void func_8001E0C4(Camera *camera, Player *player, s8 arg2) { adjust_angle(&camera->unk_2C, player->rotation[1], var_a2); func_8001CA78(player, camera, sp60, &sp74, &sp70, &sp6C, camera->unk_2C, arg2); camera->someBitFlags &= ~0x0004; - temp_t7 = func_802ADDC8(&camera->unk_54, test, sp74, sp70, sp6C); - if (camera->unk_54.unk3C[2] < 0.0f) { - sp74 += -camera->unk_54.orientationVector[0] * camera->unk_54.unk3C[2] * 1; - sp70 += -camera->unk_54.orientationVector[1] * camera->unk_54.unk3C[2] * 0.5; - sp6C += -camera->unk_54.orientationVector[2] * camera->unk_54.unk3C[2] * 1; + temp_t7 = check_bounding_collision(&camera->collision, test, sp74, sp70, sp6C); + if (camera->collision.surfaceDistance[2] < 0.0f) { + sp74 += -camera->collision.orientationVector[0] * camera->collision.surfaceDistance[2] * 1; + sp70 += -camera->collision.orientationVector[1] * camera->collision.surfaceDistance[2] * 0.5; + sp6C += -camera->collision.orientationVector[2] * camera->collision.surfaceDistance[2] * 1; } - if (camera->unk_54.unk3C[0] < 0.0f) { + if (camera->collision.surfaceDistance[0] < 0.0f) { camera->someBitFlags = camera->someBitFlags | 4 | 2; - sp74 += -camera->unk_54.unk48[0] * camera->unk_54.unk3C[0] * 1.5; - sp70 += -camera->unk_54.unk48[1] * camera->unk_54.unk3C[0] * 1; - sp6C += -camera->unk_54.unk48[2] * camera->unk_54.unk3C[0] * 1.5; + sp74 += -camera->collision.unk48[0] * camera->collision.surfaceDistance[0] * 1.5; + sp70 += -camera->collision.unk48[1] * camera->collision.surfaceDistance[0] * 1; + sp6C += -camera->collision.unk48[2] * camera->collision.surfaceDistance[0] * 1.5; } - if (camera->unk_54.unk3C[1] < 0.0f) { + if (camera->collision.surfaceDistance[1] < 0.0f) { camera->someBitFlags = camera->someBitFlags | 4 | 2; - sp74 += -camera->unk_54.unk54[0] * camera->unk_54.unk3C[1] * 1.5; - sp70 += -camera->unk_54.unk54[1] * camera->unk_54.unk3C[1] * 1; - sp6C += -camera->unk_54.unk54[2] * camera->unk_54.unk3C[1] * 1.5; + sp74 += -camera->collision.unk54[0] * camera->collision.surfaceDistance[1] * 1.5; + sp70 += -camera->collision.unk54[1] * camera->collision.surfaceDistance[1] * 1; + sp6C += -camera->collision.unk54[2] * camera->collision.surfaceDistance[1] * 1.5; } if ((temp_t7 == 0) && ((camera->someBitFlags & 2) != 2)) { camera->unk_AC = camera->unk_2C; @@ -740,7 +740,7 @@ void func_8001E45C(Camera *camera, Player *player, s8 arg2) { if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40) || ((player->effects & 0x4000) == 0x4000) || ((player->effects & 0x80000) == 0x80000) || ((player->effects & 0x800000) == 0x800000) || (((player->effects & 0x20) == 0x20) && (player->unk_078 != 0)) || - (player->unk_110.unk3C[0] <= 0.0f) || (player->unk_110.unk3C[1] <= 0.0f) || ((player->effects & 0x20000) == 0x20000)) { + (player->collision.surfaceDistance[0] <= 0.0f) || (player->collision.surfaceDistance[1] <= 0.0f) || ((player->effects & 0x20000) == 0x20000)) { func_8001CCEC(player, camera, sp64, &sp84, &sp80, &sp7C, &sp58, (s32) camera->unk_2C, (s32) arg2); } else { adjust_angle(&camera->unk_2C, (s16) (player->rotation[1] + camera->unk_B0), var_a3); @@ -748,7 +748,7 @@ void func_8001E45C(Camera *camera, Player *player, s8 arg2) { } temp = 3; camera->someBitFlags &= 0xFFFB; - func_802ADDC8(&camera->unk_54, temp, sp84, sp80, sp7C); + check_bounding_collision(&camera->collision, temp, sp84, sp80, sp7C); camera->pos[0] = sp84; camera->pos[1] = sp80; @@ -783,7 +783,7 @@ void func_8001E8E8(Camera *camera, Player *player, s8 arg2) { camera->unk_B0 = 0; camera->unk_2C = player->rotation[1]; func_8001D53C(player, camera, sp5C, &sp7C, &sp78, &sp74, (s16) (s32) player->rotation[1], (s16) (s32) arg2); - func_802ADDC8(&camera->unk_54, 5.0f, sp7C, sp78, sp74); + check_bounding_collision(&camera->collision, 5.0f, sp7C, sp78, sp74); camera->lookAt[0] = sp5C[0]; camera->lookAt[1] = sp5C[1]; camera->lookAt[2] = sp5C[2]; @@ -862,7 +862,7 @@ void func_8001EA0C(Camera *camera, Player *player, s8 arg2) { if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40) || ((player->effects & 0x4000) == 0x4000) || ((player->effects & 0x80000) == 0x80000) || ((player->effects & 0x800000) == 0x800000) || (((player->effects & 0x20) == 0x20) && (player->unk_078 != 0)) || - (player->unk_110.unk3C[0] <= 0.0f) || (player->unk_110.unk3C[1] <= 0.0f) || ((player->effects & 0x20000) == 0x20000)) { + (player->collision.surfaceDistance[0] <= 0.0f) || (player->collision.surfaceDistance[1] <= 0.0f) || ((player->effects & 0x20000) == 0x20000)) { func_8001D944(player, camera, sp64, &sp84, &sp80, &sp7C, &sp58, (s32) camera->unk_2C, (s32) arg2); } else { adjust_angle(&camera->unk_2C, (s16) (player->rotation[1] + camera->unk_B0), var_a3); @@ -870,7 +870,7 @@ void func_8001EA0C(Camera *camera, Player *player, s8 arg2) { } temp = 3; camera->someBitFlags &= 0xFFFB; - func_802ADDC8(&camera->unk_54, temp, sp84, sp80, sp7C); + check_bounding_collision(&camera->collision, temp, sp84, sp80, sp7C); camera->pos[0] = sp84; camera->pos[1] = sp80; diff --git a/src/camera.h b/src/camera.h index fa0e01e5d..12e4c4409 100644 --- a/src/camera.h +++ b/src/camera.h @@ -39,7 +39,7 @@ typedef struct { /* 0x48 */ s32 unk_48; /* 0x4C */ s32 unk_4C; /* 0x50 */ s32 unk_50; - /* 0x54 */ Collision unk_54; + /* 0x54 */ Collision collision; // When you hit a wall (or another driver) the camera's pos and lookAt bounce up and down. This is the velocity(?) of that bouncing /* 0x94 */ UnkCameraInner unk_94; // Timer for wall-hit bounce. Counts up instead of down diff --git a/src/code_800029B0.c b/src/code_800029B0.c index db3af2ded..5459b09f4 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -71,9 +71,9 @@ s16 gPlaceItemBoxes = 1; // Technically a pointer to an array, but declaring it so creates regalloc issues. CollisionTriangle *gCollisionMesh; -u16 *D_8015F584; +u16 *gCollisionIndices; u16 gCollisionMeshCount; // Number of entries in gCollisionMesh -u16 D_8015F58A; +u16 gNumCollisionTriangles; u32 D_8015F58C; Vec3f D_8015F590; diff --git a/src/code_800029B0.h b/src/code_800029B0.h index 810001f2d..76c7e0d18 100644 --- a/src/code_800029B0.h +++ b/src/code_800029B0.h @@ -68,9 +68,9 @@ extern s16 gCreditsCourseId; extern s16 gPlaceItemBoxes; extern CollisionTriangle *gCollisionMesh; -extern u16 *D_8015F584; +extern u16 *gCollisionIndices; extern u16 gCollisionMeshCount; -extern u16 D_8015F58A; +extern u16 gNumCollisionTriangles; extern u32 D_8015F58C; extern Vec3f D_8015F590; diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 060832135..d5d84e739 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -51,7 +51,7 @@ Vec3f D_80162FA0; Vec3f D_80162FB0; Vec3f D_80162FC0; s16 D_80162FCC; -s16 D_80162FCE; +s16 sSomeNearestWaypoint; s16 D_80162FD0; f32 gCourseCompletionPercentByRank[NUM_PLAYERS]; /* @@ -129,7 +129,7 @@ s16 D_8016348C; s16 D_80163490[12]; s16 D_801634A8[12]; s16 D_801634C0[12]; -s16 D_801634D8[10]; +s16 bStopAICrossing[10]; s16 D_801634EC; s32 D_801634F0; s32 D_801634F4; @@ -137,8 +137,8 @@ Test D_801634F8[10]; PathNoY *D_80163598; s32 D_8016359C; TrainStuff gTrainList[NUM_TRAINS]; -u16 isCrossingTriggeredByIndex[2]; -u16 D_801637BC[2]; +u16 isCrossingTriggeredByIndex[NUM_CROSSINGS]; +u16 sCrossingActiveTimer[NUM_CROSSINGS]; PaddleBoatStuff gPaddleBoats[NUM_PADDLE_BOATS]; VehicleStuff gBoxTruckList[NUM_RACE_BOX_TRUCKS]; VehicleStuff gSchoolBusList[NUM_RACE_SCHOOL_BUSES]; @@ -598,61 +598,69 @@ void func_80006114(Vec3f arg0, Vec3f arg1, s16 arg2) { arg0[2] = arg1[2] + temp2; } -s32 func_800061DC(Vec3f arg0, f32 arg1, s32 arg2) { - Camera *var_a0_2; - Player *var_a0; - f32 temp_f0; - f32 temp_f2; - f32 temp_f12; - f32 temp_f14; - s32 var_a1; - s32 var_v1; - s8 var_v0; +s32 set_vehicle_render_distance_flags(Vec3f vehiclePos, f32 renderDistance, s32 flags) { + Camera *camera; + Player *player; + f32 x; + f32 z; + f32 playerX; + f32 playerZ; + s32 i; + s32 flag; + s8 numScreens; - temp_f0 = arg0[0]; - temp_f2 = arg0[2]; + x = vehiclePos[0]; + z = vehiclePos[2]; switch (gActiveScreenMode) { case SCREEN_MODE_1P: - var_v0 = 1; + numScreens = 1; break; case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: - var_v0 = 2; + numScreens = 2; break; case SCREEN_MODE_3P_4P_SPLITSCREEN: - var_v0 = gPlayerCount; + numScreens = gPlayerCount; break; default: - var_v0 = 1; + numScreens = 1; break; } - var_v1 = arg2; + flag = flags; if (!gDemoMode) { - var_a0 = gPlayerOne; - for(var_a1 = 0; var_a1 < gPlayerCount; var_a1++, var_a0++) { - if (((var_a0->type & 0x4000) != 0) && ((var_a0->type & 0x1000) == 0)) { - temp_f12 = var_a0->pos[0]; - temp_f14 = var_a0->pos[2]; - if (((temp_f12 - arg1) < temp_f0) && (temp_f0 < (temp_f12 + arg1)) && ((temp_f14 - arg1) < temp_f2) && (temp_f2 < (temp_f14 + arg1))) { - var_v1 |= (1 << var_a1); + player = gPlayerOne; + // Checks distance from each player. + for(i = 0; i < gPlayerCount; i++, player++) { + if (((player->type & PLAYER_HUMAN) != 0) && ((player->type & PLAYER_KART_AI) == 0)) { + playerX = player->pos[0]; + playerZ = player->pos[2]; + + // Is player within render distance + if (((playerX - renderDistance) < x) && + ((playerX + renderDistance) > x) && + ((playerZ - renderDistance) < z) && + ((playerZ + renderDistance) > z)) { + // Sets the render flag to on for each player. + flag |= (RENDER_VEHICLE << i); } else { - var_v1 &= ~(1 << var_a1); + // Sets the render flag to off for each player. + flag &= ~(RENDER_VEHICLE << i); } } } - } else { - var_a0_2 = camera1; - for(var_a1 = 0; var_a1 < var_v0; var_a1++, var_a0_2++) { - temp_f12 = var_a0_2->pos[0]; - temp_f14 = var_a0_2->pos[2]; - if (((temp_f12 - arg1) < temp_f0) && (temp_f0 < (temp_f12 + arg1)) && ((temp_f14 - arg1) < temp_f2) && (temp_f2 < (temp_f14 + arg1))) { - var_v1 |= (1 << var_a1); + } else { // Demo cinematic uses the camera to check render distance + camera = camera1; + for(i = 0; i < numScreens; i++, camera++) { + playerX = camera->pos[0]; + playerZ = camera->pos[2]; + if (((playerX - renderDistance) < x) && (x < (playerX + renderDistance)) && ((playerZ - renderDistance) < z) && (z < (playerZ + renderDistance))) { + flag |= (RENDER_VEHICLE << i); } else { - var_v1 &= ~(1 << var_a1); + flag &= ~(RENDER_VEHICLE << i); } } } - return var_v1; + return flag; } void func_800065D0(s32 playerId, Player *player) { @@ -992,7 +1000,7 @@ void func_80007D04(s32 playerId, Player* player) { D_801634C0[playerId] = 2; } else { player->effects &= ~0x200000; - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); D_801634C0[playerId] = -1; } } @@ -1009,35 +1017,35 @@ void func_80007FA4(s32 arg0, Player *player, f32 arg2) { if (arg0 == 3) { if ((temp_f12 < 25.0f) && (D_80163410[arg0] < 5)) { D_80163410[arg0] = 4; - (arg2 < ((2.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : func_80031F48(player, 1.0f); + (arg2 < ((2.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_ai_player(player, 1.0f); } else if ((temp_f12 < 3600.0f) && (D_80163410[arg0] < 4)) { D_80163410[arg0] = 3; - (arg2 < ((5.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : func_80031F48(player, 5.0f); + (arg2 < ((5.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_ai_player(player, 5.0f); } else { - (arg2 < ((20.0 * 18.0) / 216.0)) ? func_80038BE4(player, 10) : func_80031F48(player, 1.0f); + (arg2 < ((20.0 * 18.0) / 216.0)) ? func_80038BE4(player, 10) : decelerate_ai_player(player, 1.0f); } } else { if ((temp_f12 < 25.0f) && (D_80163410[arg0] < 5)) { D_80163410[arg0] = 4; test = 2; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : func_80031F48(player, 1.0f); + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_ai_player(player, 1.0f); } else if ((temp_f12 < 4900.0f) && (D_80163410[arg0] < 4)) { D_80163410[arg0] = 3; test = 5; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : func_80031F48(player, 15.0f); + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_ai_player(player, 15.0f); } else if ((temp_f12 < 22500.0f) && (D_80163410[arg0] < 3)) { D_80163410[arg0] = 2; test = 20; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 5) : func_80031F48(player, 1.0f); + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 5) : decelerate_ai_player(player, 1.0f); } else if ((temp_f12 < 90000.0f) && (D_80163410[arg0] < 2)) { D_80163410[arg0] = 1; test = 30; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 6) : func_80031F48(player, 1.0f); + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 6) : decelerate_ai_player(player, 1.0f); } else if (D_80163410[arg0] == 0) { test = 35; - (arg2 < (((test^0) * 18.0) / 216.0)) ? func_80038BE4(player, 2) : func_80031F48(player, 1.0f); + (arg2 < (((test^0) * 18.0) / 216.0)) ? func_80038BE4(player, 2) : decelerate_ai_player(player, 1.0f); } else { - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); } } } @@ -1058,8 +1066,8 @@ void func_80008424(s32 playerId, f32 arg1, Player *player) { !(player->soundEffects & 4)) { if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { func_80007FA4(playerId, player, var_f2); - } else if ((D_801634D8[playerId] == 1) && !(player->effects & (STAR_EFFECT | BOO_EFFECT))) { - func_80031F48(player, 10.0f); + } else if ((bStopAICrossing[playerId] == 1) && !(player->effects & (STAR_EFFECT | BOO_EFFECT))) { + decelerate_ai_player(player, 10.0f); if (player->currentSpeed == 0.0) { player->velocity[0] = 0.0f; player->velocity[2] = 0.0f; @@ -1086,7 +1094,7 @@ void func_80008424(s32 playerId, f32 arg1, Player *player) { player_speed(player); } else { player->effects &= ~0x00200000; - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); } } else if ((D_801631E0[playerId] == 1) && (D_80163330[playerId] != 1)) { if (func_800088D8(playerId, gLapCountByPlayerId[playerId], D_80164408[playerId]) == 1) { @@ -1094,7 +1102,7 @@ void func_80008424(s32 playerId, f32 arg1, Player *player) { player_speed(player); } else { player->effects &= ~0x00200000; - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); } } else { var_a1 = 1; @@ -1129,14 +1137,14 @@ void func_80008424(s32 playerId, f32 arg1, Player *player) { player_speed(player); } else { player->effects &= ~0x00200000; - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); } } else { player->effects &= ~0x00200000; if (arg1 > 1.0f) { - func_80031F48(player, 2.0f); + decelerate_ai_player(player, 2.0f); } else { - func_80031F48(player, 5.0f); + decelerate_ai_player(player, 5.0f); } } } @@ -1309,10 +1317,10 @@ s32 func_80008E58(s32 payerId, s32 pathIndex) { posY = player->pos[1]; posZ = player->pos[2]; stackPadding = pathIndex; - trackSegment = func_802ABD40(player->unk_110.unk3A); + trackSegment = get_section_id(player->collision.meshIndexZX); D_80163318[payerId] = trackSegment; - D_80162FCE = func_8000C0BC(posX, posY, posZ, trackSegment, &pathIndex); - gNearestWaypointByPlayerId[payerId] = D_80162FCE; + sSomeNearestWaypoint = func_8000C0BC(posX, posY, posZ, trackSegment, &pathIndex); + gNearestWaypointByPlayerId[payerId] = sSomeNearestWaypoint; if(pathIndex) {}; gPathIndexByPlayerId[payerId] = pathIndex; func_80008DC0(pathIndex); @@ -1323,7 +1331,7 @@ s32 func_80008E58(s32 payerId, s32 pathIndex) { void func_80008F38(s32 playerId) { f32 temp_f0; - D_80164450[playerId] = (gLapCountByPlayerId[playerId] * gWaypointCountByPathIndex[0]) + D_80162FCE; + D_80164450[playerId] = (gLapCountByPlayerId[playerId] * gWaypointCountByPathIndex[0]) + sSomeNearestWaypoint; temp_f0 = (f32) gNearestWaypointByPlayerId[playerId] / (f32) gWaypointCountByPathIndex[gPathIndexByPlayerId[playerId]]; gLapCompletionPercentByPlayerId[playerId] = temp_f0; gCourseCompletionPercentByPlayerId[playerId] = temp_f0; @@ -1334,26 +1342,26 @@ void func_80009000(s32 playerId) { s16 temp_v0; temp_v0 = D_801644F8[playerId]; - if (D_80162FCE >= 0x6D) { + if (sSomeNearestWaypoint >= 0x6D) { D_801644F8[playerId] = 1; switch (D_80163448) { case 0: - if (D_80162FCE >= 0x20F) { + if (sSomeNearestWaypoint >= 0x20F) { D_801644F8[playerId] = 0; } break; case 1: - if (D_80162FCE >= 0x206) { + if (sSomeNearestWaypoint >= 0x206) { D_801644F8[playerId] = 0; } break; case 2: - if (D_80162FCE >= 0x211) { + if (sSomeNearestWaypoint >= 0x211) { D_801644F8[playerId] = 0; } break; case 3: - if (D_80162FCE >= 0x283) { + if (sSomeNearestWaypoint >= 0x283) { D_801644F8[playerId] = 0; } break; @@ -1378,15 +1386,15 @@ void func_800090F0(s32 playerId, Player *player) { posZ = player->pos[2]; if (D_80163490[playerId] == 1) { D_80163448 = func_80008E58(playerId, random_int(4U)); - D_80162FCE = func_8000CD24(posX, posY, posZ, 0, player, playerId, D_80163448); - gNearestWaypointByPlayerId[playerId] = D_80162FCE; + sSomeNearestWaypoint = func_8000CD24(posX, posY, posZ, 0, player, playerId, D_80163448); + gNearestWaypointByPlayerId[playerId] = sSomeNearestWaypoint; func_80008F38(playerId); D_80163490[playerId] = 0; } if (D_801634A8[playerId] == 1) { D_80163448 = func_80008E58(playerId, 0); - D_80162FCE = func_8000CD24(posX, posY, posZ, 0, player, playerId, D_80163448); - gNearestWaypointByPlayerId[playerId] = D_80162FCE; + sSomeNearestWaypoint = func_8000CD24(posX, posY, posZ, 0, player, playerId, D_80163448); + gNearestWaypointByPlayerId[playerId] = sSomeNearestWaypoint; func_80008F38(playerId); D_801634A8[playerId] = 0; } @@ -1420,18 +1428,18 @@ void func_8000929C(s32 playerId, Player *player) { tempPos2 = player->pos[2]; D_801630E2 = 0; D_80163240[playerId] = 0; - D_80162FCE = func_8000CD24(tempPos0, tempPos1, tempPos2, gNearestWaypointByPlayerId[playerId], player, playerId, D_80163448); - D_801630E0 = D_80162FCE; - if (gNearestWaypointByPlayerId[playerId] != D_80162FCE) { - gNearestWaypointByPlayerId[playerId] = D_80162FCE; + sSomeNearestWaypoint = func_8000CD24(tempPos0, tempPos1, tempPos2, gNearestWaypointByPlayerId[playerId], player, playerId, D_80163448); + D_801630E0 = sSomeNearestWaypoint; + if (gNearestWaypointByPlayerId[playerId] != sSomeNearestWaypoint) { + gNearestWaypointByPlayerId[playerId] = sSomeNearestWaypoint; D_801630E2 = 1; func_80008F38(playerId); } if (gCurrentCourseId == 0x0014) { - func_8000B95C(playerId, D_80162FCE, D_80163448); + func_8000B95C(playerId, sSomeNearestWaypoint, D_80163448); return; } - if ((D_80162FCE < 0x14) || ((gWaypointCountByPathIndex[D_80163448] - 0x14) < D_80162FCE) || (gCurrentCourseId == 0x000B)) { + if ((sSomeNearestWaypoint < 0x14) || ((gWaypointCountByPathIndex[D_80163448] - 0x14) < sSomeNearestWaypoint) || (gCurrentCourseId == 0x000B)) { var_v1 = 0; var_t0 = 0; if (gCurrentCourseId == 0x000B) { @@ -1486,7 +1494,7 @@ void func_8000929C(s32 playerId, Player *player) { } } D_80163450[playerId] = tempPos2; - if ((gCurrentCourseId == 4) && (D_801630E2 == 1)) { + if ((gCurrentCourseId == COURSE_YOSHI_VALLEY) && (D_801630E2 == 1)) { func_80009000(playerId); if (((player->type & 0x4000) == 0) || (player->type & 0x1000)) { func_800090F0(playerId, player); @@ -1504,7 +1512,7 @@ void func_8000929C(s32 playerId, Player *player) { } else { //???? } - func_8000B95C(playerId, D_80162FCE, D_80163448); + func_8000B95C(playerId, sSomeNearestWaypoint, D_80163448); } #else GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_8000929C.s") @@ -1758,12 +1766,12 @@ void func_80009B60(s32 playerId) { } else if (D_80162FD0 == (s16) 1U) { D_80163210[playerId] = *(f32*)segmented_to_virtual_dupe_2(&D_0D0096B8[gCurrentCourseId][gCCSelection]); D_801634F8[playerId].unk4 = -0.5f; - } else if (D_801645E0[D_80162FCE] > 0) { + } else if (D_801645E0[sSomeNearestWaypoint] > 0) { D_80163210[playerId] = *(f32*)segmented_to_virtual_dupe_2(&D_0D009418[gCurrentCourseId][gCCSelection]); } else { D_80163210[playerId] = *(f32*)segmented_to_virtual_dupe_2(&D_0D009568[gCurrentCourseId][gCCSelection]); } - func_800131DC(playerId); + check_ai_crossing_distance(playerId); func_8000D3B8(playerId); func_8000D438(playerId, D_801630E0); temp_f0 = D_80162FA0[0] - player->pos[0]; @@ -1792,7 +1800,7 @@ void func_80009B60(s32 playerId) { } if (D_801630E8[playerId] != 0) { D_80163300[playerId] = -get_angle_between_two_vectors(&player->copy_rotation_x, player->pos); - var_a0_2 = (D_801631DC[(D_80162FCE + 2) % D_80164430] * 0x168) / 65535; + var_a0_2 = (D_801631DC[(sSomeNearestWaypoint + 2) % D_80164430] * 0x168) / 65535; var_a1 = (D_80163300[playerId] * 0x168) / 65535; if (var_a0_2 < -0xB4) { var_a0_2 += 0x168; @@ -1841,8 +1849,8 @@ void func_80009B60(s32 playerId) { func_80008424(playerId, D_80163210[playerId], player); return; } - D_801630B8[playerId] = func_8000B7E4(playerId, D_80162FCE); - func_8000D438(playerId, D_80162FCE); + D_801630B8[playerId] = func_8000B7E4(playerId, sSomeNearestWaypoint); + func_8000D438(playerId, sSomeNearestWaypoint); if (gCurrentCourseId != 0x0014) { if (D_80164450[playerId] < 0xB) { stackPadding1A = D_801630E0; @@ -1966,7 +1974,7 @@ void func_80009B60(s32 playerId) { D_8016320C = D_80163028[playerId]; player->effects &= ~0x00200000; D_80163210[playerId] = D_8016320C; - func_800131DC(playerId); + check_ai_crossing_distance(playerId); func_80008424(playerId, D_8016320C, player); } } @@ -2476,7 +2484,7 @@ s16 func_8000CC88(f32 posX, f32 posY, f32 posZ, Player *player, s32 playerId, s3 u16 trackSegment; s16 ret; - trackSegment = func_802ABD40(player->unk_110.unk3A); + trackSegment = get_section_id(player->collision.meshIndexZX); if ((trackSegment <= 0) || (trackSegment >= 0x33)) { trackSegment = D_80163318[playerId]; } @@ -2494,7 +2502,7 @@ s16 func_8000CD24(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, Player *playe TrackWaypoint *temp_v1; if ((player->type & 0x4000) && !(player->type & 0x1000)) { - sp5E = func_8000C884(posX, posY, posZ, waypointIndex, pathIndex, (u16) func_802ABD40(player->unk_110.unk3A)); + sp5E = func_8000C884(posX, posY, posZ, waypointIndex, pathIndex, (u16) get_section_id(player->collision.meshIndexZX)); if (sp5E == -1) { sp5E = func_8000CC88(posX, posY, posZ, player, playerId, &pathIndex); } @@ -2509,8 +2517,8 @@ s16 func_8000CD24(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, Player *playe return waypointIndex; } if (playerId == ((s32) D_80163488 % 8)) { - func_802ADDC8(&player->unk_110, 10.0f, posX, posY, posZ); - D_80163318[playerId] = func_802ABD40(player->unk_110.unk3A); + check_bounding_collision(&player->collision, 10.0f, posX, posY, posZ); + D_80163318[playerId] = get_section_id(player->collision.meshIndexZX); sp5E = func_8000C884(posX, posY, posZ, waypointIndex, pathIndex, D_80163318[playerId]); if (sp5E == -1) { sp5E = func_8000C9DC(posX, posY, posZ, waypointIndex, pathIndex); @@ -2533,8 +2541,8 @@ s16 func_8000CD24(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, Player *playe player->pos[0] = posX; player->pos[1] = posY; player->pos[2] = posZ; - func_802ADDC8(&player->unk_110, 10.0f, posX, posY, posZ); - D_80163318[playerId] = func_802ABD40(player->unk_110.unk3A); + check_bounding_collision(&player->collision, 10.0f, posX, posY, posZ); + D_80163318[playerId] = get_section_id(player->collision.meshIndexZX); } } } else { @@ -2586,8 +2594,8 @@ s16 func_8000D24C(f32 posX, f32 posY, f32 posZ, s32 *pathIndex) { UNUSED s32 pad; Collision sp24; - func_802ADDC8(&sp24, 10.0f, posX, posY, posZ); - return func_8000C0BC(posX, posY, posZ, func_802ABD40(sp24.unk3A), pathIndex); + check_bounding_collision(&sp24, 10.0f, posX, posY, posZ); + return func_8000C0BC(posX, posY, posZ, get_section_id(sp24.meshIndexZX), pathIndex); } s16 func_8000D2B4(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, s32 pathIndex) { @@ -2904,7 +2912,7 @@ void set_bomb_kart_spawn_positions(void) { case COURSE_YOSHI_VALLEY: startingXPos = temp_s1->startingXPos; startingZPos = temp_s1->startingZPos; - startingYPos = func_802AE1C0(startingXPos, 2000.0f, startingZPos); + startingYPos = spawn_actor_on_surface(startingXPos, 2000.0f, startingZPos); break; case COURSE_AWARD_CEREMONY: temp_v0 = &D_80164550[3][temp_s1->waypointIndex]; @@ -2942,7 +2950,7 @@ void set_bomb_kart_spawn_positions(void) { gBombKarts[var_s3].unk_4A = 0; gBombKarts[var_s3].unk_4C = 1; gBombKarts[var_s3].yPos = startingYPos; - func_802ADDC8(&D_80164038[var_s3], 2.0f, startingXPos, startingYPos, startingZPos); + check_bounding_collision(&D_80164038[var_s3], 2.0f, startingXPos, startingYPos, startingZPos); } } @@ -3141,11 +3149,11 @@ void func_8000DF8C(s32 bombKartId) { var_f24 += temp_f16 / 5.0f; } temp_a0_4 = &D_80164038[bombKartId]; - var_f20 = func_802ABE30(var_f22, 2000.0f, var_f24, temp_a0_4->unk3A) + 3.5f; + var_f20 = calculate_surface_height(var_f22, 2000.0f, var_f24, temp_a0_4->meshIndexZX) + 3.5f; if (var_f20 < (-1000.0)) { var_f20 = bombKart->bombPos[1]; } - func_802ADDC8(temp_a0_4, 10.0f, var_f22, var_f20, var_f24); + check_bounding_collision(temp_a0_4, 10.0f, var_f22, var_f20, var_f24); } break; case 4: @@ -3532,12 +3540,19 @@ void func_8000F628(void) { D_80163150[i] = -1; D_80164538[i] = -1; D_801634C0[i] = 0; - D_801634D8[i] = 0; + bStopAICrossing[i] = 0; D_801630B8[i] = 1; } - D_801637BC[0] = 0; - D_801637BC[1] = 0; + +#ifdef AVOID_UB + for (i = 0; i < NUM_CROSSINGS; i++) { + sCrossingActiveTimer[i] = 0; + } +#else + sCrossingActiveTimer[0] = 0; + sCrossingActiveTimer[1] = 0; +#endif if (gDemoMode == DEMO_MODE_INACTIVE) { if (gModeSelection == GRAND_PRIX) { @@ -3879,14 +3894,14 @@ void func_80010E6C(s32 pathIndex) { } f32 func_80010F40(f32 arg0, f32 arg1, f32 arg2, UNUSED s32 arg3, UNUSED s32 arg4) { - arg1 = func_802AE1C0(arg0, 2000.0f, arg2); - func_802ADDC8(&D_80162E70, 1.0f, arg0, arg1, arg2); + arg1 = spawn_actor_on_surface(arg0, 2000.0f, arg2); + check_bounding_collision(&D_80162E70, 1.0f, arg0, arg1, arg2); return arg1; } f32 func_80010FA0(f32 arg0, f32 arg1, f32 arg2, UNUSED s32 arg3, UNUSED s32 arg4) { - arg1 = func_802AE1C0(arg0, (f32) ((f64) arg1 + 30.0), arg2); - func_802ADDC8(&D_80162E70, 10.0f, arg0, arg1, arg2); + arg1 = spawn_actor_on_surface(arg0, (f32) ((f64) arg1 + 30.0), arg2); + check_bounding_collision(&D_80162E70, 10.0f, arg0, arg1, arg2); return arg1; } @@ -3965,7 +3980,7 @@ s32 func_80011014(TrackWaypoint *pathDest, TrackWaypoint *path, s32 numPathPoint pathDest->posZ = (s16) temp_f22; - pathDest->trackSegment = func_802ABD40(D_80162E70.unk3A); + pathDest->trackSegment = get_section_id(D_80162E70.meshIndexZX); if (var_f20_2 < -500.0) { var_f20_2 = var_f28; @@ -4257,7 +4272,7 @@ void kart_ai_behaviour(s32 playerIndex) { void func_80011EC0(s32 arg0, Player *player, s32 arg2, UNUSED u16 arg3) { if ((((player->unk_094 / 18.0f) * 216.0f) >= 45.0f) && (D_801630E8[arg0] == 0)) { - switch (D_801631D8[D_80162FCE]) { + switch (D_801631D8[sSomeNearestWaypoint]) { case 0: case 2: if ((arg2 >= -9) && (D_80162FF8[arg0] == 0)) { @@ -4303,7 +4318,7 @@ void func_800120C8(void) { temp = D_80163598; D_8016359C = func_8001168C(temp, waypoint, i - 1); - D_80162EB0 = func_802AE1C0(temp[0].x, 2000.0f, temp[0].z); + D_80162EB0 = spawn_actor_on_surface(temp[0].x, 2000.0f, temp[0].z); } void func_80012190(void) { @@ -4568,7 +4583,8 @@ void update_vehicle_trains(void) { func_800C98B8(gTrainList[i].locomotive.position, gTrainList[i].locomotive.velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x0D)); } - gTrainList[i].someFlags = func_800061DC(gTrainList[i].locomotive.position, 2000.0f, gTrainList[i].someFlags); + gTrainList[i].someFlags = set_vehicle_render_distance_flags(gTrainList[i].locomotive.position, TRAIN_SMOKE_RENDER_DISTANCE, gTrainList[i].someFlags); + // Renders locomotive smoke on all screens if any player is within range. if ((((s16) D_80162FCC % 5) == 0) && (gTrainList[i].someFlags != 0)) { sp90[0] = gTrainList[i].locomotive.position[0]; sp90[1] = (f32) ((f64) gTrainList[i].locomotive.position[1] + 65.0); @@ -4655,7 +4671,7 @@ void func_80012DC0(s32 playerId, Player *player) { /** * Appears to check if the train is close to the crossing. - * Implements D_801637BC as a counter + * Implements sCrossingActiveTimer as a counter */ void func_80013054(void) { f32 temp_f16; @@ -4682,31 +4698,31 @@ void func_80013054(void) { } } - for (i = 0; i < NUM_TRAINS; i++) { + for (i = 0; i < NUM_CROSSINGS; i++) { if (isCrossingTriggeredByIndex[i] == 1) { - D_801637BC[i] += 1; + sCrossingActiveTimer[i] += 1; } else { - D_801637BC[i] = 0; + sCrossingActiveTimer[i] = 0; } } } -void func_800131DC(s32 playerId) { - D_801634D8[playerId] = 0; +void check_ai_crossing_distance(s32 playerId) { + bStopAICrossing[playerId] = 0; if (gCurrentCourseId == COURSE_KALAMARI_DESERT) { if ((!(D_801631E0[playerId] != 0)) - || (func_800061DC(gPlayers[playerId].pos, 1000.0f, 0))) { + || (set_vehicle_render_distance_flags(gPlayers[playerId].pos, TRAIN_CROSSING_AI_DISTANCE, 0))) { - if ((isCrossingTriggeredByIndex[1] == 1) - && ((D_801637BC[1]) > 240)) { + if ((isCrossingTriggeredByIndex[1] == 1) + && ((sCrossingActiveTimer[1]) > FRAMES_SINCE_CROSSING_ACTIVATED)) { - if ((D_80162FCE > 176) && (D_80162FCE < 182)) { - D_801634D8[playerId] = 1; + if ((sSomeNearestWaypoint > 176) && (sSomeNearestWaypoint < 182)) { + bStopAICrossing[playerId] = 1; } } - if ((isCrossingTriggeredByIndex[0] == 1) && (( D_801637BC[0]) > 240)) { - if ((D_80162FCE >= 306) && (D_80162FCE < 0x136)) { - D_801634D8[playerId] = 1; + if ((isCrossingTriggeredByIndex[0] == 1) && (( sCrossingActiveTimer[0]) > FRAMES_SINCE_CROSSING_ACTIVATED)) { + if ((sSomeNearestWaypoint >= 306) && (sSomeNearestWaypoint < 310)) { + bStopAICrossing[playerId] = 1; } } } @@ -4766,7 +4782,7 @@ void update_vehicle_paddle_boats(void) { temp_f28 = paddleBoat->position[1]; temp_f30 = paddleBoat->position[2]; func_8000DBAC(paddleBoat->position, (s16*)&paddleBoat->waypointIndex, paddleBoat->someMultiplier); - paddleBoat->someFlags = func_800061DC(paddleBoat->position, 2000.0f, paddleBoat->someFlags); + paddleBoat->someFlags = set_vehicle_render_distance_flags(paddleBoat->position, BOAT_SMOKE_RENDER_DISTANCE, paddleBoat->someFlags); if ((((s16) D_801630FC % 10) == 0) && (paddleBoat->someFlags != 0)) { sp78[0] = (f32) ((f64) paddleBoat->position[0] - 30.0); sp78[1] = (f32) ((f64) paddleBoat->position[1] + 180.0); @@ -4881,39 +4897,39 @@ void func_800139E4(f32 arg0, f32 arg1, s32 arg2, s32 arg3, VehicleStuff *vehicle u16 waypointOffset; s32 numWaypoints = gWaypointCountByPathIndex[0]; for (i = 0; i < arg2; i++) { - waypointOffset = (((i * numWaypoints) / arg2) + arg3) % numWaypoints; - veh = &vehicle[i]; - temp_v0 = &waypointList[waypointOffset]; - veh->position[0] = (f32) temp_v0->posX; - veh->position[1] = (f32) temp_v0->posY; - veh->position[2] = (f32) temp_v0->posZ; - veh->actorIndex = -1; - veh->waypointIndex = waypointOffset; - veh->unused = 0; - veh->velocity[0] = 0.0f; - veh->velocity[1] = 0.0f; - veh->velocity[2] = 0.0f; - veh->someFlags = 0; - veh->someFlagsTheSequel = 0; - if (gModeSelection == TIME_TRIALS) { - veh->someType = (i % 3); - } else { - veh->someType = random_int(3); - } - veh->someMultiplierTheSequel = (f32) ((f64) (f32) (veh->someType - 1) * 0.6); - if (((gCCSelection > CC_50) || (gModeSelection == TIME_TRIALS)) && (veh->someType == 2)) { - veh->someMultiplier = arg0; - } else { - veh->someMultiplier = arg1; - } - veh->rotation[0] = 0; - veh->rotation[2] = 0; - if (D_8016347A == 0) { - veh->rotation[1] = func_8000D6D0(veh->position, (s16*)&veh->waypointIndex, veh->someMultiplier, veh->someMultiplierTheSequel, 0, 3); - } else { - veh->rotation[1] = func_8000D940(veh->position, (s16*)&veh->waypointIndex, veh->someMultiplier, veh->someMultiplierTheSequel, 0); - } + waypointOffset = (((i * numWaypoints) / arg2) + arg3) % numWaypoints; + veh = &vehicle[i]; + temp_v0 = &waypointList[waypointOffset]; + veh->position[0] = (f32) temp_v0->posX; + veh->position[1] = (f32) temp_v0->posY; + veh->position[2] = (f32) temp_v0->posZ; + veh->actorIndex = -1; + veh->waypointIndex = waypointOffset; + veh->unused = 0; + veh->velocity[0] = 0.0f; + veh->velocity[1] = 0.0f; + veh->velocity[2] = 0.0f; + veh->someFlags = 0; + veh->someFlagsTheSequel = 0; + if (gModeSelection == TIME_TRIALS) { + veh->someType = (i % 3); + } else { + veh->someType = random_int(3); } + veh->someMultiplierTheSequel = (f32) ((f64) (f32) (veh->someType - 1) * 0.6); + if (((gCCSelection > CC_50) || (gModeSelection == TIME_TRIALS)) && (veh->someType == 2)) { + veh->someMultiplier = arg0; + } else { + veh->someMultiplier = arg1; + } + veh->rotation[0] = 0; + veh->rotation[2] = 0; + if (D_8016347A == 0) { + veh->rotation[1] = func_8000D6D0(veh->position, (s16*)&veh->waypointIndex, veh->someMultiplier, veh->someMultiplierTheSequel, 0, 3); + } else { + veh->rotation[1] = func_8000D940(veh->position, (s16*)&veh->waypointIndex, veh->someMultiplier, veh->someMultiplierTheSequel, 0); + } + } D_801631C8 = 10; } @@ -5052,12 +5068,12 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 (temp_f22 > -20.0)) && (temp_f22 < 20.0) && (((temp_f14) > -300.0)) && ((temp_f14) < 300.0)) { if ((D_801631C8 > 0) && (vehicle->someFlags == 0)) { D_801631C8 -= 1; - vehicle->someFlags |= (1 << playerId); + vehicle->someFlags |= (RENDER_VEHICLE << playerId); func_800C9D80(vehicle->position, vehicle->velocity, soundBits); } } else { if (vehicle->someFlags != 0) { - vehicle->someFlags &= ~(1 << playerId); + vehicle->someFlags &= ~(RENDER_VEHICLE << playerId); if (vehicle->someFlags == 0) { D_801631C8 += 1; func_800C9EF4(vehicle->position, soundBits); @@ -5068,12 +5084,12 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 if (((temp_f12) > -200.0) && ((temp_f12) < 200.0) && ((temp_f22 > -20.0)) && (temp_f22 < 20.0) && ( ((temp_f14) > -200.0)) && ((temp_f14) < 200.0)) { if (!(vehicle->someFlagsTheSequel & ((1 << playerId)))) { - + s32 var_s1 = 0; u16 path = gWaypointCountByPathIndex[0]; s32 t1; s32 t2; - + switch (D_8016347A) { case 0: t1 = func_80007BF8(vehicle->waypointIndex, gNearestWaypointByPlayerId[playerId], 10, 0, path); @@ -5201,7 +5217,7 @@ void func_800146B8(s32 playerId, s32 arg1, VehicleStuff *vehicle) { for (var_s2 = 0; var_s2 < arg1; var_s2++, vehicle++) { temp_a1 = vehicle->waypointIndex; for (var_v0 = 0; var_v0 < 0x18; var_v0 += 3) { - if (((D_80162FCE + var_v0) % waypointCount) == temp_a1) { + if (((sSomeNearestWaypoint + var_v0) % waypointCount) == temp_a1) { D_801634F8[playerId].unk4 = func_800145A8(vehicle->someType, D_80163068[playerId], temp_a1); return; } @@ -5322,7 +5338,7 @@ void func_80014D30(s32 cameraId, s32 pathIndex) { cameraWaypoint = gNearestWaypointByCameraId[cameraId]; temp_v0 = &D_80164550[pathIndex][cameraWaypoint]; - func_802ADDC8(&cameras[cameraId].unk_54, 10.0f, (f32) temp_v0->posX, (f32) temp_v0->posY + 30.0f, (f32) temp_v0->posZ); + check_bounding_collision(&cameras[cameraId].collision, 10.0f, (f32) temp_v0->posX, (f32) temp_v0->posY + 30.0f, (f32) temp_v0->posZ); } void func_80014DE4(s32 arg0) { @@ -5509,7 +5525,7 @@ void func_80015390(Camera *camera, UNUSED Player *player, UNUSED s32 arg2) { adjust_angle(&camera->unk_2C, temp_s1->rotation[1], var_a2); } func_8001D794(temp_s1, camera, sp64, &sp84, &sp80, &sp7C, camera->unk_2C); - func_802ADDC8(&camera->unk_54, 10.0f, sp84, sp80, sp7C); + check_bounding_collision(&camera->collision, 10.0f, sp84, sp80, sp7C); camera->lookAt[0] = sp64[0]; camera->lookAt[1] = sp64[1]; camera->lookAt[2] = sp64[2]; @@ -5543,7 +5559,7 @@ void func_80015544(s32 playerId, f32 arg1, s32 cameraId, s32 pathIndex) { temp_f2 = (f32) D_80164550[pathIndex][gNearestWaypointByCameraId[cameraId]].posY; - temp_f12 = func_802AE1C0(D_80162FA0[0], (f32) (temp_f2 + 30.0), D_80162FA0[2]); + temp_f12 = spawn_actor_on_surface(D_80162FA0[0], (f32) (temp_f2 + 30.0), D_80162FA0[2]); if ((temp_f12 < (temp_f2 - 20.0)) || (temp_f12 >= 3000.0)) { D_80164618[cameraId] = (f32) (temp_f2 + 10.0); } else { @@ -5694,7 +5710,7 @@ void func_80015C94(Camera *camera, UNUSED Player *unusedPlayer, UNUSED s32 arg2, } camera->pos[0] = midX; camera->pos[2] = midZ; - temp_f2_2 = func_802AE1C0(midX, (midY + 30.0), midZ); + temp_f2_2 = spawn_actor_on_surface(midX, (midY + 30.0), midZ); if ((temp_f2_2 < (midY - 20.0)) || (temp_f2_2 >= 3000.0)) { camera->pos[1] = midY + 10.0; } else { @@ -5820,7 +5836,7 @@ void func_80016494(Camera *camera, UNUSED Player *unusedPlayer, UNUSED s32 arg2, } camera->pos[0] = midX; camera->pos[2] = midZ; - temp_f2_5 = func_802AE1C0(midX, midY + 30.0, midZ); + temp_f2_5 = spawn_actor_on_surface(midX, midY + 30.0, midZ); if ((temp_f2_5 < (midY - 20.0)) || (temp_f2_5 >= 3000.0)) { camera->pos[1] = midY + 10.0; } else { @@ -6340,7 +6356,7 @@ void func_800188F4(Camera *camera, UNUSED Player *unusePlayer, UNUSED s32 arg2, } camera->pos[0] = midX; camera->pos[2] = midZ; - temp_f2_4 = func_802AE1C0(midX, midY + 30.0, midZ); + temp_f2_4 = spawn_actor_on_surface(midX, midY + 30.0, midZ); if ((temp_f2_4 < (midY - 20.0)) || (temp_f2_4 >= 3000.0)) { camera->pos[1] = midY + 10.0; } else { @@ -6377,7 +6393,7 @@ void func_80019118(s32 playerId, f32 arg1, s32 cameraId, UNUSED s16 pathIndex) { D_80164638[cameraId] = D_80162FA0[2]; temp_f2 = (f32) D_80164550[0][gNearestWaypointByCameraId[cameraId]].posY; - temp_f12 = func_802AE1C0(D_80162FA0[0], (f32) (temp_f2 + 30.0), D_80162FA0[2]); + temp_f12 = spawn_actor_on_surface(D_80162FA0[0], (f32) (temp_f2 + 30.0), D_80162FA0[2]); if ((temp_f12 < (temp_f2 - 20.0)) || (temp_f12 >= 3000.0)) { D_80164618[cameraId] = (f32) (temp_f2 + 10.0); @@ -7080,7 +7096,7 @@ void kart_ai_use_item_strategy(s32 playerId) { banana->velocity[1] = 0.0f; banana->velocity[2] = 0.0f; if (D_801631E0[playerId] == ((u16) 1)) { - banana->pos[1] = func_802AE1C0(player->pos[0], (f32) (((f64) player->pos[1]) + 30.0), player->pos[2]) + (banana->boundingBoxSize + 1.0f); + banana->pos[1] = spawn_actor_on_surface(player->pos[0], (f32) (((f64) player->pos[1]) + 30.0), player->pos[2]) + (banana->boundingBoxSize + 1.0f); } } player->soundEffects &= ~0x00040000; @@ -7136,7 +7152,7 @@ void kart_ai_use_item_strategy(s32 playerId) { banana->velocity[0] = 0.0f; banana->velocity[1] = 0.0f; banana->velocity[2] = 0.0f; - banana->pos[1] = func_802AE1C0(banana->pos[0], (f32) (((f64) banana->pos[1]) + 30.0), banana->pos[2]) + (banana->boundingBoxSize + 1.0f); + banana->pos[1] = spawn_actor_on_surface(banana->pos[0], (f32) (((f64) banana->pos[1]) + 30.0), banana->pos[2]) + (banana->boundingBoxSize + 1.0f); } player->soundEffects &= ~0x00040000; temp_s0->unk_00 = 0; @@ -7344,7 +7360,7 @@ void kart_ai_use_item_strategy(s32 playerId) { } else { func_802A1064(fakeItemBox); if (D_801631E0[playerId] == 1) { - fakeItemBox->pos[1] = func_802AE1C0(fakeItemBox->pos[0], fakeItemBox->pos[1] + 30.0, fakeItemBox->pos[2]) + fakeItemBox->boundingBoxSize; + fakeItemBox->pos[1] = spawn_actor_on_surface(fakeItemBox->pos[0], fakeItemBox->pos[1] + 30.0, fakeItemBox->pos[2]) + fakeItemBox->boundingBoxSize; } } temp_s0->unk_00 = 0; @@ -7480,7 +7496,7 @@ void func_8001BE78(void) { } temp_s0 = &D_80164550[i][gNearestWaypointByPlayerId[i]]; temp_s1->pos[0] = (f32) temp_s0->posX; - temp_s1->pos[1] = func_802AE1C0((f32) temp_s0->posX, 2000.0f, (f32) temp_s0->posZ) + temp_s1->boundingBoxSize; + temp_s1->pos[1] = spawn_actor_on_surface((f32) temp_s0->posX, 2000.0f, (f32) temp_s0->posZ) + temp_s1->boundingBoxSize; temp_s1->pos[2] = (f32) temp_s0->posZ; temp_s1->rotation[1] = (s16) *D_80164590[i]; func_8003680C(temp_s1, 0); diff --git a/src/code_80005FD0.h b/src/code_80005FD0.h index a3d57cbe3..09eafbb34 100644 --- a/src/code_80005FD0.h +++ b/src/code_80005FD0.h @@ -63,7 +63,7 @@ s16 func_80005FD0(Vec3f, Vec3f); s32 func_80006018(f32, f32, f32, f32, f32, f32, f32, f32); void func_80006114(Vec3f, Vec3f, s16); -s32 func_800061DC(Vec3f, f32, s32); +s32 set_vehicle_render_distance_flags(Vec3f, f32, s32); void func_800065D0(s32, Player*); void set_places(void); @@ -163,7 +163,7 @@ void update_vehicle_trains(void); void func_80012DC0(s32, Player*); void func_80013054(void); -void func_800131DC(s32); +void check_ai_crossing_distance(s32); void func_800132F4(void); void update_vehicle_paddle_boats(void); void func_80013854(Player*); @@ -352,7 +352,7 @@ extern s16 D_8016348C; extern s16 D_80163490[]; extern s16 D_801634A8[]; extern s16 D_801634C0[]; -extern s16 D_801634D8[]; +extern s16 bStopAICrossing[]; extern s16 D_801634EC; extern s32 D_801634F0; extern s32 D_801634F4; @@ -360,7 +360,7 @@ extern Test D_801634F8[]; extern PathNoY *D_80163598; extern s32 D_8016359C; extern u16 isCrossingTriggeredByIndex[]; -extern u16 D_801637BC[]; +extern u16 sCrossingActiveTimer[]; extern s32 D_80163DD8[]; extern struct unexpiredActors gUnexpiredActorsList[]; extern D_801642D8_entry D_801642D8[]; diff --git a/src/code_8003DC40.c b/src/code_8003DC40.c index 3de5b0add..bf8f43dda 100644 --- a/src/code_8003DC40.c +++ b/src/code_8003DC40.c @@ -18,14 +18,14 @@ UNUSED void func_8003DC50(Player *player, Vec3f arg1) { // Praise Fake Match!! if(player){}; if (player->unk_230 <= player->unk_23C) { - if (player->unk_110.unk48[1] >= 0.1736) { + if (player->collision.unk48[1] >= 0.1736) { arg1[0] = (player->unk_206 / 182) * 0x78; arg1[2] = -(player->slopeAccel / 182) * 0x78; } else { arg1[0] = thing1; arg1[2] = thing2; } - } else if (player->unk_110.unk48[1] >= 0.1736) { + } else if (player->collision.unk48[1] >= 0.1736) { arg1[0] = (player->unk_206 / 182) * 0x78; arg1[2] = -(player->slopeAccel / 182) * 0x78; } else { @@ -42,14 +42,14 @@ UNUSED void func_8003DE4C(Player *player, Vec3f arg1) { // Praise Fake Match!! if(player){}; if (player->unk_230 <= player->unk_23C) { - if (player->unk_110.unk54[1] >= 0.1736) { + if (player->collision.unk54[1] >= 0.1736) { arg1[0] = (player->unk_206 / 182) * 0x78; arg1[2] = -(player->slopeAccel / 182) * 0x78; } else { arg1[0] = thing1; arg1[2] = thing2; } - } else if (player->unk_110.unk54[1] >= 0.1736) { + } else if (player->collision.unk54[1] >= 0.1736) { arg1[0] = (player->unk_206 / 182) * 0x78; arg1[2] = -(player->slopeAccel / 182) * 0x78; } else { @@ -61,14 +61,14 @@ UNUSED void func_8003DE4C(Player *player, Vec3f arg1) { } // Stick to ground? void func_8003E048(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4, f32 *arg5, f32 *arg6, f32 *arg7) { - *arg5 += arg1[0] * player->unk_110.unk3C[2] * 1; - *arg6 += arg1[1] * player->unk_110.unk3C[2] * 0.1; - *arg7 += arg1[2] * player->unk_110.unk3C[2] * 1; + *arg5 += arg1[0] * player->collision.surfaceDistance[2] * 1; + *arg6 += arg1[1] * player->collision.surfaceDistance[2] * 0.1; + *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 1, 2); - if (player->unk_110.orientationVector[1] <= 0.8829f) { + if (player->collision.orientationVector[1] <= 0.8829f) { arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - func_80031F48(player, 4.0f); + decelerate_ai_player(player, 4.0f); player->unk_DAC = 0.5f; if ((player->effects & BOOST_EFFECT) != 0) { remove_boost_effect(player); @@ -87,15 +87,15 @@ void func_8003E048(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4 } void func_8003E37C(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4, f32 *arg5, f32 *arg6, f32 *arg7) { - *arg5 += arg1[0] * player->unk_110.unk3C[2] * 1; - *arg6 += arg1[1] * player->unk_110.unk3C[2] * 0.2; - *arg7 += arg1[2] * player->unk_110.unk3C[2] * 1; + *arg5 += arg1[0] * player->collision.surfaceDistance[2] * 1; + *arg6 += arg1[1] * player->collision.surfaceDistance[2] * 0.2; + *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 0.5f, 2); - if ((player->unk_110.orientationVector[1] <= 0.7318f) || (player->surfaceType == CLIFF)) { + if ((player->collision.orientationVector[1] <= 0.7318f) || (player->surfaceType == CLIFF)) { arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); if (((player->unk_094 / 18.0f) * 216.0f) >= 8.0f) { - func_80031F48(player, 5.0f); + decelerate_ai_player(player, 5.0f); } player->unk_DAC = 0.5f; if ((player->effects & BOOST_EFFECT) != 0) { @@ -115,14 +115,14 @@ void func_8003E37C(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4 } void func_8003E6EC(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4, f32 *arg5, f32 *arg6, f32 *arg7) { - *arg5 += arg1[0] * player->unk_110.unk3C[2] * 1; - *arg6 += arg1[1] * player->unk_110.unk3C[2] * 0.1; - *arg7 += arg1[2] * player->unk_110.unk3C[2] * 1; + *arg5 += arg1[0] * player->collision.surfaceDistance[2] * 1; + *arg6 += arg1[1] * player->collision.surfaceDistance[2] * 0.1; + *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 0.5f, 2); - if (player->unk_110.orientationVector[1] <= 0.8829f) { + if (player->collision.orientationVector[1] <= 0.8829f) { arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - func_80031F48(player, 4.0f); + decelerate_ai_player(player, 4.0f); func_8003DC40(player); } else if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { arg3[0] = ((player->unk_206 / 182) * 0x32); @@ -136,18 +136,18 @@ void func_8003E6EC(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4 } void func_8003E9EC(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4, f32 *arg5, f32 *arg6, f32 *arg7) { - *arg5 += arg1[0] * player->unk_110.unk3C[2] * 1; - *arg6 += arg1[1] * player->unk_110.unk3C[2] * 0.1; - *arg7 += arg1[2] * player->unk_110.unk3C[2] * 1; + *arg5 += arg1[0] * player->collision.surfaceDistance[2] * 1; + *arg6 += arg1[1] * player->collision.surfaceDistance[2] * 0.1; + *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 1.2f, 2); - if (player->unk_110.orientationVector[1] <= 0.8357f) { + if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0x78); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - func_80031F48(player, 4.0f); + decelerate_ai_player(player, 4.0f); func_8003DC40(player); } else { if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { - if ((player->boundingBoxCorners[2].surfaceType == ASPHALT) || (player->boundingBoxCorners[3].surfaceType == ASPHALT) || (player->boundingBoxCorners[1].surfaceType == ASPHALT) || (player->boundingBoxCorners[0].surfaceType == ASPHALT)) { + if ((player->tyres[BACK_LEFT].surfaceType == ASPHALT) || (player->tyres[BACK_RIGHT].surfaceType == ASPHALT) || (player->tyres[FRONT_RIGHT].surfaceType == ASPHALT) || (player->tyres[FRONT_LEFT].surfaceType == ASPHALT)) { arg3[0] = ((player->unk_206 / 182) * 5); } else { arg3[0] = ((player->unk_206 / 182) * 0x28); @@ -167,14 +167,14 @@ void func_8003E9EC(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4 } void func_8003EE2C(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4, f32 *arg5, f32 *arg6, f32 *arg7) { - *arg5 += arg1[0] * player->unk_110.unk3C[2] * 1; - *arg6 += arg1[1] * player->unk_110.unk3C[2] * 0.1; - *arg7 += arg1[2] * player->unk_110.unk3C[2] * 1; + *arg5 += arg1[0] * player->collision.surfaceDistance[2] * 1; + *arg6 += arg1[1] * player->collision.surfaceDistance[2] * 0.1; + *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 0.5f, 2); - if (player->unk_110.orientationVector[1] <= 0.8357f) { + if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0x78); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - func_80031F48(player, 4.0f); + decelerate_ai_player(player, 4.0f); func_8003DC40(player); } else if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { arg3[0] = ((player->unk_206 / 182) * 0x32); @@ -188,17 +188,17 @@ void func_8003EE2C(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4 } void func_8003F138(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4, f32 *arg5, f32 *arg6, f32 *arg7) { - *arg5 += arg1[0] * player->unk_110.unk3C[2] * 1; - *arg6 += arg1[1] * player->unk_110.unk3C[2] * 0.1; - *arg7 += arg1[2] * player->unk_110.unk3C[2] * 1; + *arg5 += arg1[0] * player->collision.surfaceDistance[2] * 1; + *arg6 += arg1[1] * player->collision.surfaceDistance[2] * 0.1; + *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 0.5f, 2); if (player->surfaceType == GRASS) { player->unk_044 &= ~1; } - if (player->unk_110.orientationVector[1] <= 0.8357f) { + if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0xC8); arg3[2] = (-(player->slopeAccel / 182) * 0xC8); - func_80031F48(player, 4.0f); + decelerate_ai_player(player, 4.0f); player->unk_DAC = 0.5f; arg3[0] = 0; } else if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { @@ -215,13 +215,13 @@ void func_8003F138(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4 } void func_8003F46C(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 *arg4, f32 *arg5, f32 *arg6, f32 *arg7) { - arg1[0] = -player->unk_110.orientationVector[0]; - arg1[1] = -player->unk_110.orientationVector[1]; - arg1[2] = -player->unk_110.orientationVector[2]; - if ((player->unk_110.orientationVector[1] < 0.0f) && ((player->unk_0CA & 2) == 0)) { - *arg5 += arg1[0] * player->unk_110.unk3C[2] * 1; - *arg6 += arg1[1] * player->unk_110.unk3C[2] * 1; - *arg7 += arg1[2] * player->unk_110.unk3C[2] * 1; + arg1[0] = -player->collision.orientationVector[0]; + arg1[1] = -player->collision.orientationVector[1]; + arg1[2] = -player->collision.orientationVector[2]; + if ((player->collision.orientationVector[1] < 0.0f) && ((player->unk_0CA & 2) == 0)) { + *arg5 += arg1[0] * player->collision.surfaceDistance[2] * 1; + *arg6 += arg1[1] * player->collision.surfaceDistance[2] * 1; + *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 1.2f, 0.0f); player->kartHopJerk = 0.0f; player->kartHopAcceleration = 0.0f; @@ -263,43 +263,43 @@ void func_8003F734(Player *player, Vec3f arg1, Vec3f arg2, f32 *arg3, f32 *arg4, f32 temp_f14; f32 temp_f0_2; - arg1[0] = -player->unk_110.unk48[0]; - arg1[1] = -player->unk_110.unk48[1]; - arg1[2] = -player->unk_110.unk48[2]; - if (player->unk_110.unk48[1] == 0) { - *arg4 += arg1[0] * player->unk_110.unk3C[0] * 1; - *arg5 += arg1[1] * player->unk_110.unk3C[0] * 0.1; - *arg6 += arg1[2] * player->unk_110.unk3C[0] * 1; + arg1[0] = -player->collision.unk48[0]; + arg1[1] = -player->collision.unk48[1]; + arg1[2] = -player->collision.unk48[2]; + if (player->collision.unk48[1] == 0) { + *arg4 += arg1[0] * player->collision.surfaceDistance[0] * 1; + *arg5 += arg1[1] * player->collision.surfaceDistance[0] * 0.1; + *arg6 += arg1[2] * player->collision.surfaceDistance[0] * 1; if ((player->slopeAccel < 0) && (((player->unk_094 / 18.0f) * 216.0f) < 10.0f)) { func_8002A5F4(arg1, *arg3, arg2, 2.5f, 0); } else { func_8002A5F4(arg1, *arg3, arg2, 0.5f, 0); } - } else if (player->unk_110.unk48[1] <= 0.5) { - *arg4 += arg1[0] * player->unk_110.unk3C[0] * 1; - *arg5 += arg1[1] * player->unk_110.unk3C[0] * 0.1; - *arg6 += arg1[2] * player->unk_110.unk3C[0] * 1; + } else if (player->collision.unk48[1] <= 0.5) { + *arg4 += arg1[0] * player->collision.surfaceDistance[0] * 1; + *arg5 += arg1[1] * player->collision.surfaceDistance[0] * 0.1; + *arg6 += arg1[2] * player->collision.surfaceDistance[0] * 1; func_8002A5F4(arg1, *arg3, arg2, 1, 0); if ((!(player->effects & 0x10000)) && ((player->effects & 8) == 0)) { arg2[1] *= -1e-05; } } else { - *arg4 += arg1[0] * player->unk_110.unk3C[0] * 1; - temp_f0_2 = player->unk_110.unk3C[0] * arg1[1]; + *arg4 += arg1[0] * player->collision.surfaceDistance[0] * 1; + temp_f0_2 = player->collision.surfaceDistance[0] * arg1[1]; if (temp_f0_2 < 0) { *arg5 += temp_f0_2 * 0.1; } else { *arg5 += temp_f0_2 * 0; } - *arg6 += arg1[2] * player->unk_110.unk3C[0] * 1; + *arg6 += arg1[2] * player->collision.surfaceDistance[0] * 1; func_8002A5F4(arg1, *arg3, arg2, 1.2f, 0); if ((!(player->effects & 0x10000)) && ((player->effects & 8) == 0)) { arg2[1] *= -1e-05; } } player->effects &= ~0x10; - temp_f12 = player->unk_110.unk3C[0] * arg1[0]; - temp_f14 = player->unk_110.unk3C[0] * arg1[2]; + temp_f12 = player->collision.surfaceDistance[0] * arg1[0]; + temp_f14 = player->collision.surfaceDistance[0] * arg1[2]; if (((temp_f12 >= 0) && (temp_f14 >= 0)) || ((temp_f12 < 0) && (temp_f14 >= 0))) { temp_f0_2 = player->boundingBoxSize / 2; player->unk_218 = *arg4 - temp_f12 - temp_f0_2; @@ -317,43 +317,43 @@ void func_8003FBAC(Player *player, Vec3f arg1, Vec3f arg2, f32 *arg3, f32 *arg4, f32 temp_f12; f32 temp_f14; - arg1[0] = -player->unk_110.unk54[0]; - arg1[1] = -player->unk_110.unk54[1]; - arg1[2] = -player->unk_110.unk54[2]; - if (player->unk_110.unk54[1] == 0) { - *arg4 += arg1[0] * player->unk_110.unk3C[1] * 1; - *arg5 += arg1[1] * player->unk_110.unk3C[1] * 0.1; - *arg6 += arg1[2] * player->unk_110.unk3C[1] * 1; + arg1[0] = -player->collision.unk54[0]; + arg1[1] = -player->collision.unk54[1]; + arg1[2] = -player->collision.unk54[2]; + if (player->collision.unk54[1] == 0) { + *arg4 += arg1[0] * player->collision.surfaceDistance[1] * 1; + *arg5 += arg1[1] * player->collision.surfaceDistance[1] * 0.1; + *arg6 += arg1[2] * player->collision.surfaceDistance[1] * 1; if ((player->slopeAccel < 0) && (((player->unk_094 / 18.0f) * 216.0f) < 10.0f)) { func_8002A5F4(arg1, *arg3, arg2, 1.5f, 0); } else { func_8002A5F4(arg1, *arg3, arg2, 0.5f, 0); } - } else if (player->unk_110.unk54[1] <= 0.5) { - *arg4 += arg1[0] * player->unk_110.unk3C[1] * 1; - *arg5 += arg1[1] * player->unk_110.unk3C[1] * 0.1; - *arg6 += arg1[2] * player->unk_110.unk3C[1] * 1; + } else if (player->collision.unk54[1] <= 0.5) { + *arg4 += arg1[0] * player->collision.surfaceDistance[1] * 1; + *arg5 += arg1[1] * player->collision.surfaceDistance[1] * 0.1; + *arg6 += arg1[2] * player->collision.surfaceDistance[1] * 1; func_8002A5F4(arg1, *arg3, arg2, 1, 0); if ((!(player->effects & 0x10000)) && ((player->effects & 8) == 0)) { arg2[1] *= -1e-05; } } else { - *arg4 += arg1[0] * player->unk_110.unk3C[1] * 1; - temp_f0_2 = player->unk_110.unk3C[1] * arg1[1]; + *arg4 += arg1[0] * player->collision.surfaceDistance[1] * 1; + temp_f0_2 = player->collision.surfaceDistance[1] * arg1[1]; if (temp_f0_2 < 0) { *arg5 += temp_f0_2 * 0.1; } else { *arg5 += temp_f0_2 * 0; } - *arg6 += arg1[2] * player->unk_110.unk3C[1] * 1; + *arg6 += arg1[2] * player->collision.surfaceDistance[1] * 1; func_8002A5F4(arg1, *arg3, arg2, 1.2f, 0); if ((!(player->effects & 0x10000)) && ((player->effects & 8) == 0)) { arg2[1] *= -1e-05; } } player->effects &= ~0x10; - temp_f12 = player->unk_110.unk3C[1] * arg1[0]; - temp_f14 = player->unk_110.unk3C[1] * arg1[2]; + temp_f12 = player->collision.surfaceDistance[1] * arg1[0]; + temp_f14 = player->collision.surfaceDistance[1] * arg1[2]; if (((temp_f12 >= 0) && (temp_f14 >= 0)) || ((temp_f12 >= 0) && (temp_f14 < 0))) { temp_f0_2 = player->boundingBoxSize / 2; player->unk_218 = *arg4 - temp_f12 - temp_f0_2; diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 39ab768a7..8fe7e26cc 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -224,7 +224,7 @@ UNUSED s32 D_80165910[96]; s8 D_80165A90; UNUSED s32 D_80165AA0[95]; UNUSED s32 D_80165C14; -Objects gObjectList[OBJECT_LIST_SIZE]; +Object gObjectList[OBJECT_LIST_SIZE]; UNUSED s32 D_80183D58; s32 objectListSize; Mtx D_80183D60; @@ -2848,9 +2848,9 @@ void func_8005D898(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN s32 temp_lo; if (player->unk_0C0 >= 0) { - func_8005D794(player, &player->unk_258[10 + arg1], player->boundingBoxCorners[2].cornerPos[0], player->boundingBoxCorners[2].cornerGroundY + 2.0f, player->boundingBoxCorners[2].cornerPos[2], player->boundingBoxCorners[2].surfaceType, 1); + func_8005D794(player, &player->unk_258[10 + arg1], player->tyres[BACK_LEFT].pos[0], player->tyres[BACK_LEFT].baseHeight + 2.0f, player->tyres[BACK_LEFT].pos[2], player->tyres[BACK_LEFT].surfaceType, 1); } else { - func_8005D794(player, &player->unk_258[10 + arg1], player->boundingBoxCorners[3].cornerPos[0], player->boundingBoxCorners[3].cornerGroundY + 2.0f, player->boundingBoxCorners[3].cornerPos[2], player->boundingBoxCorners[3].surfaceType, 0); + func_8005D794(player, &player->unk_258[10 + arg1], player->tyres[BACK_RIGHT].pos[0], player->tyres[BACK_RIGHT].baseHeight + 2.0f, player->tyres[BACK_RIGHT].pos[2], player->tyres[BACK_RIGHT].surfaceType, 0); } temp_lo = player->unk_0C0 / 182; @@ -2910,18 +2910,18 @@ void func_8005DAF4(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 surfaceType = 0x000000FF; temp_v0 = random_int(test); if ((temp_v0 == 0) || (temp_v0 == 4)) { - var_f2 = player->boundingBoxCorners[2].cornerPos[0]; - var_f12 = player->boundingBoxCorners[2].cornerGroundY + 2.0f; - var_f14 = player->boundingBoxCorners[2].cornerPos[2]; + var_f2 = player->tyres[BACK_LEFT].pos[0]; + var_f12 = player->tyres[BACK_LEFT].baseHeight + 2.0f; + var_f14 = player->tyres[BACK_LEFT].pos[2]; var_t3 = 1; - surfaceType = player->boundingBoxCorners[2].surfaceType; + surfaceType = player->tyres[BACK_LEFT].surfaceType; } if ((temp_v0 == 2) || (temp_v0 == 6)) { - var_f2 = player->boundingBoxCorners[3].cornerPos[0]; - var_f12 = player->boundingBoxCorners[3].cornerGroundY + 2.0f; - var_f14 = player->boundingBoxCorners[3].cornerPos[2]; + var_f2 = player->tyres[BACK_RIGHT].pos[0]; + var_f12 = player->tyres[BACK_RIGHT].baseHeight + 2.0f; + var_f14 = player->tyres[BACK_RIGHT].pos[2]; var_t3 = 0; - surfaceType = player->boundingBoxCorners[3].surfaceType; + surfaceType = player->tyres[BACK_RIGHT].surfaceType; } switch (surfaceType) { case DIRT: @@ -3104,19 +3104,19 @@ void func_8005EA94(Player *player, s16 arg1, s32 arg2, s8 arg3, UNUSED s8 arg4) var_t0 = 0x000000FF; temp_v0 = random_int(test); if ((temp_v0 == 0) || (temp_v0 == 8)) { - if ((D_801652A0[arg3] - player->boundingBoxCorners[2].cornerGroundY) >= 3.5) { - var_f2 = player->boundingBoxCorners[2].cornerPos[0]; - var_f12 = player->boundingBoxCorners[2].cornerGroundY + 2.0f; - var_f14 = player->boundingBoxCorners[2].cornerPos[2]; + if ((D_801652A0[arg3] - player->tyres[BACK_LEFT].baseHeight) >= 3.5) { + var_f2 = player->tyres[BACK_LEFT].pos[0]; + var_f12 = player->tyres[BACK_LEFT].baseHeight + 2.0f; + var_f14 = player->tyres[BACK_LEFT].pos[2]; var_t1 = 1; var_t0 = 0; } } if ((temp_v0 == 2) || (temp_v0 == 6)) { - if ((D_801652A0[arg3] - player->boundingBoxCorners[3].cornerGroundY) >= 3.5) { - var_f2 = player->boundingBoxCorners[3].cornerPos[0]; - var_f12 = player->boundingBoxCorners[3].cornerGroundY + 2.0f; - var_f14 = player->boundingBoxCorners[3].cornerPos[2]; + if ((D_801652A0[arg3] - player->tyres[BACK_RIGHT].baseHeight) >= 3.5) { + var_f2 = player->tyres[BACK_RIGHT].pos[0]; + var_f12 = player->tyres[BACK_RIGHT].baseHeight + 2.0f; + var_f14 = player->tyres[BACK_RIGHT].pos[2]; var_t1 = 0; var_t0 = 0; } @@ -3149,18 +3149,18 @@ void func_8005ED48(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 surfaceType = 0x000000FF; temp_v0 = random_int(test); if ((temp_v0 == 2) || (temp_v0 == 4)) { - var_f0 = player->boundingBoxCorners[2].cornerPos[0]; - var_f2 = player->boundingBoxCorners[2].cornerGroundY + 2.0f; - var_f12 = player->boundingBoxCorners[2].cornerPos[2]; + var_f0 = player->tyres[BACK_LEFT].pos[0]; + var_f2 = player->tyres[BACK_LEFT].baseHeight + 2.0f; + var_f12 = player->tyres[BACK_LEFT].pos[2]; var_t3 = 1; - surfaceType = player->boundingBoxCorners[2].surfaceType; + surfaceType = player->tyres[BACK_LEFT].surfaceType; } if ((temp_v0 == 0) || (temp_v0 == 6)) { - var_f0 = player->boundingBoxCorners[3].cornerPos[0]; - var_f2 = player->boundingBoxCorners[3].cornerGroundY + 2.0f; - var_f12 = player->boundingBoxCorners[3].cornerPos[2]; + var_f0 = player->tyres[BACK_RIGHT].pos[0]; + var_f2 = player->tyres[BACK_RIGHT].baseHeight + 2.0f; + var_f12 = player->tyres[BACK_RIGHT].pos[2]; var_t3 = 0; - surfaceType = player->boundingBoxCorners[3].surfaceType; + surfaceType = player->tyres[BACK_RIGHT].surfaceType; } switch (surfaceType) { case DIRT: @@ -3332,12 +3332,12 @@ void func_8005F90C(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 var_f2 = player->pos[1] - player->boundingBoxSize; var_f12 = player->pos[2]; var_t1 = 1; - surfaceType = player->boundingBoxCorners[2].surfaceType; + surfaceType = player->tyres[BACK_LEFT].surfaceType; } else { var_f0 = player->pos[0]; var_f2 = player->pos[1] - player->boundingBoxSize; var_f12 = player->pos[2]; - surfaceType = player->boundingBoxCorners[3].surfaceType; + surfaceType = player->tyres[BACK_RIGHT].surfaceType; } switch (surfaceType) { case DIRT: @@ -4279,11 +4279,11 @@ void func_80063268(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_80063408(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (player->unk_258[10 + arg1].unk_010 == 1) { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + (player->unk_258[10 + arg1].unk_01E * -7) * coss(player->unk_258[10 + arg1].unk_020); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + (player->unk_258[10 + arg1].unk_01E * -7) * sins(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + (player->unk_258[10 + arg1].unk_01E * -7) * coss(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + (player->unk_258[10 + arg1].unk_01E * -7) * sins(player->unk_258[10 + arg1].unk_020); } else { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + (player->unk_258[10 + arg1].unk_01E * -7) * coss(player->unk_258[10 + arg1].unk_020); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + (player->unk_258[10 + arg1].unk_01E * -7) * sins(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + (player->unk_258[10 + arg1].unk_01E * -7) * coss(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + (player->unk_258[10 + arg1].unk_01E * -7) * sins(player->unk_258[10 + arg1].unk_020); } ++player->unk_258[10 + arg1].unk_01E; @@ -4318,19 +4318,19 @@ void func_800635D4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (player->unk_258[10 + arg1].unk_010 == 1) { if ((player->effects & LIGHTNING_EFFECT)) { func_80062B18(&sp44, &sp40, &sp3C, -2.0f, 0.0f, (-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16, -player->unk_258[10 + arg1].unk_020, 2 * -player->unk_206); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + sp44; - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + sp3C; + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + sp44; + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + sp3C; } else { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * coss(player->unk_258[10 + arg1].unk_020); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * sins(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * coss(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * sins(player->unk_258[10 + arg1].unk_020); } } else if ((player->effects & LIGHTNING_EFFECT)) { func_80062B18(&sp44, &sp40, &sp3C, 2.0f, 0.0f, (-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16, - player->unk_258[10 + arg1].unk_020, 2 * -player->unk_206); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + sp44; - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + sp3C; + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + sp44; + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + sp3C; } else { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * coss(player->unk_258[10 + arg1].unk_020); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * sins(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * coss(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * sins(player->unk_258[10 + arg1].unk_020); } ++player->unk_258[10 + arg1].unk_01E; @@ -4366,11 +4366,11 @@ void func_800635D4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_800639DC(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (player->unk_258[10 + arg1].unk_010 == 1) { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * coss(player->unk_258[10 + arg1].unk_020); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * sins(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * coss(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * sins(player->unk_258[10 + arg1].unk_020); } else { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * coss(player->unk_258[10 + arg1].unk_020); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * sins(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * coss(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * sins(player->unk_258[10 + arg1].unk_020); } ++player->unk_258[10 + arg1].unk_01E; player->unk_258[10 + arg1].unk_000[1] += 0.3; @@ -4401,11 +4401,11 @@ void func_800639DC(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_80063BD4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (player->unk_258[10 + arg1].unk_010 == 1) { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + (-2 * player->unk_258[10 + arg1].unk_01E * coss(player->unk_258[10 + arg1].unk_020)); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + (-2 * player->unk_258[10 + arg1].unk_01E * sins(player->unk_258[10 + arg1].unk_020)); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + (-2 * player->unk_258[10 + arg1].unk_01E * coss(player->unk_258[10 + arg1].unk_020)); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + (-2 * player->unk_258[10 + arg1].unk_01E * sins(player->unk_258[10 + arg1].unk_020)); } else { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + (-2 * player->unk_258[10 + arg1].unk_01E * coss(player->unk_258[10 + arg1].unk_020)); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + (-2 * player->unk_258[10 + arg1].unk_01E * sins(player->unk_258[10 + arg1].unk_020)); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + (-2 * player->unk_258[10 + arg1].unk_01E * coss(player->unk_258[10 + arg1].unk_020)); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + (-2 * player->unk_258[10 + arg1].unk_01E * sins(player->unk_258[10 + arg1].unk_020)); } ++player->unk_258[10 + arg1].unk_01E; @@ -4422,11 +4422,11 @@ void func_80063BD4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_80063D58(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (player->unk_258[10 + arg1].unk_010 == 1) { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(player->unk_258[10 + arg1].unk_020); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(player->unk_258[10 + arg1].unk_020); } else { - player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(player->unk_258[10 + arg1].unk_020); - player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(player->unk_258[10 + arg1].unk_020); + player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(player->unk_258[10 + arg1].unk_020); } ++player->unk_258[10 + arg1].unk_01E; @@ -5106,14 +5106,14 @@ void func_80066BAC(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) { UNUSED s32 stackPadding; if ((player->unk_258[arg2].unk_01C == 1) && (player->unk_258[arg2].unk_038 != 0x00FF)) { - if (player->unk_110.unk3C[2] >= 300.0f) { + if (player->collision.surfaceDistance[2] >= 300.0f) { spDC[1] = player->pos[1] + 5.0f; } else { spDC[1] = player->pos[1] - 3.0f; } spDC[2] = player->pos[2] + (coss(player->unk_048[arg3]) * -10.0f); spDC[0] = player->pos[0] + (sins(player->unk_048[arg3]) * -10.0f); - if (player->unk_110.unk3C[2] >= 300.0f) { + if (player->collision.surfaceDistance[2] >= 300.0f) { spD4[0] = cameras[arg3].rot[0] - 0x4000; } else { spD4[0] = 0; @@ -6031,7 +6031,7 @@ void func_8006C6AC(Player *player, s16 arg1, s8 arg2, s8 arg3) { } else if (!(player->effects & 8) && !(player->effects & 2)) { if (((player->effects & 0x10) == 0x10) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { func_8005DA30(player, arg1, sp28, arg2_copy, arg3); - } else if (((f64) (D_801652A0[arg2_copy] - player->boundingBoxCorners[3].cornerGroundY) >= 3.5) || ((f64) (D_801652A0[arg2_copy] - player->boundingBoxCorners[2].cornerGroundY) >= 3.5)) { + } else if (((f64) (D_801652A0[arg2_copy] - player->tyres[BACK_RIGHT].baseHeight) >= 3.5) || ((f64) (D_801652A0[arg2_copy] - player->tyres[BACK_LEFT].baseHeight) >= 3.5)) { func_8005EA94(player, arg1, sp28, arg2_copy, arg3); } else if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40)) { func_8005F90C(player, arg1, sp28, arg2_copy, arg3); diff --git a/src/code_80057C60.h b/src/code_80057C60.h index f8f5eeeeb..1b65497fc 100644 --- a/src/code_80057C60.h +++ b/src/code_80057C60.h @@ -380,7 +380,7 @@ extern s16 D_80165900; extern s8 D_80165908; extern s8 D_80165A90; -// extern Objects gObjectList[]; -> objects.h +// extern Object gObjectList[]; -> objects.h extern s32 objectListSize; extern Mtx D_80183D60; diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 3eb226d95..c07028230 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -104,7 +104,7 @@ void func_8006EB10(void) { } void clear_object_list() { - bzero(gObjectList, OBJECT_LIST_SIZE * sizeof(Objects)); + bzero(gObjectList, OBJECT_LIST_SIZE * sizeof(Object)); objectListSize = -1; } @@ -828,7 +828,7 @@ void init_course_object(void) { objectId = indexObjectList2[i]; init_object(objectId, 0); gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] = gHedgehogSpawns[i].pos[0] * xOrientation; - gObjectList[objectId].pos[1] = gObjectList[objectId].unk_044 = gHedgehogSpawns[i].pos[1] + 6.0; + gObjectList[objectId].pos[1] = gObjectList[objectId].surfaceHeight = gHedgehogSpawns[i].pos[1] + 6.0; gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = gHedgehogSpawns[i].pos[2]; gObjectList[objectId].unk_0D5 = gHedgehogSpawns[i].unk_06; gObjectList[objectId].unk_09C = gHedgehogPatrolPoints[i][0] * xOrientation; diff --git a/src/code_80086E70.c b/src/code_80086E70.c index 0489faa0a..8e7d2bc8a 100644 --- a/src/code_80086E70.c +++ b/src/code_80086E70.c @@ -425,33 +425,33 @@ void func_80088150(s32 arg0) { void func_80088178(s32 objectIndex, s32 arg1) { s16 temp_a1; - Objects *temp_v1; + Object *object; - temp_v1 = &gObjectList[objectIndex]; + object = &gObjectList[objectIndex]; temp_a1 = atan2s(D_80165760[1] - D_80165760[0], D_80165780[1] - D_80165780[0]); - temp_a1 -= temp_v1->direction_angle[1]; + temp_a1 -= object->direction_angle[1]; if (temp_a1 > 0) { - temp_v1->direction_angle[1] += (arg1 << 8); + object->direction_angle[1] += (arg1 << 8); } else if (temp_a1 < 0) { - temp_v1->direction_angle[1] -= (arg1 << 8); + object->direction_angle[1] -= (arg1 << 8); } } // if the code is too ugly for you, then go fix it without tampering with the register allocations void func_80088228(s32 objectIndex) { - Objects *temp_v0; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_084[9] = 0; - temp_v0->controlPoints = temp_v0->spline->controlPoints; + Object *object; + object = &gObjectList[objectIndex]; + object->unk_084[9] = 0; + object->controlPoints = object->spline->controlPoints; /* This is INCREDIBLY stupid. This should really be temp_v0->unk_084[8] = temp_v0->spline->numControlPoints; but for some unholy reason that doesn't match */ - temp_v0->unk_084[8] = *((s16*)temp_v0->controlPoints - 1); - temp_v0->offset[0] = temp_v0->controlPoints[0].pos[0]; - temp_v0->offset[1] = temp_v0->controlPoints[0].pos[1]; - temp_v0->offset[2] = temp_v0->controlPoints[0].pos[2]; + object->unk_084[8] = *((s16*)object->controlPoints - 1); + object->offset[0] = object->controlPoints[0].pos[0]; + object->offset[1] = object->controlPoints[0].pos[1]; + object->offset[2] = object->controlPoints[0].pos[2]; func_80086FD4(objectIndex); } @@ -473,16 +473,16 @@ s32 func_800882B0(s32 objectIndex, s32 arg1) { } void func_80088364(s32 objectIndex) { - Objects *temp_v0; + Object *object; func_800880E4(objectIndex); func_80088178(objectIndex, 1); func_800876A0(objectIndex); if (func_800882B0(objectIndex, 0x0000000A) != 0) { - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_084[9] = (u16) temp_v0->unk_084[9] + 1; - if (((u16)temp_v0->unk_084[9] + 3) == (u16) temp_v0->unk_084[8]) { - temp_v0->unk_0AE += 1; + object = &gObjectList[objectIndex]; + object->unk_084[9] = (u16) object->unk_084[9] + 1; + if (((u16)object->unk_084[9] + 3) == (u16) object->unk_084[8]) { + object->unk_0AE += 1; } else { func_80088150(objectIndex); } @@ -511,12 +511,12 @@ s32 func_8008847C(s32 objectIndex) { sp2C = 0; set_object_flag_status_false(objectIndex, 0x00800000); if (is_obj_flag_status_active(objectIndex, 0x00000400) != 0) { - func_802ADDC8(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); + check_bounding_collision(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); if (D_8018C3B0.unk34 == 1) { sp2C = 1; set_object_flag_status_true(objectIndex, 0x00800000); } - gObjectList[objectIndex].unk_044 = func_802ABE30(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.unk3A); + gObjectList[objectIndex].surfaceHeight = calculate_surface_height(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.meshIndexZX); } return sp2C; } @@ -527,12 +527,12 @@ s32 func_80088538(s32 objectIndex) { sp2C = 0; set_object_flag_status_false(objectIndex, 0x00800000); if (is_obj_flag_status_active(objectIndex, 0x00000400) != 0) { - func_802ADDC8(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); + check_bounding_collision(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); if (D_8018C3B0.unk34 == 1) { sp2C = 1; set_object_flag_status_true(objectIndex, 0x00800000); } - gObjectList[objectIndex].unk_044 = func_802ABE30(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.unk3A); + gObjectList[objectIndex].surfaceHeight = calculate_surface_height(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.meshIndexZX); gObjectList[objectIndex].unk_0B8[0] = atan2s(D_8018C3B0.orientationVector[2], D_8018C3B0.orientationVector[1]) + 0x4000; gObjectList[objectIndex].unk_0B8[2] = atan2s(D_8018C3B0.orientationVector[0], D_8018C3B0.orientationVector[1]); } @@ -545,12 +545,12 @@ s32 func_8008861C(s32 objectIndex) { sp2C = 0; set_object_flag_status_false(objectIndex, 0x00800000); if (is_obj_flag_status_active(objectIndex, 0x00000400) != 0) { - func_802ADDC8(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); + check_bounding_collision(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); if (D_8018C3B0.unk34 == 1) { sp2C = 1; set_object_flag_status_true(objectIndex, 0x00800000); } - gObjectList[objectIndex].unk_044 = func_802ABE30(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.unk3A); + gObjectList[objectIndex].surfaceHeight = calculate_surface_height(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.meshIndexZX); gObjectList[objectIndex].unk_01C[0] = D_8018C3B0.orientationVector[0]; gObjectList[objectIndex].unk_01C[1] = D_8018C3B0.orientationVector[1]; gObjectList[objectIndex].unk_01C[2] = D_8018C3B0.orientationVector[2]; @@ -559,10 +559,10 @@ s32 func_8008861C(s32 objectIndex) { } void func_800886F4(s32 objectIndex) { - func_802ADDC8(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); + check_bounding_collision(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); if (D_8018C3B0.unk34 == 1) { set_object_flag_status_true(objectIndex, 0x00800000); - gObjectList[objectIndex].unk_044 = func_802ABE30(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.unk3A); + gObjectList[objectIndex].surfaceHeight = calculate_surface_height(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.meshIndexZX); gObjectList[objectIndex].unk_0B8[0] = atan2s(D_8018C3B0.orientationVector[2], D_8018C3B0.orientationVector[1]) + 0x4000; gObjectList[objectIndex].unk_0B8[2] = atan2s(D_8018C3B0.orientationVector[0], D_8018C3B0.orientationVector[1]); return; @@ -571,10 +571,10 @@ void func_800886F4(s32 objectIndex) { } void func_800887C0(s32 objectIndex) { - func_802ADDC8(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); + check_bounding_collision(&D_8018C3B0, 10.0f, gObjectList[objectIndex].pos[0], 20.0f, gObjectList[objectIndex].pos[2]); if (D_8018C3B0.unk34 == 1) { set_object_flag_status_true(objectIndex, 0x00800000); - gObjectList[objectIndex].unk_044 = func_802ABE30(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.unk3A); + gObjectList[objectIndex].surfaceHeight = calculate_surface_height(gObjectList[objectIndex].pos[0], 0.0f, gObjectList[objectIndex].pos[2], D_8018C3B0.meshIndexZX); gObjectList[objectIndex].velocity[0] = D_8018C3B0.orientationVector[0]; gObjectList[objectIndex].velocity[1] = D_8018C3B0.orientationVector[1]; gObjectList[objectIndex].velocity[2] = D_8018C3B0.orientationVector[2]; @@ -1005,26 +1005,26 @@ f32 func_8008933C(Player *player, s32 objectIndex, f32 arg2, f32 arg3) { f32 var_f2; f32 something; s32 playerId; - Objects *temp_v0; + Object *object; struct_D_8018CE10 *temp_v1; playerId = player - gPlayerOne; temp_v1 = &D_8018CE10[playerId]; var_f2 = 0.0f; if (temp_v1->unk_18[6] == 0) { - temp_v0 = &gObjectList[objectIndex]; + object = &gObjectList[objectIndex]; player->unk_046 |= 2; player->effects |= 0x8000; temp_v1->unk_18[6] = 4; - something = (player->pos[0] - temp_v0->pos[0]) * temp_v0->velocity[0]; + something = (player->pos[0] - object->pos[0]) * object->velocity[0]; if (something >= 0.0f) { - temp_v1->unk_04[0] = (-player->velocity[0] * arg2) + (temp_v0->velocity[0] * arg3); + temp_v1->unk_04[0] = (-player->velocity[0] * arg2) + (object->velocity[0] * arg3); } else { temp_v1->unk_04[0] = -player->velocity[0] * arg2; } - something = (player->pos[2] - temp_v0->pos[2]) * temp_v0->velocity[2]; + something = (player->pos[2] - object->pos[2]) * object->velocity[2]; if (something >= 0.0f) { - temp_v1->unk_04[2] = (-player->velocity[2] * arg2) + (temp_v0->velocity[2] * arg3); + temp_v1->unk_04[2] = (-player->velocity[2] * arg2) + (object->velocity[2] * arg3); } else { temp_v1->unk_04[2] = -player->velocity[2] * arg2; } @@ -1415,11 +1415,11 @@ UNUSED void func_8008A850(s32 arg0) { } UNUSED s32 func_8008A870(Player *player) { - return func_802ABD40(player->unk_110.unk3A); + return get_section_id(player->collision.meshIndexZX); } s32 func_8008A890(Camera *camera) { - return func_802ABD40(camera->unk_54.unk3A); + return get_section_id(camera->collision.meshIndexZX); } s32 func_8008A8B0(s16 arg0, s16 arg1) { @@ -1447,48 +1447,48 @@ void func_8008A920(s32 objectIndex) { void func_8008A9B8(s32 objectIndex) { UNUSED s32 temp_t9; - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->controlPoints++; - temp_v0->unk_09A = (s16) (10000 / (s16) (temp_v0->controlPoints[0].velocity)); - temp_v0->timer = 0; + object = &gObjectList[objectIndex]; + object->controlPoints++; + object->unk_09A = (s16) (10000 / (s16) (object->controlPoints[0].velocity)); + object->timer = 0; func_8008A920(objectIndex); } void func_8008AA3C(s32 objectIndex) { - Objects *temp_v0; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->controlPoints = temp_v0->spline->controlPoints; - temp_v0->unk_084[9] = 0; - temp_v0->timer = 0; + Object *object; + object = &gObjectList[objectIndex]; + object->controlPoints = object->spline->controlPoints; + object->unk_084[9] = 0; + object->timer = 0; /* This is INCREDIBLY stupid. This should really be temp_v0->unk_084[8] = temp_v0->spline->numControlPoints; but for some unholy reason that doesn't match */ - temp_v0->unk_084[8] = *((s16*)temp_v0->controlPoints - 1); - temp_v0->offset[0] = temp_v0->controlPoints[0].pos[0]; - temp_v0->offset[1] = temp_v0->controlPoints[0].pos[1]; - temp_v0->offset[2] = temp_v0->controlPoints[0].pos[2]; - temp_v0->unk_09A = (s16) (10000 / temp_v0->controlPoints[0].velocity); + object->unk_084[8] = *((s16*)object->controlPoints - 1); + object->offset[0] = object->controlPoints[0].pos[0]; + object->offset[1] = object->controlPoints[0].pos[1]; + object->offset[2] = object->controlPoints[0].pos[2]; + object->unk_09A = (s16) (10000 / object->controlPoints[0].velocity); func_8008A920(objectIndex); func_80086FD4(objectIndex); } void func_8008AB10(s32 objectIndex) { UNUSED s16 temp_t3; - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->offset[0] += temp_v0->velocity[0]; - temp_v0->offset[1] += temp_v0->velocity[1]; - temp_v0->offset[2] += temp_v0->velocity[2]; - temp_v0->timer += (u16)temp_v0->unk_09A; - if (temp_v0->timer >= 0x2710) { - temp_v0->unk_084[9] = (u16)temp_v0->unk_084[9] + 1; - if (((u16)temp_v0->unk_084[9] + 1) == (u16) temp_v0->unk_084[8]) { - temp_v0->unk_0AE += 1; + object = &gObjectList[objectIndex]; + object->offset[0] += object->velocity[0]; + object->offset[1] += object->velocity[1]; + object->offset[2] += object->velocity[2]; + object->timer += (u16)object->unk_09A; + if (object->timer >= 0x2710) { + object->unk_084[9] = (u16)object->unk_084[9] + 1; + if (((u16)object->unk_084[9] + 1) == (u16) object->unk_084[8]) { + object->unk_0AE += 1; } else { func_8008A9B8(objectIndex); } @@ -1577,12 +1577,12 @@ UNUSED void func_8008AE94(void) { // D_80183DC8 is where the spline's derivative polynomial calculations are stored void func_8008AE9C(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->velocity[0] = (D_80183DC8[0] * D_80165760[0]) + (D_80183DC8[1] * D_80165760[1]) + (D_80183DC8[2] * D_80165760[2]) + (D_80183DC8[3] * D_80165760[3]); - temp_v0->velocity[1] = (D_80183DC8[0] * D_80165770[0]) + (D_80183DC8[1] * D_80165770[1]) + (D_80183DC8[2] * D_80165770[2]) + (D_80183DC8[3] * D_80165770[3]); - temp_v0->velocity[2] = (D_80183DC8[0] * D_80165780[0]) + (D_80183DC8[1] * D_80165780[1]) + (D_80183DC8[2] * D_80165780[2]) + (D_80183DC8[3] * D_80165780[3]); + object = &gObjectList[objectIndex]; + object->velocity[0] = (D_80183DC8[0] * D_80165760[0]) + (D_80183DC8[1] * D_80165760[1]) + (D_80183DC8[2] * D_80165760[2]) + (D_80183DC8[3] * D_80165760[3]); + object->velocity[1] = (D_80183DC8[0] * D_80165770[0]) + (D_80183DC8[1] * D_80165770[1]) + (D_80183DC8[2] * D_80165770[2]) + (D_80183DC8[3] * D_80165770[3]); + object->velocity[2] = (D_80183DC8[0] * D_80165780[0]) + (D_80183DC8[1] * D_80165780[1]) + (D_80183DC8[2] * D_80165780[2]) + (D_80183DC8[3] * D_80165780[3]); } void func_8008AFE0(s32 objectIndex, f32 arg1) { @@ -1608,12 +1608,12 @@ UNUSED void func_8008B030(void) { // D_80183DA8 is where the spline's polynomial calculations are stored void func_8008B038(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->offset[0] = (D_80183DA8[0] * D_80165760[0]) + (D_80183DA8[1] * D_80165760[1]) + (D_80183DA8[2] * D_80165760[2]) + (D_80183DA8[3] * D_80165760[3]); - temp_v0->offset[1] = (D_80183DA8[0] * D_80165770[0]) + (D_80183DA8[1] * D_80165770[1]) + (D_80183DA8[2] * D_80165770[2]) + (D_80183DA8[3] * D_80165770[3]); - temp_v0->offset[2] = (D_80183DA8[0] * D_80165780[0]) + (D_80183DA8[1] * D_80165780[1]) + (D_80183DA8[2] * D_80165780[2]) + (D_80183DA8[3] * D_80165780[3]); + object = &gObjectList[objectIndex]; + object->offset[0] = (D_80183DA8[0] * D_80165760[0]) + (D_80183DA8[1] * D_80165760[1]) + (D_80183DA8[2] * D_80165760[2]) + (D_80183DA8[3] * D_80165760[3]); + object->offset[1] = (D_80183DA8[0] * D_80165770[0]) + (D_80183DA8[1] * D_80165770[1]) + (D_80183DA8[2] * D_80165770[2]) + (D_80183DA8[3] * D_80165770[3]); + object->offset[2] = (D_80183DA8[0] * D_80165780[0]) + (D_80183DA8[1] * D_80165780[1]) + (D_80183DA8[2] * D_80165780[2]) + (D_80183DA8[3] * D_80165780[3]); } void func_8008B17C(s32 objectIndex, f32 arg1) { @@ -1683,20 +1683,20 @@ void func_8008B284(s32 objectIndex) { } void func_8008B3E4(s32 objectIndex) { - Objects *temp_v0; + Object *object; UNUSED SplineData *spline; if (is_obj_index_flag_status_inactive(objectIndex, 8) != 0) { - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_084[9] = 0; - temp_v0->timer = 0; - temp_v0->controlPoints = temp_v0->spline->controlPoints; + object = &gObjectList[objectIndex]; + object->unk_084[9] = 0; + object->timer = 0; + object->controlPoints = object->spline->controlPoints; /* This is INCREDIBLY stupid. This should really be temp_v0->unk_084[8] = temp_v0->spline->numControlPoints; but for some unholy reason that doesn't match */ - temp_v0->unk_084[8] = *(((s16*)temp_v0->controlPoints) - 1); + object->unk_084[8] = *(((s16*)object->controlPoints) - 1); set_object_flag_status_true(objectIndex, 8); } @@ -1741,15 +1741,15 @@ void func_8008B478(s32 objectIndex, s32 arg1) { void func_8008B620(s32 objectIndex) { UNUSED s16 temp_t0; - Objects *temp_v0; + Object *object; func_8008B478(objectIndex, 0); - temp_v0 = &gObjectList[objectIndex]; - if (temp_v0->timer >= 0x2710) { + object = &gObjectList[objectIndex]; + if (object->timer >= 0x2710) { // Have to do it this way due to the u16 cast - temp_v0->unk_084[9] = (u16) temp_v0->unk_084[9] + 1; - if (((u16) temp_v0->unk_084[9] + 3) == (u16) temp_v0->unk_084[8]) { - temp_v0->unk_0AE += 1; + object->unk_084[9] = (u16) object->unk_084[9] + 1; + if (((u16) object->unk_084[9] + 3) == (u16) object->unk_084[8]) { + object->unk_0AE += 1; } else { func_8008B44C(objectIndex); } @@ -1757,14 +1757,14 @@ void func_8008B620(s32 objectIndex) { } void func_8008B6A4(s32 objectIndex) { - Objects *temp_v0; + Object *object; func_8008B478(objectIndex, 1); - temp_v0 = &gObjectList[objectIndex]; - if (temp_v0->timer >= 0x2710) { + object = &gObjectList[objectIndex]; + if (object->timer >= 0x2710) { // Have to do it this way due to the u16 cast - temp_v0->unk_084[9] = (u16) temp_v0->unk_084[9] + 1; - if ((u16)temp_v0->unk_084[9] == (u16)temp_v0->unk_084[8]) { + object->unk_084[9] = (u16) object->unk_084[9] + 1; + if ((u16)object->unk_084[9] == (u16)object->unk_084[8]) { set_object_flag_status_false(objectIndex, 8); } else { func_8008B44C(objectIndex); @@ -1834,19 +1834,19 @@ void set_obj_velocity(s32 objectIndex, f32 arg1, f32 arg2, f32 arg3) { } void func_8008B928(s32 objectIndex, s16 arg1, s16 arg2, s16 arg3, SplineData *spline) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - temp_s0->origin_pos[0] = (f32) arg1; - temp_s0->origin_pos[1] = (f32) arg2; - temp_s0->spline = spline; - temp_s0->origin_pos[2] = (f32) arg3; - temp_s0->velocity[0] = (f32) (spline->controlPoints[1].pos[0] - spline->controlPoints[0].pos[0]); - temp_s0->velocity[1] = (f32) (spline->controlPoints[1].pos[1] - spline->controlPoints[0].pos[1]); - temp_s0->velocity[2] = (f32) (spline->controlPoints[1].pos[2] - spline->controlPoints[0].pos[2]); - temp_s0->direction_angle[1] = get_y_direction_angle(objectIndex); - temp_s0->velocity[2] = func_800416D8(temp_s0->velocity[2], temp_s0->velocity[0], -temp_s0->direction_angle[1]); - temp_s0->direction_angle[0] = get_x_direction_angle(objectIndex); + object = &gObjectList[objectIndex]; + object->origin_pos[0] = (f32) arg1; + object->origin_pos[1] = (f32) arg2; + object->spline = spline; + object->origin_pos[2] = (f32) arg3; + object->velocity[0] = (f32) (spline->controlPoints[1].pos[0] - spline->controlPoints[0].pos[0]); + object->velocity[1] = (f32) (spline->controlPoints[1].pos[1] - spline->controlPoints[0].pos[1]); + object->velocity[2] = (f32) (spline->controlPoints[1].pos[2] - spline->controlPoints[0].pos[2]); + object->direction_angle[1] = get_y_direction_angle(objectIndex); + object->velocity[2] = func_800416D8(object->velocity[2], object->velocity[0], -object->direction_angle[1]); + object->direction_angle[0] = get_x_direction_angle(objectIndex); } UNUSED void object_origin_pos_randomize_around_x(s32 objectIndex, s16 x, u16 arg2) { @@ -1924,15 +1924,15 @@ void object_calculate_new_pos_offset(s32 objectIndex) { } void func_8008BF64(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - D_80183E40[0] = temp_v0->pos[0]; - D_80183E40[1] = temp_v0->pos[1]; - D_80183E40[2] = temp_v0->pos[2]; - D_80183E80[0] = temp_v0->direction_angle[0]; - D_80183E80[1] = temp_v0->direction_angle[1]; - D_80183E80[2] = temp_v0->direction_angle[2]; + object = &gObjectList[objectIndex]; + D_80183E40[0] = object->pos[0]; + D_80183E40[1] = object->pos[1]; + D_80183E40[2] = object->pos[2]; + D_80183E80[0] = object->direction_angle[0]; + D_80183E80[1] = object->direction_angle[1]; + D_80183E80[2] = object->direction_angle[2]; } void func_8008BFC0(s32 objectIndex) { @@ -1941,17 +1941,17 @@ void func_8008BFC0(s32 objectIndex) { } void func_8008BFFC(s32 objectIndex) { - Objects *temp_v1; + Object *object; - temp_v1 = &gObjectList[objectIndex]; - switch (temp_v1->unk_0DE) { + object = &gObjectList[objectIndex]; + switch (object->unk_0DE) { case 1: - if (temp_v1->unk_0AE == 1) { + if (object->unk_0AE == 1) { func_8008B620(objectIndex); } break; case 2: - switch (temp_v1->unk_0AE) { + switch (object->unk_0AE) { case 0: break; case 1: @@ -1960,7 +1960,7 @@ void func_8008BFFC(s32 objectIndex) { } break; case 3: - switch (temp_v1->unk_0AE) { + switch (object->unk_0AE) { case 0: break; case 1: @@ -1969,7 +1969,7 @@ void func_8008BFFC(s32 objectIndex) { } break; case 4: - switch (temp_v1->unk_0AE) { /* switch 1; irregular */ + switch (object->unk_0AE) { /* switch 1; irregular */ case 0: /* switch 1 */ break; case 1: /* switch 1 */ @@ -1981,7 +1981,7 @@ void func_8008BFFC(s32 objectIndex) { } break; case 5: - switch (temp_v1->unk_0AE) { /* switch 2; irregular */ + switch (object->unk_0AE) { /* switch 2; irregular */ case 0: /* switch 2 */ break; case 1: /* switch 2 */ @@ -1993,7 +1993,7 @@ void func_8008BFFC(s32 objectIndex) { } break; case 6: - switch (temp_v1->unk_0AE) { + switch (object->unk_0AE) { case 0: break; case 1: @@ -2002,7 +2002,7 @@ void func_8008BFFC(s32 objectIndex) { } break; case 7: - switch (temp_v1->unk_0AE) { /* switch 3; irregular */ + switch (object->unk_0AE) { /* switch 3; irregular */ case 0: /* switch 3 */ break; case 1: /* switch 3 */ diff --git a/src/code_80091440.c b/src/code_80091440.c index 45201bedf..9a1cc0d13 100644 --- a/src/code_80091440.c +++ b/src/code_80091440.c @@ -49,9 +49,10 @@ UNUSED void func_800914E0(void) { camera->pos[1] = (f32) (tempData->pos[1] + 7); camera->pos[2] = (f32) (tempData->pos[2] - 20); camera->lookAt[0] = gPlayerOneCopy->pos[0]; + camera->lookAt[1] = gPlayerOneCopy->pos[1]; camera->lookAt[2] = gPlayerOneCopy->pos[2]; - func_802ADDC8(&camera->unk_54, 20.0f, camera->pos[0], camera->pos[1], camera->pos[2]); + check_bounding_collision(&camera->collision, 20.0f, camera->pos[0], camera->pos[1], camera->pos[2]); sp38 = camera->lookAt[0] - camera->pos[0]; sp34 = camera->lookAt[1] - camera->pos[1]; sp30 = camera->lookAt[2] - camera->pos[2]; diff --git a/src/code_80091440.h b/src/code_80091440.h index 18aa89297..eaef6ea33 100644 --- a/src/code_80091440.h +++ b/src/code_80091440.h @@ -7,4 +7,4 @@ void func_80091440(s8); void func_800914A0(void); void func_800914E0(void); -#endif // CODE_80091440_H \ No newline at end of file +#endif // CODE_80091440_H diff --git a/src/effects.c b/src/effects.c index 52c5127e2..837bf5bcf 100644 --- a/src/effects.c +++ b/src/effects.c @@ -258,7 +258,7 @@ void func_8008C528(Player *player, s8 arg1) { void func_8008C62C(Player *player, s8 arg1) { - func_80031F48(player, 5.0f); + decelerate_ai_player(player, 5.0f); player->unk_0A8 += (s16)0xA0; player->unk_042 += (s16)0x71C; if (player->unk_0A8 >= 0x2000) { @@ -356,15 +356,15 @@ void func_8008C9EC(Player *player, s8 arg1) { player->unk_206 = 0; player->slopeAccel = 0; if ((player->unk_046 & 0x40) == 0x40) { - func_80031F48(player, 100.0f); + decelerate_ai_player(player, 100.0f); } else { if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); } else { - func_80031F48(player, 4.0f); + decelerate_ai_player(player, 4.0f); } if (!(player->type & PLAYER_HUMAN)) { - func_80031F48(player, 30.0f); + decelerate_ai_player(player, 30.0f); } } if ((player->effects & 0x80) == 0x80) { @@ -756,7 +756,7 @@ void apply_hit_effect(Player* player, s8 arg1) { player->unk_0C0 = 0; player->unk_08C = 0.0f; player->currentSpeed = 0.0f; - if ((player->unk_110.unk3C[2] >= 600.0f) || ((player->effects & 0x1000) != 0)) { D_8018D990[arg1] = 3; } // placed block on same line to match + if ((player->collision.surfaceDistance[2] >= 600.0f) || ((player->effects & 0x1000) != 0)) { D_8018D990[arg1] = 3; } // placed block on same line to match switch (D_8018D990[arg1]) { case 0: @@ -822,7 +822,7 @@ void apply_hit_effect(Player* player, s8 arg1) { player->unk_238 = 0; } - if (player->unk_110.unk3C[2] >= 600.0f) { + if (player->collision.surfaceDistance[2] >= 600.0f) { D_8018D990[arg1] = 3; } @@ -920,7 +920,7 @@ void apply_lightning_effect(Player *player, s8 arg1) { D_80165190[3][arg1] = 1; } } - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); } else { player->unk_0B0 += 1; player->unk_08C = (f32) ((f64) player->unk_08C * 0.6); diff --git a/src/main.c b/src/main.c index 19eb4f4c5..8489ef25c 100644 --- a/src/main.c +++ b/src/main.c @@ -107,7 +107,8 @@ OSMesg gSIEventMesgBuf[3]; OSContStatus gControllerStatuses[4]; OSContPad gControllerPads[4]; u8 gControllerBits; -struct UnkStruct_8015F584 D_8014F110[1024]; +// Contains a 32x32 grid of indices into gCollisionIndices containing indices into gCollisionMesh +CollisionGrid gCollisionGrid[1024]; u16 gNumActors; u16 gMatrixObjectCount; s32 gTickSpeed; diff --git a/src/main.h b/src/main.h index b1e37ea95..93c7b2584 100644 --- a/src/main.h +++ b/src/main.h @@ -56,10 +56,10 @@ struct GfxPool { /* 0x28B20 */ struct SPTask spTask; }; // size = 0x28B70 -struct UnkStruct_8015F584 { - u16 unk0; - u16 unk2; -}; +typedef struct { + u16 triangle; // Index for gCollisionIndices which has indexes for gCollisionMesh + u16 numTriangles; +} CollisionGrid; void create_thread(OSThread*, OSId, void (*entry)(void *), void*, void*, OSPri); void main_func(void); @@ -156,7 +156,7 @@ extern OSContStatus gControllerStatuses[]; extern OSContPad gControllerPads[]; extern u8 gControllerBits; -extern struct UnkStruct_8015F584 D_8014F110[]; +extern CollisionGrid gCollisionGrid[]; extern u16 gNumActors; extern u16 gMatrixObjectCount; extern s32 gTickSpeed; diff --git a/src/math_util_2.c b/src/math_util_2.c index 2afe7f201..51fb2f97d 100644 --- a/src/math_util_2.c +++ b/src/math_util_2.c @@ -444,7 +444,7 @@ s32 func_800418E8(f32 arg0, f32 arg1, Vec3f arg2) { s32 func_80041924(Collision *arg0, Vec3f arg1) { s32 ret = 0; - func_802ADDC8(arg0, 10.0f, arg1[0], arg1[1], arg1[2]); + check_bounding_collision(arg0, 10.0f, arg1[0], arg1[1], arg1[2]); if (arg0->unk34 == 1) { ret = 1; } @@ -802,32 +802,32 @@ void mtxf_set_matrix_scale_transl(Mat4 transformMatrix, Vec3f vec1, Vec3f vec2, void mtxf_set_matrix_gObjectList(s32 objectIndex, Mat4 transformMatrix) { f32 sinX; - Objects *temp_s0 = &gObjectList[objectIndex]; + Object *object = &gObjectList[objectIndex]; f32 sinY; f32 cosY; f32 sinZ; f32 cosZ; f32 cosX; - sinX = sins(temp_s0->orientation[0]); - cosX = coss(temp_s0->orientation[0]); - sinY = sins(temp_s0->orientation[1]); - cosY = coss(temp_s0->orientation[1]); - sinZ = sins(temp_s0->orientation[2]); - cosZ = coss(temp_s0->orientation[2]); + sinX = sins(object->orientation[0]); + cosX = coss(object->orientation[0]); + sinY = sins(object->orientation[1]); + cosY = coss(object->orientation[1]); + sinZ = sins(object->orientation[2]); + cosZ = coss(object->orientation[2]); - transformMatrix[0][0] = temp_s0->sizeScaling * ((cosY * cosZ) + (sinX * sinY * sinZ)); - transformMatrix[1][0] = temp_s0->sizeScaling * ((-cosY * sinZ) + sinX * sinY * cosZ); - transformMatrix[2][0] = temp_s0->sizeScaling * (cosX * sinY); - transformMatrix[3][0] = temp_s0->pos[0]; - transformMatrix[0][1] = temp_s0->sizeScaling * (cosX * sinZ); - transformMatrix[1][1] = temp_s0->sizeScaling * (cosX * cosZ); - transformMatrix[2][1] = temp_s0->sizeScaling * -sinX; - transformMatrix[3][1] = temp_s0->pos[1]; - transformMatrix[0][2] = temp_s0->sizeScaling * ((-sinY * cosZ) + (sinX * cosY * sinZ)); - transformMatrix[1][2] = temp_s0->sizeScaling * ((sinY * sinZ) + (sinX * cosY * cosZ)); - transformMatrix[2][2] = temp_s0->sizeScaling * (cosX * cosY); - transformMatrix[3][2] = temp_s0->pos[2]; + transformMatrix[0][0] = object->sizeScaling * ((cosY * cosZ) + (sinX * sinY * sinZ)); + transformMatrix[1][0] = object->sizeScaling * ((-cosY * sinZ) + sinX * sinY * cosZ); + transformMatrix[2][0] = object->sizeScaling * (cosX * sinY); + transformMatrix[3][0] = object->pos[0]; + transformMatrix[0][1] = object->sizeScaling * (cosX * sinZ); + transformMatrix[1][1] = object->sizeScaling * (cosX * cosZ); + transformMatrix[2][1] = object->sizeScaling * -sinX; + transformMatrix[3][1] = object->pos[1]; + transformMatrix[0][2] = object->sizeScaling * ((-sinY * cosZ) + (sinX * cosY * sinZ)); + transformMatrix[1][2] = object->sizeScaling * ((sinY * sinZ) + (sinX * cosY * cosZ)); + transformMatrix[2][2] = object->sizeScaling * (cosX * cosY); + transformMatrix[3][2] = object->pos[2]; transformMatrix[0][3] = 0.0f; transformMatrix[1][3] = 0.0f; transformMatrix[2][3] = 0.0f; diff --git a/src/player_controller.c b/src/player_controller.c index 5c1df7388..89fcad7fe 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -1022,61 +1022,60 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { sp8C[1] = -player->boundingBoxSize; sp8C[2] = var_f12 - 2.0f; mtxf_translate_vec3f_mat3(sp8C, sp5C); - sp80[0] = player->boundingBoxCorners[0].cornerPos[0]; - sp80[1] = player->boundingBoxCorners[0].cornerPos[1]; - sp80[2] = player->boundingBoxCorners[0].cornerPos[2]; - player->boundingBoxCorners[0].cornerPos[0] = player->pos[0] + sp8C[0]; - player->boundingBoxCorners[0].cornerPos[1] = player->pos[1] + sp8C[1]; - player->boundingBoxCorners[0].cornerPos[2] = player->pos[2] + sp8C[2]; - process_collision(player, &player->boundingBoxCorners[0], sp80[0], sp80[1], sp80[2]); + sp80[0] = player->tyres[FRONT_LEFT].pos[0]; + sp80[1] = player->tyres[FRONT_LEFT].pos[1]; + sp80[2] = player->tyres[FRONT_LEFT].pos[2]; + player->tyres[FRONT_LEFT].pos[0] = player->pos[0] + sp8C[0]; + player->tyres[FRONT_LEFT].pos[1] = player->pos[1] + sp8C[1]; + player->tyres[FRONT_LEFT].pos[2] = player->pos[2] + sp8C[2]; + process_collision(player, &player->tyres[FRONT_LEFT], sp80[0], sp80[1], sp80[2]); sp8C[0] = (-var_f12) + 3.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = var_f12 - 2.0f; mtxf_translate_vec3f_mat3(sp8C, sp5C); - sp80[0] = player->boundingBoxCorners[1].cornerPos[0]; - sp80[1] = player->boundingBoxCorners[1].cornerPos[1]; - sp80[2] = player->boundingBoxCorners[1].cornerPos[2]; - player->boundingBoxCorners[1].cornerPos[0] = player->pos[0] + sp8C[0]; - player->boundingBoxCorners[1].cornerPos[1] = player->pos[1] + sp8C[1]; - player->boundingBoxCorners[1].cornerPos[2] = player->pos[2] + sp8C[2]; - process_collision(player, &player->boundingBoxCorners[1], sp80[0], sp80[1], sp80[2]); - + sp80[0] = player->tyres[FRONT_RIGHT].pos[0]; + sp80[1] = player->tyres[FRONT_RIGHT].pos[1]; + sp80[2] = player->tyres[FRONT_RIGHT].pos[2]; + player->tyres[FRONT_RIGHT].pos[0] = player->pos[0] + sp8C[0]; + player->tyres[FRONT_RIGHT].pos[1] = player->pos[1] + sp8C[1]; + player->tyres[FRONT_RIGHT].pos[2] = player->pos[2] + sp8C[2]; + process_collision(player, &player->tyres[FRONT_RIGHT], sp80[0], sp80[1], sp80[2]); sp8C[0] = var_f12 - 2.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = (-var_f12) + 4.0f; mtxf_translate_vec3f_mat3(sp8C, sp5C); - sp80[0] = player->boundingBoxCorners[2].cornerPos[0]; - sp80[1] = player->boundingBoxCorners[2].cornerPos[1]; - sp80[2] = player->boundingBoxCorners[2].cornerPos[2]; - player->boundingBoxCorners[2].cornerPos[0] = player->pos[0] + sp8C[0]; - player->boundingBoxCorners[2].cornerPos[1] = player->pos[1] + sp8C[1]; - player->boundingBoxCorners[2].cornerPos[2] = player->pos[2] + sp8C[2]; - process_collision(player, &player->boundingBoxCorners[2], sp80[0], sp80[1], sp80[2]); + sp80[0] = player->tyres[BACK_LEFT].pos[0]; + sp80[1] = player->tyres[BACK_LEFT].pos[1]; + sp80[2] = player->tyres[BACK_LEFT].pos[2]; + player->tyres[BACK_LEFT].pos[0] = player->pos[0] + sp8C[0]; + player->tyres[BACK_LEFT].pos[1] = player->pos[1] + sp8C[1]; + player->tyres[BACK_LEFT].pos[2] = player->pos[2] + sp8C[2]; + process_collision(player, &player->tyres[BACK_LEFT], sp80[0], sp80[1], sp80[2]); sp8C[0] = (-var_f12) + 2.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = (-var_f12) + 4.0f; mtxf_translate_vec3f_mat3(sp8C, sp5C); - sp80[0] = player->boundingBoxCorners[3].cornerPos[0]; - sp80[1] = player->boundingBoxCorners[3].cornerPos[1]; - sp80[2] = player->boundingBoxCorners[3].cornerPos[2]; - player->boundingBoxCorners[3].cornerPos[0] = player->pos[0] + sp8C[0]; - player->boundingBoxCorners[3].cornerPos[1] = player->pos[1] + sp8C[1]; - player->boundingBoxCorners[3].cornerPos[2] = player->pos[2] + sp8C[2]; - process_collision(player, &player->boundingBoxCorners[3], sp80[0], sp80[1], sp80[2]); + sp80[0] = player->tyres[BACK_RIGHT].pos[0]; + sp80[1] = player->tyres[BACK_RIGHT].pos[1]; + sp80[2] = player->tyres[BACK_RIGHT].pos[2]; + player->tyres[BACK_RIGHT].pos[0] = player->pos[0] + sp8C[0]; + player->tyres[BACK_RIGHT].pos[1] = player->pos[1] + sp8C[1]; + player->tyres[BACK_RIGHT].pos[2] = player->pos[2] + sp8C[2]; + process_collision(player, &player->tyres[BACK_RIGHT], sp80[0], sp80[1], sp80[2]); if (!(player->effects & 8)) { - a = (player->boundingBoxCorners[2].cornerGroundY + player->boundingBoxCorners[0].cornerGroundY) / 2; + a = (player->tyres[BACK_LEFT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2; move_f32_towards(&player->unk_230, a, 0.5f); - b = (player->boundingBoxCorners[3].cornerGroundY + player->boundingBoxCorners[1].cornerGroundY) / 2; + b = (player->tyres[BACK_RIGHT].baseHeight + player->tyres[FRONT_RIGHT].baseHeight) / 2; move_f32_towards(&player->unk_23C, b, 0.5f); - c = (player->boundingBoxCorners[1].cornerGroundY + player->boundingBoxCorners[0].cornerGroundY) / 2; + c = (player->tyres[FRONT_RIGHT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2; move_f32_towards(&player->unk_1FC, c, 0.5f); - d = (player->boundingBoxCorners[3].cornerGroundY + player->boundingBoxCorners[2].cornerGroundY) / 2; + d = (player->tyres[BACK_RIGHT].baseHeight + player->tyres[BACK_LEFT].baseHeight) / 2; move_f32_towards(&player->unk_1F8, d, 0.5f); } temp_f2_3 = ((gCharacterSize[player->characterId] * 18.0f) + 1.0f) * player->size; @@ -1103,7 +1102,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { if (((player->effects & 8) == 8) && ((player->unk_0CA & 2) == 2)) { player->slopeAccel = (s16) ((s32) player->unk_D9C); } - player->surfaceType = get_surface_type(player->unk_110.unk3A) & 0xFF; + player->surfaceType = get_surface_type(player->collision.meshIndexZX) & 0xFF; if (player->surfaceType == BOOST_RAMP_ASPHALT) { if (((player->effects & BOOST_RAMP_ASPHALT_EFFECT) != BOOST_RAMP_ASPHALT_EFFECT) && ((player->effects & 8) != 8)) { player->soundEffects |= BOOST_RAMP_ASPHALT_SOUND_EFFECT; @@ -1133,36 +1132,36 @@ void func_8002A194(Player *player, f32 arg1, f32 arg2, f32 arg3) { var_f20 = (((gCharacterSize[player->characterId] * 18) / 2) * player->size) - 1; } - player->boundingBoxCorners[0].cornerPos[2] = (coss(temp_v1 + 0x2000) * var_f20) + arg3; + player->tyres[FRONT_LEFT].pos[2] = (coss(temp_v1 + 0x2000) * var_f20) + arg3; temp_f12 = (sins(temp_v1 + 0x2000) * var_f20) + arg1; - player->boundingBoxCorners[0].cornerPos[0] = temp_f12; - player->boundingBoxCorners[0].cornerGroundY = func_802ABE30(temp_f12, arg2, player->boundingBoxCorners[0].cornerPos[2], player->unk_110.unk3A); + player->tyres[FRONT_LEFT].pos[0] = temp_f12; + player->tyres[FRONT_LEFT].baseHeight = calculate_surface_height(temp_f12, arg2, player->tyres[FRONT_LEFT].pos[2], player->collision.meshIndexZX); - player->boundingBoxCorners[1].cornerPos[2] = (coss(temp_v1 - 0x2000) * var_f20) + arg3; + player->tyres[FRONT_RIGHT].pos[2] = (coss(temp_v1 - 0x2000) * var_f20) + arg3; temp_f12 = (sins(temp_v1 - 0x2000) * var_f20) + arg1; - player->boundingBoxCorners[1].cornerPos[0] = temp_f12; - player->boundingBoxCorners[1].cornerGroundY = func_802ABE30(temp_f12, arg2, player->boundingBoxCorners[1].cornerPos[2], player->unk_110.unk3A); + player->tyres[FRONT_RIGHT].pos[0] = temp_f12; + player->tyres[FRONT_RIGHT].baseHeight = calculate_surface_height(temp_f12, arg2, player->tyres[FRONT_RIGHT].pos[2], player->collision.meshIndexZX); - player->boundingBoxCorners[2].cornerPos[2] = (coss(temp_v1 + 0x6000) * var_f20) + arg3; + player->tyres[BACK_LEFT].pos[2] = (coss(temp_v1 + 0x6000) * var_f20) + arg3; temp_f12 = (sins(temp_v1 + 0x6000) * var_f20) + arg1; - player->boundingBoxCorners[2].cornerPos[0] = temp_f12; - player->boundingBoxCorners[2].cornerGroundY = func_802ABE30(temp_f12, arg2, player->boundingBoxCorners[2].cornerPos[2], player->unk_110.unk3A); + player->tyres[BACK_LEFT].pos[0] = temp_f12; + player->tyres[BACK_LEFT].baseHeight = calculate_surface_height(temp_f12, arg2, player->tyres[BACK_LEFT].pos[2], player->collision.meshIndexZX); - player->boundingBoxCorners[3].cornerPos[2] = (coss(temp_v1 - 0x6000) * var_f20) + arg3; - player->boundingBoxCorners[3].cornerPos[0] = (sins(temp_v1 - 0x6000) * var_f20) + arg1; - player->boundingBoxCorners[3].cornerGroundY = func_802ABE30(player->boundingBoxCorners[2].cornerPos[0], arg2, player->boundingBoxCorners[2].cornerPos[2], player->unk_110.unk3A); + player->tyres[BACK_RIGHT].pos[2] = (coss(temp_v1 - 0x6000) * var_f20) + arg3; + player->tyres[BACK_RIGHT].pos[0] = (sins(temp_v1 - 0x6000) * var_f20) + arg1; + player->tyres[BACK_RIGHT].baseHeight = calculate_surface_height(player->tyres[BACK_LEFT].pos[0], arg2, player->tyres[BACK_LEFT].pos[2], player->collision.meshIndexZX); if ((player->effects & 8) != 8) { - player->unk_230 = (player->boundingBoxCorners[2].cornerGroundY + player->boundingBoxCorners[0].cornerGroundY) / 2; - player->unk_23C = (player->boundingBoxCorners[3].cornerGroundY + player->boundingBoxCorners[1].cornerGroundY) / 2; - player->unk_1FC = (player->boundingBoxCorners[1].cornerGroundY + player->boundingBoxCorners[0].cornerGroundY) / 2; - player->unk_1F8 = (player->boundingBoxCorners[3].cornerGroundY + player->boundingBoxCorners[2].cornerGroundY) / 2; + player->unk_230 = (player->tyres[BACK_LEFT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2; + player->unk_23C = (player->tyres[BACK_RIGHT].baseHeight + player->tyres[FRONT_RIGHT].baseHeight) / 2; + player->unk_1FC = (player->tyres[FRONT_RIGHT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2; + player->unk_1F8 = (player->tyres[BACK_RIGHT].baseHeight + player->tyres[BACK_LEFT].baseHeight) / 2; } - player->surfaceType = (u8)get_surface_type(player->unk_110.unk3A); - player->boundingBoxCorners[3].surfaceType = player->surfaceType; - player->boundingBoxCorners[2].surfaceType = player->surfaceType; - player->boundingBoxCorners[1].surfaceType = player->surfaceType; - player->boundingBoxCorners[0].surfaceType = player->surfaceType; + player->surfaceType = (u8)get_surface_type(player->collision.meshIndexZX); + player->tyres[BACK_RIGHT].surfaceType = player->surfaceType; + player->tyres[BACK_LEFT].surfaceType = player->surfaceType; + player->tyres[FRONT_RIGHT].surfaceType = player->surfaceType; + player->tyres[FRONT_LEFT].surfaceType = player->surfaceType; var_f20 = (gCharacterSize[player->characterId] * 18) + 1; temp_f0 = (player->unk_23C - player->unk_230); player->unk_206 = -func_802B7C40(temp_f0 / var_f20); @@ -1179,10 +1178,10 @@ void func_8002A194(Player *player, f32 arg1, f32 arg2, f32 arg3) { } move_s16_towards(&player->slopeAccel, var_a1, 0.5f); } - if (func_802ABD7C(player->unk_110.unk3A) != 0) { - player->boundingBoxCorners[3].unk_14 |= 1; + if (func_802ABD7C(player->collision.meshIndexZX) != 0) { + player->tyres[BACK_RIGHT].unk_14 |= 1; } else { - player->boundingBoxCorners[3].unk_14 &= ~1; + player->tyres[BACK_RIGHT].unk_14 &= ~1; } if (player->surfaceType == BOOST_RAMP_ASPHALT) { if (((player->effects & BOOST_RAMP_ASPHALT_EFFECT) != BOOST_RAMP_ASPHALT_EFFECT) && ((player->effects & 8) != 8)) { @@ -1196,7 +1195,7 @@ void func_8002A194(Player *player, f32 arg1, f32 arg2, f32 arg3) { } } -// Near identical to func_802AC114 in memory.c +// Near identical to adjust_pos_orthogonally in memory.c void func_8002A5F4(Vec3f arg0, f32 arg1, Vec3f arg2, f32 arg3, f32 arg4) { f32 temp_f0; f32 temp_f2; @@ -1368,7 +1367,7 @@ void func_8002AB70(Player *player) { move_f32_towards(&player->unk_DAC, 1.0f, 0.07f); } } else { - if (player->unk_110.unk3C[2] >= 50.0f) { + if (player->collision.surfaceDistance[2] >= 50.0f) { player->unk_DAC = 2.0f; } move_f32_towards(&player->kartGravity, gKartGravityTable[player->characterId], 0.02f); @@ -1860,7 +1859,7 @@ void func_8002C11C(Player *player) { void func_8002C17C(Player *player, s8 playerId) { switch (gCurrentCourseId) { /* irregular */ case COURSE_YOSHI_VALLEY: - if ((player->unk_110.unk3C[2] >= 600.0f) && (D_80165330[playerId] == 0)) { + if ((player->collision.surfaceDistance[2] >= 600.0f) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; @@ -1868,7 +1867,7 @@ void func_8002C17C(Player *player, s8 playerId) { gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } else if (!(player->effects & 8)) { - if (func_802ABDF4(player->unk_110.unk3A) == 0) { + if (func_802ABDF4(player->collision.meshIndexZX) == 0) { D_80165330[playerId] = 0; } } @@ -1896,7 +1895,7 @@ void func_8002C17C(Player *player, s8 playerId) { } break; case COURSE_RAINBOW_ROAD: - if ((player->unk_110.unk3C[2] >= 600.0f) && (D_80165330[playerId] == 0)) { + if ((player->collision.surfaceDistance[2] >= 600.0f) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; @@ -1949,15 +1948,15 @@ void func_8002C4F8(Player *player, s8 arg1) { (gCurrentCourseId == COURSE_RAINBOW_ROAD)) { player->unk_0DE &= ~0x000C; } - if ((player->boundingBoxSize < (D_801652A0[arg1] - player->pos[1])) && (player->unk_110.unk3C[2] >= 600.0f)) { + if ((player->boundingBoxSize < (D_801652A0[arg1] - player->pos[1])) && (player->collision.surfaceDistance[2] >= 600.0f)) { player->unk_0CA |= 1; } - if (player->unk_110.unk3C[2] >= 600.0f) { + if (player->collision.surfaceDistance[2] >= 600.0f) { player->unk_0CA |= 0x0100; } else if ((player->effects & 8) != 8) { player->unk_0CA &= ~0x0100; } - if ((player->type & PLAYER_KART_AI) && ((func_802ABDF4(player->unk_110.unk3A) != 0) || (player->unk_0CA & 1))) { + if ((player->type & PLAYER_KART_AI) && ((func_802ABDF4(player->collision.meshIndexZX) != 0) || (player->unk_0CA & 1))) { if (!(player->unk_0CA & 2) && !(player->unk_0CA & 8) && !(player->effects & 0x1000)) { func_80090778(player); func_80090868(player); @@ -2023,14 +2022,14 @@ void func_8002C954(Player *player, s8 playerId, Vec3f arg2) { (temp_f0 < (-1.0f))) && ((player->effects & 0x10000) == 0)) && (player->effects & 8)) || - ((player->unk_110.unk34 == 0) && + ((player->collision.unk34 == 0) && ((player->effects & 0x10000) == 0))) && (((player->unk_0CA & 2) == 0) || (!(player->unk_0CA & 8)))) { func_8008F494(player, playerId); } if ((player->unk_046 & 0x20) != 0x20) { - if ((player->unk_110.unk3C[0] < (-1.0f)) || (player->unk_110.unk3C[1] < (-1.0f))) { + if ((player->collision.surfaceDistance[0] < (-1.0f)) || (player->collision.surfaceDistance[1] < (-1.0f))) { player->unk_256 = 1; } player->unk_046 |= 0x20; @@ -2044,7 +2043,7 @@ void func_8002C954(Player *player, s8 playerId, Vec3f arg2) { player->unk_256 = 0; } if ((player->slopeAccel >= 0) && (((player->unk_094 / 18.0f) * 216.0f) > 5.0f)) { - func_80031F48(player, 18.0f); + decelerate_ai_player(player, 18.0f); } if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { xdist = D_80165070[playerId][0] - arg2[0]; @@ -2110,7 +2109,7 @@ void apply_effect(Player *player, s8 arg1, s8 arg2) { apply_boo_effect(player, arg1); } if (((player->effects & 0x20000000) == 0x20000000) && (player->unk_228 >= 0x64)) { - func_80031F48(player, 4.0f); + decelerate_ai_player(player, 4.0f); } if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40)) { func_8008C9EC(player, arg1); @@ -2132,7 +2131,7 @@ void apply_effect(Player *player, s8 arg1, s8 arg2) { } if ((player->effects & 0x800000) == 0x800000) { func_8008D8B4(player, arg1); - func_80031F48(player, 10.0f); + decelerate_ai_player(player, 10.0f); } if (D_800DC510 != 5) { if (player->soundEffects & 0x04000000) { @@ -2249,19 +2248,19 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player player->unk_064[0] *= -1.0f; player->unk_064[2] *= -1.0f; } - if ((player->boundingBoxCorners[2].surfaceType == ASPHALT) && (player->boundingBoxCorners[3].surfaceType == ASPHALT)) { - spB4 = (-1 * (player->unk_064[0] + sp16C[0])) + ((-player->unk_110.orientationVector[0] * player->kartGravity) * 0.925); - spB0 = (-player->unk_110.orientationVector[1] * player->kartGravity); - spAC = (-1 * (player->unk_064[2] + sp16C[2])) + ((-player->unk_110.orientationVector[2] * player->kartGravity) * 0.925); + if ((player->tyres[BACK_LEFT].surfaceType == ASPHALT) && (player->tyres[BACK_RIGHT].surfaceType == ASPHALT)) { + spB4 = (-1 * (player->unk_064[0] + sp16C[0])) + ((-player->collision.orientationVector[0] * player->kartGravity) * 0.925); + spB0 = (-player->collision.orientationVector[1] * player->kartGravity); + spAC = (-1 * (player->unk_064[2] + sp16C[2])) + ((-player->collision.orientationVector[2] * player->kartGravity) * 0.925); } else { temp3 = (((player->unk_094 / 18.0f) * 216.0f) / 10.0f); if (temp3 >= 10) { temp3 = 10; } - spB4 = -1 * (player->unk_064[0] + sp16C[0]) + ((-player->unk_110.orientationVector[0] * player->kartGravity) * sp104[temp3]); - spB0 = (-player->unk_110.orientationVector[1] * player->kartGravity); - spAC = -1 * (player->unk_064[2] + sp16C[2]) + ((-player->unk_110.orientationVector[2] * player->kartGravity) * sp104[temp3]); + spB4 = -1 * (player->unk_064[0] + sp16C[0]) + ((-player->collision.orientationVector[0] * player->kartGravity) * sp104[temp3]); + spB0 = (-player->collision.orientationVector[1] * player->kartGravity); + spAC = -1 * (player->unk_064[2] + sp16C[2]) + ((-player->collision.orientationVector[2] * player->kartGravity) * sp104[temp3]); } if (((player->effects & 8) != 8) && ((player->effects & 0x20) == 0x20)) { spB4 = 0 * (player->unk_064[0] + sp16C[0]); @@ -2340,7 +2339,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player spF8 += player->kartHopVelocity; spF8 -= 0.02; } - func_802AD950(&player->unk_110, player->boundingBoxSize, spFC, spF8, spF4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z); + actor_terrain_collision(&player->collision, player->boundingBoxSize, spFC, spF8, spF4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z); player->unk_058 = 0.0f; player->unk_060 = 0.0f; player->unk_05C = 1.0f; @@ -2351,7 +2350,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player } player->effects |= 8; player->unk_0C2 += 1; - temp_var = player->unk_110.unk3C[2]; + temp_var = player->collision.surfaceDistance[2]; if (temp_var <= 0.0f) { player->effects = player->effects & (~2); player->effects = player->effects & (~8); @@ -2402,23 +2401,23 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player player->unk_0C2 = 0; player->kartHopVelocity = player->unk_0C2; } - temp_var = player->unk_110.unk3C[2]; + temp_var = player->collision.surfaceDistance[2]; if (temp_var <= 0.0f) { func_8003F46C(player, sp8C, sp98, sp178, &temp_var, &spFC, &spF8, &spF4); } - temp_var = player->unk_110.unk3C[0]; + temp_var = player->collision.surfaceDistance[0]; if (temp_var < 0.0f) { func_8003F734(player, sp8C, sp98, &temp_var, &spFC, &spF8, &spF4); func_8002C954(player, playerId, sp98); } - temp_var = player->unk_110.unk3C[1]; + temp_var = player->collision.surfaceDistance[1]; if (temp_var < 0.0f) { func_8003FBAC(player, sp8C, sp98, &temp_var, &spFC, &spF8, &spF4); func_8002C954(player, playerId, sp98); } - temp_var = player->unk_110.unk3C[0]; + temp_var = player->collision.surfaceDistance[0]; if (temp_var >= 0.0f) { - temp_var = player->unk_110.unk3C[1]; + temp_var = player->collision.surfaceDistance[1]; if (temp_var >= 0.0f) { player->unk_046 &= 0xFFDF; if (player->unk_256 != 0) { @@ -2430,14 +2429,14 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player } } } - if (((!(player->effects & 8)) && (func_802ABDB8(player->unk_110.unk3A) != 0)) && ((player->effects & 0x10000) != 0x10000)) { + if (((!(player->effects & 8)) && (func_802ABDB8(player->collision.meshIndexZX) != 0)) && ((player->effects & 0x10000) != 0x10000)) { if ((!(player->unk_0CA & 2)) || (!(player->unk_0CA & 8))) { func_8008F494(player, playerId); } - } else if (((!(player->effects & 8)) && (func_802ABDB8(player->unk_110.unk3A) == 0)) && (player->effects & 0x10000)) { + } else if (((!(player->effects & 8)) && (func_802ABDB8(player->collision.meshIndexZX) == 0)) && (player->effects & 0x10000)) { func_8008F5A4(player, playerId); } - player->unk_074 = func_802ABE30(spFC, spF8, spF4, player->unk_110.unk3A); + player->unk_074 = calculate_surface_height(spFC, spF8, spF4, player->collision.meshIndexZX); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && (((gActiveScreenMode == SCREEN_MODE_1P) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_VERTICAL)) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL))) { func_80029B4C(player, spFC, spF8, spF4); } else { @@ -2489,7 +2488,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player player->unk_094 = 1; } } - if (player->unk_110.unk3C[2] >= 500.0f) { + if (player->collision.surfaceDistance[2] >= 500.0f) { player->unk_078 = (s16) (((s16) player->unk_078) / 2); } func_8002C4F8(player, playerId); @@ -2502,7 +2501,7 @@ void func_8002E4C4(Player *player) { player->kartHopJerk = 0.0f; player->kartHopAcceleration = 0.0f; player->kartHopVelocity = 0.0f; - player->pos[1] = func_802AE1C0(player->pos[0], D_80164510[player_index] + 10.0f, player->pos[2]) + player->boundingBoxSize; + player->pos[1] = spawn_actor_on_surface(player->pos[0], D_80164510[player_index] + 10.0f, player->pos[2]) + player->boundingBoxSize; if (((player->pos[1] - D_80164510[player_index]) > 1200.0f) || ((player->pos[1] - D_80164510[player_index]) < -1200.0f)) { player->pos[1] = player->copy_rotation_y; } @@ -2549,9 +2548,9 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 screenId, s8 player if ((((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40)) || ((player->effects & 0x20000) == 0x20000)) { - sp80 = -1 * (player->unk_064[0]) + (((-player->unk_110.orientationVector[0]) * player->kartGravity) * 0.1); - sp7C = (-player->unk_110.orientationVector[1]) * player->kartGravity; - sp78 = -1 * (player->unk_064[2]) + (((-player->unk_110.orientationVector[2]) * player->kartGravity) * 0.1); + sp80 = -1 * (player->unk_064[0]) + (((-player->collision.orientationVector[0]) * player->kartGravity) * 0.1); + sp7C = (-player->collision.orientationVector[1]) * player->kartGravity; + sp78 = -1 * (player->unk_064[2]) + (((-player->collision.orientationVector[2]) * player->kartGravity) * 0.1); } else { sp80 = -1 * player->unk_064[0]; sp7C = -1 * player->kartGravity; @@ -2605,13 +2604,13 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 screenId, s8 player spC8 = posZ + player->velocity[2] + D_8018CE10[playerId].unk_04[2]; func_8002AAC0(player); spCC += player->kartHopVelocity; - func_802AD950(&player->unk_110, player->boundingBoxSize, spD0, spCC, spC8, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z); + actor_terrain_collision(&player->collision, player->boundingBoxSize, spD0, spCC, spC8, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z); player->effects |= 8; player->unk_0C2 += 1; player->unk_058 = 0.0f; player->unk_060 = 0.0f; player->unk_05C = 1.0f; - sp74 = player->unk_110.unk3C[2]; + sp74 = player->collision.surfaceDistance[2]; if (sp74 <= 0.0f) { player->effects &= ~2; player->effects &= ~8; @@ -2674,25 +2673,25 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 screenId, s8 player } player->kartHopVelocity = (f32) player->unk_0C2; } - sp74 = player->unk_110.unk3C[2]; + sp74 = player->collision.surfaceDistance[2]; if (sp74 <= 0.0f) { func_8003F46C(player, sp48, sp54, spE0, &sp74, &spD0, &spCC, &spC8); } - sp74 = player->unk_110.unk3C[0]; + sp74 = player->collision.surfaceDistance[0]; if (sp74 < 0.0f) { func_8003F734(player, sp48, sp54, &sp74, &spD0, &spCC, &spC8); func_8002C954(player, playerId, sp54); - func_80031F48(player, 6.0f); + decelerate_ai_player(player, 6.0f); } - sp74 = player->unk_110.unk3C[1]; + sp74 = player->collision.surfaceDistance[1]; if (sp74 < 0.0f) { func_8003FBAC(player, sp48, sp54, &sp74, &spD0, &spCC, &spC8); func_8002C954(player, playerId, sp54); - func_80031F48(player, 6.0f); + decelerate_ai_player(player, 6.0f); } - sp74 = player->unk_110.unk3C[0]; + sp74 = player->collision.surfaceDistance[0]; if (sp74 >= 0.0f) { - sp74 = player->unk_110.unk3C[1]; + sp74 = player->collision.surfaceDistance[1]; if (sp74 >= 0.0f) { player->unk_046 &= 0xFFDF; if (player->unk_256 != 0) { @@ -2704,14 +2703,14 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 screenId, s8 player } } } - if (((func_802ABDB8(player->unk_110.unk3A) != 0) && ((player->effects & 0x10000) != 0x10000)) && (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { + if (((func_802ABDB8(player->collision.meshIndexZX) != 0) && ((player->effects & 0x10000) != 0x10000)) && (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { if ((!(player->unk_0CA & 2)) || (!(player->unk_0CA & 8))) { func_8008F494(player, playerId); } - } else if (((!(player->effects & 8)) && (func_802ABDB8(player->unk_110.unk3A) == 0)) && (player->effects & 0x10000)) { + } else if (((!(player->effects & 8)) && (func_802ABDB8(player->collision.meshIndexZX) == 0)) && (player->effects & 0x10000)) { func_8008F5A4(player, playerId); } - player->unk_074 = func_802ABE30(spD0, spCC, spC8, player->unk_110.unk3A); + player->unk_074 = calculate_surface_height(spD0, spCC, spC8, player->collision.meshIndexZX); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && (((gActiveScreenMode == SCREEN_MODE_1P) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_VERTICAL)) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL))) { func_80029B4C(player, spD0, spCC, spC8); } else { @@ -2881,18 +2880,18 @@ void func_8002F730(Player *player, UNUSED Camera *camera, UNUSED s8 screenId, s8 func_8002AAC0(player); spC8 += player->kartHopVelocity; - func_802AD950(&player->unk_110, player->boundingBoxSize, spCC, spC8, spC4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z); + actor_terrain_collision(&player->collision, player->boundingBoxSize, spCC, spC8, spC4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z); player->unk_058 = 0.0f; player->unk_05C = 1.0f; player->unk_060 = 0.0f; calculate_orientation_matrix(player->orientationMatrix, 0.0f, 1.0f, 0.0f, (s16) (s32) player->rotation[1]); player->effects &= ~8; - sp78 = player->unk_110.unk3C[2]; + sp78 = player->collision.surfaceDistance[2]; if (sp78 <= 0.0f) { if(1) {}; func_8003F46C(player, sp5C, sp68, spE8, &sp78, &spCC, &spC8, &spC4); } - player->unk_074 = func_802ABE30(spCC, spC8, spC4, player->unk_110.unk3A); + player->unk_074 = calculate_surface_height(spCC, spC8, spC4, player->collision.meshIndexZX); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((gActiveScreenMode == SCREEN_MODE_1P) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_VERTICAL) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL))) { func_80029B4C(player, spCC, spC8, spC4); } else { @@ -2941,17 +2940,17 @@ void func_8002FCA8(Player *player, s8 arg1) { var_f0 = 0.0f; if ((player->effects & STAR_EFFECT) != STAR_EFFECT) { - if ((s32) player->boundingBoxCorners[3].surfaceType < 0xF) { - var_f0 += D_800E2A90[player->characterId][player->boundingBoxCorners[3].surfaceType]; + if ((s32) player->tyres[BACK_RIGHT].surfaceType < 0xF) { + var_f0 += D_800E2A90[player->characterId][player->tyres[BACK_RIGHT].surfaceType]; } - if ((s32) player->boundingBoxCorners[2].surfaceType < 0xF) { - var_f0 += D_800E2A90[player->characterId][player->boundingBoxCorners[2].surfaceType]; + if ((s32) player->tyres[BACK_LEFT].surfaceType < 0xF) { + var_f0 += D_800E2A90[player->characterId][player->tyres[BACK_LEFT].surfaceType]; } - if ((s32) player->boundingBoxCorners[1].surfaceType < 0xF) { - var_f0 += D_800E2AB0[player->characterId][player->boundingBoxCorners[1].surfaceType]; + if ((s32) player->tyres[FRONT_RIGHT].surfaceType < 0xF) { + var_f0 += D_800E2AB0[player->characterId][player->tyres[FRONT_RIGHT].surfaceType]; } - if ((s32) player->boundingBoxCorners[0].surfaceType < 0xF) { - var_f0 += D_800E2AB0[player->characterId][player->boundingBoxCorners[0].surfaceType]; + if ((s32) player->tyres[FRONT_LEFT].surfaceType < 0xF) { + var_f0 += D_800E2AB0[player->characterId][player->tyres[FRONT_LEFT].surfaceType]; } } if (D_801652C0[arg1] & 4) { @@ -3003,12 +3002,12 @@ void func_8002FE84(Player *player, f32 arg1) { var_f0 += (temp_lo * 0.025) / 1.2; } player->unk_098 = arg1 * (1.0f - var_f0); - if (player->boundingBoxCorners[3].surfaceType == GRASS) { - var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[3].surfaceType] * 0.7; + if (player->tyres[BACK_RIGHT].surfaceType == GRASS) { + var_f0 += D_800E2E90[player->characterId][player->tyres[BACK_RIGHT].surfaceType] * 0.7; } - if (player->boundingBoxCorners[2].surfaceType == GRASS) { + if (player->tyres[BACK_LEFT].surfaceType == GRASS) { // The unecessary "* 1.0" here is to force the compiler to save this 0.7 as a separate RO value from the 0.7 just above this comment - var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[2].surfaceType] * (0.7 * 1.0); + var_f0 += D_800E2E90[player->characterId][player->tyres[BACK_LEFT].surfaceType] * (0.7 * 1.0); } test = player->unk_0C0 / 182; if (test < 0) { @@ -3033,21 +3032,21 @@ f32 func_80030150(Player *player, s8 arg1) { var_f2 = (player->unk_094 / 18.0f) * 216.0f; if (var_f2 >= 8.0f) { if ((player->effects & STAR_EFFECT) != STAR_EFFECT) { - if ((s32) player->boundingBoxCorners[3].surfaceType >= 0xF) { + if ((s32) player->tyres[BACK_RIGHT].surfaceType >= 0xF) { // ??????? if(1) {} } else { - var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[3].surfaceType]; + var_f0 += D_800E2E90[player->characterId][player->tyres[BACK_RIGHT].surfaceType]; } - if ((s32) player->boundingBoxCorners[2].surfaceType < 0xF) - var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[2].surfaceType]; + if ((s32) player->tyres[BACK_LEFT].surfaceType < 0xF) + var_f0 += D_800E2E90[player->characterId][player->tyres[BACK_LEFT].surfaceType]; - if ((s32) player->boundingBoxCorners[1].surfaceType < 0xF) - var_f0 += D_800E2EB0[player->characterId][player->boundingBoxCorners[1].surfaceType]; + if ((s32) player->tyres[FRONT_RIGHT].surfaceType < 0xF) + var_f0 += D_800E2EB0[player->characterId][player->tyres[FRONT_RIGHT].surfaceType]; - if ((s32) player->boundingBoxCorners[0].surfaceType < 0xF) - var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[0].surfaceType]; + if ((s32) player->tyres[FRONT_LEFT].surfaceType < 0xF) + var_f0 += D_800E2E90[player->characterId][player->tyres[FRONT_LEFT].surfaceType]; } if (((player->effects & 8) != 8) && ((player->unk_0CA & 2) != 2)) { temp_lo = player->slopeAccel / 182; @@ -3095,7 +3094,7 @@ f32 func_80030150(Player *player, s8 arg1) { if ((player->unk_0DE & 2) == 2) { var_f0 += 0.15; } - if (((D_801652A0[arg1] - player->boundingBoxCorners[2].cornerGroundY) >= 3.5) || ((D_801652A0[arg1] - player->boundingBoxCorners[3].cornerGroundY) >= 3.5)) { + if (((D_801652A0[arg1] - player->tyres[BACK_LEFT].baseHeight) >= 3.5) || ((D_801652A0[arg1] - player->tyres[BACK_RIGHT].baseHeight) >= 3.5)) { var_f0 += 0.05; } } @@ -3405,11 +3404,11 @@ void player_speed(Player *player) { } } -void func_80031F48(Player *player, f32 arg1) { +void decelerate_ai_player(Player *player, f32 speed) { s32 player_index; player_index = get_player_index_for_player(player); - player->currentSpeed -= arg1; + player->currentSpeed -= speed; if (player->currentSpeed <= 0.0f) { player->currentSpeed = 0.0f; } @@ -3584,14 +3583,14 @@ void func_800323E4(Player *player) { player->effects |= 1; // This check will never be true, why is it here? if ((player->effects & 0x20) == 0x20) { - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); player->unk_20C = var_f2; } else { - if ((s32) player->boundingBoxCorners[3].surfaceType < 0xF) { - var_f2 += D_800E3210[player->characterId][player->boundingBoxCorners[3].surfaceType]; + if ((s32) player->tyres[BACK_RIGHT].surfaceType < 0xF) { + var_f2 += D_800E3210[player->characterId][player->tyres[BACK_RIGHT].surfaceType]; } - if ((s32) player->boundingBoxCorners[2].surfaceType < 0xF) { - var_f2 += D_800E3210[player->characterId][player->boundingBoxCorners[2].surfaceType]; + if ((s32) player->tyres[BACK_LEFT].surfaceType < 0xF) { + var_f2 += D_800E3210[player->characterId][player->tyres[BACK_LEFT].surfaceType]; } test = player->unk_22C - player->unk_094; if (test <= 0.0f) { @@ -3604,18 +3603,18 @@ void func_800323E4(Player *player) { } if (gIsPlayerTripleBButtonCombo[var_v1] == TRUE) { if (player->unk_20C >= 2.0f) { - func_80031F48(player, (1.0f - var_f2) * 5.0f); + decelerate_ai_player(player, (1.0f - var_f2) * 5.0f); } else { - func_80031F48(player, (1.0f - var_f2) * 3.0f); + decelerate_ai_player(player, (1.0f - var_f2) * 3.0f); } } else { if (((player->unk_094 / 18.0f) * 216.0f) <= 20.0f) { - func_80031F48(player, (1.0f - var_f2) * 4.0f); + decelerate_ai_player(player, (1.0f - var_f2) * 4.0f); } if (player->unk_20C >= 2.0f) { - func_80031F48(player, (1.0f - var_f2) * 2.5); + decelerate_ai_player(player, (1.0f - var_f2) * 2.5); } else { - func_80031F48(player, (1.0f - var_f2) * 1.2); + decelerate_ai_player(player, (1.0f - var_f2) * 1.2); } } } @@ -3938,13 +3937,13 @@ void func_80033AE0(Player *player, struct Controller *controller, s8 arg2) { player->soundEffects |= 0x80; } } - if (((s32) player->boundingBoxCorners[3].surfaceType) < 0xF) + if (((s32) player->tyres[BACK_RIGHT].surfaceType) < 0xF) { - var_f2 += D_800E3610[player->characterId][player->boundingBoxCorners[3].surfaceType]; + var_f2 += D_800E3610[player->characterId][player->tyres[BACK_RIGHT].surfaceType]; } - if (((s32) player->boundingBoxCorners[2].surfaceType) < 0xF) + if (((s32) player->tyres[BACK_LEFT].surfaceType) < 0xF) { - var_f2 += D_800E3610[player->characterId][player->boundingBoxCorners[2].surfaceType]; + var_f2 += D_800E3610[player->characterId][player->tyres[BACK_LEFT].surfaceType]; } if ((player->effects & 0x20) == 0x20) { @@ -4014,7 +4013,7 @@ void func_80033AE0(Player *player, struct Controller *controller, s8 arg2) { sp2C8 *= 1.2; sp2CC *= 1.2; } - if ((((f64) (D_801652A0[arg2] - player->boundingBoxCorners[2].cornerGroundY)) >= 3.5) || (((f64) (D_801652A0[arg2] - player->boundingBoxCorners[3].cornerGroundY)) >= 3.5)) + if ((((f64) (D_801652A0[arg2] - player->tyres[BACK_LEFT].baseHeight)) >= 3.5) || (((f64) (D_801652A0[arg2] - player->tyres[BACK_RIGHT].baseHeight)) >= 3.5)) { sp2C8 *= 1.05; sp2CC *= 1.05; @@ -4146,17 +4145,17 @@ void func_80033AE0(Player *player, struct Controller *controller, s8 arg2) { func_8002BD58(player); } player->effects &= 0xDFFFFFFF; - if (((s32) player->boundingBoxCorners[3].surfaceType) > 0xE) + if (((s32) player->tyres[BACK_RIGHT].surfaceType) > 0xE) { var_f12 = var_f12; } else { - var_f12 += D_800E3410[player->characterId][player->boundingBoxCorners[3].surfaceType]; + var_f12 += D_800E3410[player->characterId][player->tyres[BACK_RIGHT].surfaceType]; } - if (((s32) player->boundingBoxCorners[2].surfaceType) < 0xF) + if (((s32) player->tyres[BACK_LEFT].surfaceType) < 0xF) { - var_f12 += D_800E3410[player->characterId][player->boundingBoxCorners[2].surfaceType]; + var_f12 += D_800E3410[player->characterId][player->tyres[BACK_LEFT].surfaceType]; } if (((player->effects & 2) != 2) && ((player->effects & 0x10) != 0x10)) { @@ -4650,7 +4649,7 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { } if ((player->effects & 8) != 8) { func_80033AE0(player, controller, arg2); - } else if (((player->effects & 2) == 2) && (player->unk_110.unk3C[2] <= 5.0f)) { + } else if (((player->effects & 2) == 2) && (player->collision.surfaceDistance[2] <= 5.0f)) { func_80033AE0(player, controller, arg2); } player->effects &= ~1; @@ -4678,11 +4677,11 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { } else { if (gModeSelection == BATTLE) { - func_80031F48(player, 2.0f); + decelerate_ai_player(player, 2.0f); } else { - func_80031F48(player, 1.0f); + decelerate_ai_player(player, 1.0f); } detect_triple_a_combo_a_released(player); } @@ -4715,7 +4714,7 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { if (controller->button & A_BUTTON) { player_speed(player); } else { - func_80031F48(player, 5.0f); + decelerate_ai_player(player, 5.0f); } } if (((((player->effects & 0x80) == 0x80) || @@ -5012,42 +5011,42 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) func_8002AAC0(player); spE8 += player->kartHopVelocity; spE8 -= 0.02; - func_802AD950(&player->unk_110, player->boundingBoxSize, spEC, spE8, spE4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z); + actor_terrain_collision(&player->collision, player->boundingBoxSize, spEC, spE8, spE4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z); player->unk_058 = 0; player->unk_060 = 0; player->unk_05C = 1.0f; calculate_orientation_matrix(player->orientationMatrix, 0, 1.0f, 0, player->rotation[1]); player->effects |= 8; player->unk_0C2 += 1; - sp98 = player->unk_110.unk3C[2]; + sp98 = player->collision.surfaceDistance[2]; if (sp98 <= 0) { player->unk_0C2 = 0; player->effects &= ~2; player->effects &= ~8; player->kartHopVelocity = player->unk_0C2; } - sp98 = player->unk_110.unk3C[2]; + sp98 = player->collision.surfaceDistance[2]; if (sp98 <= 0) { func_8003F46C(player, sp7C, sp88, sp108, &sp98, &spEC, &spE8, &spE4); } - sp98 = player->unk_110.unk3C[0]; + sp98 = player->collision.surfaceDistance[0]; if (sp98 < 0) { func_8003F734(player, sp7C, sp88, &sp98, &spEC, &spE8, &spE4); func_8002C954(player, playerId, sp88); } - sp98 = player->unk_110.unk3C[1]; + sp98 = player->collision.surfaceDistance[1]; if (sp98 < 0) { func_8003FBAC(player, sp7C, sp88, &sp98, &spEC, &spE8, &spE4); func_8002C954(player, playerId, sp88); } - sp98 = player->unk_110.unk3C[0]; + sp98 = player->collision.surfaceDistance[0]; if (sp98 >= 0) { - sp98 = player->unk_110.unk3C[1]; + sp98 = player->collision.surfaceDistance[1]; if (sp98 >= 0) { player->unk_046 &= 0xFFDF; } } - player->unk_074 = func_802ABE30(spEC, spE8, spE4, player->unk_110.unk3A); + player->unk_074 = calculate_surface_height(spEC, spE8, spE4, player->collision.meshIndexZX); func_80029B4C(player, spEC, spE8, spE4); func_8002AE38(player, playerId, posX, posZ, spEC, spE4); sqrt = (sp88[0] * sp88[0]) + (sp88[2] * sp88[2]); @@ -5086,7 +5085,7 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) player->unk_094 = 1.0f; } } - if (player->unk_110.unk3C[2] >= 500.0f) { + if (player->collision.surfaceDistance[2] >= 500.0f) { player->unk_078 /= 2; } func_8002C4F8(player, playerId); diff --git a/src/player_controller.h b/src/player_controller.h index 84cbe7418..d04024610 100644 --- a/src/player_controller.h +++ b/src/player_controller.h @@ -74,7 +74,7 @@ void func_80030A34(Player*); void detect_triple_a_combo_a_released(Player*); void detect_triple_a_combo_a_pressed(Player*); void player_speed(Player*); -void func_80031F48(Player*, f32); +void decelerate_ai_player(Player*, f32); void detect_triple_b_combo_b_released(Player*); void detect_triple_b_combo_b_pressed(Player*); void func_800323E4(Player*); diff --git a/src/racing/actors.c b/src/racing/actors.c index 4f919a22e..66e2e18f2 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -257,7 +257,7 @@ void actor_init(struct Actor *actor, Vec3f startingPos, Vec3s startingRot, Vec3f actor->flags = actor->flags | 0x4000 | 0x1000; actor->unk_08 = 0.35f; actor->boundingBoxSize = 1.925f; - func_802ADDC8(&actor->unk30, 1.925f, actor->pos[0], actor->pos[1], actor->pos[2]); + check_bounding_collision(&actor->unk30, 1.925f, actor->pos[0], actor->pos[1], actor->pos[2]); break; case ACTOR_HOT_AIR_BALLOON_ITEM_BOX: actor->flags |= 0x4000; @@ -376,21 +376,21 @@ void func_80297760(struct Actor *arg0, Vec3f arg1) { arg1[0] = arg0->pos[0]; arg1[1] = arg0->pos[1]; arg1[2] = arg0->pos[2]; - arg1[1] = func_802ABE30(arg1[0], arg1[1], arg1[2], arg0->unk30.unk3A); + arg1[1] = calculate_surface_height(arg1[0], arg1[1], arg1[2], arg0->unk30.meshIndexZX); } void func_802977B0(Player *arg0) { - arg0->boundingBoxCorners[1].unk_14 |= 2; - arg0->boundingBoxCorners[0].unk_14 |= 2; - arg0->boundingBoxCorners[3].unk_14 |= 2; - arg0->boundingBoxCorners[2].unk_14 |= 2; + arg0->tyres[FRONT_RIGHT].unk_14 |= 2; + arg0->tyres[FRONT_LEFT].unk_14 |= 2; + arg0->tyres[BACK_RIGHT].unk_14 |= 2; + arg0->tyres[BACK_LEFT].unk_14 |= 2; } void func_802977E4(Player *arg0) { - arg0->boundingBoxCorners[1].unk_14 &= ~2 & 0xFFFF; - arg0->boundingBoxCorners[0].unk_14 &= ~2 & 0xFFFF; - arg0->boundingBoxCorners[3].unk_14 &= ~2 & 0xFFFF; - arg0->boundingBoxCorners[2].unk_14 &= ~2 & 0xFFFF; + arg0->tyres[FRONT_RIGHT].unk_14 &= ~2 & 0xFFFF; + arg0->tyres[FRONT_LEFT].unk_14 &= ~2 & 0xFFFF; + arg0->tyres[BACK_RIGHT].unk_14 &= ~2 & 0xFFFF; + arg0->tyres[BACK_LEFT].unk_14 &= ~2 & 0xFFFF; } // Invert green and red on green shell texture @@ -565,7 +565,7 @@ void evaluate_collision_players_palm_trees(void) { for (index = 0; index < 4; index++){ // wtf is up with the << 0x18 >> 0x18? is it some weird type conversion? just use & 0xFF have the same effect to keep 8 first bit - if (((gPlayers[index].type & 0xC000) != 0) && (((get_surface_type(gPlayers[index].unk_110.unk3A) << 24) >> 24) == GRASS)) { + if (((gPlayers[index].type & 0xC000) != 0) && (((get_surface_type(gPlayers[index].collision.meshIndexZX) << 24) >> 24) == GRASS)) { evaluate_collision_player_palm_trees(&gPlayers[index]); } } @@ -855,7 +855,7 @@ void spawn_palm_trees(struct ActorSpawnData *spawnData) { temp_v1 = (struct PalmTree *) &gActorList[temp]; temp_v1->variant = temp_s0->someId; - func_802ADDC8((Collision *) &temp_v1->unk30, 5.0f, temp_v1->pos[0], temp_v1->pos[1], temp_v1->pos[2]); + check_bounding_collision((Collision *) &temp_v1->unk30, 5.0f, temp_v1->pos[0], temp_v1->pos[1], temp_v1->pos[2]); func_802976EC((Collision *) &temp_v1->unk30, temp_v1->rot); temp_s0++; } @@ -935,9 +935,9 @@ void spawn_foliage(struct ActorSpawnData *arg0) { if (gGamestate == CREDITS_SEQUENCE) { func_802976D8(temp_s0->rot); } else { - func_802ADDC8(&temp_s0->unk30, 5.0f, temp_s0->pos[0], temp_s0->pos[1], temp_s0->pos[2]); - if (temp_s0->unk30.unk3C[2] < 0.0f) { - temp_s0->pos[1] = func_802ABE30(temp_s0->pos[0], temp_s0->pos[1], temp_s0->pos[2], temp_s0->unk30.unk3A); + check_bounding_collision(&temp_s0->unk30, 5.0f, temp_s0->pos[0], temp_s0->pos[1], temp_s0->pos[2]); + if (temp_s0->unk30.surfaceDistance[2] < 0.0f) { + temp_s0->pos[1] = calculate_surface_height(temp_s0->pos[0], temp_s0->pos[1], temp_s0->pos[2], temp_s0->unk30.meshIndexZX); } func_802976EC(&temp_s0->unk30, temp_s0->rot); } @@ -967,7 +967,7 @@ void spawn_all_item_boxes(struct ActorSpawnData *spawnData) { startingRot[1] = random_u16(); startingRot[2] = random_u16(); temp_s1 = add_actor_to_empty_slot(startingPos, startingRot, startingVelocity, ACTOR_ITEM_BOX); - temp_f0 = func_802AE1C0(startingPos[0], startingPos[1] + 10.0f, startingPos[2]); + temp_f0 = spawn_actor_on_surface(startingPos[0], startingPos[1] + 10.0f, startingPos[2]); // Should be struct ItemBox but not enough space in the stack. // It's either the ItemBox or the SEGMENT/OFFSET variables. diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index a28d64215..f373a9998 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -16,20 +16,20 @@ #include "effects.h" #include "sounds.h" -void copy_collision(Collision *arg0, Collision *arg1) { - arg1->unk30 = arg0->unk30; - arg1->unk32 = arg0->unk32; - arg1->unk34 = arg0->unk34; - arg1->unk36 = arg0->unk36; - arg1->unk38 = arg0->unk38; - arg1->unk3A = arg0->unk3A; - arg1->unk3C[0] = arg0->unk3C[0]; - arg1->unk3C[1] = arg0->unk3C[1]; - arg1->unk3C[2] = arg0->unk3C[2]; +void copy_collision(Collision *src, Collision *dest) { + dest->unk30 = src->unk30; + dest->unk32 = src->unk32; + dest->unk34 = src->unk34; + dest->meshIndexYX = src->meshIndexYX; + dest->meshIndexZY = src->meshIndexZY; + dest->meshIndexZX = src->meshIndexZX; + dest->surfaceDistance[0] = src->surfaceDistance[0]; + dest->surfaceDistance[1] = src->surfaceDistance[1]; + dest->surfaceDistance[2] = src->surfaceDistance[2]; - vec3f_copy_return(arg1->unk48, arg0->unk48); - vec3f_copy_return(arg1->unk54, arg0->unk54); - vec3f_copy_return(arg1->orientationVector, arg0->orientationVector); + vec3f_copy_return(dest->unk48, src->unk48); + vec3f_copy_return(dest->unk54, src->unk54); + vec3f_copy_return(dest->orientationVector, src->orientationVector); } void triple_shell_actor_collide_with_player(struct ShellActor *shell, s32 shellType) { @@ -572,7 +572,7 @@ s32 init_triple_shell(TripleShellParent *parent, Player *player, s16 shellType, startingPos[0] = player->pos[0]; startingPos[1] = player->pos[1]; startingPos[2] = player->pos[2]; - func_802AD950(&shell->unk30, shell->boundingBoxSize + 1.0f, shell->pos[0], shell->pos[1], shell->pos[2], startingPos[0], startingPos[1], startingPos[2]); + actor_terrain_collision(&shell->unk30, shell->boundingBoxSize + 1.0f, shell->pos[0], shell->pos[1], shell->pos[2], startingPos[0], startingPos[1], startingPos[2]); func_802B4E30((struct Actor *)shell); shell->flags = 0x9000; switch (shellType) { @@ -622,7 +622,7 @@ s32 use_green_shell_item(Player *player) { startingPos[0] = player->pos[0]; startingPos[1] = player->pos[1]; startingPos[2] = player->pos[2]; - func_802AD950(&shell->unk30, shell->boundingBoxSize + 1.0f, shell->pos[0], shell->pos[1], shell->pos[2], startingPos[0], startingPos[1], startingPos[2]); + actor_terrain_collision(&shell->unk30, shell->boundingBoxSize + 1.0f, shell->pos[0], shell->pos[1], shell->pos[2], startingPos[0], startingPos[1], startingPos[2]); func_802B4E30((struct Actor *)shell); shell->state = HELD_SHELL; shell->rotVelocity = 0; @@ -661,7 +661,7 @@ s32 use_red_shell_item(Player *player) { startingPos[0] = player->pos[0]; startingPos[1] = player->pos[1]; startingPos[2] = player->pos[2]; - func_802AD950(&shell->unk30, shell->boundingBoxSize + 1.0f, shell->pos[0], shell->pos[1], shell->pos[2], startingPos[0], startingPos[1], startingPos[2]); + actor_terrain_collision(&shell->unk30, shell->boundingBoxSize + 1.0f, shell->pos[0], shell->pos[1], shell->pos[2], startingPos[0], startingPos[1], startingPos[2]); func_802B4E30((struct Actor *)shell); shell->state = HELD_SHELL; shell->rotVelocity = 0; @@ -708,7 +708,7 @@ void func_802B2914(struct BananaBunchParent *banana_bunch, Player *player, s16 b startingPos[0] = player->pos[0]; startingPos[1] = player->pos[1]; startingPos[2] = player->pos[2]; - func_802AD950(&newBanana->unk30, newBanana->boundingBoxSize + 1.0f, newBanana->pos[0], newBanana->pos[1], newBanana->pos[2], startingPos[0], startingPos[1], startingPos[2]); + actor_terrain_collision(&newBanana->unk30, newBanana->boundingBoxSize + 1.0f, newBanana->pos[0], newBanana->pos[1], newBanana->pos[2], startingPos[0], startingPos[1], startingPos[2]); func_802B4E30((struct Actor*)newBanana); newBanana->flags = 0x9000; newBanana->playerId = player - gPlayerOne; @@ -960,19 +960,19 @@ void check_player_use_item(void) { #include "actors/blue_and_red_shells/update.inc.c" void func_802B4E30(struct Actor *arg0) { - if ((arg0->unk30.unk3C[2] < 0.0f) && (arg0->unk30.unk34 == 1)) { - arg0->pos[0] -= (arg0->unk30.orientationVector[0] * arg0->unk30.unk3C[2]); - arg0->pos[1] -= (arg0->unk30.orientationVector[1] * arg0->unk30.unk3C[2]); - arg0->pos[2] -= (arg0->unk30.orientationVector[2] * arg0->unk30.unk3C[2]); + if ((arg0->unk30.surfaceDistance[2] < 0.0f) && (arg0->unk30.unk34 == 1)) { + arg0->pos[0] -= (arg0->unk30.orientationVector[0] * arg0->unk30.surfaceDistance[2]); + arg0->pos[1] -= (arg0->unk30.orientationVector[1] * arg0->unk30.surfaceDistance[2]); + arg0->pos[2] -= (arg0->unk30.orientationVector[2] * arg0->unk30.surfaceDistance[2]); } - if ((arg0->unk30.unk3C[0] < 0.0f) && (arg0->unk30.unk30 == 1)) { - arg0->pos[0] -= (arg0->unk30.unk48[0] * arg0->unk30.unk3C[0]); - arg0->pos[1] -= (arg0->unk30.unk48[1] * arg0->unk30.unk3C[0]); - arg0->pos[2] -= (arg0->unk30.unk48[2] * arg0->unk30.unk3C[0]); + if ((arg0->unk30.surfaceDistance[0] < 0.0f) && (arg0->unk30.unk30 == 1)) { + arg0->pos[0] -= (arg0->unk30.unk48[0] * arg0->unk30.surfaceDistance[0]); + arg0->pos[1] -= (arg0->unk30.unk48[1] * arg0->unk30.surfaceDistance[0]); + arg0->pos[2] -= (arg0->unk30.unk48[2] * arg0->unk30.surfaceDistance[0]); } - if ((arg0->unk30.unk3C[1] < 0.0f) && (arg0->unk30.unk32 == 1)) { - arg0->pos[0] -= (arg0->unk30.unk54[0] * arg0->unk30.unk3C[1]); - arg0->pos[1] -= (arg0->unk30.unk54[1] * arg0->unk30.unk3C[1]); - arg0->pos[2] -= (arg0->unk30.unk54[2] * arg0->unk30.unk3C[1]); + if ((arg0->unk30.surfaceDistance[1] < 0.0f) && (arg0->unk30.unk32 == 1)) { + arg0->pos[0] -= (arg0->unk30.unk54[0] * arg0->unk30.surfaceDistance[1]); + arg0->pos[1] -= (arg0->unk30.unk54[1] * arg0->unk30.surfaceDistance[1]); + arg0->pos[2] -= (arg0->unk30.unk54[2] * arg0->unk30.surfaceDistance[1]); } } diff --git a/src/racing/collision.c b/src/racing/collision.c index 7673be502..539503852 100644 --- a/src/racing/collision.c +++ b/src/racing/collision.c @@ -9,6 +9,7 @@ #include "collision.h" #include "math_util.h" #include "code_800029B0.h" +#include #pragma intrinsic (sqrtf) @@ -25,15 +26,15 @@ void nullify_displaylist(uintptr_t addr) { } void func_802AAAAC(Collision *collision) { - collision->unk36 = 5000; - collision->unk38 = 5000; - collision->unk3A = 5000; + collision->meshIndexYX = 5000; + collision->meshIndexZY = 5000; + collision->meshIndexZX = 5000; collision->unk30 = 0; collision->unk32 = 0; collision->unk34 = 0; - collision->unk3C[0] = 0; - collision->unk3C[1] = 0; - collision->unk3C[2] = 0; + collision->surfaceDistance[0] = 0; + collision->surfaceDistance[1] = 0; + collision->surfaceDistance[2] = 0; vec3f_set(collision->unk48, 0.0f, 0.0f, 1.0f); vec3f_set(collision->unk54, 1.0f, 0.0f, 0.0f); vec3f_set(collision->orientationVector, 0.0f, 1.0f, 0.0f); @@ -76,14 +77,14 @@ f32 func_802AAB4C(Player *player) { } return 0.8f; case COURSE_SHERBET_LAND: - if ((get_surface_type(player->unk_110.unk3A) & 0xFF) == SNOW) { + if ((get_surface_type(player->collision.meshIndexZX) & 0xFF) == SNOW) { return (f32) (gCourseMinY - 0xA); } return D_8015F8E4; case COURSE_DK_JUNGLE: - temp_v1 = func_802ABD40(player->unk_110.unk3A) & 0xFF; + temp_v1 = get_section_id(player->collision.meshIndexZX) & 0xFF; if (temp_v1 == 0xFF) { - if ((get_surface_type(player->unk_110.unk3A) & 0xFF) == CAVE) { + if ((get_surface_type(player->collision.meshIndexZX) & 0xFF) == CAVE) { return -475.0f; } if (playerX > -478.0f) { @@ -112,7 +113,7 @@ f32 func_802AAB4C(Player *player) { } } -s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { +s32 check_collision_zx(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { CollisionTriangle *triangle = &gCollisionMesh[index]; UNUSED f32 pad; f32 x3; @@ -123,13 +124,13 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 z2; f32 x1; f32 z1; - f32 temp_f0_5; - f32 temp_f10; - f32 temp_f0_3; - f32 temp_f2_2; - s32 bool = 1; + f32 distanceToSurface; + f32 crossProductZX_1; + f32 crossProductZX_2; + f32 crossProductZX_3; + s32 bool = TRUE; - if (triangle->gravity < -0.9f) + if (triangle->normalY < -0.9f) return 0; if (triangle->minX > posX) return 0; @@ -151,35 +152,35 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, x3 = triangle->vtx3->v.ob[0]; z3 = triangle->vtx3->v.ob[2]; - temp_f10 = (z1 - posZ) * (x2 - posX) - (x1 - posX) * (z2 - posZ); + crossProductZX_1 = (z1 - posZ) * (x2 - posX) - (x1 - posX) * (z2 - posZ); - if (!temp_f10) { + if (!crossProductZX_1) { - temp_f0_3 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); + crossProductZX_2 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); - temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); + crossProductZX_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); - if ((temp_f0_3 * temp_f2_2) < 0.0f) { - bool = 0; + if ((crossProductZX_2 * crossProductZX_3) < 0.0f) { + bool = FALSE; } } else { - temp_f0_3 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); + crossProductZX_2 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); - if (!temp_f0_3) { - temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); + if (!crossProductZX_2) { + crossProductZX_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); - if ((temp_f10 * temp_f2_2) < 0.0f) { - bool = 0; + if ((crossProductZX_1 * crossProductZX_3) < 0.0f) { + bool = FALSE; } } else { - if ((temp_f10 * temp_f0_3) < 0.0f) { - bool = 0; + if ((crossProductZX_1 * crossProductZX_2) < 0.0f) { + bool = FALSE; } else { - temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); - if (temp_f2_2 != 0) { - if ((temp_f0_3 * temp_f2_2) < 0.0f) { - bool = 0; + crossProductZX_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); + if (crossProductZX_3 != 0) { + if ((crossProductZX_2 * crossProductZX_3) < 0.0f) { + bool = FALSE; } } } @@ -188,35 +189,34 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, if (!bool) { return 0; } - temp_f0_5 = ((triangle->height * posX) + (triangle->gravity * posY) + (triangle->rotation * posZ) - + triangle->height2) + distanceToSurface = ((triangle->normalX * posX) + (triangle->normalY * posY) + (triangle->normalZ * posZ) + + triangle->distance) - boundingBoxSize; - if (temp_f0_5 > 0.0f) { - if (collision->unk3C[2] > temp_f0_5) { + if (distanceToSurface > 0.0f) { + if (collision->surfaceDistance[2] > distanceToSurface) { collision->unk34 = 1; - collision->unk3A = index; - collision->unk3C[2] = temp_f0_5; - collision->orientationVector[0] = triangle->height; - collision->orientationVector[1] = triangle->gravity; - collision->orientationVector[2] = triangle->rotation; + collision->meshIndexZX = index; + collision->surfaceDistance[2] = distanceToSurface; + collision->orientationVector[0] = triangle->normalX; + collision->orientationVector[1] = triangle->normalY; + collision->orientationVector[2] = triangle->normalZ; } return 0; } - if (temp_f0_5 > -16.0f) { + if (distanceToSurface > -16.0f) { collision->unk34 = 1; - collision->unk3A = index; - collision->unk3C[2] = temp_f0_5; - collision->orientationVector[0] = triangle->height; - collision->orientationVector[1] = triangle->gravity; - collision->orientationVector[2] = triangle->rotation; + collision->meshIndexZX = index; + collision->surfaceDistance[2] = distanceToSurface; + collision->orientationVector[0] = triangle->normalX; + collision->orientationVector[1] = triangle->normalY; + collision->orientationVector[2] = triangle->normalZ; return 1; } return 0; } - -s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { +s32 check_collision_yx(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { CollisionTriangle *triangle = &gCollisionMesh[index]; UNUSED f32 pad[6]; f32 x3; @@ -228,11 +228,11 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 y2; f32 x1; f32 y1; - f32 temp_f0_4; - f32 temp_f2_2; - f32 temp_f0_2; - f32 temp_f2_3; - s32 bool = 1; + f32 distanceToSurface; + f32 crossProductYX_1; + f32 crossProductYX_2; + f32 crossProductYX_3; + s32 bool = TRUE; if (triangle->minX > posX) { return 0; @@ -263,32 +263,32 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, x3 = triangle->vtx3->v.ob[0]; y3 = triangle->vtx3->v.ob[1]; - temp_f2_2 = (y1 - posY) * (x2 - posX) - (x1 - posX) * (y2 - posY); + crossProductYX_1 = (y1 - posY) * (x2 - posX) - (x1 - posX) * (y2 - posY); - if (!temp_f2_2) { + if (!crossProductYX_1) { - temp_f0_2 = (y2 - posY) * (x3 - posX) - (x2 - posX) * (y3 - posY); + crossProductYX_2 = (y2 - posY) * (x3 - posX) - (x2 - posX) * (y3 - posY); - temp_f2_3 = (y3 - posY) * (x1 - posX) - (x3 - posX) * (y1 - posY); + crossProductYX_3 = (y3 - posY) * (x1 - posX) - (x3 - posX) * (y1 - posY); - if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + if ((crossProductYX_2 * crossProductYX_3) < 0.0f) { + bool = FALSE; } } else { - temp_f0_2 = (y2 - posY) * (x3 - posX) - (x2 - posX) * (y3 - posY); - if (!temp_f0_2) { - temp_f2_3 = (y3 - posY) * (x1 - posX) - (x3 - posX) * (y1 - posY); - if (temp_f2_2 * temp_f2_3 < 0.0f) { - bool = 0; + crossProductYX_2 = (y2 - posY) * (x3 - posX) - (x2 - posX) * (y3 - posY); + if (!crossProductYX_2) { + crossProductYX_3 = (y3 - posY) * (x1 - posX) - (x3 - posX) * (y1 - posY); + if (crossProductYX_1 * crossProductYX_3 < 0.0f) { + bool = FALSE; } } else { - if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + if ((crossProductYX_1 * crossProductYX_2) < 0.0f) { + bool = FALSE; } else { - temp_f2_3 = ((y3 - posY) * (x1 - posX)) - ((x3 - posX) * (y1 - posY)); - if (temp_f2_3 != 0) { - if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + crossProductYX_3 = ((y3 - posY) * (x1 - posX)) - ((x3 - posX) * (y1 - posY)); + if (crossProductYX_3 != 0) { + if ((crossProductYX_2 * crossProductYX_3) < 0.0f) { + bool = FALSE; } } } @@ -297,47 +297,46 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, if (!bool) { return 0; } - temp_f0_4 = ((triangle->height * posX) + (triangle->gravity * posY) + (triangle->rotation * posZ) + triangle->height2) - boundingBoxSize; - if (temp_f0_4 > 0.0f) { - if (temp_f0_4 < collision->unk3C[0]) { + distanceToSurface = ((triangle->normalX * posX) + (triangle->normalY * posY) + (triangle->normalZ * posZ) + triangle->distance) - boundingBoxSize; + if (distanceToSurface > 0.0f) { + if (distanceToSurface < collision->surfaceDistance[0]) { collision->unk30 = 1; - collision->unk36 = index; - collision->unk3C[0] = temp_f0_4; - collision->unk48[0] = triangle->height; - collision->unk48[1] = triangle->gravity; - collision->unk48[2] = triangle->rotation; + collision->meshIndexYX = index; + collision->surfaceDistance[0] = distanceToSurface; + collision->unk48[0] = triangle->normalX; + collision->unk48[1] = triangle->normalY; + collision->unk48[2] = triangle->normalZ; } return 0; } - if (temp_f0_4 > -16.0f) { + if (distanceToSurface > -16.0f) { collision->unk30 = 1; - collision->unk36 = index; - collision->unk3C[0] = temp_f0_4; - collision->unk48[0] = triangle->height; - collision->unk48[1] = triangle->gravity; - collision->unk48[2] = triangle->rotation; + collision->meshIndexYX = index; + collision->surfaceDistance[0] = distanceToSurface; + collision->unk48[0] = triangle->normalX; + collision->unk48[1] = triangle->normalY; + collision->unk48[2] = triangle->normalZ; return 1; } return 0; } - -s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { +s32 check_collision_zy(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { CollisionTriangle *triangle = &gCollisionMesh[index]; - s32 bool = 1; + s32 bool = TRUE; UNUSED f32 pad[7]; - f32 sp20; - f32 temp_f8; + f32 y3; + f32 z3; UNUSED f32 pad2[5]; - f32 sp6C; - f32 sp70; - f32 temp_f4; - f32 sp24; - f32 temp_f0_4; - f32 temp_f2_2; - f32 temp_f0_2; - f32 temp_f2_3; + f32 y2; + f32 z2; + f32 y1; + f32 z1; + f32 distanceToSurface; + f32 crossProductYZ_1; + f32 crossProductYZ_2; + f32 crossProductYZ_3; if (triangle->minZ > posZ) { return 0; } @@ -357,45 +356,45 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, return 0; } - sp24 = triangle->vtx1->v.ob[2]; - temp_f4 = triangle->vtx1->v.ob[1]; + z1 = triangle->vtx1->v.ob[2]; + y1 = triangle->vtx1->v.ob[1]; - sp70 = triangle->vtx2->v.ob[2]; - sp6C = triangle->vtx2->v.ob[1]; + z2 = triangle->vtx2->v.ob[2]; + y2 = triangle->vtx2->v.ob[1]; - temp_f8 = triangle->vtx3->v.ob[2]; - sp20 = triangle->vtx3->v.ob[1]; + z3 = triangle->vtx3->v.ob[2]; + y3 = triangle->vtx3->v.ob[1]; - temp_f2_2 = (temp_f4 - posY) * (sp70 - posZ) - (sp24 - posZ) * (sp6C - posY); + crossProductYZ_1 = (y1 - posY) * (z2 - posZ) - (z1 - posZ) * (y2 - posY); - if (!temp_f2_2) { + if (!crossProductYZ_1) { - temp_f0_2 = ((sp6C - posY) * (temp_f8 - posZ)) - ((sp70 - posZ) * (sp20 - posY)); + crossProductYZ_2 = ((y2 - posY) * (z3 - posZ)) - ((z2 - posZ) * (y3 - posY)); - temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); + crossProductYZ_3 = ((y3 - posY) * (z1 - posZ)) - ((z3 - posZ) * (y1 - posY)); - if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + if ((crossProductYZ_2 * crossProductYZ_3) < 0.0f) { + bool = FALSE; } } else { - temp_f0_2 = ((sp6C - posY) * (temp_f8 - posZ)) - ((sp70 - posZ) * (sp20 - posY)); + crossProductYZ_2 = ((y2 - posY) * (z3 - posZ)) - ((z2 - posZ) * (y3 - posY)); - if (temp_f0_2 == 0) { - temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); + if (crossProductYZ_2 == 0) { + crossProductYZ_3 = ((y3 - posY) * (z1 - posZ)) - ((z3 - posZ) * (y1 - posY)); - if ((temp_f2_2 * temp_f2_3) < 0.0f) { - bool = 0; + if ((crossProductYZ_1 * crossProductYZ_3) < 0.0f) { + bool = FALSE; } } else { - if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + if ((crossProductYZ_1 * crossProductYZ_2) < 0.0f) { + bool = FALSE; } else { - temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); - if (temp_f2_3 != 0) { - if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + crossProductYZ_3 = ((y3 - posY) * (z1 - posZ)) - ((z3 - posZ) * (y1 - posY)); + if (crossProductYZ_3 != 0) { + if ((crossProductYZ_2 * crossProductYZ_3) < 0.0f) { + bool = FALSE; } } } @@ -405,34 +404,34 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, return 0; } - temp_f0_4 = ((((triangle->height * posX) + (triangle->gravity * posY)) + (triangle->rotation * posZ)) - + triangle->height2) + distanceToSurface = ((((triangle->normalX * posX) + (triangle->normalY * posY)) + (triangle->normalZ * posZ)) + + triangle->distance) - boundingBoxSize; - if (temp_f0_4 > 0.0f) { - if (temp_f0_4 < collision->unk3C[1]) { + if (distanceToSurface > 0.0f) { + if (distanceToSurface < collision->surfaceDistance[1]) { collision->unk32 = 1; - collision->unk38 = index; - collision->unk3C[1] = temp_f0_4; - collision->unk54[0] = triangle->height; - collision->unk54[1] = triangle->gravity; - collision->unk54[2] = triangle->rotation; + collision->meshIndexZY = index; + collision->surfaceDistance[1] = distanceToSurface; + collision->unk54[0] = triangle->normalX; + collision->unk54[1] = triangle->normalY; + collision->unk54[2] = triangle->normalZ; } return 0; } - if (temp_f0_4 > (-16.0f)) { + if (distanceToSurface > (-16.0f)) { collision->unk32 = 1; - collision->unk38 = index; - collision->unk3C[1] = temp_f0_4; - collision->unk54[0] = triangle->height; - collision->unk54[1] = triangle->gravity; - collision->unk54[2] = triangle->rotation; + collision->meshIndexZY = index; + collision->surfaceDistance[1] = distanceToSurface; + collision->unk54[0] = triangle->normalX; + collision->unk54[1] = triangle->normalY; + collision->unk54[2] = triangle->normalZ; return 1; } return 0; } -s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { +s32 check_horizontally_colliding_with_triangle(f32 posX, f32 posZ, u16 index) { CollisionTriangle *triangle = &gCollisionMesh[index]; UNUSED f32 pad; f32 x3; @@ -444,10 +443,10 @@ s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { f32 x1; f32 z1; UNUSED f32 pad4[4]; - f32 temp_f2_2; - f32 temp_f2_3; - f32 temp_f0_2; - s32 bool = 1; + f32 crossProductZX_1; + f32 crossProductZX_3; + f32 crossProductZX_2; + s32 bool = TRUE; x1 = triangle->vtx1->v.ob[0]; z1 = triangle->vtx1->v.ob[2]; @@ -458,32 +457,32 @@ s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { x3 = triangle->vtx3->v.ob[0]; z3 = triangle->vtx3->v.ob[2]; - temp_f2_2 = (z1 - posZ) * (x2 - posX) - (x1 - posX) * (z2 - posZ); + crossProductZX_1 = (z1 - posZ) * (x2 - posX) - (x1 - posX) * (z2 - posZ); - if (!temp_f2_2) { + if (!crossProductZX_1) { - temp_f0_2 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); + crossProductZX_2 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); - temp_f2_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); + crossProductZX_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); - if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + if ((crossProductZX_2 * crossProductZX_3) < 0.0f) { + bool = FALSE; } } else { - temp_f0_2 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); - if (!temp_f0_2) { - temp_f2_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); - if (temp_f2_2 * temp_f2_3 < 0.0f) { - bool = 0; + crossProductZX_2 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); + if (!crossProductZX_2) { + crossProductZX_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); + if (crossProductZX_1 * crossProductZX_3 < 0.0f) { + bool = FALSE; } } else { - if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + if ((crossProductZX_1 * crossProductZX_2) < 0.0f) { + bool = FALSE; } else { - temp_f2_3 = ((z3 - posZ) * (x1 - posX)) - ((x3 - posX) * (z1 - posZ)); - if (temp_f2_3 != 0) { - if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + crossProductZX_3 = ((z3 - posZ) * (x1 - posX)) - ((x3 - posX) * (z1 - posZ)); + if (crossProductZX_3 != 0) { + if ((crossProductZX_2 * crossProductZX_3) < 0.0f) { + bool = FALSE; } } } @@ -497,7 +496,7 @@ s8 get_surface_type(u16 index) { return triangle->surfaceType; } -s16 func_802ABD40(u16 index) { +s16 get_section_id(u16 index) { CollisionTriangle *triangle = &gCollisionMesh[index]; return triangle->flags & 0xFF; } @@ -517,23 +516,23 @@ s16 func_802ABDF4(u16 index) { return triangle->flags & 0x800; } -f32 func_802ABE30(f32 x, f32 y, f32 z, u16 index) { +f32 calculate_surface_height(f32 x, f32 y, f32 z, u16 index) { CollisionTriangle *triangle = &gCollisionMesh[index]; - if (triangle->gravity == 0.0f) { + if (triangle->normalY == 0.0f) { return y; } - return ((triangle->height * x) + (triangle->rotation * z) + triangle->height2) / -triangle->gravity; + return ((triangle->normalX * x) + (triangle->normalZ * z) + triangle->distance) / -triangle->normalY; } f32 func_802ABEAC(Collision *collision, Vec3f pos) { if (collision->unk34 == 1) { - return func_802ABE30(pos[0], pos[1], pos[2], collision->unk3A); + return calculate_surface_height(pos[0], pos[1], pos[2], collision->meshIndexZX); } if (collision->unk30 == 1) { - return func_802ABE30(pos[0], pos[1], pos[2], collision->unk36); + return calculate_surface_height(pos[0], pos[1], pos[2], collision->meshIndexYX); } if (collision->unk32 == 1) { - return func_802ABE30(pos[0], pos[1], pos[2], collision->unk38); + return calculate_surface_height(pos[0], pos[1], pos[2], collision->meshIndexZY); } return pos[1]; } @@ -551,7 +550,7 @@ void process_shell_collision(Vec3f pos, UNUSED f32 boundingBoxSize, Vec3f veloci UNUSED f32 y2; f32 velocityMagnitude; UNUSED f32 z2; - f32 temp; + f32 scaleFactor; x = velocity[0]; y = velocity[1]; @@ -577,27 +576,27 @@ void process_shell_collision(Vec3f pos, UNUSED f32 boundingBoxSize, Vec3f veloci magnitude = sqrtf((x * x) + (y * y) + (z * z)); - temp = 1.0f / magnitude * velocityMagnitude; + scaleFactor = 1.0f / magnitude * velocityMagnitude; - velocity[0] = x * temp; - velocity[1] = y * temp; - velocity[2] = z * temp; + velocity[0] = x * scaleFactor; + velocity[1] = y * scaleFactor; + velocity[2] = z * scaleFactor; } void shell_collision(Collision *collision, Vec3f velocity) { - if (collision->unk3C[0] < 0.0f) { - process_shell_collision(collision->unk48, collision->unk3C[0], velocity, 2.0f); + if (collision->surfaceDistance[0] < 0.0f) { + process_shell_collision(collision->unk48, collision->surfaceDistance[0], velocity, 2.0f); } - if (collision->unk3C[1] < 0.0f) { - process_shell_collision(collision->unk54, collision->unk3C[1], velocity, 2.0f); + if (collision->surfaceDistance[1] < 0.0f) { + process_shell_collision(collision->unk54, collision->surfaceDistance[1], velocity, 2.0f); } } /** * Adjusts the position of pos2 based on pos1 but in the orthogonal direction to pos2. */ -void func_802AC114(Vec3f pos1, f32 boundingBoxSize, Vec3f pos2, UNUSED f32 unk) { +void adjust_pos_orthogonally(Vec3f pos1, f32 boundingBoxSize, Vec3f pos2, UNUSED f32 unk) { f32 x1; f32 y1; f32 z1; @@ -633,127 +632,117 @@ void func_802AC114(Vec3f pos1, f32 boundingBoxSize, Vec3f pos2, UNUSED f32 unk) } } -s32 func_802AC22C(KartBoundingBoxCorner *arg0) { - Collision spD0; - UNUSED s32 stackPadding0; - UNUSED s32 stackPadding1; - UNUSED s32 stackPadding2; - UNUSED s32 stackPadding3; - UNUSED s32 stackPadding4; - UNUSED s32 stackPadding5; - UNUSED s32 stackPadding6; - UNUSED s32 stackPadding7; - UNUSED s32 stackPadding8; - UNUSED s32 stackPadding9; - UNUSED s32 stackPaddingA; - UNUSED s32 stackPaddingB; - s32 temp1; - s32 temp2; - f32 temp_f22; - f32 temp_f24; - f32 temp_f26; - s16 temp_f4; - s16 temp_f6; - u16 var_s2; - u16 temp_v1; - u16 temp_s0; - s16 temp_v1_2; - u16 var_s1; +UNUSED s32 detect_tyre_collision(KartTyre *tyre) { + Collision collision; + UNUSED s32 pad[12]; + s32 courseLengthX; + s32 courseLengthZ; + f32 tyreX; + f32 tyreY; + f32 tyreZ; + s16 sectionIndexX; + s16 sectionIndexZ; + u16 i; + u16 numTriangles; + u16 meshIndex; + s16 gridIndex; + u16 sectionIndex; - spD0.unk30 = 0; - spD0.unk32 = 0; - spD0.unk34 = 0; - spD0.unk3C[0] = 1000.0f; - spD0.unk3C[1] = 1000.0f; - spD0.unk3C[2] = 1000.0f; - temp_f22 = arg0->cornerPos[0]; - temp_f24 = arg0->cornerPos[1]; - temp_f26 = arg0->cornerPos[2]; - switch (arg0->surfaceFlags) { /* irregular */ + collision.unk30 = 0; + collision.unk32 = 0; + collision.unk34 = 0; + collision.surfaceDistance[0] = 1000.0f; + collision.surfaceDistance[1] = 1000.0f; + collision.surfaceDistance[2] = 1000.0f; + tyreX = tyre->pos[0]; + tyreY = tyre->pos[1]; + tyreZ = tyre->pos[2]; + switch (tyre->surfaceFlags) { /* irregular */ case 0x80: - if (func_802AB6C4(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, (u16) (s32) arg0->collisionMeshIndex) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, arg0->collisionMeshIndex); + if (check_collision_zy(&collision, 5.0f, tyreX, tyreY, tyreZ, (u16) (s32) tyre->collisionMeshIndex) == 1) { + tyre->baseHeight = calculate_surface_height(tyreX, tyreY, tyreZ, tyre->collisionMeshIndex); return 1; } break; case 0x40: - if (func_802AAE4C(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, (u16) (s32) arg0->collisionMeshIndex) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, arg0->collisionMeshIndex); + if (check_collision_zx(&collision, 5.0f, tyreX, tyreY, tyreZ, (u16) (s32) tyre->collisionMeshIndex) == 1) { + tyre->baseHeight = calculate_surface_height(tyreX, tyreY, tyreZ, tyre->collisionMeshIndex); return 1; } break; case 0x20: - if (func_802AB288(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, (u16) (s32) arg0->collisionMeshIndex) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, arg0->collisionMeshIndex); + if (check_collision_yx(&collision, 5.0f, tyreX, tyreY, tyreZ, (u16) (s32) tyre->collisionMeshIndex) == 1) { + tyre->baseHeight = calculate_surface_height(tyreX, tyreY, tyreZ, tyre->collisionMeshIndex); return 1; } break; default: break; } - temp1 = gCourseMaxX - gCourseMinX; - temp2 = gCourseMaxZ - gCourseMinZ; - temp_f4 = (temp_f22 - gCourseMinX) / (temp1 / 32); - temp_f6 = (temp_f26 - gCourseMinZ) / (temp2 / 32); - if (temp_f4 < 0) { + courseLengthX = gCourseMaxX - gCourseMinX; + courseLengthZ = gCourseMaxZ - gCourseMinZ; + sectionIndexX = (tyreX - gCourseMinX) / (courseLengthX / GRID_SIZE); + sectionIndexZ = (tyreZ - gCourseMinZ) / (courseLengthZ / GRID_SIZE); + if (sectionIndexX < 0) { return 0; } - if (temp_f6 < 0) { + if (sectionIndexZ < 0) { return 0; } - if (temp_f4 >= 0x20) { + if (sectionIndexX >= GRID_SIZE) { return 0; } - if (temp_f6 >= 0x20) { + if (sectionIndexZ >= GRID_SIZE) { return 0; } - temp_v1_2 = (temp_f4 + temp_f6 * 32); - temp_v1 = D_8014F110[temp_v1_2].unk2; - if (temp_v1 == 0) { + gridIndex = (sectionIndexX + sectionIndexZ * GRID_SIZE); + numTriangles = gCollisionGrid[gridIndex].numTriangles; + if (numTriangles == 0) { return 0; } - var_s1 = D_8014F110[temp_v1_2].unk0; - for (var_s2 = 0; var_s2 < temp_v1; var_s2++) { - temp_s0 = D_8015F584[var_s1]; - if (gCollisionMesh[temp_s0].flags & 0x4000) { - if (temp_s0 != arg0->collisionMeshIndex) { - if (func_802AAE4C(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, temp_s0) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0); - arg0->surfaceType = gCollisionMesh[temp_s0].surfaceType; - arg0->surfaceFlags = 0x40; - arg0->collisionMeshIndex = temp_s0; - if (gCollisionMesh[temp_s0].flags & 0x1000) { - arg0->unk_14 = 1; + sectionIndex = gCollisionGrid[gridIndex].triangle; + for (i = 0; i < numTriangles; i++) { + meshIndex = gCollisionIndices[sectionIndex]; + if (gCollisionMesh[meshIndex].flags & FACING_Y_AXIS) { + if (meshIndex != tyre->collisionMeshIndex) { + if (check_collision_zx(&collision, 5.0f, tyreX, tyreY, tyreZ, meshIndex) == 1) { + tyre->baseHeight = calculate_surface_height(tyreX, tyreY, tyreZ, meshIndex); + tyre->surfaceType = gCollisionMesh[meshIndex].surfaceType; + tyre->surfaceFlags = 0x40; + tyre->collisionMeshIndex = meshIndex; + if (gCollisionMesh[meshIndex].flags & 0x1000) { + tyre->unk_14 = 1; } else { - arg0->unk_14 = 0; + tyre->unk_14 = 0; } return 1; } } - } else if (gCollisionMesh[temp_s0].flags & 0x8000) { - if ((gCollisionMesh[temp_s0].height != 1.0f) && (temp_s0 != arg0->collisionMeshIndex)) { - if (func_802AB6C4(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, temp_s0) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0); - arg0->surfaceType = gCollisionMesh[temp_s0].surfaceType; - arg0->surfaceFlags = 0x80; - arg0->collisionMeshIndex = temp_s0; + } else if (gCollisionMesh[meshIndex].flags & FACING_X_AXIS) { + if ((gCollisionMesh[meshIndex].normalX != 1.0f) && (meshIndex != tyre->collisionMeshIndex)) { + if (check_collision_zy(&collision, 5.0f, tyreX, tyreY, tyreZ, meshIndex) == 1) { + tyre->baseHeight = calculate_surface_height(tyreX, tyreY, tyreZ, meshIndex); + tyre->surfaceType = gCollisionMesh[meshIndex].surfaceType; + tyre->surfaceFlags = 0x80; + tyre->collisionMeshIndex = meshIndex; return 1; } } - } else if ((gCollisionMesh[temp_s0].rotation != 1.0f) && (temp_s0 != arg0->collisionMeshIndex)) { - if (func_802AB288(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, temp_s0) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0); - arg0->surfaceType = gCollisionMesh[temp_s0].surfaceType; - arg0->surfaceFlags = 0x20; - arg0->collisionMeshIndex = temp_s0; + } else if ((gCollisionMesh[meshIndex].normalZ != 1.0f) && (meshIndex != tyre->collisionMeshIndex)) { + if (check_collision_yx(&collision, 5.0f, tyreX, tyreY, tyreZ, meshIndex) == 1) { + tyre->baseHeight = calculate_surface_height(tyreX, tyreY, tyreZ, meshIndex); + tyre->surfaceType = gCollisionMesh[meshIndex].surfaceType; + tyre->surfaceFlags = 0x20; + tyre->collisionMeshIndex = meshIndex; return 1; } } - var_s1++; + sectionIndex++; } - arg0->cornerGroundY = temp_f24; - arg0->surfaceType = 0; + tyre->baseHeight = tyreY; + tyre->surfaceType = 0; + //! @bug // Another function that has a return value but doesn't have an explicit return statement in one of its codepaths. // The return value at this point will be whatever was last returned by func_802AAE4C/func_802AB6C4/func_802AB288 // depending on which (if any) if statements were entered on the loop's last cycle @@ -771,7 +760,7 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize f32 x2; UNUSED f32 y2; f32 z2; - f32 temp_f0_4; + f32 surfaceDistance; f32 temp; UNUSED s32 pad2[2]; f32 area; @@ -841,31 +830,31 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize return 0; } - temp_f0_4 = (triangle->height * x1) + (triangle->gravity * y1) + (triangle->rotation * z1) + triangle->height2; + surfaceDistance = (triangle->normalX * x1) + (triangle->normalY * y1) + (triangle->normalZ * z1) + triangle->distance; - if (temp_f0_4 > boundingBoxSize) { - if (collision->unk3C[2] > temp_f0_4) { + if (surfaceDistance > boundingBoxSize) { + if (collision->surfaceDistance[2] > surfaceDistance) { collision->unk34 = 1; - collision->unk3A = index; - collision->unk3C[2] = temp_f0_4 - boundingBoxSize; - collision->orientationVector[0] = triangle->height; - collision->orientationVector[1] = triangle->gravity; - collision->orientationVector[2] = triangle->rotation; + collision->meshIndexZX = index; + collision->surfaceDistance[2] = surfaceDistance - boundingBoxSize; + collision->orientationVector[0] = triangle->normalX; + collision->orientationVector[1] = triangle->normalY; + collision->orientationVector[2] = triangle->normalZ; } return 0; } - temp = (triangle->height * posX) + (triangle->gravity * posY) + (triangle->rotation * posZ) + triangle->height2; + temp = (triangle->normalX * posX) + (triangle->normalY * posY) + (triangle->normalZ * posZ) + triangle->distance; if (temp < 0.0f) { return 0; } collision->unk34 = 1; - collision->unk3A = index; - collision->unk3C[2] = temp_f0_4 - boundingBoxSize; - collision->orientationVector[0] = triangle->height; - collision->orientationVector[1] = triangle->gravity; - collision->orientationVector[2] = triangle->rotation; + collision->meshIndexZX = index; + collision->surfaceDistance[2] = surfaceDistance - boundingBoxSize; + collision->orientationVector[0] = triangle->normalX; + collision->orientationVector[1] = triangle->normalY; + collision->orientationVector[2] = triangle->normalZ; return 1; } @@ -882,13 +871,13 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 x2; f32 y2; UNUSED s32 pad2[3]; - f32 temp_f0_4; - f32 temp_f4_2; + f32 distanceToSurface; + f32 distanceToSurface2; UNUSED s32 pad3[2]; f32 area; f32 area2; f32 area3; - s32 bool = 1; + s32 bool = TRUE; if (triangle->minX > x1) { return 0; } @@ -925,7 +914,7 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if (area2 * area3 < 0.0f) { - bool = 0; + bool = FALSE; } } else { @@ -936,116 +925,115 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if ((area * area3) < 0.0f) { - bool = 0; + bool = FALSE; } } else { if ((area * area2) < 0.0f) { - bool = 0; + bool = FALSE; } else { area3 = (y4 - y1) * (x2 - x1) - (x4 - x1) * (y2 - y1); if (area3 != 0) { if ((area2 * area3) < 0.0f) { - bool = 0; + bool = FALSE; } } } } } - if (bool == 0) { + if (!bool) { return 0; } - temp_f0_4 = ((triangle->height * x1) + (triangle->gravity * y1) + (triangle->rotation * z1)) + triangle->height2; + distanceToSurface = ((triangle->normalX * x1) + (triangle->normalY * y1) + (triangle->normalZ * z1)) + triangle->distance; if (triangle->flags & 0x200) { - temp_f4_2 = ((triangle->height * arg6) + (triangle->gravity * arg7) + (triangle->rotation * arg8)) + triangle->height2; - //sp48 = temp_f4_2; - if ((temp_f0_4 > 0.0f) && (temp_f4_2 > 0.0f)) { - if (temp_f0_4 < boundingBoxSize) { + distanceToSurface2 = ((triangle->normalX * arg6) + (triangle->normalY * arg7) + (triangle->normalZ * arg8)) + triangle->distance; + if ((distanceToSurface > 0.0f) && (distanceToSurface2 > 0.0f)) { + if (distanceToSurface < boundingBoxSize) { arg->unk30 = 1; - arg->unk36 = arg5; - arg->unk3C[0] = temp_f0_4 - boundingBoxSize; - arg->unk48[0] = triangle->height; - arg->unk48[1] = triangle->gravity; - arg->unk48[2] = triangle->rotation; + arg->meshIndexYX = arg5; + arg->surfaceDistance[0] = distanceToSurface - boundingBoxSize; + arg->unk48[0] = triangle->normalX; + arg->unk48[1] = triangle->normalY; + arg->unk48[2] = triangle->normalZ; return 1; } return 0; } - if ((temp_f0_4 < 0.0f) && (temp_f4_2 < 0.0f)) { - temp_f0_4 *= -1.0f; - if (temp_f0_4 < boundingBoxSize) { + if ((distanceToSurface < 0.0f) && (distanceToSurface2 < 0.0f)) { + distanceToSurface *= -1.0f; + if (distanceToSurface < boundingBoxSize) { arg->unk30 = 1; - arg->unk36 = arg5; - arg->unk3C[0] = temp_f0_4 - boundingBoxSize; - arg->unk48[0] = -triangle->height; - arg->unk48[1] = -triangle->gravity; - arg->unk48[2] = -triangle->rotation; + arg->meshIndexYX = arg5; + arg->surfaceDistance[0] = distanceToSurface - boundingBoxSize; + arg->unk48[0] = -triangle->normalX; + arg->unk48[1] = -triangle->normalY; + arg->unk48[2] = -triangle->normalZ; return 1; } return 0; } - if ((temp_f0_4 > 0.0f) && (temp_f4_2 < 0.0f)) { + if ((distanceToSurface > 0.0f) && (distanceToSurface2 < 0.0f)) { arg->unk30 = 1; - arg->unk36 = arg5; - arg->unk3C[0] = -(temp_f0_4 + boundingBoxSize); - arg->unk48[0] = -triangle->height; - arg->unk48[1] = -triangle->gravity; - arg->unk48[2] = -triangle->rotation; + arg->meshIndexYX = arg5; + arg->surfaceDistance[0] = -(distanceToSurface + boundingBoxSize); + arg->unk48[0] = -triangle->normalX; + arg->unk48[1] = -triangle->normalY; + arg->unk48[2] = -triangle->normalZ; return 1; } - if ((temp_f0_4 < 0.0f) && (temp_f4_2 > 0.0f)) { + if ((distanceToSurface < 0.0f) && (distanceToSurface2 > 0.0f)) { arg->unk30 = 1; - arg->unk36 = arg5; - arg->unk3C[0] = temp_f0_4 + boundingBoxSize; - arg->unk48[0] = triangle->height; - arg->unk48[1] = triangle->gravity; - arg->unk48[2] = triangle->rotation; + arg->meshIndexYX = arg5; + arg->surfaceDistance[0] = distanceToSurface + boundingBoxSize; + arg->unk48[0] = triangle->normalX; + arg->unk48[1] = triangle->normalY; + arg->unk48[2] = triangle->normalZ; return 1; } - if (temp_f0_4 == 0.0f) { - if (temp_f4_2 >= 0.0f) { + if (distanceToSurface == 0.0f) { + if (distanceToSurface2 >= 0.0f) { arg->unk30 = 1; - arg->unk36 = arg5; - arg->unk3C[0] = temp_f4_2 + boundingBoxSize; - arg->unk48[0] = triangle->height; - arg->unk48[1] = triangle->gravity; - arg->unk48[2] = triangle->rotation; + arg->meshIndexYX = arg5; + arg->surfaceDistance[0] = distanceToSurface2 + boundingBoxSize; + arg->unk48[0] = triangle->normalX; + arg->unk48[1] = triangle->normalY; + arg->unk48[2] = triangle->normalZ; return 1; } arg->unk30 = 1; - arg->unk36 = arg5; - arg->unk3C[0] = -(temp_f4_2 + boundingBoxSize); - arg->unk48[0] = triangle->height; - arg->unk48[1] = triangle->gravity; - arg->unk48[2] = triangle->rotation; + arg->meshIndexYX = arg5; + arg->surfaceDistance[0] = -(distanceToSurface2 + boundingBoxSize); + arg->unk48[0] = triangle->normalX; + arg->unk48[1] = triangle->normalY; + arg->unk48[2] = triangle->normalZ; return 1; } return 0; } - if (temp_f0_4 > boundingBoxSize) { - if (temp_f0_4 < arg->unk3C[0]) { + if (distanceToSurface > boundingBoxSize) { + if (distanceToSurface < arg->surfaceDistance[0]) { arg->unk30 = 1; - arg->unk36 = arg5; - arg->unk3C[0] = temp_f0_4 - boundingBoxSize; - arg->unk48[0] = triangle->height; - arg->unk48[1] = triangle->gravity; - arg->unk48[2] = triangle->rotation; + arg->meshIndexYX = arg5; + arg->surfaceDistance[0] = distanceToSurface - boundingBoxSize; + arg->unk48[0] = triangle->normalX; + arg->unk48[1] = triangle->normalY; + arg->unk48[2] = triangle->normalZ; } return 0; } - temp_f4_2 = (triangle->height * arg6) + (triangle->gravity * arg7) + (triangle->rotation * arg8) + triangle->height2; - if (temp_f4_2 < 0.0f) { + distanceToSurface2 = (triangle->normalX * arg6) + (triangle->normalY * arg7) + (triangle->normalZ * arg8) + triangle->distance; + if (distanceToSurface2 < 0.0f) { return 0; } arg->unk30 = 1; - arg->unk36 = arg5; - arg->unk3C[0] = temp_f0_4 - boundingBoxSize; - arg->unk48[0] = triangle->height; - arg->unk48[1] = triangle->gravity; - arg->unk48[2] = triangle->rotation; + arg->meshIndexYX = arg5; + arg->surfaceDistance[0] = distanceToSurface - boundingBoxSize; + arg->unk48[0] = triangle->normalX; + arg->unk48[1] = triangle->normalY; + arg->unk48[2] = triangle->normalZ; return 1; } @@ -1063,8 +1051,8 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 y2; f32 z2; UNUSED s32 pad3[2]; - f32 temp_f0_4; - f32 temp_f4_2; + f32 distanceToSurface; + f32 distanceToSurface2; UNUSED s32 pad4[2]; f32 area; f32 area2; @@ -1137,379 +1125,381 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, return 0; } - temp_f0_4 = ((triangle->height * x1) + (triangle->gravity * y1) + (triangle->rotation * z1)) + triangle->height2; + distanceToSurface = ((triangle->normalX * x1) + (triangle->normalY * y1) + (triangle->normalZ * z1)) + triangle->distance; if (triangle->flags & 0x200) { - temp_f4_2 = ((triangle->height * arg6) + (triangle->gravity * arg7) + (triangle->rotation * arg8)) + triangle->height2; + distanceToSurface2 = ((triangle->normalX * arg6) + (triangle->normalY * arg7) + (triangle->normalZ * arg8)) + triangle->distance; //sp48 = temp_f4_2; - if ((temp_f0_4 > 0.0f) && (temp_f4_2 > 0.0f)) { - if (temp_f0_4 < boundingBoxSize) { + if ((distanceToSurface > 0.0f) && (distanceToSurface2 > 0.0f)) { + if (distanceToSurface < boundingBoxSize) { arg->unk32 = 1; - arg->unk38 = arg5; - arg->unk3C[1] = temp_f0_4 - boundingBoxSize; - arg->unk54[0] = triangle->height; - arg->unk54[1] = triangle->gravity; - arg->unk54[2] = triangle->rotation; + arg->meshIndexZY = arg5; + arg->surfaceDistance[1] = distanceToSurface - boundingBoxSize; + arg->unk54[0] = triangle->normalX; + arg->unk54[1] = triangle->normalY; + arg->unk54[2] = triangle->normalZ; return 1; } return 0; } - if ((temp_f0_4 < 0.0f) && (temp_f4_2 < 0.0f)) { - temp_f0_4 *= -1.0f; - if (temp_f0_4 < boundingBoxSize) { + if ((distanceToSurface < 0.0f) && (distanceToSurface2 < 0.0f)) { + distanceToSurface *= -1.0f; + if (distanceToSurface < boundingBoxSize) { arg->unk32 = 1; - arg->unk38 = arg5; - arg->unk3C[1] = temp_f0_4 - boundingBoxSize; - arg->unk54[0] = -triangle->height; - arg->unk54[1] = -triangle->gravity; - arg->unk54[2] = -triangle->rotation; + arg->meshIndexZY = arg5; + arg->surfaceDistance[1] = distanceToSurface - boundingBoxSize; + arg->unk54[0] = -triangle->normalX; + arg->unk54[1] = -triangle->normalY; + arg->unk54[2] = -triangle->normalZ; return 1; } return 0; } - if ((temp_f0_4 > 0.0f) && (temp_f4_2 < 0.0f)) { + if ((distanceToSurface > 0.0f) && (distanceToSurface2 < 0.0f)) { arg->unk32 = 1; - arg->unk38 = arg5; - arg->unk3C[1] = -(temp_f0_4 + boundingBoxSize); - arg->unk54[0] = -triangle->height; - arg->unk54[1] = -triangle->gravity; - arg->unk54[2] = -triangle->rotation; + arg->meshIndexZY = arg5; + arg->surfaceDistance[1] = -(distanceToSurface + boundingBoxSize); + arg->unk54[0] = -triangle->normalX; + arg->unk54[1] = -triangle->normalY; + arg->unk54[2] = -triangle->normalZ; return 1; } - if ((temp_f0_4 < 0.0f) && (temp_f4_2 > 0.0f)) { + if ((distanceToSurface < 0.0f) && (distanceToSurface2 > 0.0f)) { arg->unk32 = 1; - arg->unk38 = arg5; - arg->unk3C[1] = temp_f0_4 + boundingBoxSize; - arg->unk54[0] = triangle->height; - arg->unk54[1] = triangle->gravity; - arg->unk54[2] = triangle->rotation; + arg->meshIndexZY = arg5; + arg->surfaceDistance[1] = distanceToSurface + boundingBoxSize; + arg->unk54[0] = triangle->normalX; + arg->unk54[1] = triangle->normalY; + arg->unk54[2] = triangle->normalZ; return 1; } - if (temp_f0_4 == 0.0f) { - if (temp_f4_2 >= 0.0f) { + if (distanceToSurface == 0.0f) { + if (distanceToSurface2 >= 0.0f) { arg->unk32 = 1; - arg->unk38 = arg5; - arg->unk3C[1] = temp_f4_2 + boundingBoxSize; - arg->unk54[0] = triangle->height; - arg->unk54[1] = triangle->gravity; - arg->unk54[2] = triangle->rotation; + arg->meshIndexZY = arg5; + arg->surfaceDistance[1] = distanceToSurface2 + boundingBoxSize; + arg->unk54[0] = triangle->normalX; + arg->unk54[1] = triangle->normalY; + arg->unk54[2] = triangle->normalZ; return 1; } arg->unk32 = 1; - arg->unk38 = arg5; - arg->unk3C[1] = -(temp_f4_2 + boundingBoxSize); - arg->unk54[0] = triangle->height; - arg->unk54[1] = triangle->gravity; - arg->unk54[2] = triangle->rotation; + arg->meshIndexZY = arg5; + arg->surfaceDistance[1] = -(distanceToSurface2 + boundingBoxSize); + arg->unk54[0] = triangle->normalX; + arg->unk54[1] = triangle->normalY; + arg->unk54[2] = triangle->normalZ; return 1; } return 0; } - if (temp_f0_4 > boundingBoxSize) { - if (arg->unk3C[1] > temp_f0_4) { + if (distanceToSurface > boundingBoxSize) { + if (arg->surfaceDistance[1] > distanceToSurface) { arg->unk32 = 1; - arg->unk38 = arg5; - arg->unk3C[1] = temp_f0_4 - boundingBoxSize; - arg->unk54[0] = triangle->height; - arg->unk54[1] = triangle->gravity; - arg->unk54[2] = triangle->rotation; + arg->meshIndexZY = arg5; + arg->surfaceDistance[1] = distanceToSurface - boundingBoxSize; + arg->unk54[0] = triangle->normalX; + arg->unk54[1] = triangle->normalY; + arg->unk54[2] = triangle->normalZ; } return 0; } - temp_f4_2 = (triangle->height * arg6) + (triangle->gravity * arg7) + (triangle->rotation * arg8) + triangle->height2; - if (temp_f4_2 < 0.0f) { + distanceToSurface2 = (triangle->normalX * arg6) + (triangle->normalY * arg7) + (triangle->normalZ * arg8) + triangle->distance; + if (distanceToSurface2 < 0.0f) { return 0; } arg->unk32 = 1; - arg->unk38 = arg5; - arg->unk3C[1] = temp_f0_4 - boundingBoxSize; - arg->unk54[0] = triangle->height; - arg->unk54[1] = triangle->gravity; - arg->unk54[2] = triangle->rotation; + arg->meshIndexZY = arg5; + arg->surfaceDistance[1] = distanceToSurface - boundingBoxSize; + arg->unk54[0] = triangle->normalX; + arg->unk54[1] = triangle->normalY; + arg->unk54[2] = triangle->normalZ; return 1; } -u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2) { - s32 temp_v0_4; - s32 temp_v1; - s16 temp_f10; - s16 temp_f16; - u16 temp_s6; - u16 surfaceIndex; - s16 temp_v1_2; - - u16 phi_s2; - +u16 actor_terrain_collision(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2) { + s32 courseLengthX; + s32 courseLengthZ; + s16 sectionIndexX; + s16 sectionIndexZ; + u16 numTriangles; + u16 collisionIndex; + s16 gridIndex; + u16 sectionIndex; u16 flags = 0; - s32 temp1; - s32 temp2; + s32 sectionX; + s32 sectionZ; u16 i; collision->unk30 = 0; collision->unk32 = 0; collision->unk34 = 0; - collision->unk3C[0] = 1000.0f; - collision->unk3C[1] = 1000.0f; - collision->unk3C[2] = 1000.0f; + collision->surfaceDistance[0] = 1000.0f; + collision->surfaceDistance[1] = 1000.0f; + collision->surfaceDistance[2] = 1000.0f; - if ((s32) collision->unk3A < (s32) gCollisionMeshCount) { - if (is_colliding_with_drivable_surface(collision, boundingBoxSize, x1, y1, z1, collision->unk3A, x2, y2, z2) == 1) { - flags |= 0x4000; + // Check if an intersection test has already been performed. + if ((s32) collision->meshIndexZX < (s32) gCollisionMeshCount) { + if (is_colliding_with_drivable_surface(collision, boundingBoxSize, x1, y1, z1, collision->meshIndexZX, x2, y2, z2) == 1) { + flags |= FACING_Y_AXIS; } } - if ((s32) collision->unk36 < (s32) gCollisionMeshCount) { - if (is_colliding_with_wall2(collision, boundingBoxSize, x1, y1, z1, collision->unk36, x2, y2, z2) == 1) { - flags |= 0x2000; + if ((s32) collision->meshIndexYX < (s32) gCollisionMeshCount) { + if (is_colliding_with_wall2(collision, boundingBoxSize, x1, y1, z1, collision->meshIndexYX, x2, y2, z2) == 1) { + flags |= FACING_Z_AXIS; } } - if ((s32) collision->unk38 < (s32) gCollisionMeshCount) { - if (is_colliding_with_wall1(collision, boundingBoxSize, x1, y1, z1, collision->unk38, x2, y2, z2) == 1) { - flags |= 0x8000; + if ((s32) collision->meshIndexZY < (s32) gCollisionMeshCount) { + if (is_colliding_with_wall1(collision, boundingBoxSize, x1, y1, z1, collision->meshIndexZY, x2, y2, z2) == 1) { + flags |= FACING_X_AXIS; } } - if (flags == (0x4000 | 0x2000 | 0x8000)) { + if (flags == (FACING_Y_AXIS | FACING_Z_AXIS | FACING_X_AXIS)) { return flags; } + courseLengthX = (s32) gCourseMaxX - gCourseMinX; + courseLengthZ = (s32) gCourseMaxZ - gCourseMinZ; - temp_v0_4 = (s32) gCourseMaxX - gCourseMinX; - temp_v1 = (s32) gCourseMaxZ - gCourseMinZ; + sectionX = courseLengthX / GRID_SIZE; + sectionZ = courseLengthZ / GRID_SIZE; - temp1 = temp_v0_4 / 32; - temp2 = temp_v1 / 32; + sectionIndexX = (x1 - gCourseMinX) / sectionX; + sectionIndexZ = (z1 - gCourseMinZ) / sectionZ; - temp_f10 = (x1 - gCourseMinX) / temp1; - temp_f16 = (z1 - gCourseMinZ) / temp2; - - if (temp_f10 < 0) { + if (sectionIndexX < 0) { return 0; } - if (temp_f16 < 0) { + if (sectionIndexZ < 0) { return 0; } - if (temp_f10 >= 32) { + if (sectionIndexX >= GRID_SIZE) { return 0; } - if (temp_f16 >= 32) { + if (sectionIndexZ >= GRID_SIZE) { return 0; } - temp_v1_2 = (temp_f10 + temp_f16 * 32); - temp_s6 = D_8014F110[temp_v1_2].unk2; + gridIndex = (sectionIndexX + sectionIndexZ * GRID_SIZE); + numTriangles = gCollisionGrid[gridIndex].numTriangles; - if (temp_s6 == 0) { + if (numTriangles == 0) { return flags; } - phi_s2 = D_8014F110[temp_v1_2].unk0; + sectionIndex = gCollisionGrid[gridIndex].triangle; - for (i = 0; i < temp_s6; i++) { - if (flags == (0x4000 | 0x2000 | 0x8000)) { + for (i = 0; i < numTriangles; i++) { + if (flags == (FACING_Y_AXIS | FACING_Z_AXIS | FACING_X_AXIS)) { return flags; } - surfaceIndex = D_8015F584[phi_s2]; + collisionIndex = gCollisionIndices[sectionIndex]; - if ((gCollisionMesh[surfaceIndex].flags & 0x4000)) { - if ((flags & 0x4000) == 0) { - if (surfaceIndex != collision->unk3A) { - if (is_colliding_with_drivable_surface(collision, boundingBoxSize, x1, y1, z1, surfaceIndex, x2, y2, z2) == 1) { - flags |= 0x4000; + if ((gCollisionMesh[collisionIndex].flags & FACING_Y_AXIS)) { + if ((flags & FACING_Y_AXIS) == 0) { + if (collisionIndex != collision->meshIndexZX) { + if (is_colliding_with_drivable_surface(collision, boundingBoxSize, x1, y1, z1, collisionIndex, x2, y2, z2) == 1) { + flags |= FACING_Y_AXIS; } } } - } else if ((gCollisionMesh[surfaceIndex].flags & 0x8000) != 0) { - if ((flags & 0x8000) == 0) { - if (surfaceIndex != collision->unk38) { - if (is_colliding_with_wall1(collision, boundingBoxSize, x1, y1, z1, surfaceIndex, x2, y2, z2) == 1) { - flags |= 0x8000; + } else if ((gCollisionMesh[collisionIndex].flags & FACING_X_AXIS) != 0) { + if ((flags & FACING_X_AXIS) == 0) { + if (collisionIndex != collision->meshIndexZY) { + if (is_colliding_with_wall1(collision, boundingBoxSize, x1, y1, z1, collisionIndex, x2, y2, z2) == 1) { + flags |= FACING_X_AXIS; } } } - } else if ((flags & 0x2000) == 0) { - if (surfaceIndex != collision->unk36) { - if (is_colliding_with_wall2(collision, boundingBoxSize, x1, y1, z1, surfaceIndex, x2, y2, z2) == 1) { - flags |= 0x2000; + } else if ((flags & FACING_Z_AXIS) == 0) { + if (collisionIndex != collision->meshIndexYX) { + if (is_colliding_with_wall2(collision, boundingBoxSize, x1, y1, z1, collisionIndex, x2, y2, z2) == 1) { + flags |= FACING_Z_AXIS; } } } - phi_s2++; + sectionIndex++; } return flags; } -u16 func_802ADDC8(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ) { - u16 temp_v1; - s32 temp_f4; - s32 temp_f6; - u16 temp_v0_4; - s32 temp1; - s32 temp2; - s16 temp_f10; - s16 temp_f16; - s16 temp; +u16 check_bounding_collision(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ) { + u16 numTriangles; + s32 courseLengthX; + s32 courseLengthZ; + u16 meshIndex; + s32 sectionX; + s32 sectionZ; + s16 sectionIndexX; + s16 sectionIndexZ; + s16 gridIndex; u16 i; - u16 var_s2; - u16 var_s4; + u16 sectionIndex; + u16 flags; collision->unk30 = 0; collision->unk32 = 0; collision->unk34 = 0; - collision->unk3C[0] = 1000.0f; - collision->unk3C[1] = 1000.0f; - collision->unk3C[2] = 1000.0f; - var_s4 = 0; - if (collision->unk3A < gCollisionMeshCount) { - if (func_802AAE4C(collision, boundingBoxSize, posX, posY, posZ, collision->unk3A) == 1) { - var_s4 |= 0x4000; + collision->surfaceDistance[0] = 1000.0f; + collision->surfaceDistance[1] = 1000.0f; + collision->surfaceDistance[2] = 1000.0f; + flags = 0; + if (collision->meshIndexZX < gCollisionMeshCount) { + if (check_collision_zx(collision, boundingBoxSize, posX, posY, posZ, collision->meshIndexZX) == 1) { + flags |= FACING_Y_AXIS; } } - if (collision->unk36 < gCollisionMeshCount) { - if (func_802AB288(collision, boundingBoxSize, posX, posY, posZ, collision->unk36) == 1) { - var_s4 |= 0x2000; + if (collision->meshIndexYX < gCollisionMeshCount) { + if (check_collision_yx(collision, boundingBoxSize, posX, posY, posZ, collision->meshIndexYX) == 1) { + flags |= FACING_Z_AXIS; } } - if (collision->unk38 < gCollisionMeshCount) { - if (func_802AB6C4(collision, boundingBoxSize, posX, posY, posZ, collision->unk38 ) == 1) { - var_s4 |= 0x8000; + if (collision->meshIndexZY < gCollisionMeshCount) { + if (check_collision_zy(collision, boundingBoxSize, posX, posY, posZ, collision->meshIndexZY ) == 1) { + flags |= FACING_X_AXIS; } } - if (var_s4 == (0x4000 | 0x2000 | 0x8000)) { - return var_s4; + if (flags == (FACING_Y_AXIS | FACING_Z_AXIS | FACING_X_AXIS)) { + return flags; } - temp_f4 = (s32) gCourseMaxX - gCourseMinX; - temp_f6 = (s32) gCourseMaxZ - gCourseMinZ; + courseLengthX = (s32) gCourseMaxX - gCourseMinX; + courseLengthZ = (s32) gCourseMaxZ - gCourseMinZ; - temp1 = temp_f4 / 32; - temp2 = temp_f6 / 32; + sectionX = courseLengthX / GRID_SIZE; + sectionZ = courseLengthZ / GRID_SIZE; - temp_f10 = (posX - gCourseMinX) / temp1; - temp_f16 = (posZ - gCourseMinZ) / temp2; + sectionIndexX = (posX - gCourseMinX) / sectionX; + sectionIndexZ = (posZ - gCourseMinZ) / sectionZ; - if (temp_f10 < 0) { + if (sectionIndexX < 0) { return 0; } - if (temp_f16 < 0) { + if (sectionIndexZ < 0) { return 0; } - if (temp_f10 >= 32) { + if (sectionIndexX >= GRID_SIZE) { return 0; } - if (temp_f16 >= 32) { + if (sectionIndexZ >= GRID_SIZE) { return 0; } - temp = temp_f10 + temp_f16 * 32; - temp_v1 = D_8014F110[temp].unk2; - if (temp_v1 == 0) { - return var_s4; + gridIndex = sectionIndexX + sectionIndexZ * GRID_SIZE; + numTriangles = gCollisionGrid[gridIndex].numTriangles; + if (numTriangles == 0) { + return flags; } - var_s2 = D_8014F110[temp].unk0; + sectionIndex = gCollisionGrid[gridIndex].triangle; - for (i = 0; i < temp_v1; i++) { - if (var_s4 == (0x8000 | 0x4000 | 0x2000)) { - return var_s4; + for (i = 0; i < numTriangles; i++) { + if (flags == (FACING_X_AXIS | FACING_Y_AXIS | FACING_Z_AXIS)) { + return flags; } - temp_v0_4 = D_8015F584[var_s2]; - if (gCollisionMesh[temp_v0_4].flags & 0x4000) { - if (!(var_s4 & 0x4000)) { - if (temp_v0_4 != collision->unk3A) { - if (func_802AAE4C(collision, boundingBoxSize, posX, posY, posZ, temp_v0_4) == 1) { - var_s4 |= 0x4000; + meshIndex = gCollisionIndices[sectionIndex]; + if (gCollisionMesh[meshIndex].flags & FACING_Y_AXIS) { + if (!(flags & FACING_Y_AXIS)) { + if (meshIndex != collision->meshIndexZX) { + if (check_collision_zx(collision, boundingBoxSize, posX, posY, posZ, meshIndex) == 1) { + flags |= FACING_Y_AXIS; } } } - } else if (gCollisionMesh[temp_v0_4].flags & 0x8000) { - if (!(var_s4 & 0x8000)) { - if (temp_v0_4 != collision->unk38) { - if (func_802AB6C4(collision, boundingBoxSize, posX, posY, posZ, temp_v0_4) == 1) { - var_s4 |= 0x8000; + } else if (gCollisionMesh[meshIndex].flags & FACING_X_AXIS) { + if (!(flags & FACING_X_AXIS)) { + if (meshIndex != collision->meshIndexZY) { + if (check_collision_zy(collision, boundingBoxSize, posX, posY, posZ, meshIndex) == 1) { + flags |= FACING_X_AXIS; } } } } else { - if (!(var_s4 & 0x2000)) { - if (temp_v0_4 != collision->unk36) { - if (func_802AB288(collision, boundingBoxSize, posX, posY, posZ, temp_v0_4) == 1) { - var_s4 |= 0x2000; + if (!(flags & FACING_Z_AXIS)) { + if (meshIndex != collision->meshIndexYX) { + if (check_collision_yx(collision, boundingBoxSize, posX, posY, posZ, meshIndex) == 1) { + flags |= FACING_Z_AXIS; } } } } - var_s2++; + sectionIndex++; } - return var_s4; + return flags; } extern u8 D_8014F1110; -f32 func_802AE1C0(f32 posX, f32 posY, f32 posZ) { - f32 temp_f0; - s16 temp_f4; - s16 temp_f6; - s16 temp_f66; +/** + * If unable to spawn actor on the surface set to -3000.0f or + * if outside the collision grid, spawn in the air (3000.0f). +*/ +f32 spawn_actor_on_surface(f32 posX, f32 posY, f32 posZ) { + f32 height; + s16 sectionIndexX; + s16 sectionIndexZ; + s16 gridSection; u16 index; - u16 iter; - u16 phi_s1; + u16 numTriangles; + u16 sectionIndex; f32 phi_f20 = -3000.0f; u16 i; - s32 a; - s32 b; - s32 c; - s32 d; + s32 courseLengthX; + s32 courseLengthZ; + s32 sectionX; + s32 sectionZ; - a = (gCourseMaxX - gCourseMinX); - b = (gCourseMaxZ - gCourseMinZ); - c = a / 32; - d = b / 32; + courseLengthX = (gCourseMaxX - gCourseMinX); + courseLengthZ = (gCourseMaxZ - gCourseMinZ); + sectionX = courseLengthX / GRID_SIZE; + sectionZ = courseLengthZ / GRID_SIZE; - temp_f4 = (s16) ((posX - gCourseMinX) / c); - temp_f6 = (s16) ((posZ - gCourseMinZ) / d); - temp_f66 = temp_f4 + (temp_f6 * 32); - iter = D_8014F110[temp_f66].unk2; + sectionIndexX = (s16) ((posX - gCourseMinX) / sectionX); + sectionIndexZ = (s16) ((posZ - gCourseMinZ) / sectionZ); + gridSection = sectionIndexX + (sectionIndexZ * GRID_SIZE); + numTriangles = gCollisionGrid[gridSection].numTriangles; - if (temp_f4 < 0) { + if (sectionIndexX < 0) { return 3000.0f; } - if (temp_f6 < 0) { + if (sectionIndexZ < 0) { return 3000.0f; } - if (temp_f4 >= 32) { + if (sectionIndexX >= GRID_SIZE) { return 3000.0f; } - if (temp_f6 >= 32) { + if (sectionIndexZ >= GRID_SIZE) { return 3000.0f; } - if (iter == 0) { + if (numTriangles == 0) { return 3000.0f; } - phi_s1 = D_8014F110[temp_f66].unk0; + sectionIndex = gCollisionGrid[gridSection].triangle; - for (i = 0; i < iter; i++) { + for (i = 0; i < numTriangles; i++) { - index = D_8015F584[phi_s1]; + index = gCollisionIndices[sectionIndex]; - if ((gCollisionMesh[index].flags & 0x4000) && (func_802ABB04(posX, posZ, index) == 1)) { - temp_f0 = func_802ABE30(posX, posY, posZ, index); - if ((temp_f0 <= posY) && (phi_f20 < temp_f0)) { - phi_f20 = temp_f0; + if ((gCollisionMesh[index].flags & FACING_Y_AXIS) && (check_horizontally_colliding_with_triangle(posX, posZ, index) == 1)) { + height = calculate_surface_height(posX, posY, posZ, index); + if ((height <= posY) && (phi_f20 < height)) { + phi_f20 = height; } } - phi_s1++; + sectionIndex++; } return phi_f20; } @@ -1536,7 +1526,7 @@ f32 func_802AE1C0(f32 posX, f32 posY, f32 posZ) { } else\ out = c;\ -void set_collision_triangle(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionId) { +void add_collision_triangle(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionId) { CollisionTriangle *triangle = &gCollisionMesh[gCollisionMeshCount]; s16 x2; s16 z2; @@ -1682,13 +1672,14 @@ void set_collision_triangle(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 gCourseMaxZ = maxZ; } - triangle->height = normalX; - triangle->gravity = normalY; - triangle->rotation = normalZ; - triangle->height2 = distance; + triangle->normalX = normalX; + triangle->normalY = normalY; + triangle->normalZ = normalZ; + triangle->distance = distance; triangle->surfaceType = (u16) surfaceType; + // Square the crossProduct to produce a magnitude crossProductX = crossProductX * crossProductX; crossProductY = crossProductY * crossProductY; crossProductZ = crossProductZ * crossProductZ; @@ -1714,15 +1705,17 @@ void set_collision_triangle(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 triangle->flags = flags; + // Find the axis with the highest magnitude. + // Y is the significant axis if ((crossProductX <= crossProductY) && (crossProductY >= crossProductZ)) { - triangle->flags |= 0x4000; + triangle->flags |= FACING_Y_AXIS; // X is the significant axis } else if ((crossProductX > crossProductY) && (crossProductX >= crossProductZ)) { - triangle->flags |= 0x8000; + triangle->flags |= FACING_X_AXIS; // Z is the significant axis } else { - triangle->flags |= 0x2000; + triangle->flags |= FACING_Z_AXIS; } gCollisionMeshCount++; } @@ -1739,7 +1732,7 @@ void set_vtx_from_triangle(u32 triangle, s8 surfaceType, u16 sectionId) { Vtx *vtx2 = vtxBuffer[vert2]; Vtx *vtx3 = vtxBuffer[vert3]; - set_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); + add_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); } void set_vtx_from_tri2(u32 triangle1, u32 triangle2, s8 surfaceType, u16 sectionId) { @@ -1762,9 +1755,9 @@ void set_vtx_from_tri2(u32 triangle1, u32 triangle2, s8 surfaceType, u16 section Vtx *vtx6 = vtxBuffer[vert6]; // Triangle 1 - set_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); + add_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); // Triangle 2 - set_collision_triangle(vtx4, vtx5, vtx6, surfaceType, sectionId); + add_collision_triangle(vtx4, vtx5, vtx6, surfaceType, sectionId); } void set_vtx_from_quadrangle(u32 line, s8 surfaceType, u16 sectionId) { @@ -1785,9 +1778,9 @@ void set_vtx_from_quadrangle(u32 line, s8 surfaceType, u16 sectionId) { vtx4 = vtxBuffer[vert4]; // Triangle 1 - set_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); + add_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); // Triangle 2 - set_collision_triangle(vtx1, vtx3, vtx4, surfaceType, sectionId); + add_collision_triangle(vtx1, vtx3, vtx4, surfaceType, sectionId); } /** @@ -1904,10 +1897,11 @@ s32 is_triangle_intersecting_bounding_box(s16 minX, s16 maxX, s16 minZ, s16 maxZ } /** - * Appears to initialize some variables and struct members after - * course displaylists have been parsed. + * Splits the collision mesh into 32x32 sections. This allows the game to check only + * nearby geography for a collision rather than checking against the whole collision mesh. + * (checking against the whole mesh for every actor would be expensive) */ -void func_802AF314(void) { +void generate_collision_grid(void) { CollisionTriangle *triangle; s32 i, j, k; UNUSED s32 pad[5]; @@ -1915,39 +1909,40 @@ void func_802AF314(void) { s16 maxZ; s16 minX; s16 minZ; - s32 scaledZ; - s32 scaledX; + s32 sectionZ; + s32 sectionX; s32 courseLengthX; s32 courseLengthZ; s32 index; courseLengthX = (s32) gCourseMaxX - gCourseMinX; courseLengthZ = (s32) gCourseMaxZ - gCourseMinZ; - scaledX = courseLengthX / 32; - scaledZ = courseLengthZ / 32; + // Separate the course into 32 sections + sectionX = courseLengthX / GRID_SIZE; + sectionZ = courseLengthZ / GRID_SIZE; + // Reset the collision grid for (i = 0; i < 1024; i++) { - D_8014F110[i].unk2 = 0; + gCollisionGrid[i].numTriangles = 0; } - D_8015F58A = 0; + gNumCollisionTriangles = 0; /** - * @bug possibly bug. Allocate memory but not increment the pointer. - * This is bad, dumb code, and more importantly it's bad dumb code that doesn't make any sense here. - * It is incremented after this function completes using a different variable. - * Not good. + * @warning gNextFreeMemoryAddress incremented just outside this function. Bad practice to hide memory allocation like this. */ - D_8015F584 = (u16 *) gNextFreeMemoryAddress; + gCollisionIndices = (u16 *) gNextFreeMemoryAddress; - for (j = 0; j < 32; j++) { - for (k = 0; k < 32; k++) { - index = k + j * 32; + // 32x32 grid + for (j = 0; j < GRID_SIZE; j++) { + for (k = 0; k < GRID_SIZE; k++) { + index = k + j * GRID_SIZE; - minX = (gCourseMinX + (scaledX * k)) - 20; - minZ = (gCourseMinZ + (scaledZ * j)) - 20; + // Select a section of the course using min/max akin to drawing a bounding-box + minX = (gCourseMinX + (sectionX * k)) - 20; + minZ = (gCourseMinZ + (sectionZ * j)) - 20; - maxX = minX + scaledX + 40; - maxZ = minZ + scaledZ + 40; + maxX = minX + sectionX + 40; + maxZ = minZ + sectionZ + 40; for (i = 0; i < gCollisionMeshCount; i++) { triangle = gCollisionMesh + i; @@ -1956,13 +1951,15 @@ void func_802AF314(void) { if (triangle->maxX < minX) { continue; } if (triangle->minX > maxX) { continue; } + // Add the collision triangle to the list if it's inside the bounding-box if (is_triangle_intersecting_bounding_box(minX, maxX, minZ, maxZ, (u16) i) == 1) { - if (D_8014F110[index].unk2 == 0) { - D_8014F110[index].unk0 = D_8015F58A; + // Point this grid section to the first triangle in the section + if (gCollisionGrid[index].numTriangles == 0) { + gCollisionGrid[index].triangle = gNumCollisionTriangles; } - D_8014F110[index].unk2++; - D_8015F584[D_8015F58A] = (s16) i; - D_8015F58A++; + gCollisionGrid[index].numTriangles++; + gCollisionIndices[gNumCollisionTriangles] = (s16) i; + gNumCollisionTriangles++; } } @@ -2110,71 +2107,71 @@ void subtract_scaled_vector(Vec3f pos1, f32 boundingBoxSize, Vec3f pos2) { pos2[2] -= pos1[2] * boundingBoxSize; } -u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerPosX, f32 cornerPosY, f32 cornerPosZ) { +u16 process_collision(Player *player, KartTyre *tyre, f32 tyre2X, f32 tyre2Y, f32 tyre2Z) { Collision wtf; Collision *collision = &wtf; UNUSED s32 pad; u16 i; - u16 collisionMeshIndex; - u16 iter; - u16 phi_s2; - f32 cornerPos1; - f32 cornerPos2; - f32 cornerPos3; + u16 meshIndex; + u16 numTriangles; + u16 sectionIndex; + f32 tyreX; + f32 tyreY; + f32 tyreZ; f32 boundingBoxSize; - f32 temp_f0; + f32 height; s32 courseLengthX; s32 courseLengthZ; - s16 temp_f10; - s16 temp_f16; - s16 temp_v1_2; + s16 sectionIndexX; + s16 sectionIndexZ; + s16 gridIndex; - s32 temp1; - s32 temp2; + s32 sectionX; + s32 sectionZ; UNUSED s32 pad2[9]; - collision->unk3C[0] = 1000.0f; - collision->unk3C[1] = 1000.0f; - collision->unk3C[2] = 1000.0f; + collision->surfaceDistance[0] = 1000.0f; + collision->surfaceDistance[1] = 1000.0f; + collision->surfaceDistance[2] = 1000.0f; boundingBoxSize = player->boundingBoxSize; - collision->unk36 = 5000; - collision->unk38 = 5000; - collision->unk3A = 5000; + collision->meshIndexYX = 5000; + collision->meshIndexZY = 5000; + collision->meshIndexZX = 5000; collision->unk30 = 0; collision->unk32 = 0; collision->unk34 = 0; - cornerPos1 = corner->cornerPos[0]; - cornerPos2 = corner->cornerPos[1]; - cornerPos3 = corner->cornerPos[2]; - switch (corner->surfaceFlags) { + tyreX = tyre->pos[0]; + tyreY = tyre->pos[1]; + tyreZ = tyre->pos[2]; + switch (tyre->surfaceFlags) { case 0x80: - if (is_colliding_with_wall1(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, corner->collisionMeshIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, corner->collisionMeshIndex); - if ((!(temp_f0 > player->pos[1])) && !((player->pos[1] - temp_f0) > (2 * boundingBoxSize))) { - corner->cornerGroundY = temp_f0; - subtract_scaled_vector(collision->unk54, collision->unk3C[1], corner->cornerPos); + if (is_colliding_with_wall1(collision, boundingBoxSize, tyreX, tyreY, tyreZ, tyre->collisionMeshIndex, tyre2X, tyre2Y, tyre2Z) == 1) { + height = calculate_surface_height(tyreX, tyreY, tyreZ, tyre->collisionMeshIndex); + if ((!(height > player->pos[1])) && !((player->pos[1] - height) > (2 * boundingBoxSize))) { + tyre->baseHeight = height; + subtract_scaled_vector(collision->unk54, collision->surfaceDistance[1], tyre->pos); return 1; } } break; case 0x40: - if (is_colliding_with_drivable_surface(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, corner->collisionMeshIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, corner->collisionMeshIndex); - if (!(player->pos[1] < temp_f0) && !((2 * boundingBoxSize) < (player->pos[1] - temp_f0))) { - corner->cornerGroundY = temp_f0; - subtract_scaled_vector(collision->orientationVector, collision->unk3C[2], corner->cornerPos); + if (is_colliding_with_drivable_surface(collision, boundingBoxSize, tyreX, tyreY, tyreZ, tyre->collisionMeshIndex, tyre2X, tyre2Y, tyre2Z) == 1) { + height = calculate_surface_height(tyreX, tyreY, tyreZ, tyre->collisionMeshIndex); + if (!(player->pos[1] < height) && !((2 * boundingBoxSize) < (player->pos[1] - height))) { + tyre->baseHeight = height; + subtract_scaled_vector(collision->orientationVector, collision->surfaceDistance[2], tyre->pos); return 1; } } break; case 0x20: - if (is_colliding_with_wall2(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, corner->collisionMeshIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, corner->collisionMeshIndex); - if (!(player->pos[1] < temp_f0) && !((2 * boundingBoxSize) < (player->pos[1] - temp_f0))) { - corner->cornerGroundY = temp_f0; - subtract_scaled_vector(collision->unk48, collision->unk3C[0], corner->cornerPos); + if (is_colliding_with_wall2(collision, boundingBoxSize, tyreX, tyreY, tyreZ, tyre->collisionMeshIndex, tyre2X, tyre2Y, tyre2Z) == 1) { + height = calculate_surface_height(tyreX, tyreY, tyreZ, tyre->collisionMeshIndex); + if (!(player->pos[1] < height) && !((2 * boundingBoxSize) < (player->pos[1] - height))) { + tyre->baseHeight = height; + subtract_scaled_vector(collision->unk48, collision->surfaceDistance[0], tyre->pos); return 1; } } @@ -2188,85 +2185,85 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP courseLengthX = (s32) gCourseMaxX - gCourseMinX; courseLengthZ = (s32) gCourseMaxZ - gCourseMinZ; - temp1 = courseLengthX / 32; - temp2 = courseLengthZ / 32; + sectionX = courseLengthX / GRID_SIZE; + sectionZ = courseLengthZ / GRID_SIZE; - temp_f10 = (cornerPos1 - gCourseMinX) / temp1; - temp_f16 = (cornerPos3 - gCourseMinZ) / temp2; + sectionIndexX = (tyreX - gCourseMinX) / sectionX; + sectionIndexZ = (tyreZ - gCourseMinZ) / sectionZ; - if (temp_f10 < 0) { return 0; } - if (temp_f16 < 0) { return 0; } - if (temp_f10 >= 32) { return 0; } - if (temp_f16 >= 32) { return 0; } + if (sectionIndexX < 0) { return 0; } + if (sectionIndexZ < 0) { return 0; } + if (sectionIndexX >= GRID_SIZE) { return 0; } + if (sectionIndexZ >= GRID_SIZE) { return 0; } - temp_v1_2 = temp_f10 + temp_f16 * 32; - iter = D_8014F110[temp_v1_2].unk2; + gridIndex = sectionIndexX + sectionIndexZ * GRID_SIZE; + numTriangles = gCollisionGrid[gridIndex].numTriangles; - if (iter == 0) { return 0; } + if (numTriangles == 0) { return 0; } - phi_s2 = D_8014F110[temp_v1_2].unk0; + sectionIndex = gCollisionGrid[gridIndex].triangle; - for (i = 0; i < iter; i++) { - collisionMeshIndex = D_8015F584[phi_s2]; - if (gCollisionMesh[collisionMeshIndex].flags & 0x4000) { - if (collisionMeshIndex != corner->collisionMeshIndex) { - if (is_colliding_with_drivable_surface(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, collisionMeshIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, collisionMeshIndex); + for (i = 0; i < numTriangles; i++) { + meshIndex = gCollisionIndices[sectionIndex]; + if (gCollisionMesh[meshIndex].flags & FACING_Y_AXIS) { + if (meshIndex != tyre->collisionMeshIndex) { + if (is_colliding_with_drivable_surface(collision, boundingBoxSize, tyreX, tyreY, tyreZ, meshIndex, tyre2X, tyre2Y, tyre2Z) == 1) { + height = calculate_surface_height(tyreX, tyreY, tyreZ, meshIndex); - if (!(player->pos[1] < temp_f0) && !((2 * boundingBoxSize) < (player->pos[1] - temp_f0))) { - subtract_scaled_vector(collision->orientationVector, collision->unk3C[2], corner->cornerPos); - corner->cornerGroundY = temp_f0; - corner->surfaceType = (u8) gCollisionMesh[collisionMeshIndex].surfaceType; - corner->surfaceFlags = 0x40; - corner->collisionMeshIndex = collisionMeshIndex; - if (gCollisionMesh[collisionMeshIndex].flags & 0x1000) { - corner->unk_14 = 1; + if (!(player->pos[1] < height) && !((2 * boundingBoxSize) < (player->pos[1] - height))) { + subtract_scaled_vector(collision->orientationVector, collision->surfaceDistance[2], tyre->pos); + tyre->baseHeight = height; + tyre->surfaceType = (u8) gCollisionMesh[meshIndex].surfaceType; + tyre->surfaceFlags = 0x40; + tyre->collisionMeshIndex = meshIndex; + if (gCollisionMesh[meshIndex].flags & 0x1000) { + tyre->unk_14 = 1; } else { - corner->unk_14 = 0; + tyre->unk_14 = 0; } return 1; } } } - } else if (gCollisionMesh[collisionMeshIndex].flags & 0x8000) { - if (gCollisionMesh[collisionMeshIndex].gravity != 0.0f) { - if (collisionMeshIndex != corner->collisionMeshIndex) { - if (is_colliding_with_wall1(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, collisionMeshIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, collisionMeshIndex); - if (!(player->pos[1] < temp_f0) && !((2 * boundingBoxSize) < (player->pos[1] - temp_f0))) { - corner->cornerGroundY = temp_f0; - subtract_scaled_vector(collision->unk54, collision->unk3C[1], corner->cornerPos); - corner->cornerGroundY = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, collisionMeshIndex); - corner->surfaceType = (u8) gCollisionMesh[collisionMeshIndex].surfaceType; - corner->surfaceFlags = 0x80; - corner->collisionMeshIndex = collisionMeshIndex; + } else if (gCollisionMesh[meshIndex].flags & FACING_X_AXIS) { + if (gCollisionMesh[meshIndex].normalY != 0.0f) { + if (meshIndex != tyre->collisionMeshIndex) { + if (is_colliding_with_wall1(collision, boundingBoxSize, tyreX, tyreY, tyreZ, meshIndex, tyre2X, tyre2Y, tyre2Z) == 1) { + height = calculate_surface_height(tyreX, tyreY, tyreZ, meshIndex); + if (!(player->pos[1] < height) && !((2 * boundingBoxSize) < (player->pos[1] - height))) { + tyre->baseHeight = height; + subtract_scaled_vector(collision->unk54, collision->surfaceDistance[1], tyre->pos); + tyre->baseHeight = calculate_surface_height(tyreX, tyreY, tyreZ, meshIndex); + tyre->surfaceType = (u8) gCollisionMesh[meshIndex].surfaceType; + tyre->surfaceFlags = 0x80; + tyre->collisionMeshIndex = meshIndex; return 1; } } } } } else { - if (gCollisionMesh[collisionMeshIndex].gravity != 0.0f) { - if (collisionMeshIndex != corner->collisionMeshIndex) { - if (is_colliding_with_wall2(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, collisionMeshIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, collisionMeshIndex); - if (!(player->pos[1] < temp_f0) && !((2 * boundingBoxSize) < (player->pos[1] - temp_f0))) { - corner->cornerGroundY = temp_f0; - subtract_scaled_vector(collision->unk48, collision->unk3C[0], corner->cornerPos); - corner->surfaceType = (u8) gCollisionMesh[collisionMeshIndex].surfaceType; - corner->surfaceFlags = 0x20; - corner->collisionMeshIndex = collisionMeshIndex; + if (gCollisionMesh[meshIndex].normalY != 0.0f) { + if (meshIndex != tyre->collisionMeshIndex) { + if (is_colliding_with_wall2(collision, boundingBoxSize, tyreX, tyreY, tyreZ, meshIndex, tyre2X, tyre2Y, tyre2Z) == 1) { + height = calculate_surface_height(tyreX, tyreY, tyreZ, meshIndex); + if (!(player->pos[1] < height) && !((2 * boundingBoxSize) < (player->pos[1] - height))) { + tyre->baseHeight = height; + subtract_scaled_vector(collision->unk48, collision->surfaceDistance[0], tyre->pos); + tyre->surfaceType = (u8) gCollisionMesh[meshIndex].surfaceType; + tyre->surfaceFlags = 0x20; + tyre->collisionMeshIndex = meshIndex; return 1; } } } } } - phi_s2++; + sectionIndex++; } - corner->cornerGroundY = cornerPos2; - corner->surfaceType = 0; + tyre->baseHeight = tyreY; + tyre->surfaceType = 0; return 0; } diff --git a/src/racing/collision.h b/src/racing/collision.h index 4ae6d0ad9..975ebfe89 100644 --- a/src/racing/collision.h +++ b/src/racing/collision.h @@ -9,28 +9,28 @@ void nullify_displaylist(uintptr_t); void func_802AAAAC(Collision*); f32 func_802AAB4C(Player*); -s32 func_802AAE4C(Collision*, f32, f32, f32, f32, u16); -s32 func_802AB288(Collision*, f32, f32, f32, f32, u16); -s32 func_802AB6C4(Collision*, f32, f32, f32, f32, u16); +s32 check_collision_zx(Collision*, f32, f32, f32, f32, u16); +s32 check_collision_yx(Collision*, f32, f32, f32, f32, u16); +s32 check_collision_zy(Collision*, f32, f32, f32, f32, u16); s8 get_surface_type(u16); -s16 func_802ABD40(u16); +s16 get_section_id(u16); s16 func_802ABD7C(u16); s16 func_802ABDB8(u16); s16 func_802ABDF4(u16); -f32 func_802ABE30(f32, f32, f32, u16); +f32 calculate_surface_height(f32, f32, f32, u16); f32 func_802ABEAC(Collision*, Vec3f); void shell_collision(Collision *, Vec3f); void process_shell_collision(Vec3f, f32, Vec3f, f32); -u16 process_collision(Player*, KartBoundingBoxCorner*, f32, f32, f32); -void func_802AC114(Vec3f, f32, Vec3f, f32); -s32 func_802AC22C(KartBoundingBoxCorner*); -u16 func_802AD950(Collision*, f32, f32, f32, f32, f32, f32, f32); -u16 func_802ADDC8(Collision*, f32, f32, f32, f32); -f32 func_802AE1C0(f32, f32, f32); +u16 process_collision(Player*, KartTyre*, f32, f32, f32); +void adjust_pos_orthogonally(Vec3f, f32, Vec3f, f32); +s32 detect_tyre_collision(KartTyre*); +u16 actor_terrain_collision(Collision*, f32, f32, f32, f32, f32, f32, f32); +u16 check_bounding_collision(Collision*, f32, f32, f32, f32); +f32 spawn_actor_on_surface(f32, f32, f32); void set_vtx_buffer(uintptr_t, u32, u32); s32 is_line_intersecting_rectangle(s16, s16, s16, s16, s16, s16, s16, s16); s32 is_triangle_intersecting_bounding_box(s16, s16, s16, s16, u16); -void func_802AF314(void); +void generate_collision_grid(void); void generate_collision_mesh_with_defaults(Gfx*); void generate_collision_mesh_with_default_section_id(Gfx*, s8); void generate_collision_mesh(Gfx*, s8, u16); diff --git a/src/racing/math_util.c b/src/racing/math_util.c index 3305cb931..5d74ab630 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -1202,16 +1202,16 @@ void func_802B8614(Player *arg0) { f64 temp_f4; f64 temp_f6; - temp_f6 = (f64) arg0->boundingBoxCorners[1].cornerPos[0]; + temp_f6 = (f64) arg0->tyres[FRONT_RIGHT].pos[0]; sp78 = temp_f6; - sp70 = (f64) arg0->boundingBoxCorners[1].cornerGroundY; - sp68 = (f64) arg0->boundingBoxCorners[1].cornerPos[2]; - temp_f30 = (f64) arg0->boundingBoxCorners[0].cornerPos[0]; - sp58 = (f64) arg0->boundingBoxCorners[0].cornerGroundY; - sp50 = (f64) arg0->boundingBoxCorners[0].cornerPos[2]; - sp48 = (f64) arg0->boundingBoxCorners[3].cornerPos[0]; - sp40 = (f64) arg0->boundingBoxCorners[3].cornerGroundY; - temp_f4 = (f64) arg0->boundingBoxCorners[3].cornerPos[2]; + sp70 = (f64) arg0->tyres[FRONT_RIGHT].baseHeight; + sp68 = (f64) arg0->tyres[FRONT_RIGHT].pos[2]; + temp_f30 = (f64) arg0->tyres[FRONT_LEFT].pos[0]; + sp58 = (f64) arg0->tyres[FRONT_LEFT].baseHeight; + sp50 = (f64) arg0->tyres[FRONT_LEFT].pos[2]; + sp48 = (f64) arg0->tyres[BACK_RIGHT].pos[0]; + sp40 = (f64) arg0->tyres[BACK_RIGHT].baseHeight; + temp_f4 = (f64) arg0->tyres[BACK_RIGHT].pos[2]; temp_f2 = sp58 - sp70; sp38 = temp_f4; temp_f12 = temp_f4 - sp50; diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index 13375489f..b2722a801 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -31,13 +31,13 @@ s16 D_802B87D4 = 0; s16 currentScreenSection = 0; s32 func_80290C20(Camera *camera) { - if (camera->unk_54.unk34 == 0) { + if (camera->collision.unk34 == 0) { return 1; } - if ((camera->unk_54.unk30 == 1) && (camera->unk_54.unk3C[0] < 3.0f)) { + if ((camera->collision.unk30 == 1) && (camera->collision.surfaceDistance[0] < 3.0f)) { return 1; } - if ((camera->unk_54.unk32 == 1) && (camera->unk_54.unk3C[1] < 3.0f)) { + if ((camera->collision.unk32 == 1) && (camera->collision.surfaceDistance[1] < 3.0f)) { return 1; } return 0; @@ -116,19 +116,19 @@ void render_course_segments(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { arg1->playerDirection = var_a3; if (D_80152300[camera - camera1] == 1) { - sp1E = func_802ABD40(camera->unk_54.unk3A); - temp_v0_3 = func_802ABD40(player->unk_110.unk3A); + sp1E = get_section_id(camera->collision.meshIndexZX); + temp_v0_3 = get_section_id(player->collision.meshIndexZX); index = sp1E - temp_v0_3; if ((index < 2) && (index >= -1)) { if (sp1E == 255) { if (temp_v0_3 == 255) { index = arg1->pathCounter; - } else if (player->unk_110.unk3C[2] > 30.0f) { + } else if (player->collision.surfaceDistance[2] > 30.0f) { index = arg1->pathCounter; } else { index = temp_v0_3; } - } else if (camera->unk_54.unk3C[2] > 30.0f) { + } else if (camera->collision.surfaceDistance[2] > 30.0f) { index = arg1->pathCounter; } else { index = sp1E; @@ -161,7 +161,7 @@ void render_course_segments(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { default: if (temp_v0_3 == 255) { index = arg1->pathCounter; - } else if (player->unk_110.unk3C[2] > 30.0f) { + } else if (player->collision.surfaceDistance[2] > 30.0f) { index = arg1->pathCounter; } else { index = temp_v0_3; @@ -170,8 +170,8 @@ void render_course_segments(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { } } } else { - index = func_802ABD40(camera->unk_54.unk3A); - if (camera->unk_54.unk3C[2] > 30.0f) { + index = get_section_id(camera->collision.meshIndexZX); + if (camera->collision.surfaceDistance[2] > 30.0f) { index = arg1->pathCounter; } else if (index == 255) { index = arg1->pathCounter; @@ -1369,16 +1369,16 @@ void render_course(struct UnkStruct_800DC5EC *arg0) { void func_80295BF8(s32 playerIndex) { Player* player = &gPlayers[playerIndex]; - func_802AAAAC(&player->unk_110); - player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceFlags = 0; + func_802AAAAC(&player->collision); + player->tyres[FRONT_RIGHT].surfaceFlags = 0; + player->tyres[FRONT_LEFT].surfaceFlags = 0; + player->tyres[BACK_RIGHT].surfaceFlags = 0; + player->tyres[BACK_LEFT].surfaceFlags = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].collisionMeshIndex = 0x1388; - player->boundingBoxCorners[FRONT_LEFT_TYRE].collisionMeshIndex = 0x1388; - player->boundingBoxCorners[BACK_RIGHT_TYRE].collisionMeshIndex = 0x1388; - player->boundingBoxCorners[BACK_LEFT_TYRE].collisionMeshIndex = 0x1388; + player->tyres[FRONT_RIGHT].collisionMeshIndex = 0x1388; + player->tyres[FRONT_LEFT].collisionMeshIndex = 0x1388; + player->tyres[BACK_RIGHT].collisionMeshIndex = 0x1388; + player->tyres[BACK_LEFT].collisionMeshIndex = 0x1388; } void func_80295C6C(void) { @@ -1388,8 +1388,8 @@ void func_80295C6C(void) { gCourseMinX += -20; gCourseMinZ += -20; gCourseMinY += -20; - func_802AF314(); - gNextFreeMemoryAddress += ALIGN16(D_8015F58A * 2); + generate_collision_grid(); + gNextFreeMemoryAddress += ALIGN16(gNumCollisionTriangles * 2); } UNUSED void func_80295D50(s16 arg0, s16 arg1) { diff --git a/src/racing/render_courses.h b/src/racing/render_courses.h index d7b5efd80..ac0421b2e 100644 --- a/src/racing/render_courses.h +++ b/src/racing/render_courses.h @@ -49,6 +49,6 @@ extern Lights1 D_800DC610[]; extern Lights1 D_800DC610[]; // Light data? -extern u16 D_8015F58A; +extern u16 gNumCollisionTriangles; #endif diff --git a/src/render_objects.c b/src/render_objects.c index 371c9ca0f..c220bc2bb 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -1195,7 +1195,7 @@ UNUSED void func_8004A5E4(Vec3f arg0, Vec3su arg1, f32 arg2, u8 *texture, Vtx *a void func_8004A630(Collision *arg0, Vec3f arg1, f32 arg2) { if (func_80041924(arg0, arg1) != 0) { D_80183E50[0] = arg1[0]; - D_80183E50[1] = func_802ABE30(arg1[0], 0.0f, arg1[2], arg0->unk3A) + 0.8; + D_80183E50[1] = calculate_surface_height(arg1[0], 0.0f, arg1[2], arg0->meshIndexZX) + 0.8; D_80183E50[2] = arg1[2]; rsp_set_matrix_transl_rot_scale(D_80183E50, arg0->orientationVector, arg2); gSPDisplayList(gDisplayListHead++, D_0D007B98); @@ -1203,26 +1203,26 @@ void func_8004A630(Collision *arg0, Vec3f arg1, f32 arg2) { } void func_8004A6EC(s32 objectIndex, f32 scale) { - Objects *temp_v0; + Object *object; if ((is_obj_flag_status_active(objectIndex, 0x00000020) != 0) && (is_obj_flag_status_active(objectIndex, 0x00800000) != 0)) { - temp_v0 = &gObjectList[objectIndex]; - D_80183E50[0] = temp_v0->pos[0]; - D_80183E50[1] = temp_v0->unk_044 + 0.8; - D_80183E50[2] = temp_v0->pos[2]; - rsp_set_matrix_transformation(D_80183E50, temp_v0->unk_0B8, scale); + object = &gObjectList[objectIndex]; + D_80183E50[0] = object->pos[0]; + D_80183E50[1] = object->surfaceHeight + 0.8; + D_80183E50[2] = object->pos[2]; + rsp_set_matrix_transformation(D_80183E50, object->unk_0B8, scale); gSPDisplayList(gDisplayListHead++, D_0D007B20); } } void func_8004A7AC(s32 objectIndex, f32 arg1) { - Objects *temp_v0; + Object *object; if (is_obj_flag_status_active(objectIndex, 0x00000020) != 0) { - temp_v0 = &gObjectList[objectIndex]; - D_80183E50[0] = temp_v0->pos[0]; - D_80183E50[1] = temp_v0->unk_044 + 0.8; - D_80183E50[2] = temp_v0->pos[2]; + object = &gObjectList[objectIndex]; + D_80183E50[0] = object->pos[0]; + D_80183E50[1] = object->surfaceHeight + 0.8; + D_80183E50[2] = object->pos[2]; D_80183E98[0] = 0x4000; D_80183E98[1] = 0; D_80183E98[2] = 0; @@ -1233,14 +1233,14 @@ void func_8004A7AC(s32 objectIndex, f32 arg1) { void func_8004A870(s32 objectIndex, f32 arg1) { Mat4 sp30; - Objects *temp_v0; + Object *object; if ((is_obj_flag_status_active(objectIndex, 0x00000020) != 0) && (is_obj_flag_status_active(objectIndex, 0x00800000) != 0)) { - temp_v0 = &gObjectList[objectIndex]; - D_80183E50[0] = temp_v0->pos[0]; - D_80183E50[1] = temp_v0->unk_044 + 0.8; - D_80183E50[2] = temp_v0->pos[2]; - set_transform_matrix(sp30, temp_v0->unk_01C, D_80183E50, 0U, arg1); + object = &gObjectList[objectIndex]; + D_80183E50[0] = object->pos[0]; + D_80183E50[1] = object->surfaceHeight + 0.8; + D_80183E50[2] = object->pos[2]; + set_transform_matrix(sp30, object->unk_01C, D_80183E50, 0U, arg1); convert_to_fixed_point_matrix(&gGfxPool->mtxHud[gMatrixHudCount], sp30); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxHud[gMatrixHudCount++]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, D_0D007B98); @@ -2193,27 +2193,27 @@ UNUSED void func_8004E604(s32 arg0, s32 arg1, u8 *tlut, u8 *texture) { void draw_item_window(s32 playerId) { s32 objectIndex; - Objects *temp_v1; + Object *object; hud_player *temp_v0; objectIndex = gItemWindowObjectByPlayerId[playerId]; - temp_v1 = &gObjectList[objectIndex]; - if (temp_v1->state >= 2) { + object = &gObjectList[objectIndex]; + if (object->state >= 2) { temp_v0 = &playerHUD[playerId]; - func_8004E4CC(temp_v0->slideItemBoxX + temp_v0->itemBoxX, temp_v0->slideItemBoxY + temp_v0->itemBoxY, (u8 *) temp_v1->activeTLUT, temp_v1->activeTexture); + func_8004E4CC(temp_v0->slideItemBoxX + temp_v0->itemBoxX, temp_v0->slideItemBoxY + temp_v0->itemBoxY, (u8 *) object->activeTLUT, object->activeTexture); } } void func_8004E6C4(s32 playerId) { s32 objectIndex; - Objects *temp_v1; + Object *object; hud_player *temp_v0; objectIndex = gItemWindowObjectByPlayerId[playerId]; - temp_v1 = &gObjectList[objectIndex]; - if (temp_v1->state >= 2) { + object = &gObjectList[objectIndex]; + if (object->state >= 2) { temp_v0 = &playerHUD[playerId]; - func_80047910(temp_v0->slideItemBoxX + temp_v0->itemBoxX, temp_v0->slideItemBoxY + temp_v0->itemBoxY, 0U, temp_v0->unknownScaling, (u8 *) temp_v1->activeTLUT, (u8 *) temp_v1->activeTexture, D_0D005C30, 0x00000028, 0x00000020, 0x00000028, 0x00000020); + func_80047910(temp_v0->slideItemBoxX + temp_v0->itemBoxX, temp_v0->slideItemBoxY + temp_v0->itemBoxY, 0U, temp_v0->unknownScaling, (u8 *) object->activeTLUT, (u8 *) object->activeTexture, D_0D005C30, 0x00000028, 0x00000020, 0x00000028, 0x00000020); } } @@ -2808,7 +2808,7 @@ void func_80050E34(s32 playerId, s32 arg1) { s32 characterId; s32 spB8; s32 temp_v0_2; - Objects *object; + Object *object; Player *player; player = &gPlayerOne[playerId]; @@ -2911,7 +2911,7 @@ void func_800514BC(void) { void render_object_leaf_particle(UNUSED s32 cameraId) { s32 someIndex; s32 leafIndex; - Objects *object; + Object *object; gSPDisplayList(gDisplayListHead++, D_0D0079C8); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BOTH); @@ -2976,7 +2976,7 @@ void func_800519D4(s32 objectIndex, s16 arg1, s16 arg2) { void func_80051ABC(s16 arg0, s32 arg1) { s32 var_s0; s32 objectIndex; - Objects *object; + Object *object; D_8018D228 = 0xFF; gSPDisplayList(gDisplayListHead++, D_0D007A60); @@ -3001,7 +3001,7 @@ void func_80051C60(s16 arg0, s32 arg1) { s16 var_s5; s32 var_s0; s32 objectIndex; - Objects *object; + Object *object; if (D_801658FE == 0) { if (gCurrentCourseId == 6) { @@ -3094,7 +3094,7 @@ void func_800520C0(s32 arg0) { } void func_8005217C(UNUSED s32 arg0) { - Objects *object; + Object *object; s32 temp_a3; temp_a3 = indexObjectList2[0]; @@ -3123,7 +3123,7 @@ void func_8005217C(UNUSED s32 arg0) { void func_800523B8(s32 objectIndex, s32 arg1, u32 arg2) { UNUSED s32 pad[2]; - Objects *object; + Object *object; Camera *camera = &camera1[arg1]; object = &gObjectList[objectIndex]; @@ -3187,7 +3187,7 @@ void render_object_bat(s32 cameraId) { void render_object_trash_bin(s32 cameraId) { s32 objectIndex; - Objects *object; + Object *object; objectIndex = indexObjectList1[1]; func_8008A364(objectIndex, cameraId, 0x5555U, 0x00000320); @@ -3215,7 +3215,7 @@ void func_8005285C(s32 arg0) { void func_800528EC(s32 arg0) { s32 var_s3; s32 objectIndex; - Objects *object; + Object *object; D_80183E80[0] = D_8016582C[0]; D_80183E80[1] = D_8016582C[1]; @@ -3315,7 +3315,7 @@ void render_object_snowmans_list_2(s32 cameraId) { Camera *sp44; s32 someIndex; s32 objectIndex; - Objects *object; + Object *object; sp44 = &camera1[cameraId]; load_texture_and_tlut(d_course_frappe_snowland_snow_tlut, d_course_frappe_snowland_snow, 0x00000020, 0x00000020); @@ -3373,7 +3373,7 @@ void render_lakitu(s32 cameraId) { f32 var_f0; f32 var_f2; s32 objectIndex; - Objects *object; + Object *object; objectIndex = gIndexLakituList[cameraId]; camera = &camera1[cameraId]; @@ -3457,7 +3457,7 @@ void render_object_thwomps(s32 cameraId) { UNUSED s32 stackPadding0; s16 minusone, plusone; Camera *camera; - Objects *object; + Object *object; camera = &camera1[cameraId]; if (cameraId == PLAYER_ONE) { @@ -3522,13 +3522,13 @@ void render_object_thwomps(s32 cameraId) { } void func_80053D74(s32 objectIndex, UNUSED s32 arg1, s32 vertexIndex) { - Objects *temp_v0; + Object *object; if (gMatrixHudCount <= MTX_HUD_POOL_SIZE_MAX) { - temp_v0 = &gObjectList[objectIndex]; - D_80183E80[2] = (s16) (temp_v0->unk_084[6] + 0x8000); - rsp_set_matrix_transformation(temp_v0->pos, (u16 *) D_80183E80, temp_v0->sizeScaling); - set_color_render((s32) temp_v0->unk_084[0], (s32) temp_v0->unk_084[1], (s32) temp_v0->unk_084[2], (s32) temp_v0->unk_084[3], (s32) temp_v0->unk_084[4], (s32) temp_v0->unk_084[5], (s32) temp_v0->primAlpha); + object = &gObjectList[objectIndex]; + D_80183E80[2] = (s16) (object->unk_084[6] + 0x8000); + rsp_set_matrix_transformation(object->pos, (u16 *) D_80183E80, object->sizeScaling); + set_color_render((s32) object->unk_084[0], (s32) object->unk_084[1], (s32) object->unk_084[2], (s32) object->unk_084[3], (s32) object->unk_084[4], (s32) object->unk_084[5], (s32) object->primAlpha); gSPVertex(gDisplayListHead++, &common_vtx_hedgehog[vertexIndex], 4, 0); gSPDisplayList(gDisplayListHead++, common_rectangle_display); } @@ -3655,18 +3655,18 @@ void render_object_paddle_boat_smoke_particles(s32 cameraId) { void render_object_bowser_flame_particle(s32 objectIndex, s32 cameraId) { Camera *camera; - Objects *temp_s0; + Object *object; camera = &camera1[cameraId]; if (gMatrixHudCount <= MTX_HUD_POOL_SIZE_MAX) { - temp_s0 = &gObjectList[objectIndex]; - if (temp_s0->unk_0D5 == 9) { - func_8004B72C(0xFF, (s32) temp_s0->type, 0, (s32) temp_s0->unk_0A2, 0, 0, (s32) temp_s0->primAlpha); + object = &gObjectList[objectIndex]; + if (object->unk_0D5 == 9) { + func_8004B72C(0xFF, (s32) object->type, 0, (s32) object->unk_0A2, 0, 0, (s32) object->primAlpha); } else { - func_8004B138(0xFF, (s32) temp_s0->type, 0, (s32) temp_s0->primAlpha); + func_8004B138(0xFF, (s32) object->type, 0, (s32) object->primAlpha); } - D_80183E80[1] = func_800418AC(temp_s0->pos[0], temp_s0->pos[2], camera->pos); - func_800431B0(temp_s0->pos, D_80183E80, temp_s0->sizeScaling, D_0D005AE0); + D_80183E80[1] = func_800418AC(object->pos[0], object->pos[2], camera->pos); + func_800431B0(object->pos, D_80183E80, object->sizeScaling, D_0D005AE0); } } @@ -3715,7 +3715,7 @@ void render_object_smoke_particles(s32 cameraId) { Camera *sp54; s32 var_s0; s32 objectIndex; - Objects *object; + Object *object; sp54 = &camera1[cameraId]; gSPDisplayList(gDisplayListHead++, D_0D007AE0); @@ -3788,7 +3788,7 @@ void func_80054E10(s32 objectIndex) { if (gObjectList[objectIndex].state > 0) { if (is_obj_flag_status_active(objectIndex, 0x00800000) != 0) { D_80183E50[0] = gObjectList[objectIndex].pos[0]; - D_80183E50[1] = gObjectList[objectIndex].unk_044 + 0.8; + D_80183E50[1] = gObjectList[objectIndex].surfaceHeight + 0.8; D_80183E50[2] = gObjectList[objectIndex].pos[2]; D_80183E70[0] = gObjectList[objectIndex].velocity[0]; D_80183E70[1] = gObjectList[objectIndex].velocity[1]; @@ -3811,7 +3811,7 @@ void func_80054F04(s32 cameraId) { s32 var_s2; s32 objectIndex; Camera *sp44; - Objects * object; + Object *object; sp44 = &camera1[cameraId]; gSPDisplayList(gDisplayListHead++, D_0D0079C8); @@ -3966,7 +3966,7 @@ UNUSED void func_800557AC() { void func_800557B4(s32 objectIndex, u32 arg1, u32 arg2) { Vec3f sp34; - Objects *object; + Object *object; object = &gObjectList[objectIndex]; if (object->state >= 2) { @@ -4076,7 +4076,7 @@ void func_80055CCC(s32 objectIndex, s32 cameraId) { camera = &camera1[cameraId]; if (gObjectList[objectIndex].state >= 2) { func_8008A454(objectIndex, cameraId, 0x0000012C); - test = gObjectList[objectIndex].pos[1] - gObjectList[objectIndex].unk_044; + test = gObjectList[objectIndex].pos[1] - gObjectList[objectIndex].surfaceHeight; func_8004A6EC(objectIndex, (20.0 / test) + 0.5); if (is_obj_index_flag_status_inactive(objectIndex, 0x00100000) != 0) { func_80043328(gObjectList[objectIndex].pos, (u16 *) gObjectList[objectIndex].direction_angle, gObjectList[objectIndex].sizeScaling, d_course_luigi_raceway_dl_F960); @@ -4109,7 +4109,7 @@ void render_object_hot_air_balloon(s32 arg0) { } void func_80055EF4(s32 objectIndex, UNUSED s32 arg1) { - Objects *object; + Object *object; object = &gObjectList[objectIndex]; if (object->state >= 2) { @@ -4128,7 +4128,7 @@ void func_80055F48(s32 arg0) { void func_80055FA0(s32 objectIndex, UNUSED s32 arg1) { Mat4 someMatrix1; Mat4 someMatrix2; - Objects *object; + Object *object; object = &gObjectList[objectIndex]; if (object->state >= 2) { @@ -4153,7 +4153,7 @@ void render_object_neon(s32 cameraId) { Camera *camera; s32 var_s2; s32 objectIndex; - Objects *object; + Object *object; camera = &camera1[cameraId]; for (var_s2 =0; var_s2 < 10; var_s2++) { @@ -4184,7 +4184,7 @@ void func_800563DC(s32 objectIndex, s32 cameraId, s32 arg2) { s32 temp_v0; s32 residue; Camera *camera; - Objects *object; + Object *object; camera = &camera1[cameraId]; object = &gObjectList[objectIndex]; @@ -4240,9 +4240,9 @@ void func_800568A0(s32 objectIndex, s32 playerId) { player = &gPlayerOne[playerId]; D_80183E50[0] = gObjectList[objectIndex].pos[0]; - D_80183E50[1] = gObjectList[objectIndex].unk_044 + 0.8; + D_80183E50[1] = gObjectList[objectIndex].surfaceHeight + 0.8; D_80183E50[2] = gObjectList[objectIndex].pos[2]; - set_transform_matrix(sp30, player->unk_110.orientationVector, D_80183E50, 0U, 0.5f); + set_transform_matrix(sp30, player->collision.orientationVector, D_80183E50, 0U, 0.5f); convert_to_fixed_point_matrix(&gGfxPool->mtxHud[gMatrixHudCount], sp30); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxHud[gMatrixHudCount++]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, D_0D007B98); @@ -4273,18 +4273,18 @@ void render_object_bomb_kart(s32 cameraId) { s32 temp_s1; s32 temp_s0; s32 payerId; - Objects *temp_v1; + Object *object; for (payerId = 0; payerId < NUM_BOMB_KARTS_BATTLE; payerId++) { temp_s0 = gIndexObjectBombKart[payerId]; - temp_v1 = &gObjectList[temp_s0]; - if (temp_v1->state != 0) { - temp_s1 = temp_v1->primAlpha; + object = &gObjectList[temp_s0]; + if (object->state != 0) { + temp_s1 = object->primAlpha; temp_v0 = &gPlayerOne[payerId]; - temp_v1->pos[0] = temp_v0->pos[0]; - temp_v1->pos[1] = temp_v0->pos[1] - 2.0; - temp_v1->pos[2] = temp_v0->pos[2]; - temp_v1->unk_044 = temp_v0->unk_074; + object->pos[0] = temp_v0->pos[0]; + object->pos[1] = temp_v0->pos[1] - 2.0; + object->pos[2] = temp_v0->pos[2]; + object->surfaceHeight = temp_v0->unk_074; func_800563DC(temp_s0, cameraId, temp_s1); func_8005669C(temp_s0, cameraId, temp_s1); func_800568A0(temp_s0, cameraId); diff --git a/src/render_player.c b/src/render_player.c index 656e6e824..6e9e337b7 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -1078,7 +1078,7 @@ void render_light_environment_on_player(Player *player, s8 arg1) { if (((gNearestWaypointByPlayerId[arg1] >= 0x15) && (gNearestWaypointByPlayerId[arg1] < 0x2A)) || ((gNearestWaypointByPlayerId[arg1] >= 0x14D) && (gNearestWaypointByPlayerId[arg1] < 0x15C)) || ((gNearestWaypointByPlayerId[arg1] >= 0x1D1) && (gNearestWaypointByPlayerId[arg1] < 0x1E4)) - || (player->unk_110.unk3C[2] >= 500.0f)) { // over lava + || (player->collision.surfaceDistance[2] >= 500.0f)) { // over lava change_player_color_effect_rgb(player, arg1, COLOR_LAVA, 0.3f); change_player_color_effect_cmy(player, arg1, 0x004040, 0.3f); D_80164B80[arg1] = 0; @@ -1215,9 +1215,9 @@ void func_800235AC(Player *player, s8 arg1) { } } if (is_player_under_light_luigi_raceway(player, arg1) != TRUE) { - if (((player->boundingBoxCorners[3].unk_14 & 1) == 1) - || ((player->boundingBoxCorners[3].unk_14 & 2) == 2) - || ((player->boundingBoxCorners[0].unk_14 & 3) == 3)) { + if (((player->tyres[BACK_RIGHT].unk_14 & 1) == 1) + || ((player->tyres[BACK_RIGHT].unk_14 & 2) == 2) + || ((player->tyres[FRONT_LEFT].unk_14 & 3) == 3)) { change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.3f); change_player_color_effect_cmy(player, arg1, 0x6F6F6F, 0.3f); return; @@ -1270,12 +1270,12 @@ void render_player_shadow(Player *player, s8 playerId, s8 screenId) { || ((player->effects & 0x10000) == 0x10000) || ((player->effects & 8) == 8)) { - var_f2 = (f32) (1.0 - ((f64) player->unk_110.unk3C[2] * 0.02)); + var_f2 = (f32) (1.0 - ((f64) player->collision.surfaceDistance[2] * 0.02)); if (var_f2 < 0.0f) {var_f2 = 0.0f;} if (var_f2 > 1.0f) {var_f2 = 1.0f;} - spB4[0] = player->unk_110.orientationVector[0]; - spB4[2] = player->unk_110.orientationVector[2]; - spB4[1] = player->unk_110.orientationVector[1]; + spB4[0] = player->collision.orientationVector[0]; + spB4[2] = player->collision.orientationVector[2]; + spB4[1] = player->collision.orientationVector[1]; spCC[0] = player->pos[0] + ((spB0 * sins(spC0)) + (spAC * coss(spC0))); spCC[1] = player->unk_074 + 1.0f; @@ -1670,7 +1670,7 @@ void render_player(Player *player, s8 playerId, s8 screenId) { } func_80023BF0(player, playerId, screenId, var_v1); temp_t1 = 8 << (screenId * 4); - if ((temp_t1 == (player->unk_002 & temp_t1)) && (player->unk_110.unk3C[2] <= 50.0f) && (player->surfaceType != ICE)) { + if ((temp_t1 == (player->unk_002 & temp_t1)) && (player->collision.surfaceDistance[2] <= 50.0f) && (player->surfaceType != ICE)) { if ((player->effects & BOO_EFFECT) == BOO_EFFECT) { if (playerId == screenId) { render_player_shadow(player, playerId, screenId); @@ -1685,7 +1685,7 @@ void render_player(Player *player, s8 playerId, s8 screenId) { render_ghost(player, playerId, screenId, var_v1); } osRecvMesg(&gDmaMesgQueue, (OSMesg *) &sp34, OS_MESG_BLOCK); - if ((temp_t1 == (player->unk_002 & temp_t1)) && (player->surfaceType == ICE) && ((player->unk_0CA & 1) != 1) && (player->unk_110.unk3C[2] <= 30.0f)) { + if ((temp_t1 == (player->unk_002 & temp_t1)) && (player->surfaceType == ICE) && ((player->unk_0CA & 1) != 1) && (player->collision.surfaceDistance[2] <= 30.0f)) { render_player_ice_reflection(player, playerId, screenId, var_v1); } if (player->boostPower >= 2.0f) { diff --git a/src/spawn_players.c b/src/spawn_players.c index 6cc12aa53..86e3d3d43 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -110,7 +110,7 @@ void spawn_player(Player *player, s8 playerIndex, f32 startingRow, f32 startingC } player->pos[0] = startingRow; - ret = func_802AE1C0(startingRow, arg4 + 50.0f, startingColumn) + player->boundingBoxSize; + ret = spawn_actor_on_surface(startingRow, arg4 + 50.0f, startingColumn) + player->boundingBoxSize; player->pos[2] = startingColumn; player->pos[1] = ret; player->copy_rotation_x = startingRow; @@ -291,66 +291,66 @@ void spawn_player(Player *player, s8 playerIndex, f32 startingRow, f32 startingC D_801654C0[playerIndex] = 0; D_80165340 = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceType = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceType = 0; - player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceType = 0; - player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceType = 0; + player->tyres[FRONT_LEFT].surfaceType = 0; + player->tyres[FRONT_RIGHT].surfaceType = 0; + player->tyres[BACK_LEFT].surfaceType = 0; + player->tyres[BACK_RIGHT].surfaceType = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceFlags = 0; + player->tyres[FRONT_LEFT].surfaceFlags = 0; + player->tyres[FRONT_RIGHT].surfaceFlags = 0; + player->tyres[BACK_LEFT].surfaceFlags = 0; + player->tyres[BACK_RIGHT].surfaceFlags = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].collisionMeshIndex = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].collisionMeshIndex = 0; - player->boundingBoxCorners[BACK_LEFT_TYRE].collisionMeshIndex = 0; - player->boundingBoxCorners[BACK_RIGHT_TYRE].collisionMeshIndex = 0; + player->tyres[FRONT_LEFT].collisionMeshIndex = 0; + player->tyres[FRONT_RIGHT].collisionMeshIndex = 0; + player->tyres[BACK_LEFT].collisionMeshIndex = 0; + player->tyres[BACK_RIGHT].collisionMeshIndex = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].unk_14 = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].unk_14 = 0; - player->boundingBoxCorners[BACK_LEFT_TYRE].unk_14 = 0; - player->boundingBoxCorners[BACK_RIGHT_TYRE].unk_14 = 0; + player->tyres[FRONT_RIGHT].unk_14 = 0; + player->tyres[FRONT_LEFT].unk_14 = 0; + player->tyres[BACK_LEFT].unk_14 = 0; + player->tyres[BACK_RIGHT].unk_14 = 0; - player->unk_110.unk30 = 0; - player->unk_110.unk32 = 0; - player->unk_110.unk34 = 0; - player->unk_110.unk36 = 0; - player->unk_110.unk38 = 0; - player->unk_110.unk3A = 0; + player->collision.unk30 = 0; + player->collision.unk32 = 0; + player->collision.unk34 = 0; + player->collision.meshIndexYX = 0; + player->collision.meshIndexZY = 0; + player->collision.meshIndexZX = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].cornerPos[0] = 0.0f; - player->boundingBoxCorners[FRONT_LEFT_TYRE].cornerPos[1] = 0.0f; - player->boundingBoxCorners[FRONT_LEFT_TYRE].cornerPos[2] = 0.0f; + player->tyres[FRONT_LEFT].pos[0] = 0.0f; + player->tyres[FRONT_LEFT].pos[1] = 0.0f; + player->tyres[FRONT_LEFT].pos[2] = 0.0f; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].cornerPos[0] = 0.0f; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].cornerPos[1] = 0.0f; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].cornerPos[2] = 0.0f; + player->tyres[FRONT_RIGHT].pos[0] = 0.0f; + player->tyres[FRONT_RIGHT].pos[1] = 0.0f; + player->tyres[FRONT_RIGHT].pos[2] = 0.0f; - player->boundingBoxCorners[BACK_LEFT_TYRE].cornerPos[0] = 0.0f; - player->boundingBoxCorners[BACK_LEFT_TYRE].cornerPos[1] = 0.0f; - player->boundingBoxCorners[BACK_LEFT_TYRE].cornerPos[2] = 0.0f; + player->tyres[BACK_LEFT].pos[0] = 0.0f; + player->tyres[BACK_LEFT].pos[1] = 0.0f; + player->tyres[BACK_LEFT].pos[2] = 0.0f; - player->boundingBoxCorners[BACK_RIGHT_TYRE].cornerPos[0] = 0.0f; - player->boundingBoxCorners[BACK_RIGHT_TYRE].cornerPos[1] = 0.0f; - player->boundingBoxCorners[BACK_RIGHT_TYRE].cornerPos[2] = 0.0f; + player->tyres[BACK_RIGHT].pos[0] = 0.0f; + player->tyres[BACK_RIGHT].pos[1] = 0.0f; + player->tyres[BACK_RIGHT].pos[2] = 0.0f; - player->boundingBoxCorners[ FRONT_LEFT_TYRE].cornerGroundY = 0.0f; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].cornerGroundY = 0.0f; - player->boundingBoxCorners[ BACK_LEFT_TYRE].cornerGroundY = 0.0f; - player->boundingBoxCorners[ BACK_RIGHT_TYRE].cornerGroundY = 0.0f; + player->tyres[FRONT_LEFT].baseHeight = 0.0f; + player->tyres[FRONT_RIGHT].baseHeight = 0.0f; + player->tyres[BACK_LEFT].baseHeight = 0.0f; + player->tyres[BACK_RIGHT].baseHeight = 0.0f; - player->unk_110.unk3C[0] = 0.0f; - player->unk_110.unk3C[1] = 0.0f; - player->unk_110.unk3C[2] = 0.0f; - player->unk_110.unk48[0] = 0.0f; - player->unk_110.unk48[1] = 0.0f; - player->unk_110.unk48[2] = 0.0f; - player->unk_110.unk54[0] = 0.0f; - player->unk_110.unk54[1] = 0.0f; - player->unk_110.unk54[2] = 0.0f; - player->unk_110.orientationVector[0] = 0.0f; - player->unk_110.orientationVector[1] = 0.0f; - player->unk_110.orientationVector[2] = 0.0f; + player->collision.surfaceDistance[0] = 0.0f; + player->collision.surfaceDistance[1] = 0.0f; + player->collision.surfaceDistance[2] = 0.0f; + player->collision.unk48[0] = 0.0f; + player->collision.unk48[1] = 0.0f; + player->collision.unk48[2] = 0.0f; + player->collision.unk54[0] = 0.0f; + player->collision.unk54[1] = 0.0f; + player->collision.unk54[2] = 0.0f; + player->collision.orientationVector[0] = 0.0f; + player->collision.orientationVector[1] = 0.0f; + player->collision.orientationVector[2] = 0.0f; D_80165300[playerIndex] = 0; D_8018CE10[playerIndex].unk_04[0] = 0.0f; diff --git a/src/update_objects.c b/src/update_objects.c index 09996421b..674ace1c8 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -1304,10 +1304,10 @@ void func_80074924(s32 objectIndex) { s32 sp20; s16 temp_v0; s32 temp_a0; - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - temp_s0->sizeScaling = 0.15f; + object = &gObjectList[objectIndex]; + object->sizeScaling = 0.15f; temp_v0 = gCurrentCourseId; switch (temp_v0) { /* irregular */ case COURSE_MARIO_RACEWAY: @@ -1315,49 +1315,49 @@ void func_80074924(s32 objectIndex) { sp28 = random_int(D_80165748); sp24 = random_int(0x0096U); sp20 = random_int(0x2000U); - temp_s0->origin_pos[0] = (f32) ((((f64) D_80165718 + 100.0) - (f64) sp2C) * (f64) xOrientation); - temp_s0->origin_pos[1] = (f32) (D_80165720 + sp28); - temp_s0->origin_pos[2] = (f32) (((f64) D_80165728 + 200.0) - (f64) sp24); + object->origin_pos[0] = (f32) ((((f64) D_80165718 + 100.0) - (f64) sp2C) * (f64) xOrientation); + object->origin_pos[1] = (f32) (D_80165720 + sp28); + object->origin_pos[2] = (f32) (((f64) D_80165728 + 200.0) - (f64) sp24); break; case COURSE_ROYAL_RACEWAY: sp2C = random_int(0x0168U); sp28 = random_int(D_80165748); sp24 = random_int(0x00B4U); sp20 = random_int(0x2000U); - temp_s0->origin_pos[0] = (f32) ((((f64) D_80165718 + 180.0) - (f64) sp2C) * (f64) xOrientation); - temp_s0->origin_pos[1] = (f32) (D_80165720 + sp28); - temp_s0->origin_pos[2] = (f32) (((f64) D_80165728 + 200.0) - (f64) sp24); + object->origin_pos[0] = (f32) ((((f64) D_80165718 + 180.0) - (f64) sp2C) * (f64) xOrientation); + object->origin_pos[1] = (f32) (D_80165720 + sp28); + object->origin_pos[2] = (f32) (((f64) D_80165728 + 200.0) - (f64) sp24); break; case COURSE_LUIGI_RACEWAY: sp2C = random_int(0x012CU); sp28 = random_int(D_80165748); sp24 = random_int(0x0096U); sp20 = random_int(0x2000U); - temp_s0->origin_pos[0] = (f32) ((((f64) D_80165718 + 150.0) - (f64) sp2C) * (f64) xOrientation); - temp_s0->origin_pos[1] = (f32) (D_80165720 + sp28); - temp_s0->origin_pos[2] = (f32) (((f64) D_80165728 + 200.0) - (f64) sp24); + object->origin_pos[0] = (f32) ((((f64) D_80165718 + 150.0) - (f64) sp2C) * (f64) xOrientation); + object->origin_pos[1] = (f32) (D_80165720 + sp28); + object->origin_pos[2] = (f32) (((f64) D_80165728 + 200.0) - (f64) sp24); break; } set_obj_origin_offset(objectIndex, 0, 0, 0); if (gPlayerCount == 1) { - temp_s0->velocity[1] = (f32) (((f64) (f32) (sp2C % 4) * 0.25) + 0.8); + object->velocity[1] = (f32) (((f64) (f32) (sp2C % 4) * 0.25) + 0.8); } else { - temp_s0->velocity[1] = (f32) (((f64) (f32) (sp2C % 3) * 0.2) + 0.4); + object->velocity[1] = (f32) (((f64) (f32) (sp2C % 3) * 0.2) + 0.4); } temp_a0 = sp2C % 8; - temp_s0->unk_084[0] = D_800E6F30[temp_a0][0]; - temp_s0->unk_084[1] = D_800E6F30[temp_a0][1]; - temp_s0->unk_084[2] = D_800E6F30[temp_a0][2]; - temp_s0->unk_084[3] = D_800E6F48[temp_a0][0]; - temp_s0->unk_084[4] = D_800E6F48[temp_a0][1]; - temp_s0->unk_084[5] = D_800E6F48[temp_a0][2]; - temp_s0->unk_084[6] = sp20 - 0x1000; + object->unk_084[0] = D_800E6F30[temp_a0][0]; + object->unk_084[1] = D_800E6F30[temp_a0][1]; + object->unk_084[2] = D_800E6F30[temp_a0][2]; + object->unk_084[3] = D_800E6F48[temp_a0][0]; + object->unk_084[4] = D_800E6F48[temp_a0][1]; + object->unk_084[5] = D_800E6F48[temp_a0][2]; + object->unk_084[6] = sp20 - 0x1000; if (sp2C & 1) { - temp_s0->unk_084[7] = (sp20 / 32) + 0x100; + object->unk_084[7] = (sp20 / 32) + 0x100; } else { - temp_s0->unk_084[7] = -0x100 - (sp20 / 32); + object->unk_084[7] = -0x100 - (sp20 / 32); } - temp_s0->primAlpha = 0x00E6; + object->primAlpha = 0x00E6; func_80072488(objectIndex); } @@ -1396,7 +1396,7 @@ void func_80074EE8(void) { s32 someIndex; s32 objectIndex; s32 someCount; - Objects *object; + Object *object; someCount = 0; for (someIndex = 0; someIndex < D_80165738; someIndex++) { @@ -1441,24 +1441,24 @@ void func_80074FD8(s32 objectIndex) { void func_800750D8(s32 objectIndex, s32 arg1, Vec3f arg2, s32 arg3, s32 arg4) { s32 sp24; s32 temp_v0; - Objects *temp_v1; + Object *object; init_object(objectIndex, 0); sp24 = random_int(0x01F4U); temp_v0 = random_int(0x0032U); - temp_v1 = &gObjectList[objectIndex]; - temp_v1->unk_0D5 = arg3; - temp_v1->sizeScaling = ((f64) (f32) sp24 * 0.0005) + 0.05; + object = &gObjectList[objectIndex]; + object->unk_0D5 = arg3; + object->sizeScaling = ((f64) (f32) sp24 * 0.0005) + 0.05; // ALL HAIL THE FAKE MATCH GODS!!!!! - temp_v1->velocity[1] = ((f64) (f32) temp_v0 * (0.05 * 1.0)) + 2.0; - temp_v1->unk_034 = ((f64) (f32)(temp_v0 % 5) * 0.1) + 1.0; - temp_v1->direction_angle[1] = (arg1 << 0x10) / arg4; - temp_v1->origin_pos[0] = (arg2[0] + (temp_v0 / 2)) - 12.0f; - temp_v1->origin_pos[1] = (arg2[1] - 10.0) + random_int(0x000AU); - temp_v1->origin_pos[2] = (arg2[2] + (temp_v0 / 2)) - 12.0f; - temp_v1->orientation[0] = sp24 << 7; - temp_v1->orientation[1] = temp_v0 * 0x50; - temp_v1->orientation[2] = temp_v0 * 0x50; + object->velocity[1] = ((f64) (f32) temp_v0 * (0.05 * 1.0)) + 2.0; + object->unk_034 = ((f64) (f32)(temp_v0 % 5) * 0.1) + 1.0; + object->direction_angle[1] = (arg1 << 0x10) / arg4; + object->origin_pos[0] = (arg2[0] + (temp_v0 / 2)) - 12.0f; + object->origin_pos[1] = (arg2[1] - 10.0) + random_int(0x000AU); + object->origin_pos[2] = (arg2[2] + (temp_v0 / 2)) - 12.0f; + object->orientation[0] = sp24 << 7; + object->orientation[1] = temp_v0 * 0x50; + object->orientation[2] = temp_v0 * 0x50; } void func_80075304(Vec3f arg0, s32 arg1, s32 arg2, s32 arg3) { @@ -1486,7 +1486,7 @@ void func_8007542C(s32 arg0) { s32 objectIndex; s32 var_s2; s32 *var_s3; - Objects *temp_s0; + Object *object; D_8016582C[0] += 0x2000; D_8016582C[1] += 0x1000; @@ -1505,10 +1505,10 @@ void func_8007542C(s32 arg0) { } objectIndex = var_s3[var_s2]; if (objectIndex != DELETED_OBJECT_ID) { - temp_s0 = &gObjectList[objectIndex]; - if (temp_s0->state != 0) { + object = &gObjectList[objectIndex]; + if (object->state != 0) { func_80074FD8(objectIndex); - if (temp_s0->state == 0) { + if (object->state == 0) { delete_object_wrapper(&var_s3[var_s2]); } } @@ -1518,16 +1518,16 @@ void func_8007542C(s32 arg0) { } void func_80075574(s32 objectIndex, Vec3f arg1, f32 arg2) { - Objects *temp_v1; + Object *object; UNUSED s32 pad[2]; init_object(objectIndex, 0); - temp_v1 = &gObjectList[objectIndex]; - temp_v1->origin_pos[0] = arg1[0]; - temp_v1->origin_pos[1] = arg1[1]; - temp_v1->origin_pos[2] = arg1[2]; - temp_v1->velocity[1] = arg2; - temp_v1->type = random_int(0x0064U) + 0x1E; + object = &gObjectList[objectIndex]; + object->origin_pos[0] = arg1[0]; + object->origin_pos[1] = arg1[1]; + object->origin_pos[2] = arg1[2]; + object->velocity[1] = arg2; + object->type = random_int(0x0064U) + 0x1E; } s32 func_800755FC(s32 arg0, Vec3f arg1, f32 arg2) { @@ -1590,7 +1590,7 @@ void update_train_smoke(void) { s32 count; s32 i; s32 temp_a0; - Objects *temp; + Object *object; if (D_8016578C != 0) { D_8016578C -= 1; } @@ -1602,10 +1602,10 @@ void update_train_smoke(void) { for (i = 0; i < 128; i++) { temp_a0 = gObjectParticle2[i]; if (temp_a0 != -1) { - temp = &gObjectList[temp_a0]; - if (temp->state != 0) { + object = &gObjectList[temp_a0]; + if (object->state != 0) { func_80075714(temp_a0); - if (temp->state == 0) { + if (object->state == 0) { delete_object_wrapper(&gObjectParticle2[i]); } count += 1; @@ -1621,10 +1621,10 @@ void update_train_smoke(void) { for (i = 0; i < 128; i++) { temp_a0 = gObjectParticle3[i]; if (temp_a0 != -1) { - temp = &gObjectList[temp_a0]; - if (temp->state != 0) { + object = &gObjectList[temp_a0]; + if (object->state != 0) { func_80075714(temp_a0); - if (temp->state == 0) { + if (object->state == 0) { delete_object_wrapper(&gObjectParticle3[i]); } count += 1; @@ -1638,16 +1638,16 @@ void update_train_smoke(void) { } void func_800759EC(s32 objectIndex, Vec3f arg1, f32 arg2) { - Objects *temp_v0; + Object *object; init_object(objectIndex, 0); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->origin_pos[0] = arg1[0]; - temp_v0->origin_pos[1] = arg1[1]; - temp_v0->origin_pos[2] = arg1[2]; - temp_v0->velocity[1] = arg2; - temp_v0->type = 0x00FF; - temp_v0->unk_0A2 = 0x0096; + object = &gObjectList[objectIndex]; + object->origin_pos[0] = arg1[0]; + object->origin_pos[1] = arg1[1]; + object->origin_pos[2] = arg1[2]; + object->velocity[1] = arg2; + object->type = 0x00FF; + object->unk_0A2 = 0x0096; } s32 func_80075A6C(s32 arg0, Vec3f arg1, f32 arg2) { @@ -1711,7 +1711,7 @@ void update_ferries_smoke_particle(void) { s32 count; s32 i; s32 temp_a0; - Objects *temp; + Object *object; if (D_8016578C != 0) { D_8016578C -= 1; } @@ -1723,10 +1723,10 @@ void update_ferries_smoke_particle(void) { for (i = 0; i < 128; i++) { temp_a0 = gObjectParticle2[i]; if (temp_a0 != -1) { - temp = &gObjectList[temp_a0]; - if (temp->state != 0) { + object = &gObjectList[temp_a0]; + if (object->state != 0) { func_80075B84(temp_a0); - if (temp->state == 0) { + if (object->state == 0) { delete_object_wrapper(&gObjectParticle2[i]); } count += 1; @@ -1742,10 +1742,10 @@ void update_ferries_smoke_particle(void) { for (i = 0; i < 128; i++) { temp_a0 = gObjectParticle3[i]; if (temp_a0 != -1) { - temp = &gObjectList[temp_a0]; - if (temp->state != 0) { + object = &gObjectList[temp_a0]; + if (object->state != 0) { func_80075B84(temp_a0); - if (temp->state == 0) { + if (object->state == 0) { delete_object_wrapper(&gObjectParticle3[i]); } count += 1; @@ -1759,22 +1759,22 @@ void update_ferries_smoke_particle(void) { } void func_80075E5C(s32 objectIndex, Vec3f arg1, u16 arg2, f32 arg3, s32 arg4) { - Objects *temp_v0; + Object *object; init_object(objectIndex, 0); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->sizeScaling = 0.5f; - temp_v0->unk_0D5 = 5; - temp_v0->origin_pos[0] = arg1[0]; - temp_v0->origin_pos[1] = arg1[1]; - temp_v0->origin_pos[2] = arg1[2]; - temp_v0->direction_angle[0] = 0x0C00; - temp_v0->direction_angle[2] = 0; - temp_v0->unk_034 = arg3 * 4.0; - temp_v0->direction_angle[1] = arg2; - temp_v0->type = 0x00FF; - temp_v0->unk_0A2 = 0x00FF; - temp_v0->unk_048 = arg4 * 2; + object = &gObjectList[objectIndex]; + object->sizeScaling = 0.5f; + object->unk_0D5 = 5; + object->origin_pos[0] = arg1[0]; + object->origin_pos[1] = arg1[1]; + object->origin_pos[2] = arg1[2]; + object->direction_angle[0] = 0x0C00; + object->direction_angle[2] = 0; + object->unk_034 = arg3 * 4.0; + object->direction_angle[1] = arg2; + object->type = 0x00FF; + object->unk_0A2 = 0x00FF; + object->unk_048 = arg4 * 2; } s32 func_80075F28(Vec3f arg0, u16 arg1, f32 arg2, s32 arg3) { @@ -1841,25 +1841,25 @@ void func_8007614C(void) { } void func_80076194(s32 objectIndex, Vec3f arg1, f32 arg2, s32 arg3) { - Objects *temp_v0; + Object *object; init_object(objectIndex, 0); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_0D5 = 4; - temp_v0->sizeScaling = 1.0f; - temp_v0->origin_pos[0] = arg1[0]; - temp_v0->origin_pos[1] = arg1[1]; - temp_v0->origin_pos[2] = arg1[2]; - temp_v0->direction_angle[0] = 0x0C00; - temp_v0->direction_angle[2] = 0; - temp_v0->direction_angle[1] = 0x2100; + object = &gObjectList[objectIndex]; + object->unk_0D5 = 4; + object->sizeScaling = 1.0f; + object->origin_pos[0] = arg1[0]; + object->origin_pos[1] = arg1[1]; + object->origin_pos[2] = arg1[2]; + object->direction_angle[0] = 0x0C00; + object->direction_angle[2] = 0; + object->direction_angle[1] = 0x2100; if (gIsMirrorMode != 0) { - temp_v0->direction_angle[1] += -0x4000; + object->direction_angle[1] += -0x4000; } - temp_v0->type = 0x00FF; - temp_v0->unk_0A2 = 0x00FF; - temp_v0->unk_048 = arg3 * 2; - temp_v0->unk_034 = arg2 * 8.0; + object->type = 0x00FF; + object->unk_0A2 = 0x00FF; + object->unk_048 = arg3 * 2; + object->unk_034 = arg2 * 8.0; } s32 func_80076278(Vec3f arg0, f32 arg1, s32 arg2) { @@ -1881,42 +1881,42 @@ void func_800762DC(Vec3f arg0, f32 arg1) { } void func_8007634C(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->activeTexture = common_texture_particle_smoke[0]; - temp_v0->textureList = common_texture_particle_smoke[0]; - temp_v0->primAlpha = 0x00FF; + object = &gObjectList[objectIndex]; + object->activeTexture = common_texture_particle_smoke[0]; + object->textureList = common_texture_particle_smoke[0]; + object->primAlpha = 0x00FF; set_obj_orientation(objectIndex, 0U, 0U, 0U); set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); func_80072488(objectIndex); } void func_800763CC(s32 objectIndex) { - Objects *temp_s0; + Object *object; if(objectIndex){} - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->state) { + object = &gObjectList[objectIndex]; + switch (object->state) { case 1: func_8007634C(objectIndex); break; case 2: - if (func_8007278C(objectIndex, temp_s0->unk_048) != 0) { + if (func_8007278C(objectIndex, object->unk_048) != 0) { func_80086E70(objectIndex); } break; case 3: - if (temp_s0->unk_0D5 == 4) { - f32_step_towards(&temp_s0->sizeScaling, 4.0f, 0.1f); - s16_step_towards(&temp_s0->type, 0, 0x0018); - s16_step_towards(&temp_s0->unk_0A2, 0x0080, 0x000C); + if (object->unk_0D5 == 4) { + f32_step_towards(&object->sizeScaling, 4.0f, 0.1f); + s16_step_towards(&object->type, 0, 0x0018); + s16_step_towards(&object->unk_0A2, 0x0080, 0x000C); } else { - f32_step_towards(&temp_s0->sizeScaling, 1.0f, 0.1f); - s16_step_towards(&temp_s0->type, 0, 0x0018); - s16_step_towards(&temp_s0->unk_0A2, 0x0080, 0x000C); + f32_step_towards(&object->sizeScaling, 1.0f, 0.1f); + s16_step_towards(&object->type, 0, 0x0018); + s16_step_towards(&object->unk_0A2, 0x0080, 0x000C); } - if ((temp_s0->unk_0AE >= 2) && (func_80073B00(objectIndex, &temp_s0->primAlpha, 0x000000FF, 0x00000050, 0x00000020, 0, 0) != 0)) { + if ((object->unk_0AE >= 2) && (func_80073B00(objectIndex, &object->primAlpha, 0x000000FF, 0x00000050, 0x00000020, 0, 0) != 0)) { func_80072488(objectIndex); } break; @@ -1990,23 +1990,23 @@ void func_8007661C(void) { } void func_8007675C(s32 objectIndex, Vec3s arg1, s32 arg2) { - Objects *temp_v0; + Object *object; init_object(objectIndex, 0); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_0D5 = 9; - temp_v0->sizeScaling = 1.0f; - temp_v0->origin_pos[0] = arg1[0]; - temp_v0->origin_pos[1] = arg1[1]; - temp_v0->origin_pos[2] = arg1[2]; - temp_v0->direction_angle[0] = 0x0C00; - temp_v0->direction_angle[1] = 0x2100; - temp_v0->direction_angle[2] = 0; - temp_v0->type = 0x00FF; - temp_v0->unk_0A2 = 0x00FF; - temp_v0->unk_034 = 8.0f; - temp_v0->velocity[1] = 8.0f; - temp_v0->unk_048 = arg2; + object = &gObjectList[objectIndex]; + object->unk_0D5 = 9; + object->sizeScaling = 1.0f; + object->origin_pos[0] = arg1[0]; + object->origin_pos[1] = arg1[1]; + object->origin_pos[2] = arg1[2]; + object->direction_angle[0] = 0x0C00; + object->direction_angle[1] = 0x2100; + object->direction_angle[2] = 0; + object->type = 0x00FF; + object->unk_0A2 = 0x00FF; + object->unk_034 = 8.0f; + object->velocity[1] = 8.0f; + object->unk_048 = arg2; } s32 func_80076828(Vec3s arg0, s32 arg1) { @@ -2051,36 +2051,36 @@ void func_80076884(s32 arg0) { } void func_80076958(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->activeTexture = common_texture_particle_smoke[0]; - temp_v0->textureList = common_texture_particle_smoke[0]; - temp_v0->primAlpha = 0x00FF; + object = &gObjectList[objectIndex]; + object->activeTexture = common_texture_particle_smoke[0]; + object->textureList = common_texture_particle_smoke[0]; + object->primAlpha = 0x00FF; set_obj_orientation(objectIndex, 0U, 0U, 0U); set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); func_80072488(objectIndex); } void func_800769D8(s32 objectIndex) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->state) { + object = &gObjectList[objectIndex]; + switch (object->state) { case 0: break; case 1: func_80076958(objectIndex); break; case 2: - if (func_8007278C(objectIndex, temp_s0->unk_048) != 0) { + if (func_8007278C(objectIndex, object->unk_048) != 0) { func_80086E70(objectIndex); } break; case 3: - f32_step_towards(&temp_s0->sizeScaling, 2.0f, 0.05f); - s16_step_towards(&temp_s0->type, 0, 0x0018); - if ((temp_s0->unk_0AE >= 2) && (func_80073B00(objectIndex, &temp_s0->primAlpha, 0x000000FF, 0x00000050, 0x00000020, 0, 0) != 0)) { + f32_step_towards(&object->sizeScaling, 2.0f, 0.05f); + s16_step_towards(&object->type, 0, 0x0018); + if ((object->unk_0AE >= 2) && (func_80073B00(objectIndex, &object->primAlpha, 0x000000FF, 0x00000050, 0x00000020, 0, 0) != 0)) { func_80072488(objectIndex); } break; @@ -2117,7 +2117,7 @@ void func_80076B7C(void) { void update_flame_particle(void) { s32 someIndex; s32 objectIndex; - Objects *object; + Object *object; func_8007661C(); func_8007614C(); @@ -2142,17 +2142,17 @@ void update_flame_particle(void) { } void init_object_smoke_paticle(s32 objectIndex, Vec3f arg1, s16 arg2) { - Objects *temp_v0; + Object *object; init_object(objectIndex, (s32) arg2); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_0D5 = 0x0A; - temp_v0->activeTexture = common_texture_particle_smoke[0]; - temp_v0->textureList = common_texture_particle_smoke[0]; - temp_v0->sizeScaling = 0.3f; + object = &gObjectList[objectIndex]; + object->unk_0D5 = 0x0A; + object->activeTexture = common_texture_particle_smoke[0]; + object->textureList = common_texture_particle_smoke[0]; + object->sizeScaling = 0.3f; set_obj_origin_pos(objectIndex, arg1[0], arg1[1], arg1[2]); - temp_v0->type = 0x00FF; - temp_v0->unk_034 = 0.0f; + object->type = 0x00FF; + object->unk_034 = 0.0f; set_obj_orientation(objectIndex, 0U, 0U, 0U); set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); } @@ -2202,7 +2202,7 @@ void func_80076ED8(s32 objectIndex) { void func_80076F2C(void) { s32 someIndex; s32 flameIndex; - Objects *object; + Object *object; for (someIndex = 0; someIndex < gObjectParticle4_SIZE; someIndex++) { flameIndex = gObjectParticle4[someIndex]; @@ -2338,18 +2338,18 @@ void func_80077450(s32 objectIndex) { } void func_80077584(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - if ((temp_v0->unk_0AE != 0) && (temp_v0->unk_0AE == 1) && ((u8) temp_v0->unk_0D8 != 0)) { - if (temp_v0->velocity[1] >= -0.5) { - temp_v0->velocity[1] -= 0.15; + object = &gObjectList[objectIndex]; + if ((object->unk_0AE != 0) && (object->unk_0AE == 1) && ((u8) object->unk_0D8 != 0)) { + if (object->velocity[1] >= -0.5) { + object->velocity[1] -= 0.15; } else { - temp_v0->velocity[2] = 0.0f; - temp_v0->velocity[0] = 0.0f; + object->velocity[2] = 0.0f; + object->velocity[0] = 0.0f; } } - temp_v0->orientation[2] += temp_v0->unk_084[3]; + object->orientation[2] += object->unk_084[3]; object_add_velocity_offset_xyz(objectIndex); object_calculate_new_pos_offset(objectIndex); } @@ -2357,7 +2357,7 @@ void func_80077584(s32 objectIndex) { void func_80077640(void) { s32 someIndex; s32 objectIndex; - Objects *object; + Object *object; for(someIndex = 0; someIndex < gObjectParticle3_SIZE; someIndex++) { objectIndex = gObjectParticle3[someIndex]; @@ -2386,7 +2386,7 @@ void init_object_leaf_particle(s32 objectIndex, Vec3f arg1, s32 num) { gObjectList[objectIndex].activeTLUT = (u8*) common_texture_particle_leaf; gObjectList[objectIndex].tlutList = (u8*) common_texture_particle_leaf; gObjectList[objectIndex].sizeScaling = 0.1f; - gObjectList[objectIndex].unk_044 = arg1[1]; + gObjectList[objectIndex].surfaceHeight = arg1[1]; switch (gCurrentCourseId) { case COURSE_MARIO_RACEWAY: object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 25.0, arg1[2], 0x14, 0x1E, 0x14); @@ -2440,17 +2440,17 @@ void func_80077B14(s32 arg0) { } void func_80077B3C(s32 objectIndex) { - Objects *temp_v1; - temp_v1 = &gObjectList[objectIndex]; + Object *object; + object = &gObjectList[objectIndex]; - switch (temp_v1->state) { + switch (object->state) { case 0: break; case 1: func_80077B14(objectIndex); break; case 2: - if (temp_v1->unk_0AE == 0) { + if (object->unk_0AE == 0) { func_80072488(objectIndex); } break; @@ -2466,7 +2466,7 @@ void func_80077BCC(s32 objectIndex) { func_80087E08(objectIndex, gObjectList[objectIndex].velocity[1], 0.2f, gObjectList[objectIndex].unk_034, (s16) (s32) gObjectList[objectIndex].direction_angle[1], 0x0000000A); break; case 2: - if (func_80087B84(objectIndex, 0.4f, gObjectList[objectIndex].unk_044) != 0) { + if (func_80087B84(objectIndex, 0.4f, gObjectList[objectIndex].surfaceHeight) != 0) { func_80086F60(objectIndex); } break; @@ -2479,7 +2479,7 @@ void func_80077BCC(s32 objectIndex) { void update_leaf(void) { s32 someIndex; s32 leafIndex; - Objects *object; + Object *object; for(someIndex = 0; someIndex < gLeafParticle_SIZE; someIndex++) { leafIndex = gLeafParticle[someIndex]; @@ -2516,21 +2516,21 @@ void func_80077D5C(s32 arg0) { } void func_80077E20(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->activeTexture = D_0D0293D8; - temp_v0->textureList = D_0D0293D8; + object = &gObjectList[objectIndex]; + object->activeTexture = D_0D0293D8; + object->textureList = D_0D0293D8; // There's something up with the handling of common_vtx_rectangle and the loading of 0x10 right here - temp_v0->vertex = common_vtx_rectangle; - temp_v0->textureHeight = 0x10; - temp_v0->textureWidth = temp_v0->textureHeight; - temp_v0->sizeScaling = 0.15f; + object->vertex = common_vtx_rectangle; + object->textureHeight = 0x10; + object->textureWidth = object->textureHeight; + object->sizeScaling = 0.15f; set_object_flag_status_true(objectIndex, 0x00000010); func_80086EF0(objectIndex); - temp_v0->primAlpha = 0x00FF; - temp_v0->unk_0D5 = 0; - temp_v0->type = 0; + object->primAlpha = 0x00FF; + object->unk_0D5 = 0; + object->type = 0; func_80072488(objectIndex); } @@ -2611,13 +2611,13 @@ void func_80078170(s32 arg0, Camera *arg1) { } void func_80078220(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->activeTexture = D_0D0293D8; - temp_v0->textureList = D_0D0293D8; - temp_v0->vertex = common_vtx_rectangle; - temp_v0->sizeScaling = 0.15f; + object = &gObjectList[objectIndex]; + object->activeTexture = D_0D0293D8; + object->textureList = D_0D0293D8; + object->vertex = common_vtx_rectangle; + object->sizeScaling = 0.15f; func_80086EF0(objectIndex); func_80072488(objectIndex); } @@ -2934,19 +2934,19 @@ void func_80079114(s32 objectIndex, s32 arg1, s32 arg2) { } void func_800791F0(s32 objectIndex, s32 playerId) { - Player *temp_v1 = &gPlayerOne[playerId]; + Player *player = &gPlayerOne[playerId]; if ((gObjectList[objectIndex].unk_0D8 != 3) && (gObjectList[objectIndex].unk_0D8 != 7)) { func_800722CC(objectIndex, 1); if (gCurrentCourseId == COURSE_SHERBET_LAND) { - temp_v1->unk_0CA &= 0xFFEF; + player->unk_0CA &= 0xFFEF; } } else { // ????? } if (gCurrentCourseId == COURSE_SHERBET_LAND) { func_800722CC(objectIndex, 0x00000010); - temp_v1->unk_0CA &= 0xFFDF; + player->unk_0CA &= 0xFFDF; } func_800C9018(playerId, SOUND_ARG_LOAD(0x01, 0x00, 0xFA, 0x28)); } @@ -3044,17 +3044,17 @@ void update_object_lakitu_countdown(s32 objectIndex, s32 arg1) { } void init_obj_lakitu_red_flag(s32 objectIndex, s32 playerIndex) { - Objects *temp_v0; + Object *object; func_800791F0(objectIndex, playerIndex); init_texture_object(objectIndex, (u8*) common_tlut_lakitu_checkered_flag, gTextureLakituCheckeredFlag01, 0x48U, (u16) 0x00000038); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->activeTexture = D_8018C028; - temp_v0->vertex = common_vtx_also_lakitu; - temp_v0->pos[2] = 5000.0f; - temp_v0->pos[1] = 5000.0f; - temp_v0->pos[0] = 5000.0f; - temp_v0->sizeScaling = 0.15f; + object = &gObjectList[objectIndex]; + object->activeTexture = D_8018C028; + object->vertex = common_vtx_also_lakitu; + object->pos[2] = 5000.0f; + object->pos[1] = 5000.0f; + object->pos[0] = 5000.0f; + object->sizeScaling = 0.15f; func_80086F10(objectIndex, 2, &D_800E6834); set_object_flag_status_false(objectIndex, 0x00000010); func_80072488(objectIndex); @@ -3103,7 +3103,7 @@ void func_80079860(s32 playerId) { player = &gPlayerOne[playerId]; if ((func_80072354(objectIndex, 1) != 0) && ( - ((func_802ABDF4(player->unk_110.unk3A) != 0) && (player->unk_110.unk3C[2] <= 3.0f)) || + ((func_802ABDF4(player->collision.meshIndexZX) != 0) && (player->collision.surfaceDistance[2] <= 3.0f)) || (player->unk_0CA & 1) || ((player->surfaceType == OUT_OF_BOUNDS) && !(player->effects & 8)) ) @@ -3215,10 +3215,8 @@ void update_object_lakitu_fishing(s32 objectIndex, s32 playerId) { } void update_object_lakitu_fishing2(s32 objectIndex, s32 playerId) { + Player *player = &gPlayerOne[playerId]; - Player *temp_s1; - - temp_s1 = &gPlayerOne[playerId]; switch (gObjectList[objectIndex].state) { /* switch 1; irregular */ case 0: /* switch 1 */ break; @@ -3228,7 +3226,7 @@ void update_object_lakitu_fishing2(s32 objectIndex, s32 playerId) { case 2: /* switch 1 */ set_object_flag_status_true(objectIndex, 0x00000010); func_800736E0(objectIndex); - temp_s1->unk_0CA |= 0x80; + player->unk_0CA |= 0x80; func_80072488(objectIndex); break; case 3: /* switch 1 */ @@ -3243,15 +3241,15 @@ void update_object_lakitu_fishing2(s32 objectIndex, s32 playerId) { } break; case 2: - func_80090868(temp_s1); + func_80090868(player); func_800722A4(objectIndex, 4); func_80073654(objectIndex); break; case 3: - if ((temp_s1->surfaceType == ICE) && !(temp_s1->unk_0CA & 1) && ((f64) temp_s1->unk_110.unk3C[2] <= 30.0)) { + if ((player->surfaceType == ICE) && !(player->unk_0CA & 1) && ((f64) player->collision.surfaceDistance[2] <= 30.0)) { func_800722A4(objectIndex, 8); } - if (!(temp_s1->unk_0CA & 2)) { + if (!(player->unk_0CA & 2)) { func_80086EAC(objectIndex, 0, 3); func_80073654(objectIndex); } @@ -3260,7 +3258,7 @@ void update_object_lakitu_fishing2(s32 objectIndex, s32 playerId) { func_8007375C(objectIndex, 0x0000001E); break; case 5: - temp_s1->unk_0CA &= 0xFF7F; + player->unk_0CA &= 0xFF7F; func_800722A4(objectIndex, 0x00000010); func_800722A4(objectIndex, 0x00000020); func_800722CC(objectIndex, 4); @@ -3271,8 +3269,8 @@ void update_object_lakitu_fishing2(s32 objectIndex, s32 playerId) { case 6: if (func_8007375C(objectIndex, 0x000000A0) != 0) { func_800722CC(objectIndex, 0x00000010); - temp_s1->unk_0CA &= 0xFFEF; - temp_s1->unk_0CA |= 0x20; + player->unk_0CA &= 0xFFEF; + player->unk_0CA |= 0x20; } break; case 7: @@ -3281,30 +3279,30 @@ void update_object_lakitu_fishing2(s32 objectIndex, s32 playerId) { case 8: func_80073720(objectIndex); func_80072428(objectIndex); - temp_s1->unk_0CA &= 0xFFDF; + player->unk_0CA &= 0xFFDF; func_800722CC(objectIndex, 1); func_800C9018((u8) playerId, SOUND_ARG_LOAD(0x01, 0x00, 0xFA, 0x28)); break; } if (gObjectList[objectIndex].state >= 2) { - func_8007993C(objectIndex, temp_s1); + func_8007993C(objectIndex, player); } - func_80079A5C(objectIndex, temp_s1); + func_80079A5C(objectIndex, player); } void func_8007A060(s32 objectIndex, s32 playerIndex) { - Objects *temp_v0; + Object *object; func_800791F0(objectIndex, playerIndex); init_texture_object(objectIndex, (u8*) common_tlut_lakitu_second_lap, gTextureLakituSecondLap01, 0x48U, (u16) 0x00000038); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->activeTexture = D_8018C028; - temp_v0->vertex = common_vtx_also_lakitu; - temp_v0->pos[2] = 5000.0f; - temp_v0->pos[1] = 5000.0f; - temp_v0->pos[0] = 5000.0f; - temp_v0->sizeScaling = 0.15f; + object = &gObjectList[objectIndex]; + object->activeTexture = D_8018C028; + object->vertex = common_vtx_also_lakitu; + object->pos[2] = 5000.0f; + object->pos[1] = 5000.0f; + object->pos[0] = 5000.0f; + object->sizeScaling = 0.15f; set_object_flag_status_false(objectIndex, 0x00000010); func_80086F10(objectIndex, 5, &D_800E694C); func_80072488(objectIndex); @@ -3342,17 +3340,17 @@ void update_object_lakitu_second_lap(s32 objectIndex, s32 playerIndex) { } void func_8007A228(s32 objectIndex, s32 playerIndex) { - Objects *temp_v0; + Object *object; func_800791F0(objectIndex, playerIndex); init_texture_object(objectIndex, (u8*) common_tlut_lakitu_final_lap, gTextureLakituFinalLap01, 0x48U, (u16) 0x00000038); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->activeTexture = D_8018C028; - temp_v0->vertex = common_vtx_also_lakitu; - temp_v0->pos[2] = 5000.0f; - temp_v0->pos[1] = 5000.0f; - temp_v0->pos[0] = 5000.0f; - temp_v0->sizeScaling = 0.15f; + object = &gObjectList[objectIndex]; + object->activeTexture = D_8018C028; + object->vertex = common_vtx_also_lakitu; + object->pos[2] = 5000.0f; + object->pos[1] = 5000.0f; + object->pos[0] = 5000.0f; + object->sizeScaling = 0.15f; set_object_flag_status_false(objectIndex, 0x00000010); func_80086F10(objectIndex, 5, &D_800E694C); func_80072488(objectIndex); @@ -3759,7 +3757,7 @@ void func_8007B254(s32 objectIndex, s32 arg1) { void func_8007B34C(s32 playerId) { s32 temp_s0; s32 sp40; - Objects *temp_t0; + Object *object; Player *sp38; struct Controller *new_var; @@ -3773,8 +3771,8 @@ void func_8007B34C(s32 playerId) { if (D_80165888 != 0) { init_object(temp_s0, 0); } - temp_t0 = &gObjectList[temp_s0]; - switch (temp_t0->state) { + object = &gObjectList[temp_s0]; + switch (object->state) { case 1: func_8007B254(temp_s0, playerId); break; @@ -3813,20 +3811,20 @@ void func_8007B34C(s32 playerId) { func_80072E54(temp_s0, 1, 4, 1, 0x00000010, 1); break; case 6: - temp_t0->itemDisplay = func_8007AFB0(temp_s0, playerId); - temp_t0->unk_04C = 8; - temp_t0->unk_0D6 = 2; + object->itemDisplay = func_8007AFB0(temp_s0, playerId); + object->unk_04C = 8; + object->unk_0D6 = 2; func_80072488(temp_s0); func_800C9018((u8) playerId, SOUND_ARG_LOAD(0x01, 0x00, 0xFE, 0x1C)); func_800C8F80((u8) playerId, SOUND_ARG_LOAD(0x01, 0x00, 0xFE, 0x47)); break; case 7: - func_80072D3C(temp_s0, (s32) temp_t0->unk_0A2, 0, 8, 0x0000000A); + func_80072D3C(temp_s0, (s32) object->unk_0A2, 0, 8, 0x0000000A); break; case 9: func_800722CC(temp_s0, 4); func_80073600(temp_s0); - temp_t0->itemDisplay = 0; + object->itemDisplay = 0; func_80072488(temp_s0); break; case 10: @@ -3857,55 +3855,55 @@ void func_8007B34C(s32 playerId) { func_80072428(temp_s0); break; case 20: - if (temp_t0->unk_0A2 == 0x000B) { - func_80072D3C(temp_s0, temp_t0->unk_0A2, 0, 8, 0x0000000A); + if (object->unk_0A2 == 0x000B) { + func_80072D3C(temp_s0, object->unk_0A2, 0, 8, 0x0000000A); } else { - func_80072D3C(temp_s0, temp_t0->unk_0A2, 0x0000000B, 8, 0x0000000A); + func_80072D3C(temp_s0, object->unk_0A2, 0x0000000B, 8, 0x0000000A); } break; case 21: func_800726CC(temp_s0, 8); - temp_t0->unk_0D6 = 2; + object->unk_0D6 = 2; break; case 30: - if (temp_t0->unk_0A2 == 0x000B) { - func_80072D3C(temp_s0, temp_t0->unk_0A2, 0, 8, 0x0000000A); + if (object->unk_0A2 == 0x000B) { + func_80072D3C(temp_s0, object->unk_0A2, 0, 8, 0x0000000A); } else { - func_80072D3C(temp_s0, temp_t0->unk_0A2, 0x0000000B, 8, 0x0000000A); + func_80072D3C(temp_s0, object->unk_0A2, 0x0000000B, 8, 0x0000000A); } break; case 31: func_800726CC(temp_s0, 9); break; case 40: - if (temp_t0->unk_0A2 == 0x000D) { - func_80072D3C(temp_s0, temp_t0->unk_0A2, 0x0000000E, 8, 0x0000000A); + if (object->unk_0A2 == 0x000D) { + func_80072D3C(temp_s0, object->unk_0A2, 0x0000000E, 8, 0x0000000A); } else { - func_80072D3C(temp_s0, temp_t0->unk_0A2, 0x0000000D, 8, 0x0000000A); + func_80072D3C(temp_s0, object->unk_0A2, 0x0000000D, 8, 0x0000000A); } break; case 41: func_800726CC(temp_s0, 8); break; case 50: - func_80072D3C(temp_s0, (s32) temp_t0->unk_0A2, 0, 8, 0x00000064); + func_80072D3C(temp_s0, (s32) object->unk_0A2, 0, 8, 0x00000064); break; case 0: default: break; } if (func_80072320(temp_s0, 2) != 0) { - if (temp_t0->timer == 0) { + if (object->timer == 0) { consume_item(playerId); } else { - temp_t0->timer--; + object->timer--; } } - if (temp_t0->unk_04C >= 0) { - if (temp_t0->unk_04C > 0) { - temp_t0->unk_04C--; + if (object->unk_04C >= 0) { + if (object->unk_04C > 0) { + object->unk_04C--; } else { - switch (temp_t0->unk_0D6) { /* switch 1; irregular */ + switch (object->unk_0D6) { /* switch 1; irregular */ case 1: /* switch 1 */ if (sp40 != 0) { func_80073600(temp_s0); @@ -3913,23 +3911,23 @@ void func_8007B34C(s32 playerId) { } break; case 2: /* switch 1 */ - set_type_object(temp_s0, (s32) temp_t0->unk_0A2); - temp_t0->unk_0D6 = 3; + set_type_object(temp_s0, (s32) object->unk_0A2); + object->unk_0D6 = 3; break; case 3: /* switch 1 */ - if (temp_t0->type == 0) { + if (object->type == 0) { if (func_80072354(temp_s0, 1) != 0) { - if (temp_t0->unk_0A2 == 0x000B) { + if (object->unk_0A2 == 0x000B) { if (func_8007B040(temp_s0, playerId) != 0) { func_800726CC(temp_s0, 0x00000014); - temp_t0->unk_0D6 = 0; + object->unk_0D6 = 0; } else { func_800726CC(temp_s0, 9); } - } else if ((temp_t0->unk_0A2 == 0x000D) || (temp_t0->unk_0A2 == 0x000E)) { - temp_t0->unk_0A2--; - set_type_object(temp_s0, (s32) temp_t0->unk_0A2); - temp_t0->unk_0D6 = 3; + } else if ((object->unk_0A2 == 0x000D) || (object->unk_0A2 == 0x000E)) { + object->unk_0A2--; + set_type_object(temp_s0, (s32) object->unk_0A2); + object->unk_0D6 = 3; func_800726CC(temp_s0, 0x00000028); } else { func_800726CC(temp_s0, 9); @@ -3937,16 +3935,16 @@ void func_8007B34C(s32 playerId) { } else { func_800722CC(temp_s0, 1); func_800726CC(temp_s0, 0x0000001E); - temp_t0->unk_0D6 = 0; + object->unk_0D6 = 0; } } break; } } } - temp_t0->activeTLUT = (u8*) gItemWindowTLUTs[temp_t0->itemDisplay]; - temp_t0->activeTexture = gItemWindowTextures[temp_t0->itemDisplay]; - sp38->currentItemCopy = temp_t0->type; + object->activeTLUT = (u8*) gItemWindowTLUTs[object->itemDisplay]; + object->activeTexture = gItemWindowTextures[object->itemDisplay]; + sp38->currentItemCopy = object->type; } void func_8007BB9C(s32 arg0) { @@ -3955,14 +3953,14 @@ void func_8007BB9C(s32 arg0) { void func_8007BBBC(s32 objectIndex) { f32 var_f14; - Objects *temp_s1; + Object *object; - temp_s1 = &gObjectList[objectIndex]; - switch (temp_s1->state) { /* irregular */ + object = &gObjectList[objectIndex]; + switch (object->state) { /* irregular */ case 1: func_800735BC(objectIndex, d_course_banshee_boardwalk_dl_cheep_cheep, 2.0f); set_object_flag_status_true(objectIndex, 0x00000010); - temp_s1->unk_0D5 = 0; + object->unk_0D5 = 0; break; case 2: if (gIsMirrorMode != 0) { @@ -3970,12 +3968,12 @@ void func_8007BBBC(s32 objectIndex) { } else { func_80087E08(objectIndex, 18.0f, 0.7f, 25.0f, (s16) 0x00005800, 0x0000012C); } - if (temp_s1->velocity[2] < 0.0f) { - var_f14 = -temp_s1->velocity[2]; + if (object->velocity[2] < 0.0f) { + var_f14 = -object->velocity[2]; } else { - var_f14 = temp_s1->velocity[2]; + var_f14 = object->velocity[2]; } - temp_s1->direction_angle[0] = func_80041658(temp_s1->velocity[1], var_f14); + object->direction_angle[0] = func_80041658(object->velocity[1], var_f14); func_8007278C(objectIndex, 0x00000046); break; case 3: @@ -4009,13 +4007,13 @@ void update_cheep_cheep_race(void) { } void init_var_cheep_cheep(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_0D5 = 1; - temp_v0->status = 0; - temp_v0->model = d_course_banshee_boardwalk_dl_cheep_cheep; - temp_v0->sizeScaling = 0.2f; + object = &gObjectList[objectIndex]; + object->unk_0D5 = 1; + object->status = 0; + object->model = d_course_banshee_boardwalk_dl_cheep_cheep; + object->sizeScaling = 0.2f; func_80072488(objectIndex); set_obj_origin_pos(objectIndex, D_800E634C[0][0], D_800E634C[0][1] + 55.0, D_800E634C[0][2]); set_obj_origin_offset(objectIndex, 0.0f, 30.0f, 0.0f); @@ -4023,10 +4021,10 @@ void init_var_cheep_cheep(s32 objectIndex) { } void func_8007BEC8(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - switch (temp_v0->state) { + object = &gObjectList[objectIndex]; + switch (object->state) { case 1: init_var_cheep_cheep(objectIndex); break; @@ -4037,7 +4035,7 @@ void func_8007BEC8(s32 objectIndex) { } break; case 3: - if (temp_v0->unk_0AE == 0) { + if (object->unk_0AE == 0) { func_80072488(objectIndex); } break; @@ -4047,7 +4045,7 @@ void func_8007BEC8(s32 objectIndex) { } break; case 5: - if (temp_v0->unk_0AE == 0) { + if (object->unk_0AE == 0) { func_80072428(objectIndex); } break; @@ -4058,47 +4056,47 @@ void func_8007BEC8(s32 objectIndex) { } void func_8007BFB0(s32 objectIndex) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->unk_0AE) { + object = &gObjectList[objectIndex]; + switch (object->unk_0AE) { case 0: break; case 1: - temp_s0->velocity[1] = -0.2f; - if ((f64) temp_s0->offset[1] <= 0.0) { - temp_s0->offset[1] = 0.0f; - temp_s0->velocity[1] = 0.0f; + object->velocity[1] = -0.2f; + if ((f64) object->offset[1] <= 0.0) { + object->offset[1] = 0.0f; + object->velocity[1] = 0.0f; func_80086F60(objectIndex); } break; case 2: if (func_800871AC(objectIndex, 0x00000014) != 0) { - temp_s0->unk_084[7] = 0x0040; + object->unk_084[7] = 0x0040; } break; case 3: - temp_s0->sizeScaling = (f32) ((f64) temp_s0->sizeScaling - 0.0015); - if ((s32) temp_s0->direction_angle[0] >= 0xA01) { - temp_s0->unk_084[7] -= 4; + object->sizeScaling = (f32) ((f64) object->sizeScaling - 0.0015); + if ((s32) object->direction_angle[0] >= 0xA01) { + object->unk_084[7] -= 4; } - if (u16_step_up_towards(temp_s0->direction_angle, 0x0C00U, (u16) temp_s0->unk_084[7]) != 0) { + if (u16_step_up_towards(object->direction_angle, 0x0C00U, (u16) object->unk_084[7]) != 0) { func_80086FD4(objectIndex); } break; case 4: - temp_s0->sizeScaling = (f32) ((f64) temp_s0->sizeScaling - 0.0015); - temp_s0->unk_034 = 0.001f; + object->sizeScaling = (f32) ((f64) object->sizeScaling - 0.0015); + object->unk_034 = 0.001f; func_80086FD4(objectIndex); - temp_s0->unk_084[7] = 0; + object->unk_084[7] = 0; break; case 5: - if (temp_s0->unk_034 <= 0.004) { - temp_s0->unk_034 += 0.0002; + if (object->unk_034 <= 0.004) { + object->unk_034 += 0.0002; } - temp_s0->sizeScaling += temp_s0->unk_034; - s16_step_up_towards(&temp_s0->unk_084[7], 0x0100, 0x0010); - temp_s0->direction_angle[0] -= temp_s0->unk_084[7]; + object->sizeScaling += object->unk_034; + s16_step_up_towards(&object->unk_084[7], 0x0100, 0x0010); + object->direction_angle[0] -= object->unk_084[7]; if (func_80087060(objectIndex, 0x00000035) != 0) { func_80086FD4(objectIndex); } @@ -4110,10 +4108,10 @@ void func_8007BFB0(s32 objectIndex) { } break; case 7: - temp_s0->sizeScaling = (f32) ((f64) temp_s0->sizeScaling - 0.05); - if ((f64) temp_s0->sizeScaling <= 0.01) { + object->sizeScaling = (f32) ((f64) object->sizeScaling - 0.05); + if ((f64) object->sizeScaling <= 0.01) { set_object_flag_status_false(objectIndex, 0x00000010); - temp_s0->sizeScaling = 0.000001f; + object->sizeScaling = 0.000001f; func_80086FD4(objectIndex); } break; @@ -4121,8 +4119,8 @@ void func_8007BFB0(s32 objectIndex) { func_80086F60(objectIndex); break; } - if (temp_s0->unk_0AE < 0xA) { - func_80074344(objectIndex, &temp_s0->sizeScaling, 0.2f, 0.21f, 0.001f, 0, -1); + if (object->unk_0AE < 0xA) { + func_80074344(objectIndex, &object->sizeScaling, 0.2f, 0.21f, 0.001f, 0, -1); } object_add_velocity_offset_y(objectIndex); object_calculate_new_pos_offset(objectIndex); @@ -4206,24 +4204,24 @@ void func_8007C550(s32 objectIndex) { } void func_8007C5B4(s32 objectIndex) { - Objects *temp_s0; + Object *object; init_texture_object(objectIndex, d_course_banshee_boardwalk_boo_tlut, D_80165880, 48, 40); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->pos[0] = 0.0f; - temp_s0->pos[1] = 0.0f; - temp_s0->pos[2] = 0.0f; + object = &gObjectList[objectIndex]; + object->pos[0] = 0.0f; + object->pos[1] = 0.0f; + object->pos[2] = 0.0f; set_object_flag_status_true(objectIndex, 0x00000020); func_80072488(objectIndex); - temp_s0->primAlpha = 0; + object->primAlpha = 0; func_80073844(objectIndex); - temp_s0->sizeScaling = 0.15f; - temp_s0->unk_034 = 1.0f; + object->sizeScaling = 0.15f; + object->unk_034 = 1.0f; func_80073FD4(objectIndex); func_80086EF0(objectIndex); set_object_flag_status_true(objectIndex, 0x00000800); - temp_s0->orientation[0] = 0; - temp_s0->orientation[2] = 0x8000; + object->orientation[0] = 0; + object->orientation[2] = 0x8000; } void func_8007C684(s32 objectIndex) { @@ -4378,7 +4376,7 @@ void update_boos(void) { s32 objectIndex; Player *player; Camera *camera; - Objects *object; + Object *object; func_8007CA70(); for (someIndex = 0; someIndex < NUM_BOOS; someIndex++) { @@ -4404,28 +4402,28 @@ void update_boos(void) { } void func_8007CE0C(s32 objectIndex) { - Objects *temp_s0; + Object *object; init_texture_object(objectIndex, d_course_banshee_boardwalk_boo_tlut, gTextureGhosts, 0x30U, (u16) 0x00000028); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->itemDisplay = 0x1C; - temp_s0->pos[0] = 0.0f; - temp_s0->pos[1] = 0.0f; - temp_s0->pos[2] = 0.0f; - temp_s0->sizeScaling = 0.15f; + object = &gObjectList[objectIndex]; + object->itemDisplay = 0x1C; + object->pos[0] = 0.0f; + object->pos[1] = 0.0f; + object->pos[2] = 0.0f; + object->sizeScaling = 0.15f; func_80072488(objectIndex); - temp_s0->primAlpha = 0; + object->primAlpha = 0; func_80073844(objectIndex); func_80086EF0(objectIndex); - temp_s0->direction_angle[2] = 0x8000; - temp_s0->direction_angle[1] = atan2s(D_8018CF1C->pos[0] - temp_s0->origin_pos[0], D_8018CF1C->pos[2] - temp_s0->origin_pos[2]); + object->direction_angle[2] = 0x8000; + object->direction_angle[1] = atan2s(D_8018CF1C->pos[0] - object->origin_pos[0], D_8018CF1C->pos[2] - object->origin_pos[2]); } void func_8007CEDC(s32 objectIndex) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->state) { /* switch 1 */ + object = &gObjectList[objectIndex]; + switch (object->state) { /* switch 1 */ case 0: /* switch 1 */ break; case 1: /* switch 1 */ @@ -4443,21 +4441,21 @@ void func_8007CEDC(s32 objectIndex) { default: /* switch 2 */ break; } - if (temp_s0->state >= 2) { - func_80072950(objectIndex, (s32) temp_s0->unk_0DC, 0, 4); + if (object->state >= 2) { + func_80072950(objectIndex, (s32) object->unk_0DC, 0, 4); func_80073514(objectIndex); - switch (temp_s0->unk_0DC) { /* switch 2 */ + switch (object->unk_0DC) { /* switch 2 */ case 1: /* switch 2 */ - func_80073998(objectIndex, &temp_s0->primAlpha, 0x00000028, 0x00000050, 4, 0, 0); + func_80073998(objectIndex, &object->primAlpha, 0x00000028, 0x00000050, 4, 0, 0); break; case 2: /* switch 2 */ - func_80073CB0(objectIndex, &temp_s0->primAlpha, 0x00000050, 0x000000B4, 2, 0, -1); - if ((temp_s0->unk_0AE == 0) || (temp_s0->state == 3)) { - temp_s0->unk_0DC += 1; + func_80073CB0(objectIndex, &object->primAlpha, 0x00000050, 0x000000B4, 2, 0, -1); + if ((object->unk_0AE == 0) || (object->state == 3)) { + object->unk_0DC += 1; } break; case 3: /* switch 2 */ - func_80073DC0(objectIndex, &temp_s0->primAlpha, 0, 4); + func_80073DC0(objectIndex, &object->primAlpha, 0, 4); break; case 4: /* switch 2 */ func_80073884(objectIndex); @@ -4553,14 +4551,14 @@ void func_8007D360(s32 objectIndex, s32 arg1) { void func_8007D6A8(s32 objectIndex, s32 arg1) { UNUSED s32 pad[2]; - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_0D5 = 0x0D; + object = &gObjectList[objectIndex]; + object->unk_0D5 = 0x0D; func_8007D360(objectIndex, arg1); - temp_v0->sizeScaling = 0.1f; + object->sizeScaling = 0.1f; set_object_flag_status_true(objectIndex, 0x00000200); - temp_v0->boundingBoxSize = 3; + object->boundingBoxSize = 3; } void func_8007D714(s32 arg0) { @@ -4668,7 +4666,7 @@ void func_8007DAF8(s32 objectIndex, s32 arg1) { void update_bat(void) { s32 var_s2; s32 temp_s0; - Objects *temp_s1; + Object *object; if (D_8018CFC8 != 0) { D_8018CFC8 -= 1; @@ -4679,22 +4677,22 @@ void update_bat(void) { temp_s0 = indexObjectList1[0]; func_80072E54(temp_s0, 0, 3, 1, 0, -1); func_80073514(temp_s0); - temp_s1 = &gObjectList[temp_s0]; - func_80073CB0(temp_s0, &temp_s1->primAlpha, -0x00001000, 0x00001000, 0x00000400, 0, -1); - temp_s1->orientation[2] = temp_s1->primAlpha + 0x8000; + object = &gObjectList[temp_s0]; + func_80073CB0(temp_s0, &object->primAlpha, -0x00001000, 0x00001000, 0x00000400, 0, -1); + object->orientation[2] = object->primAlpha + 0x8000; if ((D_8018CFB0 != 0) || (D_8018CFC8 != 0)) { D_8018CFD8 = 0; for (var_s2 = 0; var_s2 < 40; var_s2++) { temp_s0 = gObjectParticle2[var_s2]; if (temp_s0 == -1) continue; - temp_s1 = &gObjectList[temp_s0]; - if (temp_s1->state == 0) continue; + object = &gObjectList[temp_s0]; + if (object->state == 0) continue; func_8007D8D4(temp_s0, 1); func_8007DAF8(temp_s0, 1); func_8007D794(temp_s0); - if (temp_s1->state == 0) { + if (object->state == 0) { delete_object_wrapper(&gObjectParticle2[var_s2]); } D_8018CFD8 += 1; @@ -4709,13 +4707,13 @@ void update_bat(void) { temp_s0 = gObjectParticle3[var_s2]; if (temp_s0 == -1) continue; - temp_s1 = &gObjectList[temp_s0]; - if (temp_s1->state == 0) continue; + object = &gObjectList[temp_s0]; + if (object->state == 0) continue; func_8007D8D4(temp_s0, 2); func_8007DAF8(temp_s0, 2); func_8007D794(temp_s0); - if (temp_s1->state == 0) { + if (object->state == 0) { delete_object_wrapper(&gObjectParticle3[var_s2]); } D_8018D010 += 1; @@ -4728,41 +4726,41 @@ void update_bat(void) { void func_8007DDC0(s32 objectIndex) { f32 sp2C; - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - if (temp_s0->unk_04C > 0) { - temp_s0->unk_04C--; - if (temp_s0->unk_04C == 0) { + object = &gObjectList[objectIndex]; + if (object->unk_04C > 0) { + object->unk_04C--; + if (object->unk_04C == 0) { func_800722CC(objectIndex, 1); } } - if (temp_s0->unk_048 > 0) { - temp_s0->unk_048--; - if (temp_s0->unk_048 == 0) { - func_800C9EF4(temp_s0->pos, SOUND_ARG_LOAD(0x51, 0x02, 0x80, 0x06)); + if (object->unk_048 > 0) { + object->unk_048--; + if (object->unk_048 == 0) { + func_800C9EF4(object->pos, SOUND_ARG_LOAD(0x51, 0x02, 0x80, 0x06)); } } - if (temp_s0->unk_04C == 0) { + if (object->unk_04C == 0) { if ((gCCSelection == CC_50) || (gCCSelection == CC_100) || (gCCSelection == CC_150) || (gCCSelection == CC_EXTRA)) { sp2C = 1150.0f; } func_8008A6DC(objectIndex, sp2C); if ((is_obj_flag_status_active(objectIndex, VISIBLE) != 0) && (func_80072354(objectIndex, 1) != 0)) { func_800722A4(objectIndex, 1); - func_800C9D80(temp_s0->pos, temp_s0->velocity, SOUND_ARG_LOAD(0x51, 0x02, 0x80, 0x06)); + func_800C9D80(object->pos, object->velocity, SOUND_ARG_LOAD(0x51, 0x02, 0x80, 0x06)); func_800726CC(objectIndex, 3); - if (temp_s0->type > 0) { - temp_s0->type--; - temp_s0->unk_04C = 0x00000168; + if (object->type > 0) { + object->type--; + object->unk_04C = 0x00000168; } else { - temp_s0->unk_04C = 0x00000168; + object->unk_04C = 0x00000168; } - temp_s0->unk_048 = 0x0000012C; + object->unk_048 = 0x0000012C; } } if (func_8008A8B0(0x000F, 0x0012) == 0) { - temp_s0->type = 2; + object->type = 2; } } @@ -4846,41 +4844,41 @@ void update_trash_bin(void) { void func_8007E1F4(s32 objectIndex) { f32 sp2C; - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - if (temp_s0->unk_04C > 0) { - temp_s0->unk_04C--; - if (temp_s0->unk_04C == 0) { + object = &gObjectList[objectIndex]; + if (object->unk_04C > 0) { + object->unk_04C--; + if (object->unk_04C == 0) { func_800722CC(objectIndex, 1); } } - if (temp_s0->unk_048 > 0) { - temp_s0->unk_048--; - if (temp_s0->unk_048 == 0) { - func_800C9EF4(temp_s0->pos, SOUND_ARG_LOAD(0x51, 0x02, 0x80, 0x06)); + if (object->unk_048 > 0) { + object->unk_048--; + if (object->unk_048 == 0) { + func_800C9EF4(object->pos, SOUND_ARG_LOAD(0x51, 0x02, 0x80, 0x06)); } } - if (temp_s0->unk_04C == 0) { + if (object->unk_04C == 0) { if ((gCCSelection == CC_50) || (gCCSelection == CC_100) || (gCCSelection == CC_150) || (gCCSelection == CC_EXTRA)) { sp2C = 700.0f; } func_8008A6DC(objectIndex, sp2C); if ((is_obj_flag_status_active(objectIndex, VISIBLE) != 0) && (func_80072354(objectIndex, 1) != 0)) { func_800722A4(objectIndex, 1); - func_800C9D80(temp_s0->pos, temp_s0->velocity, SOUND_ARG_LOAD(0x51, 0x02, 0x80, 0x06)); + func_800C9D80(object->pos, object->velocity, SOUND_ARG_LOAD(0x51, 0x02, 0x80, 0x06)); func_800726CC(objectIndex, 3); - if (temp_s0->type > 0) { - temp_s0->type--; - temp_s0->unk_04C = 0x00000168; + if (object->type > 0) { + object->type--; + object->unk_04C = 0x00000168; } else { - temp_s0->unk_04C = 0x00000168; + object->unk_04C = 0x00000168; } - temp_s0->unk_048 = 0x0000012C; + object->unk_048 = 0x0000012C; } } if (func_8008A8B0(0x000F, 0x0013) == 0) { - temp_s0->type = 2; + object->type = 2; } } @@ -5099,11 +5097,11 @@ void func_8007E63C(s32 objectIndex) { } void func_8007EC30(s32 objectIndex) { - Objects *temp_s1; + Object *object; - temp_s1 = &gObjectList[objectIndex]; - temp_s1->unk_044 = 0.0f; - temp_s1->origin_pos[1] = 0.0f; + object = &gObjectList[objectIndex]; + object->surfaceHeight = 0.0f; + object->origin_pos[1] = 0.0f; set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); if (gIsMirrorMode != 0) { set_obj_direction_angle(objectIndex, 0U, 0x4000U, 0U); @@ -5113,13 +5111,13 @@ void func_8007EC30(s32 objectIndex) { set_obj_orientation(objectIndex, 0U, 0xC000U, 0U); } init_texture_object(objectIndex, d_course_bowsers_castle_thwomp_tlut, (u8*) d_course_bowsers_castle_thwomp_faces, 0x10U, (u16) 0x00000040); - temp_s1->model = d_course_bowsers_castle_dl_thwomp; - temp_s1->boundingBoxSize = 0x000C; - temp_s1->sizeScaling = 1.0f; - temp_s1->unk_01C[1] = 30.0f; + object->model = d_course_bowsers_castle_dl_thwomp; + object->boundingBoxSize = 0x000C; + object->sizeScaling = 1.0f; + object->unk_01C[1] = 30.0f; set_object_flag_status_true(objectIndex, 0x05000220); - temp_s1->type = 0; - temp_s1->unk_0DF = 6; + object->type = 0; + object->unk_0DF = 6; func_800724DC(objectIndex); func_80072488(objectIndex); } @@ -5153,21 +5151,21 @@ void func_8007ED6C(s32 objectIndex) { } void func_8007EE5C(s32 objectIndex) { - Objects *temp_s0; + Object *object; init_texture_object(objectIndex, d_course_bowsers_castle_thwomp_tlut, (u8*) d_course_bowsers_castle_thwomp_faces, 0x10U, (u16) 0x00000040); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->sizeScaling = 1.0f; - temp_s0->model = d_course_bowsers_castle_dl_thwomp; - temp_s0->boundingBoxSize = 0x000C; + object = &gObjectList[objectIndex]; + object->sizeScaling = 1.0f; + object->model = d_course_bowsers_castle_dl_thwomp; + object->boundingBoxSize = 0x000C; set_object_flag_status_true(objectIndex, 0x04000220); - temp_s0->type = 0; - temp_s0->unk_0DF = 6; + object->type = 0; + object->unk_0DF = 6; func_80086E70(objectIndex); - temp_s0->unk_044 = 0.0f; - temp_s0->origin_pos[1] = 0.0f; + object->surfaceHeight = 0.0f; + object->origin_pos[1] = 0.0f; set_obj_origin_offset(objectIndex, 0.0f, 20.0f, 0.0f); - temp_s0->unk_01C[1] = 20.0f; + object->unk_01C[1] = 20.0f; if (gIsMirrorMode != 0) { set_obj_direction_angle(objectIndex, 0U, 0x4000U, 0U); set_obj_orientation(objectIndex, 0U, 0x4000U, 0U); @@ -5175,11 +5173,11 @@ void func_8007EE5C(s32 objectIndex) { set_obj_direction_angle(objectIndex, 0U, 0xC000U, 0U); set_obj_orientation(objectIndex, 0U, 0xC000U, 0U); } - temp_s0->unk_0AE = 1; - if (temp_s0->primAlpha == 0) { - temp_s0->unk_0DD = 1; + object->unk_0AE = 1; + if (object->primAlpha == 0) { + object->unk_0DD = 1; } else { - temp_s0->unk_0DD = 2; + object->unk_0DD = 2; } func_80072488(objectIndex); } @@ -5370,14 +5368,14 @@ void func_8007F5A8(s32 objectIndex) { } void func_8007F660(s32 objectIndex, s32 arg1, s32 arg2) { - Objects *temp_v0; + Object *object; func_800722A4(objectIndex, 8); func_80086E70(objectIndex); - temp_v0 = &gObjectList[objectIndex]; - temp_v0->unk_0DD = 1; - temp_v0->unk_0D1 = arg1; - temp_v0->unk_048 = arg2; + object = &gObjectList[objectIndex]; + object->unk_0DD = 1; + object->unk_0D1 = arg1; + object->unk_048 = arg2; } void func_8007F6C4(s32 objectIndex, s32 playerId) { @@ -5427,7 +5425,7 @@ void func_8007F8D8(void) { s32 var_s0; s32 someIndex; s32 var_s4; - Objects *object; + Object *object; player = gPlayerOne; var_s4 = 1; @@ -5452,17 +5450,17 @@ void func_8007F8D8(void) { } void func_8007FA08(s32 objectIndex) { - Objects *temp_s0; + Object *object; init_texture_object(objectIndex, d_course_bowsers_castle_thwomp_tlut, (u8*) d_course_bowsers_castle_thwomp_faces, 0x10U, (u16) 0x00000040); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->model = d_course_bowsers_castle_dl_thwomp; - temp_s0->boundingBoxSize = 0x000C; - temp_s0->sizeScaling = 1.0f; + object = &gObjectList[objectIndex]; + object->model = d_course_bowsers_castle_dl_thwomp; + object->boundingBoxSize = 0x000C; + object->sizeScaling = 1.0f; set_object_flag_status_true(objectIndex, 0x04000220); - temp_s0->type = 0; - temp_s0->unk_044 = 0.0f; - temp_s0->origin_pos[1] = 0.0f; + object->type = 0; + object->surfaceHeight = 0.0f; + object->origin_pos[1] = 0.0f; set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); set_obj_direction_angle(objectIndex, 0U, 0U, 0U); if (gIsMirrorMode != 0) { @@ -5470,12 +5468,12 @@ void func_8007FA08(s32 objectIndex) { } else { set_obj_orientation(objectIndex, 0U, 0x4000U, 0U); } - temp_s0->velocity[0] = 0.0f; - temp_s0->direction_angle[1] = temp_s0->orientation[1]; - temp_s0->unk_0DD = 1; - temp_s0->unk_0DF = 8; - temp_s0->offset[1] = 15.0f; - temp_s0->unk_01C[1] = 15.0f; + object->velocity[0] = 0.0f; + object->direction_angle[1] = object->orientation[1]; + object->unk_0DD = 1; + object->unk_0DF = 8; + object->offset[1] = 15.0f; + object->unk_01C[1] = 15.0f; func_80072488(objectIndex); } @@ -5556,12 +5554,12 @@ void func_8007FB48(s32 objectIndex) { } void func_8007FEA4(s32 objectIndex) { - Objects *temp_v1; + Object *object; - temp_v1 = &gObjectList[objectIndex]; - switch (temp_v1->unk_0AE) { + object = &gObjectList[objectIndex]; + switch (object->unk_0AE) { case 1: - if (f32_step_towards(&temp_v1->offset[0], temp_v1->unk_01C[0], 5.0f) != 0) { + if (f32_step_towards(&object->offset[0], object->unk_01C[0], 5.0f) != 0) { func_800726CC(objectIndex, 3); func_80086FD4(objectIndex); break; @@ -5570,7 +5568,7 @@ void func_8007FEA4(s32 objectIndex) { case 2: break; case 3: - if (f32_step_towards(&temp_v1->offset[0], 0.0f, 5.0f) != 0) { + if (f32_step_towards(&object->offset[0], 0.0f, 5.0f) != 0) { func_80086FD4(objectIndex); func_800722CC(objectIndex, 8); } @@ -5612,38 +5610,38 @@ void func_8007FFC0(s32 objectIndex) { } void func_80080078(s32 objectIndex) { - Objects *temp_s0; + Object *object; init_texture_object(objectIndex, d_course_bowsers_castle_thwomp_tlut, (u8*) d_course_bowsers_castle_thwomp_faces, 0x10U, (u16) 0x00000040); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->model = d_course_bowsers_castle_dl_thwomp; - temp_s0->boundingBoxSize = 0x000C; - temp_s0->sizeScaling = 1.0f; + object = &gObjectList[objectIndex]; + object->model = d_course_bowsers_castle_dl_thwomp; + object->boundingBoxSize = 0x000C; + object->sizeScaling = 1.0f; set_object_flag_status_true(objectIndex, 0x04000220); - temp_s0->type = 2; - temp_s0->unk_0DF = 8; + object->type = 2; + object->unk_0DF = 8; set_obj_direction_angle(objectIndex, 0U, 0U, 0U); - temp_s0->unk_044 = 0.0f; - temp_s0->origin_pos[1] = 0.0f; + object->surfaceHeight = 0.0f; + object->origin_pos[1] = 0.0f; set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); - temp_s0->unk_01C[1] = 30.0f; + object->unk_01C[1] = 30.0f; if (gIsMirrorMode != 0) { set_obj_orientation(objectIndex, 0U, 0x4000U, 0U); } else { set_obj_orientation(objectIndex, 0U, 0xC000U, 0U); } - switch (temp_s0->primAlpha) { /* irregular */ + switch (object->primAlpha) { /* irregular */ case 0: - temp_s0->unk_050 = 2; + object->unk_050 = 2; break; case 1: - temp_s0->unk_050 = 0x0000003C; + object->unk_050 = 0x0000003C; break; case 2: - temp_s0->unk_050 = 0x00000078; + object->unk_050 = 0x00000078; break; case 3: - temp_s0->unk_050 = 0x000000B4; + object->unk_050 = 0x000000B4; break; } func_800724DC(objectIndex); @@ -5651,23 +5649,23 @@ void func_80080078(s32 objectIndex) { } void func_800801FC(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - switch (temp_v0->state) { + object = &gObjectList[objectIndex]; + switch (object->state) { case 0: break; case 1: func_80080078(objectIndex); break; case 2: - func_8007278C(objectIndex, temp_v0->unk_050); + func_8007278C(objectIndex, object->unk_050); break; case 3: func_80072568(objectIndex, 0x00000032); break; case 4: - temp_v0->unk_050 = 0x0000003C; + object->unk_050 = 0x0000003C; func_800726CC(objectIndex, 2); break; } @@ -5677,31 +5675,31 @@ void func_800801FC(s32 objectIndex) { } void func_800802C0(s32 objectIndex) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - temp_s0->unk_0D8 = 0; + object = &gObjectList[objectIndex]; + object->unk_0D8 = 0; init_texture_object(objectIndex, d_course_bowsers_castle_thwomp_tlut, (u8*) d_course_bowsers_castle_thwomp_faces, 0x10U, (u16) 0x00000040); - temp_s0->model = d_course_bowsers_castle_dl_thwomp; - temp_s0->itemDisplay = 0; - temp_s0->boundingBoxSize = 0x000C; - temp_s0->sizeScaling = 1.5f; + object->model = d_course_bowsers_castle_dl_thwomp; + object->itemDisplay = 0; + object->boundingBoxSize = 0x000C; + object->sizeScaling = 1.5f; set_object_flag_status_true(objectIndex, 0x05000220); - temp_s0->type = 1; - temp_s0->unk_0DF = 6; + object->type = 1; + object->unk_0DF = 6; set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); set_obj_direction_angle(objectIndex, 0U, 0U, 0U); - temp_s0->unk_044 = 0.0f; - temp_s0->origin_pos[1] = 0.0f; - temp_s0->offset[1] = 10.0f; - temp_s0->unk_01C[1] = 10.0f; + object->surfaceHeight = 0.0f; + object->origin_pos[1] = 0.0f; + object->offset[1] = 10.0f; + object->unk_01C[1] = 10.0f; if (gIsMirrorMode != 0) { set_obj_orientation(objectIndex, 0U, 0x4000U, 0U); } else { set_obj_orientation(objectIndex, 0U, 0xC000U, 0U); } - temp_s0->offset[0] = 0.0f; - temp_s0->offset[2] = 0.0f; + object->offset[0] = 0.0f; + object->offset[2] = 0.0f; func_800724DC(objectIndex); func_80072488(objectIndex); } @@ -5736,36 +5734,36 @@ void func_80080408(s32 objectIndex) { } void func_80080524(s32 objectIndex) { - Objects *temp_s0; + Object *object; init_texture_object(objectIndex, d_course_bowsers_castle_thwomp_tlut, (u8*) d_course_bowsers_castle_thwomp_faces, 0x10U, (u16) 0x00000040); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->model = d_course_bowsers_castle_dl_thwomp; - temp_s0->boundingBoxSize = 0x000C; - temp_s0->itemDisplay = 0; - temp_s0->sizeScaling = 1.0f; + object = &gObjectList[objectIndex]; + object->model = d_course_bowsers_castle_dl_thwomp; + object->boundingBoxSize = 0x000C; + object->itemDisplay = 0; + object->sizeScaling = 1.0f; set_object_flag_status_true(objectIndex, 0x04000220); - temp_s0->type = 0; - temp_s0->unk_0DF = 0x0A; + object->type = 0; + object->unk_0DF = 0x0A; func_80086E70(objectIndex); set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); - temp_s0->unk_044 = 70.0f; - temp_s0->origin_pos[1] = 70.0f; - temp_s0->unk_01C[1] = 0.0f; + object->surfaceHeight = 70.0f; + object->origin_pos[1] = 70.0f; + object->unk_01C[1] = 0.0f; set_obj_direction_angle(objectIndex, 0U, 0U, 0U); if ((gIsMirrorMode != 0) || (gGamestate == 9)) { set_obj_orientation(objectIndex, 0U, 0xC000U, 0U); } else { set_obj_orientation(objectIndex, 0U, 0x4000U, 0U); } - switch (temp_s0->primAlpha) { /* irregular */ + switch (object->primAlpha) { /* irregular */ case 0: - temp_s0->unk_0DD = 2; - temp_s0->velocity[2] = -1.0f; + object->unk_0DD = 2; + object->velocity[2] = -1.0f; break; case 1: - temp_s0->unk_0DD = 2; - temp_s0->velocity[2] = -1.5f; + object->unk_0DD = 2; + object->velocity[2] = -1.5f; break; } func_800722A4(objectIndex, 0x00000080); @@ -5849,7 +5847,7 @@ void func_800808CC(s32 objectIndex) { void func_80080A14(s32 objectIndex, Player *player) { if (is_within_horizontal_distance_of_player(objectIndex, player, 12.0f) != 0) { - player->boundingBoxCorners[0].unk_14 |= 3; + player->tyres[FRONT_LEFT].unk_14 |= 3; } } @@ -5938,7 +5936,7 @@ void func_80080E8C(s32 objectIndex1, s32 objectIndex2, s32 arg2) { thing1 = func_800416D8(temp_v1[1], temp_v1[0], anAngle); thing0 = func_80041724(temp_v1[1], temp_v1[0], anAngle); gObjectList[objectIndex1].origin_pos[0] = gObjectList[objectIndex2].pos[0] + thing0; - gObjectList[objectIndex1].origin_pos[1] = gObjectList[objectIndex2].unk_044 - 9.0; + gObjectList[objectIndex1].origin_pos[1] = gObjectList[objectIndex2].surfaceHeight - 9.0; gObjectList[objectIndex1].origin_pos[2] = gObjectList[objectIndex2].pos[2] + thing1; anAngle = D_800E597C[arg2] + gObjectList[objectIndex2].direction_angle[1]; gObjectList[objectIndex1].velocity[0] = sins(anAngle) * 0.6; @@ -5960,19 +5958,19 @@ void func_80080FEC(s32 arg0) { } void func_80081080(s32 objectIndex) { - Objects *temp_v0; + Object *object; - temp_v0 = &gObjectList[objectIndex]; - temp_v0->activeTexture = D_8018D490; - temp_v0->textureList = D_8018D490; - temp_v0->primAlpha = 0x00FF; - temp_v0->direction_angle[1] = 0; - temp_v0->orientation[0] = 0; - temp_v0->orientation[2] = 0; - temp_v0->offset[0] = 0.0f; - temp_v0->offset[1] = 0.0f; - temp_v0->offset[2] = 0.0f; - temp_v0->sizeScaling = 0.25f; + object = &gObjectList[objectIndex]; + object->activeTexture = D_8018D490; + object->textureList = D_8018D490; + object->primAlpha = 0x00FF; + object->direction_angle[1] = 0; + object->orientation[0] = 0; + object->orientation[2] = 0; + object->offset[0] = 0.0f; + object->offset[1] = 0.0f; + object->offset[2] = 0.0f; + object->sizeScaling = 0.25f; func_80072488(objectIndex); } @@ -6044,7 +6042,7 @@ void func_80081210(void) { } player = gPlayerOne; for (var_s4 = 0; var_s4 < NUM_PLAYERS; var_s4++, player++) { - player->boundingBoxCorners[0].unk_14 &= ~3; + player->tyres[FRONT_LEFT].unk_14 &= ~3; player->unk_046 &= ~0x0006; for (var_s2_3 = 0; var_s2_3 < gNumActiveThwomps; var_s2_3++) { objectIndex = indexObjectList1[var_s2_3]; @@ -6195,28 +6193,28 @@ void func_80081A88(s32 objectIndex) { void func_80081AFC(s32 objectIndex, s32 arg1) { s8 *sp2C; - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->state) { /* irregular */ + object = &gObjectList[objectIndex]; + switch (object->state) { /* irregular */ case 0x1: func_80081848(objectIndex); break; case 0x2: - if (temp_s0->unk_04C == 0) { + if (object->unk_04C == 0) { func_80086EAC(objectIndex, 2, 1); func_80072488(objectIndex); set_object_flag_status_true(objectIndex, 0x00000200); } else { - temp_s0->unk_04C--; + object->unk_04C--; } break; case 0x3: - if (temp_s0->unk_0AE == 0) { + if (object->unk_0AE == 0) { func_80086EAC(objectIndex, 2, 4); func_8008153C(objectIndex); func_80072488(objectIndex); - func_800C98B8(temp_s0->pos, temp_s0->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x07)); + func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x07)); } break; case 0x4: @@ -6226,12 +6224,12 @@ void func_80081AFC(s32 objectIndex, s32 arg1) { break; case 0xA: func_80072E54(objectIndex, 1, 6, 1, 0, -1); - if (temp_s0->unk_0AE == 0) { + if (object->unk_0AE == 0) { func_800726CC(objectIndex, 0x00000064); } break; case 0x64: - if (temp_s0->unk_0AE == 0) { + if (object->unk_0AE == 0) { set_object_flag_status_false(objectIndex, 0x00000200); func_80072428(objectIndex); switch (arg1) { /* switch 1; irregular */ @@ -6245,58 +6243,58 @@ void func_80081AFC(s32 objectIndex, s32 arg1) { sp2C = D_8018D1B8; break; } - sp2C[temp_s0->type] = 0; + sp2C[object->type] = 0; } break; case 0: default: break; } - if (temp_s0->state >= 2) { + if (object->state >= 2) { func_80073514(objectIndex); } } void func_80081D34(s32 objectIndex) { - Player *var_s1; + Player *player; Camera *var_s4; s32 var_s2; s32 var_s5; - Objects *temp_s0; + Object *object; var_s5 = 0; - var_s1 = gPlayerOne; + player = gPlayerOne; var_s4 = camera1; - for (var_s2 = 0; var_s2 < D_8018D158; var_s2++, var_s1++, var_s4++) { - if ((is_obj_flag_status_active(objectIndex, 0x00000200) != 0) && !(var_s1->effects & 0x80000000) && (has_collided_with_player(objectIndex, var_s1) != 0)) { - if ((var_s1->type & 0x8000) && !(var_s1->type & 0x100)) { + for (var_s2 = 0; var_s2 < D_8018D158; var_s2++, player++, var_s4++) { + if ((is_obj_flag_status_active(objectIndex, 0x00000200) != 0) && !(player->effects & 0x80000000) && (has_collided_with_player(objectIndex, player) != 0)) { + if ((player->type & 0x8000) && !(player->type & 0x100)) { var_s5 = 1; - temp_s0 = &gObjectList[objectIndex]; + object = &gObjectList[objectIndex]; if (is_obj_flag_status_active(objectIndex, 0x04000000) != 0) { func_80072180(); } - if (var_s1->effects & 0x200) { + if (player->effects & 0x200) { func_800C9060(var_s2, 0x1900A046U); } else { - var_s1->soundEffects |= 2; + player->soundEffects |= 2; } - temp_s0->direction_angle[1] = var_s4->rot[1]; - temp_s0->velocity[1] = (var_s1->unk_094 / 2) + 3.0; - temp_s0->unk_034 = var_s1->unk_094 + 1.0; - if (temp_s0->velocity[1] >= 5.0) { - temp_s0->velocity[1] = 5.0f; + object->direction_angle[1] = var_s4->rot[1]; + object->velocity[1] = (player->unk_094 / 2) + 3.0; + object->unk_034 = player->unk_094 + 1.0; + if (object->velocity[1] >= 5.0) { + object->velocity[1] = 5.0f; } - if (temp_s0->unk_034 >= 4.0) { - temp_s0->velocity[1] = 4.0f; + if (object->unk_034 >= 4.0) { + object->velocity[1] = 4.0f; } } } } if (var_s5 != 0) { - temp_s0 = &gObjectList[objectIndex]; + object = &gObjectList[objectIndex]; set_object_flag_status_false(objectIndex, 0x00000200); func_80086F60(objectIndex); - set_obj_origin_pos(objectIndex, temp_s0->pos[0], temp_s0->pos[1], temp_s0->pos[2]); + set_obj_origin_pos(objectIndex, object->pos[0], object->pos[1], object->pos[2]); set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); func_80086EAC(objectIndex, 2, 0x000A); func_800726CC(objectIndex, 0x0000000A); @@ -6474,7 +6472,7 @@ void func_8008275C(s32 objectIndex) { } void update_seagulls(void) { - Objects *temp_s1; + Object *object; UNUSED s32 *var_s4; s32 temp_s0; s32 var_s3; @@ -6482,8 +6480,8 @@ void update_seagulls(void) { for (var_s3 = 0; var_s3 < NUM_SEAGULLS; var_s3++) { temp_s0 = indexObjectList2[var_s3]; - temp_s1 = &gObjectList[temp_s0]; - if (temp_s1->state == 0) continue; + object = &gObjectList[temp_s0]; + if (object->state == 0) continue; func_80082714(temp_s0, var_s3); func_8008275C(temp_s0); @@ -6495,12 +6493,12 @@ void update_seagulls(void) { D_80183E40[1] = 0.0f; D_80183E40[2] = 0.0f; if (gGamestate != CREDITS_SEQUENCE) { - func_800C98B8(temp_s1->pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43)); + func_800C98B8(object->pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43)); } else { temp_s0 = indexObjectList2[1]; if (gCutsceneShotTimer < 0x97) { - temp_s1 = &gObjectList[temp_s0]; - func_800C98B8(temp_s1->pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43)); + object = &gObjectList[temp_s0]; + func_800C98B8(object->pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43)); } } } @@ -6522,7 +6520,7 @@ void update_seagulls(void) { } void init_ktb_crab(s32 objectIndex) { - Objects *object; + Object *object; init_texture_object(objectIndex, d_course_koopa_troopa_beach_crab_tlut, (u8*) d_course_koopa_troopa_beach_crab_frames, 0x40U, (u16) 0x00000040); object = &gObjectList[objectIndex]; @@ -6594,7 +6592,7 @@ void func_80082C30(s32 objectIndex) { object_calculate_new_pos_offset(objectIndex); if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) { func_80088538(objectIndex); - gObjectList[objectIndex].pos[1] = (f32) (gObjectList[objectIndex].unk_044 + 2.5); + gObjectList[objectIndex].pos[1] = (f32) (gObjectList[objectIndex].surfaceHeight + 2.5); } } @@ -6667,22 +6665,22 @@ void func_80083080(void) { } void func_8008311C(s32 objectIndex, s32 arg1) { - Objects *temp_s0; + Object *object; init_texture_object(objectIndex, d_course_yoshi_valley_hedgehog_tlut, d_course_yoshi_valley_hedgehog, 0x40U, (u16) 0x00000040); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->activeTLUT = d_course_yoshi_valley_hedgehog_tlut; - temp_s0->activeTexture = d_course_yoshi_valley_hedgehog; - temp_s0->vertex = common_vtx_hedgehog; - temp_s0->sizeScaling = 0.2f; - temp_s0->itemDisplay = 0; + object = &gObjectList[objectIndex]; + object->activeTLUT = d_course_yoshi_valley_hedgehog_tlut; + object->activeTexture = d_course_yoshi_valley_hedgehog; + object->vertex = common_vtx_hedgehog; + object->sizeScaling = 0.2f; + object->itemDisplay = 0; func_80072488(objectIndex); set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); set_obj_orientation(objectIndex, 0U, 0U, 0x8000U); - temp_s0->unk_034 = ((arg1 % 6) * 0.1) + 0.5; + object->unk_034 = ((arg1 % 6) * 0.1) + 0.5; func_80086E70(objectIndex); set_object_flag_status_true(objectIndex, 0x04000600); - temp_s0->boundingBoxSize = 2; + object->boundingBoxSize = 2; } void func_80083248(s32 objectIndex) { @@ -6713,7 +6711,7 @@ void func_80083248(s32 objectIndex) { if (is_obj_flag_status_active(objectIndex, 0x00400000) != 0) { func_8008861C(objectIndex); } - gObjectList[objectIndex].pos[1] = gObjectList[objectIndex].unk_044 + 6.0; + gObjectList[objectIndex].pos[1] = gObjectList[objectIndex].surfaceHeight + 6.0; } } @@ -6755,25 +6753,25 @@ void update_hedgehogs(void) { } void func_80083538(s32 objectIndex, Vec3f arg1, s32 arg2, s32 arg3) { - Objects *temp_s0; + Object *object; init_object(objectIndex, 0); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->activeTexture = d_course_frappe_snowland_snow; - temp_s0->textureList = d_course_frappe_snowland_snow; - temp_s0->activeTLUT = d_course_frappe_snowland_snow_tlut; - temp_s0->tlutList = d_course_frappe_snowland_snow_tlut; - temp_s0->sizeScaling = random_int(0x0064U); - temp_s0->sizeScaling = (temp_s0->sizeScaling * 0.001) + 0.05; - temp_s0->velocity[1] = random_int(0x0014U); - temp_s0->velocity[1] = (temp_s0->velocity[1] * 0.5) + 2.6; - temp_s0->unk_034 = random_int(0x000AU); - temp_s0->unk_034 = (temp_s0->unk_034 *0.1) + 4.5; - temp_s0->direction_angle[1] = (arg2 << 0x10) / arg3; - temp_s0->origin_pos[0] = arg1[0]; - temp_s0->origin_pos[1] = arg1[1]; - temp_s0->origin_pos[2] = arg1[2]; - temp_s0->primAlpha = random_int(0x4000U) + 0x1000; + object = &gObjectList[objectIndex]; + object->activeTexture = d_course_frappe_snowland_snow; + object->textureList = d_course_frappe_snowland_snow; + object->activeTLUT = d_course_frappe_snowland_snow_tlut; + object->tlutList = d_course_frappe_snowland_snow_tlut; + object->sizeScaling = random_int(0x0064U); + object->sizeScaling = (object->sizeScaling * 0.001) + 0.05; + object->velocity[1] = random_int(0x0014U); + object->velocity[1] = (object->velocity[1] * 0.5) + 2.6; + object->unk_034 = random_int(0x000AU); + object->unk_034 = (object->unk_034 *0.1) + 4.5; + object->direction_angle[1] = (arg2 << 0x10) / arg3; + object->origin_pos[0] = arg1[0]; + object->origin_pos[1] = arg1[1]; + object->origin_pos[2] = arg1[2]; + object->primAlpha = random_int(0x4000U) + 0x1000; } void func_800836F0(Vec3f arg0) { @@ -6806,21 +6804,21 @@ void func_8008379C(s32 objectIndex) { } void func_80083868(s32 objectIndex) { - Objects *temp_s0; + Object *object; init_texture_object(objectIndex, d_course_frappe_snowland_snowman_tlut, d_course_frappe_snowland_snowman_head, 0x40U, (u16) 0x00000040); - temp_s0 = &gObjectList[objectIndex]; - temp_s0->vertex = D_0D0061B0; - temp_s0->sizeScaling = 0.1f; - temp_s0->itemDisplay = 0; + object = &gObjectList[objectIndex]; + object->vertex = D_0D0061B0; + object->sizeScaling = 0.1f; + object->itemDisplay = 0; func_80072488(objectIndex); set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); - temp_s0->orientation[0] = 0; - temp_s0->orientation[1] = 0; - temp_s0->orientation[2] = 0x8000; - temp_s0->primAlpha = random_int(0x2000U) - 0x1000; + object->orientation[0] = 0; + object->orientation[1] = 0; + object->orientation[2] = 0x8000; + object->primAlpha = random_int(0x2000U) - 0x1000; func_80086E70(objectIndex); - temp_s0->unk_034 = 1.5f; + object->unk_034 = 1.5f; set_object_flag_status_true(objectIndex, 0x00000200); } @@ -6890,10 +6888,10 @@ void func_80083BE4(s32 objectIndex) { } void func_80083C04(s32 objectIndex) { - Objects *temp_s1; + Object *object; - temp_s1 = &gObjectList[objectIndex]; - switch (temp_s1->state) { + object = &gObjectList[objectIndex]; + switch (object->state) { case 0: break; case 1: @@ -6910,11 +6908,11 @@ void func_80083C04(s32 objectIndex) { case 11: if (func_8007278C(objectIndex, 0x0000000A) != 0) { set_object_flag_status_true(objectIndex, 0x00000010); - temp_s1->sizeScaling = 0.001f; + object->sizeScaling = 0.001f; } break; case 12: - if (func_80074118(objectIndex, &temp_s1->sizeScaling, 0.001f, 0.1f, 0.0025f, 0, 0) != 0) { + if (func_80074118(objectIndex, &object->sizeScaling, 0.001f, 0.1f, 0.0025f, 0, 0) != 0) { func_80072488(objectIndex); } break; @@ -6923,7 +6921,7 @@ void func_80083C04(s32 objectIndex) { set_object_flag_status_false(objectIndex, 0x00001000); break; } - if (temp_s1->state >= 2) { + if (object->state >= 2) { func_80073514(objectIndex); } func_80083BE4(objectIndex); @@ -6934,7 +6932,7 @@ void update_snowmen(void) { s32 var_s3; s32 var_s4; s32 objectIndex; - Objects *temp_s1; + Object *object; for (var_s0 = 0; var_s0 < gObjectParticle2_SIZE; var_s0++) { objectIndex = gObjectParticle2[var_s0]; @@ -6954,13 +6952,13 @@ void update_snowmen(void) { func_80083A94(var_s3); func_80083C04(var_s4); if (is_obj_index_flag_status_inactive(var_s4, 0x00001000) != 0) { - temp_s1 = &gObjectList[var_s4]; - if ((func_8008A8B0(temp_s1->unk_0D5 - 1, temp_s1->unk_0D5 + 1) != 0) && (func_80089B50(var_s4) != 0)) { + object = &gObjectList[var_s4]; + if ((func_8008A8B0(object->unk_0D5 - 1, object->unk_0D5 + 1) != 0) && (func_80089B50(var_s4) != 0)) { set_object_flag_status_true(var_s4, 0x00001000); set_object_flag_status_false(var_s4, 0x00000010); func_800726CC(var_s4, 0x0000000A); func_8008701C(var_s3, 0x0000000A); - func_800836F0(temp_s1->pos); + func_800836F0(object->pos); } } else if (func_80072320(var_s4, 2) != 0) { func_800722CC(var_s4, 2); @@ -6987,22 +6985,22 @@ void func_80083F18(s32 objectIndex) { } void func_80083FD0(s32 objectIndex, s32 arg1, s32 playerId) { - Objects *temp_s0; + Object *object; Player *sp20; - temp_s0 = &gObjectList[objectIndex]; + object = &gObjectList[objectIndex]; sp20 = &gPlayerOne[playerId]; - temp_s0->unk_084[7] = playerId; + object->unk_084[7] = playerId; init_object(objectIndex, 0); - temp_s0->activeTLUT = d_course_sherbet_land_ice; - temp_s0->tlutList = d_course_sherbet_land_ice; - temp_s0->sizeScaling = ((f32) random_int(0x01F4U) * 0.0002) + 0.04; - temp_s0->velocity[1] = ((f32) random_int(0x0032U) * 0.05) + 1.0; - temp_s0->unk_034 = ((f32) random_int(0x000AU) * 0.1) + 1.0; - temp_s0->direction_angle[1] = D_801657A2 * arg1; - temp_s0->origin_pos[0] = (sp20->pos[0] + random_int(0x0014U)) - 10.0f; - temp_s0->origin_pos[1] = (sp20->pos[1] - 10.0) + random_int(0x000AU); - temp_s0->origin_pos[2] = (sp20->pos[2] + random_int(0x0014U)) - 10.0f; + object->activeTLUT = d_course_sherbet_land_ice; + object->tlutList = d_course_sherbet_land_ice; + object->sizeScaling = ((f32) random_int(0x01F4U) * 0.0002) + 0.04; + object->velocity[1] = ((f32) random_int(0x0032U) * 0.05) + 1.0; + object->unk_034 = ((f32) random_int(0x000AU) * 0.1) + 1.0; + object->direction_angle[1] = D_801657A2 * arg1; + object->origin_pos[0] = (sp20->pos[0] + random_int(0x0014U)) - 10.0f; + object->origin_pos[1] = (sp20->pos[1] - 10.0) + random_int(0x000AU); + object->origin_pos[2] = (sp20->pos[2] + random_int(0x0014U)) - 10.0f; } void func_8008421C(UNUSED s32 arg0, s32 playerId) { @@ -7047,22 +7045,22 @@ void func_800842C8(void) { } void func_80084430(s32 objectIndex, UNUSED s32 arg1) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - temp_s0->unk_0D8 = 0; - temp_s0->model = (Gfx *) d_course_sherbet_land_unk_data1; - temp_s0->vertex = (Vtx *) d_course_sherbet_land_unk_data11; - temp_s0->sizeScaling = 0.2f; - temp_s0->boundingBoxSize = 0x000C; - temp_s0->unk_09C = 1; + object = &gObjectList[objectIndex]; + object->unk_0D8 = 0; + object->model = (Gfx *) d_course_sherbet_land_unk_data1; + object->vertex = (Vtx *) d_course_sherbet_land_unk_data11; + object->sizeScaling = 0.2f; + object->boundingBoxSize = 0x000C; + object->unk_09C = 1; set_obj_origin_pos(objectIndex, xOrientation * -383.0, 2.0f, -690.0f); set_obj_direction_angle(objectIndex, 0U, 0U, 0U); - temp_s0->unk_0DD = 1; + object->unk_0DD = 1; func_80086EF0(objectIndex); - temp_s0->spline = D_800E672C[0]; + object->spline = D_800E672C[0]; set_object_flag_status_true(objectIndex, 0x04000800); - temp_s0->type = func_80004EAC(d_course_sherbet_land_unk_data11, 0); + object->type = func_80004EAC(d_course_sherbet_land_unk_data11, 0); func_80072488(objectIndex); } @@ -7082,38 +7080,38 @@ void func_8008453C(s32 objectIndex, s32 arg1) { } void func_800845C8(s32 objectIndex, s32 arg1) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - temp_s0->unk_0D8 = 0; - temp_s0->model = (Gfx *) d_course_sherbet_land_unk_data1; - temp_s0->vertex = (Vtx *) d_course_sherbet_land_unk_data11; - temp_s0->boundingBoxSize = 4; - temp_s0->unk_09C = 2; - temp_s0->unk_04C = random_int(0x012CU); + object = &gObjectList[objectIndex]; + object->unk_0D8 = 0; + object->model = (Gfx *) d_course_sherbet_land_unk_data1; + object->vertex = (Vtx *) d_course_sherbet_land_unk_data11; + object->boundingBoxSize = 4; + object->unk_09C = 2; + object->unk_04C = random_int(0x012CU); set_object_flag_status_true(objectIndex, 0x04000220); if ((arg1 > 0) && (arg1 < 9)) { if ((arg1 == 1) || (arg1 == 2)) { set_obj_origin_pos(objectIndex, xOrientation * -2960.0, -80.0f, 1521.0f); - temp_s0->unk_0C6 = 0x0150; - temp_s0->unk_01C[1] = 100.0f; + object->unk_0C6 = 0x0150; + object->unk_01C[1] = 100.0f; } else if ((arg1 == 3) || (arg1 == 4)) { set_obj_origin_pos(objectIndex, xOrientation * -2490.0, -80.0f, 1612.0f); - temp_s0->unk_0C6 = 0x0100; - temp_s0->unk_01C[1] = 80.0f; + object->unk_0C6 = 0x0100; + object->unk_01C[1] = 80.0f; } else if ((arg1 == 5) || (arg1 == 6)) { set_obj_origin_pos(objectIndex, xOrientation * -2098.0, -80.0f, 1624.0f); - temp_s0->unk_0C6 = 0xFF00; - temp_s0->unk_01C[1] = 80.0f; + object->unk_0C6 = 0xFF00; + object->unk_01C[1] = 80.0f; } else if ((arg1 == 7) || (arg1 == 8)) { set_obj_origin_pos(objectIndex, xOrientation * -2080.0, -80.0f, 1171.0f); - temp_s0->unk_0C6 = 0x0150; - temp_s0->unk_01C[1] = 80.0f; + object->unk_0C6 = 0x0150; + object->unk_01C[1] = 80.0f; } - temp_s0->unk_0C4 = (arg1 << 0xF) & 0xFFFF; - temp_s0->unk_044 = -80.0f; - temp_s0->sizeScaling = 0.08f; - temp_s0->unk_0DD = 2; + object->unk_0C4 = (arg1 << 0xF) & 0xFFFF; + object->surfaceHeight = -80.0f; + object->sizeScaling = 0.08f; + object->unk_0DD = 2; func_800722A4(objectIndex, 8); } else if ((arg1 > 8) && (arg1 < 15)) { switch (arg1) { /* irregular */ @@ -7122,91 +7120,91 @@ void func_800845C8(s32 objectIndex, s32 arg1) { set_obj_origin_pos(objectIndex, xOrientation * 146.0, 0.0f, -380.0f); } else { set_obj_origin_pos(objectIndex, xOrientation * 380.0, 0.0f, -535.0f); - temp_s0->sizeScaling = 0.15f; + object->sizeScaling = 0.15f; } - temp_s0->unk_0C6 = 0x9000; + object->unk_0C6 = 0x9000; if (gIsMirrorMode != 0) { - temp_s0->unk_0C6 -= 0x4000; + object->unk_0C6 -= 0x4000; } - temp_s0->unk_0DD = 3; + object->unk_0DD = 3; break; case 10: set_obj_origin_pos(objectIndex, xOrientation * 380.0, 0.0f, -766.0f); - temp_s0->unk_0C6 = 0x5000; + object->unk_0C6 = 0x5000; if (gIsMirrorMode != 0) { - temp_s0->unk_0C6 += 0x8000; + object->unk_0C6 += 0x8000; } - temp_s0->unk_0DD = 4; + object->unk_0DD = 4; break; case 11: set_obj_origin_pos(objectIndex, xOrientation * -2300.0, 0.0f, -210.0f); - temp_s0->unk_0C6 = 0xC000; - temp_s0->unk_0DD = 6; + object->unk_0C6 = 0xC000; + object->unk_0DD = 6; if (gIsMirrorMode != 0) { - temp_s0->unk_0C6 += 0x8000; + object->unk_0C6 += 0x8000; } break; case 12: set_obj_origin_pos(objectIndex, xOrientation * -2500.0, 0.0f, -250.0f); - temp_s0->unk_0C6 = 0x4000; - temp_s0->unk_0DD = 6; + object->unk_0C6 = 0x4000; + object->unk_0DD = 6; if (gIsMirrorMode != 0) { - temp_s0->unk_0C6 += 0x8000; + object->unk_0C6 += 0x8000; } break; case 13: set_obj_origin_pos(objectIndex, xOrientation * -535.0, 0.0f, 875.0f); - temp_s0->unk_0C6 = 0x8000; - temp_s0->unk_0DD = 6; + object->unk_0C6 = 0x8000; + object->unk_0DD = 6; if (gIsMirrorMode != 0) { - temp_s0->unk_0C6 -= 0x4000; + object->unk_0C6 -= 0x4000; } break; case 14: set_obj_origin_pos(objectIndex, xOrientation * -250.0, 0.0f, 953.0f); - temp_s0->unk_0C6 = 0x9000; - temp_s0->unk_0DD = 6; + object->unk_0C6 = 0x9000; + object->unk_0DD = 6; if (gIsMirrorMode != 0) { - temp_s0->unk_0C6 -= 0x4000; + object->unk_0C6 -= 0x4000; } break; default: break; } - set_obj_direction_angle(objectIndex, 0U, temp_s0->unk_0C6 + 0x8000, 0U); - temp_s0->unk_044 = 5.0f; - temp_s0->sizeScaling = 0.04f; + set_obj_direction_angle(objectIndex, 0U, object->unk_0C6 + 0x8000, 0U); + object->surfaceHeight = 5.0f; + object->sizeScaling = 0.04f; func_800722A4(objectIndex, 0x00000014); } func_80086EF0(objectIndex); - temp_s0->unk_034 = 0.0f; - temp_s0->type = func_80004EAC(d_course_sherbet_land_unk_data11, 0); + object->unk_034 = 0.0f; + object->type = func_80004EAC(d_course_sherbet_land_unk_data11, 0); func_80072488(objectIndex); } void func_80084B7C(s32 objectIndex, s32 arg1) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->state) { + object = &gObjectList[objectIndex]; + switch (object->state) { case 0: break; case 1: func_800845C8(objectIndex, arg1); break; case 2: - func_80072E54(objectIndex, 0, (s32) temp_s0->type, (s32) temp_s0->unk_09C, 0, -1); + func_80072E54(objectIndex, 0, (s32) object->type, (s32) object->unk_09C, 0, -1); if (func_80072354(objectIndex, 0x00000020) != 0) { - if (temp_s0->unk_084[6] == 0) { - temp_s0->unk_084[6] = random_int(0x005AU) + 0x5A; + if (object->unk_084[6] == 0) { + object->unk_084[6] = random_int(0x005AU) + 0x5A; func_800722A4(objectIndex, 0x00000080); } else { - temp_s0->unk_084[6]--; + object->unk_084[6]--; } } break; case 3: - func_80072E54(objectIndex, 0, temp_s0->type, 1, 0, 0); + func_80072E54(objectIndex, 0, object->type, 1, 0, 0); break; case 4: func_800722CC(objectIndex, 2); @@ -7214,19 +7212,19 @@ void func_80084B7C(s32 objectIndex, s32 arg1) { break; } if (func_80072320(objectIndex, 0x00000020) != 0) { - if (temp_s0->unk_084[6] == 0) { + if (object->unk_084[6] == 0) { func_800722A4(objectIndex, 0x00000080); - temp_s0->unk_084[6] = 0x0010; + object->unk_084[6] = 0x0010; } else { - temp_s0->unk_084[6]--; + object->unk_084[6]--; } } if (func_80072320(objectIndex, 0x00000080) != 0) { func_800722CC(objectIndex, 0x00000080); if (func_80072320(objectIndex, 0x00000010) != 0) { - func_800C98B8(temp_s0->pos, temp_s0->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x49)); + func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x49)); } else { - func_800C98B8(temp_s0->pos, temp_s0->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x17)); + func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x17)); } } } @@ -7330,10 +7328,10 @@ void func_80085080(s32 objectIndex) { } void func_800850B0(s32 objectIndex, s32 arg1) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->unk_0DD) { + object = &gObjectList[objectIndex]; + switch (object->unk_0DD) { case 1: func_80085080(objectIndex); break; @@ -7356,21 +7354,21 @@ void func_800850B0(s32 objectIndex, s32 arg1) { if (func_80072320(objectIndex, 0x00000020) != 0) { if (func_80072320(objectIndex, 0x00000040) != 0) { func_800722CC(objectIndex, 0x00000040); - temp_s0->unk_084[6] = 0; - temp_s0->unk_084[7] = 0x0096; + object->unk_084[6] = 0; + object->unk_084[7] = 0x0096; } - if (temp_s0->unk_084[7] == 0) { + if (object->unk_084[7] == 0) { func_800722CC(objectIndex, 0x00000020); } else { - temp_s0->unk_084[7]--; - temp_s0->orientation[0] = temp_s0->direction_angle[0]; - temp_s0->orientation[1] += 0x2000; - temp_s0->orientation[2] = temp_s0->direction_angle[2]; + object->unk_084[7]--; + object->orientation[0] = object->direction_angle[0]; + object->orientation[1] += 0x2000; + object->orientation[2] = object->direction_angle[2]; } } else { - temp_s0->orientation[0] = temp_s0->direction_angle[0]; - temp_s0->orientation[1] = temp_s0->direction_angle[1]; - temp_s0->orientation[2] = temp_s0->direction_angle[2]; + object->orientation[0] = object->direction_angle[0]; + object->orientation[1] = object->direction_angle[1]; + object->orientation[2] = object->direction_angle[2]; } } @@ -7501,58 +7499,58 @@ void update_hot_air_balloon(void) { void func_80085878(s32 objectIndex, s32 arg1) { TrackWaypoint *temp_v0; - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - temp_s0->unk_0D8 = 1; - temp_s0->model = (Gfx *) d_rainbow_road_unk4; - temp_s0->vertex = (Vtx *) d_rainbow_road_unk3; - temp_s0->sizeScaling = 0.03f; - temp_s0->boundingBoxSize = 0x000A; + object = &gObjectList[objectIndex]; + object->unk_0D8 = 1; + object->model = (Gfx *) d_rainbow_road_unk4; + object->vertex = (Vtx *) d_rainbow_road_unk3; + object->sizeScaling = 0.03f; + object->boundingBoxSize = 0x000A; set_object_flag_status_true(objectIndex, 0x04000200); - temp_s0->unk_084[8] = (arg1 * 0x12C) + 0x1F4; + object->unk_084[8] = (arg1 * 0x12C) + 0x1F4; set_obj_origin_pos(objectIndex, 0.0f, -15.0f, 0.0f); - temp_v0 = &D_80164490[(u16)temp_s0->unk_084[8]]; + temp_v0 = &D_80164490[(u16)object->unk_084[8]]; set_obj_origin_offset(objectIndex, temp_v0->posX, temp_v0->posY, temp_v0->posZ); set_obj_direction_angle(objectIndex, 0U, 0U, 0U); - temp_s0->unk_034 = 4.0f; - temp_s0->type = func_80004EAC(d_rainbow_road_unk3, 0); + object->unk_034 = 4.0f; + object->type = func_80004EAC(d_rainbow_road_unk3, 0); func_80072488(objectIndex); } void func_800859C8(s32 objectIndex, s32 arg1) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->state) { /* irregular */ + object = &gObjectList[objectIndex]; + switch (object->state) { /* irregular */ case 0: break; case 1: func_80085878(objectIndex, arg1); break; case 2: - func_80072E54(objectIndex, 0, (s32) temp_s0->type, 1, 0, -1); + func_80072E54(objectIndex, 0, (s32) object->type, 1, 0, -1); break; } if (D_8018D40C == 0) { - func_800C98B8(temp_s0->pos, temp_s0->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x57)); + func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x57)); } - func_80074344(objectIndex, &temp_s0->unk_044, -0.8f, 0.8f, 0.03f, 0, -1); + func_80074344(objectIndex, &object->surfaceHeight, -0.8f, 0.8f, 0.03f, 0, -1); } void update_chain_chomps(void) { s32 objectIndex; s32 var_s4; - Objects *temp_s0; + Object *object; for (var_s4 = 0; var_s4 < NUM_CHAIN_CHOMPS; var_s4++) { objectIndex = indexObjectList2[var_s4]; - temp_s0 = &gObjectList[objectIndex]; - if (temp_s0->state != 0) { + object = &gObjectList[objectIndex]; + if (object->state != 0) { func_800859C8(objectIndex, var_s4); - vec3f_copy(temp_s0->unk_01C, temp_s0->offset); - func_8000D940(temp_s0->offset, &temp_s0->unk_084[8], temp_s0->unk_034, temp_s0->unk_044, 0); - temp_s0->direction_angle[1] = get_angle_between_two_vectors(temp_s0->unk_01C, temp_s0->offset); + vec3f_copy(object->unk_01C, object->offset); + func_8000D940(object->offset, &object->unk_084[8], object->unk_034, object->surfaceHeight, 0); + object->direction_angle[1] = get_angle_between_two_vectors(object->unk_01C, object->offset); object_calculate_new_pos_offset(objectIndex); func_80089CBC(objectIndex, 30.0f); } @@ -7863,19 +7861,19 @@ void func_80086700(s32 objectIndex) { } void func_80086940(s32 objectIndex) { - Objects *temp_s0; + Object *object; - temp_s0 = &gObjectList[objectIndex]; - switch (temp_s0->unk_0AE) { + object = &gObjectList[objectIndex]; + switch (object->unk_0AE) { case 0: break; case 1: func_80086FD4(objectIndex); break; case 2: - f32_step_towards(&temp_s0->sizeScaling, 0.025f, 0.001f); + f32_step_towards(&object->sizeScaling, 0.025f, 0.001f); func_80087C48(objectIndex, 6.0f, 0.1f, 0x000000C8); - if ((f64) temp_s0->velocity[1] <= 0.0) { + if ((f64) object->velocity[1] <= 0.0) { func_8008701C(objectIndex, 3); } break; @@ -7884,27 +7882,27 @@ void func_80086940(s32 objectIndex) { break; case 4: D_801658D6 = 1; - temp_s0->velocity[1] = -0.4f; + object->velocity[1] = -0.4f; func_80086FD4(objectIndex); - temp_s0->origin_pos[1] = 90.0f; - temp_s0->offset[1] = 60.0f; + object->origin_pos[1] = 90.0f; + object->offset[1] = 60.0f; switch (D_802874D8.unk1D) { /* switch 1; irregular */ case 1: /* switch 1 */ - temp_s0->origin_pos[0] -= 3.0; - temp_s0->origin_pos[2] += 15.0; + object->origin_pos[0] -= 3.0; + object->origin_pos[2] += 15.0; break; case 2: /* switch 1 */ - temp_s0->origin_pos[0] -= 2.0; - temp_s0->origin_pos[2] -= 15.0; + object->origin_pos[0] -= 2.0; + object->origin_pos[2] -= 15.0; break; } break; case 5: - if ((f64) temp_s0->offset[1] <= 8.0) { - f32_step_towards(&temp_s0->velocity[1], -0.1f, -0.01f); + if ((f64) object->offset[1] <= 8.0) { + f32_step_towards(&object->velocity[1], -0.1f, -0.01f); } object_add_velocity_offset_y(objectIndex); - if ((f64) temp_s0->offset[1] <= 0.0) { + if ((f64) object->offset[1] <= 0.0) { func_80086FD4(objectIndex); } break; @@ -7921,12 +7919,12 @@ void func_80086940(s32 objectIndex) { break; } if (D_801658D6 != 0) { - temp_s0->direction_angle[0] += 0x400; - temp_s0->direction_angle[1] = 0xE800; - temp_s0->direction_angle[2] = 0xDA00; + object->direction_angle[0] += 0x400; + object->direction_angle[1] = 0xE800; + object->direction_angle[2] = 0xDA00; } else { - temp_s0->direction_angle[0] += 0x400; - temp_s0->direction_angle[1] -= 0x200; + object->direction_angle[0] += 0x400; + object->direction_angle[1] -= 0x200; } object_calculate_new_pos_offset(objectIndex); }