diff --git a/enhancements/flycam.patch b/enhancements/flycam.patch index 8db6ca596..8efaae248 100644 --- a/enhancements/flycam.patch +++ b/enhancements/flycam.patch @@ -430,7 +430,7 @@ diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index c2a84aa..338e2bd 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c -@@ -180,6 +180,11 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { +@@ -180,6 +180,11 @@ void render_course_segments(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { arg1->pathCounter = temp_v1; temp_v1 = ((temp_v1 - 1) * 4) + var_a3; diff --git a/include/common_structs.h b/include/common_structs.h index c7384e036..ecf0287d1 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -203,15 +203,17 @@ typedef struct { //bit 4: 1 = out of bounds //bit 3: 1 = player tumbles upon contact (may fall right through) /* 0x02 */ u16 surfaceType; - /* 0x04 */ s16 vtx31; - s16 vtx32; - s16 vtx33; //X, Y, Z of poly's third vertex - s16 vtx21; - s16 vtx22; - /* 0x0A */ s16 vtx23; //X, Y, Z of poly's second vertex - /* 0x10 */ Vtx *vtxPoly1; //pointer to the 3 vertices of this poly - Vtx *vtxPoly2; - Vtx *vtxPoly3; + + // For AABB bounding-box style collision. Box style collision is cheaper than checking each vtx. + /* 0x04 */ s16 minX; // Minimum x coordinate + s16 minY; // Minimum y coordinate + s16 minZ; // Minimum z coordinate + s16 maxX; // Maximum x coordinate + s16 maxY; // Maximum y coordinate + /* 0x0A */ s16 maxZ; // Maximum z coordinate + /* 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; @@ -227,17 +229,17 @@ typedef struct { /* 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. -} mk64_surface_map_ram; // size = 0x2C +} 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 surface_map "flag" member + // Close to being a copy of the top byte of the CollisionTriangle "flags" member /* 0x0D */ u8 surfaceFlags; // Don't know if "tile" is right the right term - // gSurfaceMap is a pointer to an array of "tile" structs. This is an index to that array - /* 0x0E */ u16 surfaceMapIndex; + // 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; diff --git a/src/code_800029B0.c b/src/code_800029B0.c index c55bcc712..db3af2ded 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -70,9 +70,9 @@ s16 gCreditsCourseId = COURSE_LUIGI_RACEWAY; s16 gPlaceItemBoxes = 1; // Technically a pointer to an array, but declaring it so creates regalloc issues. -mk64_surface_map_ram *gSurfaceMap; +CollisionTriangle *gCollisionMesh; u16 *D_8015F584; -u16 D_8015F588; // Number of entries in gSurfaceMap +u16 gCollisionMeshCount; // Number of entries in gCollisionMesh u16 D_8015F58A; u32 D_8015F58C; diff --git a/src/code_800029B0.h b/src/code_800029B0.h index 40376ff2e..810001f2d 100644 --- a/src/code_800029B0.h +++ b/src/code_800029B0.h @@ -67,9 +67,9 @@ extern s32 gIsMirrorMode; // D_800DC604 extern s16 gCreditsCourseId; extern s16 gPlaceItemBoxes; -extern mk64_surface_map_ram *gSurfaceMap; +extern CollisionTriangle *gCollisionMesh; extern u16 *D_8015F584; -extern u16 D_8015F588; +extern u16 gCollisionMeshCount; extern u16 D_8015F58A; extern u32 D_8015F58C; diff --git a/src/ending/code_80280000.c b/src/ending/code_80280000.c index f9f1fe824..28730e986 100644 --- a/src/ending/code_80280000.c +++ b/src/ending/code_80280000.c @@ -151,10 +151,10 @@ void load_credits(void) { D_8015F59C = 0; D_8015F5A0 = 0; D_8015F58C = 0; - D_8015F588 = 0; + gCollisionMeshCount = 0; D_800DC5BC = 0; D_800DC5C8 = 0; - gSurfaceMap = (mk64_surface_map_ram *) gNextFreeMemoryAddress; + gCollisionMesh = (CollisionTriangle *) gNextFreeMemoryAddress; camera->pos[0] = 1400.0f; camera->pos[1] = 300.0f; camera->pos[2] = 1400.0f; diff --git a/src/ending/code_80281780.c b/src/ending/code_80281780.c index 4b33160a1..b5974fa92 100644 --- a/src/ending/code_80281780.c +++ b/src/ending/code_80281780.c @@ -127,31 +127,31 @@ void load_ceremony_cutscene(void) { D_8015F59C = 0; D_8015F5A0 = 0; D_8015F58C = 0; - D_8015F588 = (u16)0; + gCollisionMeshCount = (u16)0; D_800DC5BC = (u16)0; D_800DC5C8 = (u16)0; - gSurfaceMap = (mk64_surface_map_ram *) gNextFreeMemoryAddress; + gCollisionMesh = (CollisionTriangle *) gNextFreeMemoryAddress; //! @bug these segmented addresses need to be symbols for mobility // d_course_royal_raceway_packed_dl_67E8 - set_vertex_data_with_default_section_id((Gfx *)0x070067E8, -1); + generate_collision_mesh_with_default_section_id((Gfx *)0x070067E8, -1); // d_course_royal_raceway_packed_dl_AEF8 - set_vertex_data_with_default_section_id((Gfx *)0x0700AEF8, -1); + generate_collision_mesh_with_default_section_id((Gfx *)0x0700AEF8, -1); // d_course_royal_raceway_packed_dl_A970 - set_vertex_data_with_default_section_id((Gfx *)0x0700A970, 8); + generate_collision_mesh_with_default_section_id((Gfx *)0x0700A970, 8); // d_course_royal_raceway_packed_dl_AC30 - set_vertex_data_with_default_section_id((Gfx *)0x0700AC30, 8); + generate_collision_mesh_with_default_section_id((Gfx *)0x0700AC30, 8); // d_course_royal_raceway_packed_dl_CE0 - set_vertex_data_with_default_section_id((Gfx *)0x07000CE0, 0x10); + generate_collision_mesh_with_default_section_id((Gfx *)0x07000CE0, 0x10); // d_course_royal_raceway_packed_dl_E88 - set_vertex_data_with_default_section_id((Gfx *)0x07000E88, 0x10); + generate_collision_mesh_with_default_section_id((Gfx *)0x07000E88, 0x10); // d_course_royal_raceway_packed_dl_A618 - set_vertex_data_with_default_section_id((Gfx *)0x0700A618, -1); + generate_collision_mesh_with_default_section_id((Gfx *)0x0700A618, -1); // d_course_royal_raceway_packed_dl_A618 - set_vertex_data_with_default_section_id((Gfx *)0x0700A618, -1); + generate_collision_mesh_with_default_section_id((Gfx *)0x0700A618, -1); // d_course_royal_raceway_packed_dl_23F8 - set_vertex_data_with_default_section_id((Gfx *)0x070023F8, 1); + generate_collision_mesh_with_default_section_id((Gfx *)0x070023F8, 1); // d_course_royal_raceway_packed_dl_2478 - set_vertex_data_with_default_section_id((Gfx *)0x07002478, 1); + generate_collision_mesh_with_default_section_id((Gfx *)0x07002478, 1); func_80295C6C(); debug_switch_character_ceremony_cutscene(); func_802818BC(); diff --git a/src/racing/collision.c b/src/racing/collision.c index f42acaf5a..cd7293d7e 100644 --- a/src/racing/collision.c +++ b/src/racing/collision.c @@ -113,7 +113,7 @@ f32 func_802AAB4C(Player *player) { } s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { - mk64_surface_map_ram *surfaceMap = &gSurfaceMap[index]; + CollisionTriangle *triangle = &gCollisionMesh[index]; UNUSED f32 pad; f32 x3; UNUSED f32 pad2; @@ -129,27 +129,27 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 temp_f2_2; s32 bool = 1; - if (surfaceMap->gravity < -0.9f) + if (triangle->gravity < -0.9f) return 0; - if (surfaceMap->vtx31 > posX) + if (triangle->minX > posX) return 0; - if (surfaceMap->vtx33 > posZ) + if (triangle->minZ > posZ) return 0; - if (surfaceMap->vtx21 < posX) + if (triangle->maxX < posX) return 0; - if (surfaceMap->vtx23 < posZ) + if (triangle->maxZ < posZ) return 0; - if ((surfaceMap->vtx32 - boundingBoxSize * 3.0f) > posY) + if ((triangle->minY - boundingBoxSize * 3.0f) > posY) return 0; - x1 = surfaceMap->vtxPoly1->v.ob[0]; - z1 = surfaceMap->vtxPoly1->v.ob[2]; + x1 = triangle->vtx1->v.ob[0]; + z1 = triangle->vtx1->v.ob[2]; - x2 = surfaceMap->vtxPoly2->v.ob[0]; - z2 = surfaceMap->vtxPoly2->v.ob[2]; + x2 = triangle->vtx2->v.ob[0]; + z2 = triangle->vtx2->v.ob[2]; - x3 = surfaceMap->vtxPoly3->v.ob[0]; - z3 = surfaceMap->vtxPoly3->v.ob[2]; + x3 = triangle->vtx3->v.ob[0]; + z3 = triangle->vtx3->v.ob[2]; temp_f10 = (z1 - posZ) * (x2 - posX) - (x1 - posX) * (z2 - posZ); @@ -188,17 +188,17 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, if (!bool) { return 0; } - temp_f0_5 = ((surfaceMap->height * posX) + (surfaceMap->gravity * posY) + (surfaceMap->rotation * posZ) - + surfaceMap->height2) + temp_f0_5 = ((triangle->height * posX) + (triangle->gravity * posY) + (triangle->rotation * posZ) + + triangle->height2) - boundingBoxSize; if (temp_f0_5 > 0.0f) { if (collision->unk3C[2] > temp_f0_5) { collision->unk34 = 1; collision->unk3A = index; collision->unk3C[2] = temp_f0_5; - collision->orientationVector[0] = surfaceMap->height; - collision->orientationVector[1] = surfaceMap->gravity; - collision->orientationVector[2] = surfaceMap->rotation; + collision->orientationVector[0] = triangle->height; + collision->orientationVector[1] = triangle->gravity; + collision->orientationVector[2] = triangle->rotation; } return 0; } @@ -207,9 +207,9 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, collision->unk34 = 1; collision->unk3A = index; collision->unk3C[2] = temp_f0_5; - collision->orientationVector[0] = surfaceMap->height; - collision->orientationVector[1] = surfaceMap->gravity; - collision->orientationVector[2] = surfaceMap->rotation; + collision->orientationVector[0] = triangle->height; + collision->orientationVector[1] = triangle->gravity; + collision->orientationVector[2] = triangle->rotation; return 1; } return 0; @@ -217,7 +217,7 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { - mk64_surface_map_ram *surfaceMap = &gSurfaceMap[index]; + CollisionTriangle *triangle = &gCollisionMesh[index]; UNUSED f32 pad[6]; f32 x3; f32 y3; @@ -234,34 +234,34 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 temp_f2_3; s32 bool = 1; - if (surfaceMap->vtx31 > posX) { + if (triangle->minX > posX) { return 0; } - if (surfaceMap->vtx21 < posX) { + if (triangle->maxX < posX) { return 0; } - if (surfaceMap->vtx22 < posY) { + if (triangle->maxY < posY) { return 0; } - if (surfaceMap->vtx32 > posY) { + if (triangle->minY > posY) { return 0; } - if ((surfaceMap->vtx33 - boundingBoxSize * 3.0f) > posZ) { + if ((triangle->minZ - boundingBoxSize * 3.0f) > posZ) { return 0; } - if ((surfaceMap->vtx23 + boundingBoxSize * 3.0f) < posZ) { + if ((triangle->maxZ + boundingBoxSize * 3.0f) < posZ) { return 0; } - x1 = surfaceMap->vtxPoly1->v.ob[0]; - y1 = surfaceMap->vtxPoly1->v.ob[1]; + x1 = triangle->vtx1->v.ob[0]; + y1 = triangle->vtx1->v.ob[1]; - x2 = surfaceMap->vtxPoly2->v.ob[0]; - y2 = surfaceMap->vtxPoly2->v.ob[1]; + x2 = triangle->vtx2->v.ob[0]; + y2 = triangle->vtx2->v.ob[1]; - x3 = surfaceMap->vtxPoly3->v.ob[0]; - y3 = surfaceMap->vtxPoly3->v.ob[1]; + x3 = triangle->vtx3->v.ob[0]; + y3 = triangle->vtx3->v.ob[1]; temp_f2_2 = (y1 - posY) * (x2 - posX) - (x1 - posX) * (y2 - posY); @@ -297,15 +297,15 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, if (!bool) { return 0; } - temp_f0_4 = ((surfaceMap->height * posX) + (surfaceMap->gravity * posY) + (surfaceMap->rotation * posZ) + surfaceMap->height2) - boundingBoxSize; + 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]) { collision->unk30 = 1; collision->unk36 = index; collision->unk3C[0] = temp_f0_4; - collision->unk48[0] = surfaceMap->height; - collision->unk48[1] = surfaceMap->gravity; - collision->unk48[2] = surfaceMap->rotation; + collision->unk48[0] = triangle->height; + collision->unk48[1] = triangle->gravity; + collision->unk48[2] = triangle->rotation; } return 0; } @@ -314,9 +314,9 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, collision->unk30 = 1; collision->unk36 = index; collision->unk3C[0] = temp_f0_4; - collision->unk48[0] = surfaceMap->height; - collision->unk48[1] = surfaceMap->gravity; - collision->unk48[2] = surfaceMap->rotation; + collision->unk48[0] = triangle->height; + collision->unk48[1] = triangle->gravity; + collision->unk48[2] = triangle->rotation; return 1; } return 0; @@ -324,7 +324,7 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { - mk64_surface_map_ram *surfaceMap = &gSurfaceMap[index]; + CollisionTriangle *triangle = &gCollisionMesh[index]; s32 bool = 1; UNUSED f32 pad[7]; f32 sp20; @@ -338,33 +338,33 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 temp_f2_2; f32 temp_f0_2; f32 temp_f2_3; - if (surfaceMap->vtx33 > posZ) { + if (triangle->minZ > posZ) { return 0; } - if (surfaceMap->vtx23 < posZ) { + if (triangle->maxZ < posZ) { return 0; } - if (surfaceMap->vtx22 < posY) { + if (triangle->maxY < posY) { return 0; } - if (surfaceMap->vtx32 > posY) { + if (triangle->minY > posY) { return 0; } - if ((surfaceMap->vtx31 - (boundingBoxSize * 3.0f)) > posX) { + if ((triangle->minX - (boundingBoxSize * 3.0f)) > posX) { return 0; } - if ((surfaceMap->vtx21 + (boundingBoxSize * 3.0f)) < posX) { + if ((triangle->maxX + (boundingBoxSize * 3.0f)) < posX) { return 0; } - sp24 = surfaceMap->vtxPoly1->v.ob[2]; - temp_f4 = surfaceMap->vtxPoly1->v.ob[1]; + sp24 = triangle->vtx1->v.ob[2]; + temp_f4 = triangle->vtx1->v.ob[1]; - sp70 = surfaceMap->vtxPoly2->v.ob[2]; - sp6C = surfaceMap->vtxPoly2->v.ob[1]; + sp70 = triangle->vtx2->v.ob[2]; + sp6C = triangle->vtx2->v.ob[1]; - temp_f8 = surfaceMap->vtxPoly3->v.ob[2]; - sp20 = surfaceMap->vtxPoly3->v.ob[1]; + temp_f8 = triangle->vtx3->v.ob[2]; + sp20 = triangle->vtx3->v.ob[1]; temp_f2_2 = (temp_f4 - posY) * (sp70 - posZ) - (sp24 - posZ) * (sp6C - posY); @@ -405,8 +405,8 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, return 0; } - temp_f0_4 = ((((surfaceMap->height * posX) + (surfaceMap->gravity * posY)) + (surfaceMap->rotation * posZ)) - + surfaceMap->height2) + temp_f0_4 = ((((triangle->height * posX) + (triangle->gravity * posY)) + (triangle->rotation * posZ)) + + triangle->height2) - boundingBoxSize; if (temp_f0_4 > 0.0f) { @@ -414,9 +414,9 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, collision->unk32 = 1; collision->unk38 = index; collision->unk3C[1] = temp_f0_4; - collision->unk54[0] = surfaceMap->height; - collision->unk54[1] = surfaceMap->gravity; - collision->unk54[2] = surfaceMap->rotation; + collision->unk54[0] = triangle->height; + collision->unk54[1] = triangle->gravity; + collision->unk54[2] = triangle->rotation; } return 0; } @@ -424,16 +424,16 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, collision->unk32 = 1; collision->unk38 = index; collision->unk3C[1] = temp_f0_4; - collision->unk54[0] = surfaceMap->height; - collision->unk54[1] = surfaceMap->gravity; - collision->unk54[2] = surfaceMap->rotation; + collision->unk54[0] = triangle->height; + collision->unk54[1] = triangle->gravity; + collision->unk54[2] = triangle->rotation; return 1; } return 0; } s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { - mk64_surface_map_ram *surfaceMap = &gSurfaceMap[index]; + CollisionTriangle *triangle = &gCollisionMesh[index]; UNUSED f32 pad; f32 x3; UNUSED f32 pad2; @@ -449,14 +449,14 @@ s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { f32 temp_f0_2; s32 bool = 1; - x1 = surfaceMap->vtxPoly1->v.ob[0]; - z1 = surfaceMap->vtxPoly1->v.ob[2]; + x1 = triangle->vtx1->v.ob[0]; + z1 = triangle->vtx1->v.ob[2]; - x2 = surfaceMap->vtxPoly2->v.ob[0]; - z2 = surfaceMap->vtxPoly2->v.ob[2]; + x2 = triangle->vtx2->v.ob[0]; + z2 = triangle->vtx2->v.ob[2]; - x3 = surfaceMap->vtxPoly3->v.ob[0]; - z3 = surfaceMap->vtxPoly3->v.ob[2]; + x3 = triangle->vtx3->v.ob[0]; + z3 = triangle->vtx3->v.ob[2]; temp_f2_2 = (z1 - posZ) * (x2 - posX) - (x1 - posX) * (z2 - posZ); @@ -493,36 +493,36 @@ s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { } s8 get_surface_type(u16 index) { - mk64_surface_map_ram *tile = &gSurfaceMap[index]; - return tile->surfaceType; + CollisionTriangle *triangle = &gCollisionMesh[index]; + return triangle->surfaceType; } s16 func_802ABD40(u16 index) { - mk64_surface_map_ram *tile = &gSurfaceMap[index]; - return tile->flags & 0xFF; + CollisionTriangle *triangle = &gCollisionMesh[index]; + return triangle->flags & 0xFF; } s16 func_802ABD7C(u16 index) { - mk64_surface_map_ram *tile = &gSurfaceMap[index]; - return tile->flags & 0x1000; + CollisionTriangle *triangle = &gCollisionMesh[index]; + return triangle->flags & 0x1000; } s16 func_802ABDB8(u16 index) { - mk64_surface_map_ram *tile = &gSurfaceMap[index]; - return tile->flags & 0x400; + CollisionTriangle *triangle = &gCollisionMesh[index]; + return triangle->flags & 0x400; } s16 func_802ABDF4(u16 index) { - mk64_surface_map_ram *tile = &gSurfaceMap[index]; - return tile->flags & 0x800; + CollisionTriangle *triangle = &gCollisionMesh[index]; + return triangle->flags & 0x800; } f32 func_802ABE30(f32 x, f32 y, f32 z, u16 index) { - mk64_surface_map_ram *tile = &gSurfaceMap[index]; - if (tile->gravity == 0.0f) { + CollisionTriangle *triangle = &gCollisionMesh[index]; + if (triangle->gravity == 0.0f) { return y; } - return ((tile->height * x) + (tile->rotation * z) + tile->height2) / -tile->gravity; + return ((triangle->height * x) + (triangle->rotation * z) + triangle->height2) / -triangle->gravity; } f32 func_802ABEAC(Collision *collision, Vec3f pos) { @@ -671,20 +671,20 @@ s32 func_802AC22C(KartBoundingBoxCorner *arg0) { temp_f26 = arg0->cornerPos[2]; switch (arg0->surfaceFlags) { /* irregular */ case 0x80: - if (func_802AB6C4(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, (u16) (s32) arg0->surfaceMapIndex) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, arg0->surfaceMapIndex); + 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); return 1; } break; case 0x40: - if (func_802AAE4C(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, (u16) (s32) arg0->surfaceMapIndex) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, arg0->surfaceMapIndex); + 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); return 1; } break; case 0x20: - if (func_802AB288(&spD0, 5.0f, temp_f22, temp_f24, temp_f26, (u16) (s32) arg0->surfaceMapIndex) == 1) { - arg0->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, arg0->surfaceMapIndex); + 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); return 1; } break; @@ -716,14 +716,14 @@ s32 func_802AC22C(KartBoundingBoxCorner *arg0) { 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 (gSurfaceMap[temp_s0].flags & 0x4000) { - if (temp_s0 != arg0->surfaceMapIndex) { + 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 = gSurfaceMap[temp_s0].surfaceType; + arg0->surfaceType = gCollisionMesh[temp_s0].surfaceType; arg0->surfaceFlags = 0x40; - arg0->surfaceMapIndex = temp_s0; - if (gSurfaceMap[temp_s0].flags & 0x1000) { + arg0->collisionMeshIndex = temp_s0; + if (gCollisionMesh[temp_s0].flags & 0x1000) { arg0->unk_14 = 1; } else { arg0->unk_14 = 0; @@ -731,22 +731,22 @@ s32 func_802AC22C(KartBoundingBoxCorner *arg0) { return 1; } } - } else if (gSurfaceMap[temp_s0].flags & 0x8000) { - if ((gSurfaceMap[temp_s0].height != 1.0f) && (temp_s0 != arg0->surfaceMapIndex)) { + } 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 = gSurfaceMap[temp_s0].surfaceType; + arg0->surfaceType = gCollisionMesh[temp_s0].surfaceType; arg0->surfaceFlags = 0x80; - arg0->surfaceMapIndex = temp_s0; + arg0->collisionMeshIndex = temp_s0; return 1; } } - } else if ((gSurfaceMap[temp_s0].rotation != 1.0f) && (temp_s0 != arg0->surfaceMapIndex)) { + } 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 = gSurfaceMap[temp_s0].surfaceType; + arg0->surfaceType = gCollisionMesh[temp_s0].surfaceType; arg0->surfaceFlags = 0x20; - arg0->surfaceMapIndex = temp_s0; + arg0->collisionMeshIndex = temp_s0; return 1; } } @@ -760,7 +760,7 @@ s32 func_802AC22C(KartBoundingBoxCorner *arg0) { } s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 index, f32 posX, f32 posY, f32 posZ) { - mk64_surface_map_ram *tile = &gSurfaceMap[index]; + CollisionTriangle *triangle = &gCollisionMesh[index]; UNUSED s32 pad; f32 x4; UNUSED f32 y4; @@ -779,30 +779,30 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize f32 area3; s32 bool = 1; - if (tile->vtx31 > x1) { + if (triangle->minX > x1) { return 0; } - if (tile->vtx33 > z1) { + if (triangle->minZ > z1) { return 0; } - if (tile->vtx21 < x1) { + if (triangle->maxX < x1) { return 0; } - if (tile->vtx23 < z1) { + if (triangle->maxZ < z1) { return 0; } - if ((tile->vtx32 - boundingBoxSize * 3.0f) > y1) { + if ((triangle->minY - boundingBoxSize * 3.0f) > y1) { return 0; } - x2 = (f32) tile->vtxPoly1->v.ob[0]; - z2 = (f32) tile->vtxPoly1->v.ob[2]; + x2 = (f32) triangle->vtx1->v.ob[0]; + z2 = (f32) triangle->vtx1->v.ob[2]; - x3 = (f32) tile->vtxPoly2->v.ob[0]; - z3 = (f32) tile->vtxPoly2->v.ob[2]; + x3 = (f32) triangle->vtx2->v.ob[0]; + z3 = (f32) triangle->vtx2->v.ob[2]; - x4 = (f32) tile->vtxPoly3->v.ob[0]; - z4 = (f32) tile->vtxPoly3->v.ob[2]; + x4 = (f32) triangle->vtx3->v.ob[0]; + z4 = (f32) triangle->vtx3->v.ob[2]; area = (z2 - z1) * (x3 - x1) - (x2 - x1) * (z3 - z1); @@ -841,21 +841,21 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize return 0; } - temp_f0_4 = (tile->height * x1) + (tile->gravity * y1) + (tile->rotation * z1) + tile->height2; + temp_f0_4 = (triangle->height * x1) + (triangle->gravity * y1) + (triangle->rotation * z1) + triangle->height2; if (temp_f0_4 > boundingBoxSize) { if (collision->unk3C[2] > temp_f0_4) { collision->unk34 = 1; collision->unk3A = index; collision->unk3C[2] = temp_f0_4 - boundingBoxSize; - collision->orientationVector[0] = tile->height; - collision->orientationVector[1] = tile->gravity; - collision->orientationVector[2] = tile->rotation; + collision->orientationVector[0] = triangle->height; + collision->orientationVector[1] = triangle->gravity; + collision->orientationVector[2] = triangle->rotation; } return 0; } - temp = (tile->height * posX) + (tile->gravity * posY) + (tile->rotation * posZ) + tile->height2; + temp = (triangle->height * posX) + (triangle->gravity * posY) + (triangle->rotation * posZ) + triangle->height2; if (temp < 0.0f) { return 0; @@ -863,9 +863,9 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize collision->unk34 = 1; collision->unk3A = index; collision->unk3C[2] = temp_f0_4 - boundingBoxSize; - collision->orientationVector[0] = tile->height; - collision->orientationVector[1] = tile->gravity; - collision->orientationVector[2] = tile->rotation; + collision->orientationVector[0] = triangle->height; + collision->orientationVector[1] = triangle->gravity; + collision->orientationVector[2] = triangle->rotation; return 1; } @@ -873,7 +873,7 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize * Wall collision */ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 arg5, f32 arg6, f32 arg7, f32 arg8) { - mk64_surface_map_ram *tile = &gSurfaceMap[arg5]; + CollisionTriangle *triangle = &gCollisionMesh[arg5]; UNUSED s32 pad[6]; f32 x4; f32 y4; @@ -889,33 +889,33 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 area2; f32 area3; s32 bool = 1; - if (tile->vtx31 > x1) { + if (triangle->minX > x1) { return 0; } - if (tile->vtx21 < x1) { + if (triangle->maxX < x1) { return 0; } - if (tile->vtx22 < y1) { + if (triangle->maxY < y1) { return 0; } - if (tile->vtx32 > y1) { + if (triangle->minY > y1) { return 0; } - if ((tile->vtx33 - boundingBoxSize * 3.0f) > z1) { + if ((triangle->minZ - boundingBoxSize * 3.0f) > z1) { return 0; } - if ((tile->vtx23 + boundingBoxSize * 3.0f) < z1) { + if ((triangle->maxZ + boundingBoxSize * 3.0f) < z1) { return 0; } - x2 = (f32) tile->vtxPoly1->v.ob[0]; - y2 = (f32) tile->vtxPoly1->v.ob[1]; + x2 = (f32) triangle->vtx1->v.ob[0]; + y2 = (f32) triangle->vtx1->v.ob[1]; - x3 = (f32) tile->vtxPoly2->v.ob[0]; - y3 = (f32) tile->vtxPoly2->v.ob[1]; + x3 = (f32) triangle->vtx2->v.ob[0]; + y3 = (f32) triangle->vtx2->v.ob[1]; - x4 = (f32) tile->vtxPoly3->v.ob[0]; - y4 = (f32) tile->vtxPoly3->v.ob[1]; + x4 = (f32) triangle->vtx3->v.ob[0]; + y4 = (f32) triangle->vtx3->v.ob[1]; area = (y2 - y1) * (x3 - x1) - (x2 - x1) * (y3 - y1); @@ -956,18 +956,18 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, return 0; } - temp_f0_4 = ((tile->height * x1) + (tile->gravity * y1) + (tile->rotation * z1)) + tile->height2; - if (tile->flags & 0x200) { - temp_f4_2 = ((tile->height * arg6) + (tile->gravity * arg7) + (tile->rotation * arg8)) + tile->height2; + temp_f0_4 = ((triangle->height * x1) + (triangle->gravity * y1) + (triangle->rotation * z1)) + triangle->height2; + 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) { arg->unk30 = 1; arg->unk36 = arg5; arg->unk3C[0] = temp_f0_4 - boundingBoxSize; - arg->unk48[0] = tile->height; - arg->unk48[1] = tile->gravity; - arg->unk48[2] = tile->rotation; + arg->unk48[0] = triangle->height; + arg->unk48[1] = triangle->gravity; + arg->unk48[2] = triangle->rotation; return 1; } return 0; @@ -979,9 +979,9 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, arg->unk30 = 1; arg->unk36 = arg5; arg->unk3C[0] = temp_f0_4 - boundingBoxSize; - arg->unk48[0] = -tile->height; - arg->unk48[1] = -tile->gravity; - arg->unk48[2] = -tile->rotation; + arg->unk48[0] = -triangle->height; + arg->unk48[1] = -triangle->gravity; + arg->unk48[2] = -triangle->rotation; return 1; } return 0; @@ -990,18 +990,18 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, arg->unk30 = 1; arg->unk36 = arg5; arg->unk3C[0] = -(temp_f0_4 + boundingBoxSize); - arg->unk48[0] = -tile->height; - arg->unk48[1] = -tile->gravity; - arg->unk48[2] = -tile->rotation; + arg->unk48[0] = -triangle->height; + arg->unk48[1] = -triangle->gravity; + arg->unk48[2] = -triangle->rotation; return 1; } if ((temp_f0_4 < 0.0f) && (temp_f4_2 > 0.0f)) { arg->unk30 = 1; arg->unk36 = arg5; arg->unk3C[0] = temp_f0_4 + boundingBoxSize; - arg->unk48[0] = tile->height; - arg->unk48[1] = tile->gravity; - arg->unk48[2] = tile->rotation; + arg->unk48[0] = triangle->height; + arg->unk48[1] = triangle->gravity; + arg->unk48[2] = triangle->rotation; return 1; } if (temp_f0_4 == 0.0f) { @@ -1009,17 +1009,17 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, arg->unk30 = 1; arg->unk36 = arg5; arg->unk3C[0] = temp_f4_2 + boundingBoxSize; - arg->unk48[0] = tile->height; - arg->unk48[1] = tile->gravity; - arg->unk48[2] = tile->rotation; + arg->unk48[0] = triangle->height; + arg->unk48[1] = triangle->gravity; + arg->unk48[2] = triangle->rotation; return 1; } arg->unk30 = 1; arg->unk36 = arg5; arg->unk3C[0] = -(temp_f4_2 + boundingBoxSize); - arg->unk48[0] = tile->height; - arg->unk48[1] = tile->gravity; - arg->unk48[2] = tile->rotation; + arg->unk48[0] = triangle->height; + arg->unk48[1] = triangle->gravity; + arg->unk48[2] = triangle->rotation; return 1; } return 0; @@ -1029,23 +1029,23 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, arg->unk30 = 1; arg->unk36 = arg5; arg->unk3C[0] = temp_f0_4 - boundingBoxSize; - arg->unk48[0] = tile->height; - arg->unk48[1] = tile->gravity; - arg->unk48[2] = tile->rotation; + arg->unk48[0] = triangle->height; + arg->unk48[1] = triangle->gravity; + arg->unk48[2] = triangle->rotation; } return 0; } - temp_f4_2 = (tile->height * arg6) + (tile->gravity * arg7) + (tile->rotation * arg8) + tile->height2; + temp_f4_2 = (triangle->height * arg6) + (triangle->gravity * arg7) + (triangle->rotation * arg8) + triangle->height2; if (temp_f4_2 < 0.0f) { return 0; } arg->unk30 = 1; arg->unk36 = arg5; arg->unk3C[0] = temp_f0_4 - boundingBoxSize; - arg->unk48[0] = tile->height; - arg->unk48[1] = tile->gravity; - arg->unk48[2] = tile->rotation; + arg->unk48[0] = triangle->height; + arg->unk48[1] = triangle->gravity; + arg->unk48[2] = triangle->rotation; return 1; } @@ -1053,7 +1053,7 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, * This is actually more like colliding with face X/Y/Z */ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 arg5, f32 arg6, f32 arg7, f32 arg8) { - mk64_surface_map_ram *tile = &gSurfaceMap[arg5]; + CollisionTriangle *triangle = &gCollisionMesh[arg5]; s32 bool = 1; UNUSED s32 pad[7]; f32 y4; @@ -1070,33 +1070,33 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 area2; f32 area3; - if (tile->vtx33 > z1) { + if (triangle->minZ > z1) { return 0; } - if (tile->vtx23 < z1) { + if (triangle->maxZ < z1) { return 0; } - if (tile->vtx22 < y1) { + if (triangle->maxY < y1) { return 0; } - if (tile->vtx32 > y1) { + if (triangle->minY > y1) { return 0; } - if ((tile->vtx31 - boundingBoxSize * 3.0f) > x1) { + if ((triangle->minX - boundingBoxSize * 3.0f) > x1) { return 0; } - if ((tile->vtx21 + boundingBoxSize * 3.0f) < x1) { + if ((triangle->maxX + boundingBoxSize * 3.0f) < x1) { return 0; } - z2 = (f32) tile->vtxPoly1->v.ob[2]; - y2 = (f32) tile->vtxPoly1->v.ob[1]; + z2 = (f32) triangle->vtx1->v.ob[2]; + y2 = (f32) triangle->vtx1->v.ob[1]; - z3 = (f32) tile->vtxPoly2->v.ob[2]; - y3 = (f32) tile->vtxPoly2->v.ob[1]; + z3 = (f32) triangle->vtx2->v.ob[2]; + y3 = (f32) triangle->vtx2->v.ob[1]; - z4 = (f32) tile->vtxPoly3->v.ob[2]; - y4 = (f32) tile->vtxPoly3->v.ob[1]; + z4 = (f32) triangle->vtx3->v.ob[2]; + y4 = (f32) triangle->vtx3->v.ob[1]; area = (y2 - y1) * (z3 - z1) - (z2 - z1) * (y3 - y1); @@ -1137,18 +1137,18 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, return 0; } - temp_f0_4 = ((tile->height * x1) + (tile->gravity * y1) + (tile->rotation * z1)) + tile->height2; - if (tile->flags & 0x200) { - temp_f4_2 = ((tile->height * arg6) + (tile->gravity * arg7) + (tile->rotation * arg8)) + tile->height2; + temp_f0_4 = ((triangle->height * x1) + (triangle->gravity * y1) + (triangle->rotation * z1)) + triangle->height2; + 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) { arg->unk32 = 1; arg->unk38 = arg5; arg->unk3C[1] = temp_f0_4 - boundingBoxSize; - arg->unk54[0] = tile->height; - arg->unk54[1] = tile->gravity; - arg->unk54[2] = tile->rotation; + arg->unk54[0] = triangle->height; + arg->unk54[1] = triangle->gravity; + arg->unk54[2] = triangle->rotation; return 1; } return 0; @@ -1160,9 +1160,9 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, arg->unk32 = 1; arg->unk38 = arg5; arg->unk3C[1] = temp_f0_4 - boundingBoxSize; - arg->unk54[0] = -tile->height; - arg->unk54[1] = -tile->gravity; - arg->unk54[2] = -tile->rotation; + arg->unk54[0] = -triangle->height; + arg->unk54[1] = -triangle->gravity; + arg->unk54[2] = -triangle->rotation; return 1; } return 0; @@ -1171,18 +1171,18 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, arg->unk32 = 1; arg->unk38 = arg5; arg->unk3C[1] = -(temp_f0_4 + boundingBoxSize); - arg->unk54[0] = -tile->height; - arg->unk54[1] = -tile->gravity; - arg->unk54[2] = -tile->rotation; + arg->unk54[0] = -triangle->height; + arg->unk54[1] = -triangle->gravity; + arg->unk54[2] = -triangle->rotation; return 1; } if ((temp_f0_4 < 0.0f) && (temp_f4_2 > 0.0f)) { arg->unk32 = 1; arg->unk38 = arg5; arg->unk3C[1] = temp_f0_4 + boundingBoxSize; - arg->unk54[0] = tile->height; - arg->unk54[1] = tile->gravity; - arg->unk54[2] = tile->rotation; + arg->unk54[0] = triangle->height; + arg->unk54[1] = triangle->gravity; + arg->unk54[2] = triangle->rotation; return 1; } if (temp_f0_4 == 0.0f) { @@ -1190,17 +1190,17 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, arg->unk32 = 1; arg->unk38 = arg5; arg->unk3C[1] = temp_f4_2 + boundingBoxSize; - arg->unk54[0] = tile->height; - arg->unk54[1] = tile->gravity; - arg->unk54[2] = tile->rotation; + arg->unk54[0] = triangle->height; + arg->unk54[1] = triangle->gravity; + arg->unk54[2] = triangle->rotation; return 1; } arg->unk32 = 1; arg->unk38 = arg5; arg->unk3C[1] = -(temp_f4_2 + boundingBoxSize); - arg->unk54[0] = tile->height; - arg->unk54[1] = tile->gravity; - arg->unk54[2] = tile->rotation; + arg->unk54[0] = triangle->height; + arg->unk54[1] = triangle->gravity; + arg->unk54[2] = triangle->rotation; return 1; } return 0; @@ -1210,23 +1210,23 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, arg->unk32 = 1; arg->unk38 = arg5; arg->unk3C[1] = temp_f0_4 - boundingBoxSize; - arg->unk54[0] = tile->height; - arg->unk54[1] = tile->gravity; - arg->unk54[2] = tile->rotation; + arg->unk54[0] = triangle->height; + arg->unk54[1] = triangle->gravity; + arg->unk54[2] = triangle->rotation; } return 0; } - temp_f4_2 = (tile->height * arg6) + (tile->gravity * arg7) + (tile->rotation * arg8) + tile->height2; + temp_f4_2 = (triangle->height * arg6) + (triangle->gravity * arg7) + (triangle->rotation * arg8) + triangle->height2; if (temp_f4_2 < 0.0f) { return 0; } arg->unk32 = 1; arg->unk38 = arg5; arg->unk3C[1] = temp_f0_4 - boundingBoxSize; - arg->unk54[0] = tile->height; - arg->unk54[1] = tile->gravity; - arg->unk54[2] = tile->rotation; + arg->unk54[0] = triangle->height; + arg->unk54[1] = triangle->gravity; + arg->unk54[2] = triangle->rotation; return 1; } @@ -1256,19 +1256,19 @@ u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 collision->unk3C[1] = 1000.0f; collision->unk3C[2] = 1000.0f; - if ((s32) collision->unk3A < (s32) D_8015F588) { + 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; } } - if ((s32) collision->unk36 < (s32) D_8015F588) { + 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->unk38 < (s32) D_8015F588) { + if ((s32) collision->unk38 < (s32) gCollisionMeshCount) { if (is_colliding_with_wall1(collision, boundingBoxSize, x1, y1, z1, collision->unk38, x2, y2, z2) == 1) { flags |= 0x8000; } @@ -1317,7 +1317,7 @@ u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 surfaceIndex = D_8015F584[phi_s2]; - if ((gSurfaceMap[surfaceIndex].flags & 0x4000)) { + 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) { @@ -1325,7 +1325,7 @@ u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 } } } - } else if ((gSurfaceMap[surfaceIndex].flags & 0x8000) != 0) { + } 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) { @@ -1368,17 +1368,17 @@ u16 func_802ADDC8(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, collision->unk3C[1] = 1000.0f; collision->unk3C[2] = 1000.0f; var_s4 = 0; - if (collision->unk3A < D_8015F588) { + if (collision->unk3A < gCollisionMeshCount) { if (func_802AAE4C(collision, boundingBoxSize, posX, posY, posZ, collision->unk3A) == 1) { var_s4 |= 0x4000; } } - if (collision->unk36 < D_8015F588) { + if (collision->unk36 < gCollisionMeshCount) { if (func_802AB288(collision, boundingBoxSize, posX, posY, posZ, collision->unk36) == 1) { var_s4 |= 0x2000; } } - if (collision->unk38 < D_8015F588) { + if (collision->unk38 < gCollisionMeshCount) { if (func_802AB6C4(collision, boundingBoxSize, posX, posY, posZ, collision->unk38 ) == 1) { var_s4 |= 0x8000; } @@ -1422,7 +1422,7 @@ u16 func_802ADDC8(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, return var_s4; } temp_v0_4 = D_8015F584[var_s2]; - if (gSurfaceMap[temp_v0_4].flags & 0x4000) { + 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) { @@ -1430,7 +1430,7 @@ u16 func_802ADDC8(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, } } } - } else if (gSurfaceMap[temp_v0_4].flags & 0x8000) { + } 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) { @@ -1503,7 +1503,7 @@ f32 func_802AE1C0(f32 posX, f32 posY, f32 posZ) { index = D_8015F584[phi_s1]; - if ((gSurfaceMap[index].flags & 0x4000) && (func_802ABB04(posX, posZ, index) == 1)) { + 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; @@ -1536,18 +1536,18 @@ f32 func_802AE1C0(f32 posX, f32 posY, f32 posZ) { } else\ out = c;\ -void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionId) { - mk64_surface_map_ram *tile = &gSurfaceMap[D_8015F588]; +void set_collision_triangle(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionId) { + CollisionTriangle *triangle = &gCollisionMesh[gCollisionMeshCount]; s16 x2; s16 z2; - u16 poly1Flag; + u16 vtx1Flag; s16 x3; s16 x1; s16 y1; s16 z1; - u16 poly2Flag; + u16 vtx2Flag; s16 y2; - u16 poly3Flag; + u16 vtx3Flag; u16 flags; s16 y3; s16 z3; @@ -1574,38 +1574,38 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI s16 maxY; s16 minZ; - tile->vtxPoly1 = vtx1; - tile->vtxPoly2 = vtx2; - tile->vtxPoly3 = vtx3; - if ((tile->vtxPoly1->v.flag == 4) && - (tile->vtxPoly2->v.flag == 4) && - (tile->vtxPoly3->v.flag == 4)) { + triangle->vtx1 = vtx1; + triangle->vtx2 = vtx2; + triangle->vtx3 = vtx3; + if ((triangle->vtx1->v.flag == 4) && + (triangle->vtx2->v.flag == 4) && + (triangle->vtx3->v.flag == 4)) { return; } - x1 = tile->vtxPoly1->v.ob[0]; - y1 = tile->vtxPoly1->v.ob[1]; - z1 = tile->vtxPoly1->v.ob[2]; - x2 = tile->vtxPoly2->v.ob[0]; - y2 = tile->vtxPoly2->v.ob[1]; - z2 = tile->vtxPoly2->v.ob[2]; - x3 = tile->vtxPoly3->v.ob[0]; - y3 = tile->vtxPoly3->v.ob[1]; - z3 = tile->vtxPoly3->v.ob[2]; + x1 = triangle->vtx1->v.ob[0]; + y1 = triangle->vtx1->v.ob[1]; + z1 = triangle->vtx1->v.ob[2]; + x2 = triangle->vtx2->v.ob[0]; + y2 = triangle->vtx2->v.ob[1]; + z2 = triangle->vtx2->v.ob[2]; + x3 = triangle->vtx3->v.ob[0]; + y3 = triangle->vtx3->v.ob[1]; + z3 = triangle->vtx3->v.ob[2]; if ((x1 == x2) && (z1 == z2)) { - tile->vtxPoly1 = vtx1; - tile->vtxPoly3 = vtx2; - tile->vtxPoly2 = vtx3; - x1 = tile->vtxPoly1->v.ob[0]; - y1 = tile->vtxPoly1->v.ob[1]; - z1 = tile->vtxPoly1->v.ob[2]; - x2 = tile->vtxPoly3->v.ob[0]; - y2 = tile->vtxPoly3->v.ob[1]; - z2 = tile->vtxPoly3->v.ob[2]; - x3 = tile->vtxPoly2->v.ob[0]; - y3 = tile->vtxPoly2->v.ob[1]; - z3 = tile->vtxPoly2->v.ob[2]; + triangle->vtx1 = vtx1; + triangle->vtx3 = vtx2; + triangle->vtx2 = vtx3; + x1 = triangle->vtx1->v.ob[0]; + y1 = triangle->vtx1->v.ob[1]; + z1 = triangle->vtx1->v.ob[2]; + x2 = triangle->vtx3->v.ob[0]; + y2 = triangle->vtx3->v.ob[1]; + z2 = triangle->vtx3->v.ob[2]; + x3 = triangle->vtx2->v.ob[0]; + y3 = triangle->vtx2->v.ob[1]; + z3 = triangle->vtx2->v.ob[2]; } MAX3(x1, x2, x3, maxX) @@ -1655,13 +1655,14 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI } } - tile->vtx21 = maxX; - tile->vtx23 = maxZ; - tile->vtx31 = minX; - tile->vtx33 = minZ; - tile->vtx32 = minY; - tile->vtx22 = maxY; + triangle->maxX = maxX; + triangle->maxZ = maxZ; + triangle->minX = minX; + triangle->minZ = minZ; + triangle->minY = minY; + triangle->maxY = maxY; + // Define the minimum and maximum dimensions of the course. if (minX < gCourseMinX) { gCourseMinX = minX; } @@ -1681,12 +1682,12 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI gCourseMaxZ = maxZ; } - tile->height = normalX; - tile->gravity = normalY; - tile->rotation = normalZ; - tile->height2 = distance; + triangle->height = normalX; + triangle->gravity = normalY; + triangle->rotation = normalZ; + triangle->height2 = distance; - tile->surfaceType = (u16) surfaceType; + triangle->surfaceType = (u16) surfaceType; crossProductX = crossProductX * crossProductX; crossProductY = crossProductY * crossProductY; @@ -1695,35 +1696,35 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI D_8015F6FA = 0; D_8015F6FC = 0; - poly1Flag = tile->vtxPoly1->v.flag; - poly2Flag = tile->vtxPoly2->v.flag; - poly3Flag = tile->vtxPoly3->v.flag; + vtx1Flag = triangle->vtx1->v.flag; + vtx2Flag = triangle->vtx2->v.flag; + vtx3Flag = triangle->vtx3->v.flag; flags = sectionId; - if ((poly1Flag == 1) && (poly2Flag == 1) && (poly3Flag == 1)) { + if ((vtx1Flag == 1) && (vtx2Flag == 1) && (vtx3Flag == 1)) { flags |= 0x400; - } else if ((poly1Flag == 2) && (poly2Flag == 2) && (poly3Flag == 2)) { + } else if ((vtx1Flag == 2) && (vtx2Flag == 2) && (vtx3Flag == 2)) { flags |= 0x800; - } else if ((poly1Flag == 3) && (poly2Flag == 3) && (poly3Flag == 3)) { + } else if ((vtx1Flag == 3) && (vtx2Flag == 3) && (vtx3Flag == 3)) { flags |= 0x1000; } else if (D_8015F5A4 != 0) { flags |= 0x200; } - tile->flags = flags; + triangle->flags = flags; // Y is the significant axis if ((crossProductX <= crossProductY) && (crossProductY >= crossProductZ)) { - tile->flags |= 0x4000; + triangle->flags |= 0x4000; // X is the significant axis } else if ((crossProductX > crossProductY) && (crossProductX >= crossProductZ)) { - tile->flags |= 0x8000; + triangle->flags |= 0x8000; // Z is the significant axis } else { - tile->flags |= 0x2000; + triangle->flags |= 0x2000; } - D_8015F588++; + gCollisionMeshCount++; } /** @@ -1738,7 +1739,7 @@ void set_vtx_from_triangle(u32 triangle, s8 surfaceType, u16 sectionId) { Vtx *vtx2 = vtxBuffer[vert2]; Vtx *vtx3 = vtxBuffer[vert3]; - func_802AE434(vtx1, vtx2, vtx3, surfaceType, sectionId); + set_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); } void set_vtx_from_tri2(u32 triangle1, u32 triangle2, s8 surfaceType, u16 sectionId) { @@ -1761,9 +1762,9 @@ void set_vtx_from_tri2(u32 triangle1, u32 triangle2, s8 surfaceType, u16 section Vtx *vtx6 = vtxBuffer[vert6]; // Triangle 1 - func_802AE434(vtx1, vtx2, vtx3, surfaceType, sectionId); + set_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); // Triangle 2 - func_802AE434(vtx4, vtx5, vtx6, surfaceType, sectionId); + set_collision_triangle(vtx4, vtx5, vtx6, surfaceType, sectionId); } void set_vtx_from_quadrangle(u32 line, s8 surfaceType, u16 sectionId) { @@ -1784,9 +1785,9 @@ void set_vtx_from_quadrangle(u32 line, s8 surfaceType, u16 sectionId) { vtx4 = vtxBuffer[vert4]; // Triangle 1 - func_802AE434(vtx1, vtx2, vtx3, surfaceType, sectionId); + set_collision_triangle(vtx1, vtx2, vtx3, surfaceType, sectionId); // Triangle 2 - func_802AE434(vtx1, vtx3, vtx4, surfaceType, sectionId); + set_collision_triangle(vtx1, vtx3, vtx4, surfaceType, sectionId); } /** @@ -1867,7 +1868,7 @@ s32 is_line_intersecting_rectangle(s16 minX, s16 maxX, s16 minZ, s16 maxZ, s16 x } s32 is_triangle_intersecting_bounding_box(s16 minX, s16 maxX, s16 minZ, s16 maxZ, u16 index) { - mk64_surface_map_ram *surfaceMap = &gSurfaceMap[index]; + CollisionTriangle *triangle = &gCollisionMesh[index]; s16 x1; s16 z1; s16 x2; @@ -1875,12 +1876,12 @@ s32 is_triangle_intersecting_bounding_box(s16 minX, s16 maxX, s16 minZ, s16 maxZ s16 x3; s16 z3; - x1 = surfaceMap->vtxPoly1->v.ob[0]; - z1 = surfaceMap->vtxPoly1->v.ob[2]; - x2 = surfaceMap->vtxPoly2->v.ob[0]; - z2 = surfaceMap->vtxPoly2->v.ob[2]; - x3 = surfaceMap->vtxPoly3->v.ob[0]; - z3 = surfaceMap->vtxPoly3->v.ob[2]; + x1 = triangle->vtx1->v.ob[0]; + z1 = triangle->vtx1->v.ob[2]; + x2 = triangle->vtx2->v.ob[0]; + z2 = triangle->vtx2->v.ob[2]; + x3 = triangle->vtx3->v.ob[0]; + z3 = triangle->vtx3->v.ob[2]; if ((x1 >= minX) && (maxX >= x1) && (z1 >= minZ) && (maxZ >= z1)) { return 1; } @@ -1907,7 +1908,7 @@ s32 is_triangle_intersecting_bounding_box(s16 minX, s16 maxX, s16 minZ, s16 maxZ * course displaylists have been parsed. */ void func_802AF314(void) { - mk64_surface_map_ram *tile; + CollisionTriangle *triangle; s32 i, j, k; UNUSED s32 pad[5]; s16 temp_a1; @@ -1948,12 +1949,12 @@ void func_802AF314(void) { temp_a1 = temp_s1 + temp_s6 + 40; temp_a3 = temp_s2 + temp_fp + 40; - for (i = 0; i < D_8015F588; i++) { - tile = gSurfaceMap + i; - if (tile->vtx23 < temp_s2) { continue; } - if (tile->vtx33 > temp_a3) { continue; } - if (tile->vtx21 < temp_s1) { continue; } - if (tile->vtx31 > temp_a1) { continue; } + for (i = 0; i < gCollisionMeshCount; i++) { + triangle = gCollisionMesh + i; + if (triangle->maxZ < temp_s2) { continue; } + if (triangle->minZ > temp_a3) { continue; } + if (triangle->maxX < temp_s1) { continue; } + if (triangle->minX > temp_a1) { continue; } if (is_triangle_intersecting_bounding_box(temp_s1, temp_a1, temp_s2, temp_a3, (u16) i) == 1) { if (D_8014F110[index].unk2 == 0) { @@ -1972,23 +1973,23 @@ void func_802AF314(void) { /** * Recursive search for vtx and set surfaceTypes to -1 and sectionId's to 0xFF */ -void set_vertex_data_with_defaults(Gfx *gfx) { - find_and_set_vertex_data(gfx, SURFACE_DEFAULT, 0xFF); +void generate_collision_mesh_with_defaults(Gfx *gfx) { + generate_collision_mesh(gfx, SURFACE_DEFAULT, 0xFF); } /** * Recursive search for vtx and set sectionId's to 0xFF */ -void set_vertex_data_with_default_section_id(Gfx *gfx, s8 surfaceType) { - find_and_set_vertex_data(gfx, surfaceType, 0xFF); +void generate_collision_mesh_with_default_section_id(Gfx *gfx, s8 surfaceType) { + generate_collision_mesh(gfx, surfaceType, 0xFF); } extern u32 D_8015F58C; /** - * Recursive search and set for vertex data + * Generate via a recursive search and set for vertex data. */ -void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) { +void generate_collision_mesh(Gfx *addr, s8 surfaceType, u16 sectionId) { s32 opcode; uintptr_t lo; uintptr_t hi; @@ -2007,7 +2008,7 @@ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) { if (opcode == (G_DL << 24)) { // G_DL's hi contains an addr to another DL. - find_and_set_vertex_data((Gfx *) hi, surfaceType, sectionId); + generate_collision_mesh((Gfx *) hi, surfaceType, sectionId); } else if (opcode == (G_VTX << 24)) { set_vtx_buffer(hi, (lo >> 10) & 0x3F, ((lo >> 16) & 0xFF) >> 1); @@ -2114,7 +2115,7 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP Collision *collision = &wtf; UNUSED s32 pad; u16 i; - u16 surfaceMapIndex; + u16 collisionMeshIndex; u16 iter; u16 phi_s2; f32 cornerPos1; @@ -2149,8 +2150,8 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP cornerPos3 = corner->cornerPos[2]; switch (corner->surfaceFlags) { case 0x80: - if (is_colliding_with_wall1(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, corner->surfaceMapIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, corner->surfaceMapIndex); + 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); @@ -2159,8 +2160,8 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP } break; case 0x40: - if (is_colliding_with_drivable_surface(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, corner->surfaceMapIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, corner->surfaceMapIndex); + 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); @@ -2169,8 +2170,8 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP } break; case 0x20: - if (is_colliding_with_wall2(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, corner->surfaceMapIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, corner->surfaceMapIndex); + 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); @@ -2208,19 +2209,19 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP phi_s2 = D_8014F110[temp_v1_2].unk0; for (i = 0; i < iter; i++) { - surfaceMapIndex = D_8015F584[phi_s2]; - if (gSurfaceMap[surfaceMapIndex].flags & 0x4000) { - if (surfaceMapIndex != corner->surfaceMapIndex) { - if (is_colliding_with_drivable_surface(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, surfaceMapIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, surfaceMapIndex); + 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); 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) gSurfaceMap[surfaceMapIndex].surfaceType; + corner->surfaceType = (u8) gCollisionMesh[collisionMeshIndex].surfaceType; corner->surfaceFlags = 0x40; - corner->surfaceMapIndex = surfaceMapIndex; - if (gSurfaceMap[surfaceMapIndex].flags & 0x1000) { + corner->collisionMeshIndex = collisionMeshIndex; + if (gCollisionMesh[collisionMeshIndex].flags & 0x1000) { corner->unk_14 = 1; } else { corner->unk_14 = 0; @@ -2229,34 +2230,34 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP } } } - } else if (gSurfaceMap[surfaceMapIndex].flags & 0x8000) { - if (gSurfaceMap[surfaceMapIndex].gravity != 0.0f) { - if (surfaceMapIndex != corner->surfaceMapIndex) { - if (is_colliding_with_wall1(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, surfaceMapIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, surfaceMapIndex); + } 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, surfaceMapIndex); - corner->surfaceType = (u8) gSurfaceMap[surfaceMapIndex].surfaceType; + corner->cornerGroundY = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, collisionMeshIndex); + corner->surfaceType = (u8) gCollisionMesh[collisionMeshIndex].surfaceType; corner->surfaceFlags = 0x80; - corner->surfaceMapIndex = surfaceMapIndex; + corner->collisionMeshIndex = collisionMeshIndex; return 1; } } } } } else { - if (gSurfaceMap[surfaceMapIndex].gravity != 0.0f) { - if (surfaceMapIndex != corner->surfaceMapIndex) { - if (is_colliding_with_wall2(collision, boundingBoxSize, cornerPos1, cornerPos2, cornerPos3, surfaceMapIndex, cornerPosX, cornerPosY, cornerPosZ) == 1) { - temp_f0 = func_802ABE30(cornerPos1, cornerPos2, cornerPos3, surfaceMapIndex); + 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) gSurfaceMap[surfaceMapIndex].surfaceType; + corner->surfaceType = (u8) gCollisionMesh[collisionMeshIndex].surfaceType; corner->surfaceFlags = 0x20; - corner->surfaceMapIndex = surfaceMapIndex; + corner->collisionMeshIndex = collisionMeshIndex; return 1; } } diff --git a/src/racing/collision.h b/src/racing/collision.h index 4391e9660..4ae6d0ad9 100644 --- a/src/racing/collision.h +++ b/src/racing/collision.h @@ -31,9 +31,9 @@ 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 set_vertex_data_with_defaults(Gfx*); -void set_vertex_data_with_default_section_id(Gfx*, s8); -void find_and_set_vertex_data(Gfx*, s8, u16); +void generate_collision_mesh_with_defaults(Gfx*); +void generate_collision_mesh_with_default_section_id(Gfx*, s8); +void generate_collision_mesh(Gfx*, s8, u16); void find_and_set_tile_size(uintptr_t, s32, s32); void set_vertex_colours(u32, u32, s32, s8, u8, u8, u8); void find_vtx_and_set_colours(uintptr_t, s8, u8, u8, u8); diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index 8bb715a79..13375489f 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -64,14 +64,14 @@ void parse_course_displaylists(uintptr_t addr) { } else { D_8015F5A4 = 0; } - find_and_set_vertex_data(section->addr, section->surfaceType, section->sectionId); + generate_collision_mesh(section->addr, section->surfaceType, section->sectionId); section++; } } extern u32 isFlycam; -void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { +void render_course_segments(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { Player *player = arg1->player; Camera *camera = arg1->camera; u32 segment = SEGMENT_NUMBER2(addr); @@ -79,7 +79,7 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { //! @todo Should be Gfx* s32 *gfx = (s32 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); s16 var_a3; - s16 temp_v1; + s16 index; s16 sp1E; s16 temp_v0_3; u16 rot; @@ -118,70 +118,70 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { if (D_80152300[camera - camera1] == 1) { sp1E = func_802ABD40(camera->unk_54.unk3A); temp_v0_3 = func_802ABD40(player->unk_110.unk3A); - temp_v1 = sp1E - temp_v0_3; - if ((temp_v1 < 2) && (temp_v1 >= -1)) { + index = sp1E - temp_v0_3; + if ((index < 2) && (index >= -1)) { if (sp1E == 255) { if (temp_v0_3 == 255) { - temp_v1 = arg1->pathCounter; + index = arg1->pathCounter; } else if (player->unk_110.unk3C[2] > 30.0f) { - temp_v1 = arg1->pathCounter; + index = arg1->pathCounter; } else { - temp_v1 = temp_v0_3; + index = temp_v0_3; } } else if (camera->unk_54.unk3C[2] > 30.0f) { - temp_v1 = arg1->pathCounter; + index = arg1->pathCounter; } else { - temp_v1 = sp1E; + index = sp1E; } } else { switch(gCurrentCourseId) { case COURSE_BOWSER_CASTLE: if ((temp_v0_3 >= 0x11) && (temp_v0_3 < 0x18)) { - temp_v1 = temp_v0_3; + index = temp_v0_3; } else if ((temp_v0_3 == 255) && (sp1E != 255)) { - temp_v1 = sp1E; + index = sp1E; } else if ((temp_v0_3 != 255) && (sp1E == 255)) { - temp_v1 = temp_v0_3; + index = temp_v0_3; } else { - temp_v1 = arg1->pathCounter; + index = arg1->pathCounter; } break; case COURSE_CHOCO_MOUNTAIN: if ((temp_v0_3 >= 0xE) && (temp_v0_3 < 0x16)) { - temp_v1 = temp_v0_3; + index = temp_v0_3; } else if ((temp_v0_3 == 255) && (sp1E != 255)) { - temp_v1 = sp1E; + index = sp1E; } else if ((temp_v0_3 != 255) && (sp1E == 255)) { - temp_v1 = temp_v0_3; + index = temp_v0_3; } else { - temp_v1 = arg1->pathCounter; + index = arg1->pathCounter; } break; default: if (temp_v0_3 == 255) { - temp_v1 = arg1->pathCounter; + index = arg1->pathCounter; } else if (player->unk_110.unk3C[2] > 30.0f) { - temp_v1 = arg1->pathCounter; + index = arg1->pathCounter; } else { - temp_v1 = temp_v0_3; + index = temp_v0_3; } break; } } } else { - temp_v1 = func_802ABD40(camera->unk_54.unk3A); + index = func_802ABD40(camera->unk_54.unk3A); if (camera->unk_54.unk3C[2] > 30.0f) { - temp_v1 = arg1->pathCounter; - } else if (temp_v1 == 255) { - temp_v1 = arg1->pathCounter; + index = arg1->pathCounter; + } else if (index == 255) { + index = arg1->pathCounter; } } - arg1->pathCounter = temp_v1; - temp_v1 = ((temp_v1 - 1) * 4) + var_a3; + arg1->pathCounter = index; + index = ((index - 1) * 4) + var_a3; - gSPDisplayList(gDisplayListHead++, gfx[temp_v1]); + gSPDisplayList(gDisplayListHead++, gfx[index]); } void func_80291198(void) { @@ -287,7 +287,7 @@ void func_8029122C(struct UnkStruct_800DC5EC *arg0, s32 playerId) { gDPSetBlendMask(gDisplayListHead++, 0xFF); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); - load_surface_map((uintptr_t)d_course_koopa_troopa_beach_dl_list2, arg0); + render_course_segments((uintptr_t)d_course_koopa_troopa_beach_dl_list2, arg0); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 1, 1, G_OFF); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); @@ -305,7 +305,7 @@ void func_8029122C(struct UnkStruct_800DC5EC *arg0, s32 playerId) { mtxf_identity(matrix); render_set_position(matrix, 0); - load_surface_map((uintptr_t) sherbet_land_dls_2, arg0); + render_course_segments((uintptr_t) sherbet_land_dls_2, arg0); gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); if ((func_80290C20(arg0->camera) == 1) && (func_802AAB4C(player) < player->pos[1])) { @@ -322,7 +322,7 @@ void func_8029122C(struct UnkStruct_800DC5EC *arg0, s32 playerId) { mtxf_identity(matrix); render_set_position(matrix, 0); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); - load_surface_map((uintptr_t) &d_course_rainbow_road_dl_list, arg0); + render_course_segments((uintptr_t) &d_course_rainbow_road_dl_list, arg0); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); gDPPipeSync(gDisplayListHead++); @@ -608,7 +608,7 @@ void render_mario_raceway(struct UnkStruct_800DC5EC *arg0) { // d_course_mario_raceway_packed_dl_14A0 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x070014A0)); - load_surface_map((uintptr_t) mario_raceway_dls, arg0); + render_course_segments((uintptr_t) mario_raceway_dls, arg0); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); @@ -655,7 +655,7 @@ void render_choco_mountain(struct UnkStruct_800DC5EC *arg0) { gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x07005868)); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); - load_surface_map((uintptr_t) choco_mountain_dls, arg0); + render_course_segments((uintptr_t) choco_mountain_dls, arg0); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetRenderMode(gDisplayListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); @@ -693,7 +693,7 @@ void render_bowsers_castle(struct UnkStruct_800DC5EC *arg0) { if (D_802B87BC > 255) { D_802B87BC = 0; } - load_surface_map((uintptr_t) bowsers_castle_dls, arg0); + render_course_segments((uintptr_t) bowsers_castle_dls, arg0); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); @@ -732,7 +732,7 @@ void render_banshee_boardwalk(struct UnkStruct_800DC5EC *arg0) { // d_course_banshee_boardwalk_packed_dl_69B0 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x070069B0)); - load_surface_map((uintptr_t) banshee_boardwalk_dls, arg0); + render_course_segments((uintptr_t) banshee_boardwalk_dls, arg0); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); @@ -766,7 +766,7 @@ void render_yoshi_valley(struct UnkStruct_800DC5EC *arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); - load_surface_map((uintptr_t) d_course_yoshi_valley_dl_list, arg0); + render_course_segments((uintptr_t) d_course_yoshi_valley_dl_list, arg0); gDPPipeSync(gDisplayListHead++); } @@ -785,7 +785,7 @@ void render_frappe_snowland(struct UnkStruct_800DC5EC *arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - load_surface_map((uintptr_t) d_course_frappe_snowland_dl_list, arg0); + render_course_segments((uintptr_t) d_course_frappe_snowland_dl_list, arg0); } void render_koopa_troopa_beach(struct UnkStruct_800DC5EC *arg0) { @@ -805,7 +805,7 @@ void render_koopa_troopa_beach(struct UnkStruct_800DC5EC *arg0) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_koopa_troopa_beach_packed_dl_9688 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x07009688)); - load_surface_map((uintptr_t) d_course_koopa_troopa_beach_dl_list1, arg0); + render_course_segments((uintptr_t) d_course_koopa_troopa_beach_dl_list1, arg0); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); @@ -833,7 +833,7 @@ void render_royal_raceway(struct UnkStruct_800DC5EC *arg0) { // d_course_royal_raceway_packed_dl_A648 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x0700A648)); - load_surface_map((uintptr_t) royal_raceway_dls, arg0); + render_course_segments((uintptr_t) royal_raceway_dls, arg0); // d_course_royal_raceway_packed_dl_11A8 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x070011A8)); @@ -865,7 +865,7 @@ void render_luigi_raceway(struct UnkStruct_800DC5EC *arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - load_surface_map((uintptr_t) luigi_raceway_dls, arg0); + render_course_segments((uintptr_t) luigi_raceway_dls, arg0); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); @@ -936,7 +936,7 @@ void render_moo_moo_farm(struct UnkStruct_800DC5EC *arg0) { gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x07005640)); gSPFogPosition(gDisplayListHead++, D_802B87B0, D_802B87B4); - load_surface_map((uintptr_t) moo_moo_farm_dls, arg0); + render_course_segments((uintptr_t) moo_moo_farm_dls, arg0); if ((temp_s0 < 14) && (temp_s0 > 10)) { if ((temp_s1 == 2) || (temp_s1 == 3) || (temp_s1 == 1)) @@ -1003,7 +1003,7 @@ void render_toads_turnpike(struct UnkStruct_800DC5EC *arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_PASS2); gDPSetRenderMode(gDisplayListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); - load_surface_map((uintptr_t) d_course_toads_turnpike_dl_list, arg0); + render_course_segments((uintptr_t) d_course_toads_turnpike_dl_list, arg0); gDPSetRenderMode(gDisplayListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); gDPSetCombineMode(gDisplayListHead++, G_CC_DECALRGBA, G_CC_PASS2); @@ -1034,7 +1034,7 @@ void render_kalimari_desert(struct UnkStruct_800DC5EC *arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - load_surface_map((uintptr_t) kalimari_desert_dls, arg0); + render_course_segments((uintptr_t) kalimari_desert_dls, arg0); // d_course_kalimari_desert_packed_dl_1ED8 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x07001ED8)); // d_course_kalimari_desert_packed_dl_1B18 @@ -1058,7 +1058,7 @@ void render_sherbet_land(struct UnkStruct_800DC5EC *arg0) { gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - load_surface_map((uintptr_t) sherbet_land_dls, arg0); + render_course_segments((uintptr_t) sherbet_land_dls, arg0); } void render_rainbow_road(UNUSED struct UnkStruct_800DC5EC *arg0) { @@ -1088,7 +1088,7 @@ void render_wario_stadium(struct UnkStruct_800DC5EC *arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATERGBA, G_CC_MODULATERGBA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - load_surface_map((uintptr_t) wario_stadium_dls, arg0); + render_course_segments((uintptr_t) wario_stadium_dls, arg0); // d_course_wario_stadium_packed_dl_A228 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x0700A228)); @@ -1201,7 +1201,7 @@ void render_dks_jungle_parkway(struct UnkStruct_800DC5EC *arg0) { gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); - load_surface_map((uintptr_t) d_course_dks_jungle_parkway_unknown_dl_list, arg0); + render_course_segments((uintptr_t) d_course_dks_jungle_parkway_unknown_dl_list, arg0); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); } @@ -1375,14 +1375,14 @@ void func_80295BF8(s32 playerIndex) { player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceFlags = 0; player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceMapIndex = 0x1388; - player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceMapIndex = 0x1388; - player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceMapIndex = 0x1388; - player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceMapIndex = 0x1388; + 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; } void func_80295C6C(void) { - gNextFreeMemoryAddress += ALIGN16(D_8015F588 * sizeof(mk64_surface_map_ram)); + gNextFreeMemoryAddress += ALIGN16(gCollisionMeshCount * sizeof(CollisionTriangle)); gCourseMaxX += 20; gCourseMaxZ += 20; gCourseMinX += -20; @@ -1417,20 +1417,20 @@ void func_80295D88(void) { D_8015F5A0 = 0; func_80295D6C(); D_8015F58C = 0; - D_8015F588 = 0; - gSurfaceMap = (mk64_surface_map_ram *) gNextFreeMemoryAddress; + gCollisionMeshCount = 0; + gCollisionMesh = (CollisionTriangle *) gNextFreeMemoryAddress; D_800DC5BC = 0; D_800DC5C8 = 0; switch (gCurrentCourseId) { case COURSE_MARIO_RACEWAY: // d_course_mario_raceway_packed_dl_1140 - set_vertex_data_with_defaults((Gfx *)0x07001140); + generate_collision_mesh_with_defaults((Gfx *)0x07001140); if (gScreenModeSelection == SCREEN_MODE_1P) { // d_course_mario_raceway_packed_dl_8E8 - set_vertex_data_with_defaults((Gfx *)0x070008E8); + generate_collision_mesh_with_defaults((Gfx *)0x070008E8); } else { // d_course_mario_raceway_packed_dl_2D68 - set_vertex_data_with_defaults((Gfx *)0x07002D68); + generate_collision_mesh_with_defaults((Gfx *)0x07002D68); } parse_course_displaylists((uintptr_t) d_course_mario_raceway_addr); func_80295C6C(); @@ -1585,22 +1585,22 @@ void func_80295D88(void) { break; case COURSE_BLOCK_FORT: // d_course_block_fort_packed_dl_15C0 - set_vertex_data_with_default_section_id((Gfx *)0x070015C0, 1); + generate_collision_mesh_with_default_section_id((Gfx *)0x070015C0, 1); func_80295C6C(); D_8015F8E4 = gCourseMinY - 10.0f; break; case COURSE_SKYSCRAPER: // d_course_skyscraper_packed_dl_1110 - set_vertex_data_with_default_section_id((Gfx *)0x07001110, 1); + generate_collision_mesh_with_default_section_id((Gfx *)0x07001110, 1); // d_course_skyscraper_packed_dl_258 - set_vertex_data_with_default_section_id((Gfx *)0x07000258, 1); + generate_collision_mesh_with_default_section_id((Gfx *)0x07000258, 1); func_80295C6C(); D_8015F8E4 = -480.0f; break; case COURSE_DOUBLE_DECK: // d_course_double_deck_packed_dl_738 - set_vertex_data_with_default_section_id((Gfx *)0x07000738, 1); + generate_collision_mesh_with_default_section_id((Gfx *)0x07000738, 1); func_80295C6C(); D_8015F8E4 = gCourseMinY - 10.0f; break; @@ -1613,15 +1613,15 @@ void func_80295D88(void) { break; case COURSE_BIG_DONUT: // d_course_big_donut_packed_dl_1018 - set_vertex_data_with_default_section_id((Gfx *)0x07001018, 6); + generate_collision_mesh_with_default_section_id((Gfx *)0x07001018, 6); // d_course_big_donut_packed_dl_450 - set_vertex_data_with_default_section_id((Gfx *)0x07000450, 6); + generate_collision_mesh_with_default_section_id((Gfx *)0x07000450, 6); // d_course_big_donut_packed_dl_AC0 - set_vertex_data_with_default_section_id((Gfx *)0x07000AC0, 6); + generate_collision_mesh_with_default_section_id((Gfx *)0x07000AC0, 6); // d_course_big_donut_packed_dl_B58 - set_vertex_data_with_default_section_id((Gfx *)0x07000B58, 6); + generate_collision_mesh_with_default_section_id((Gfx *)0x07000B58, 6); // d_course_big_donut_packed_dl_230 - set_vertex_data_with_default_section_id((Gfx *)0x07000230, 6); + generate_collision_mesh_with_default_section_id((Gfx *)0x07000230, 6); func_80295C6C(); D_8015F8E4 = 100.0f; break; diff --git a/src/racing/render_courses.h b/src/racing/render_courses.h index a41659f6c..d7b5efd80 100644 --- a/src/racing/render_courses.h +++ b/src/racing/render_courses.h @@ -6,7 +6,7 @@ void func_8029122C(struct UnkStruct_800DC5EC*, s32); s32 func_80290C20(Camera*); void parse_course_displaylists(uintptr_t); -void load_surface_map(uintptr_t, struct UnkStruct_800DC5EC*); +void render_course_segments(uintptr_t, struct UnkStruct_800DC5EC*); void func_80291198(void); void func_802911C4(void); void render_mario_raceway(struct UnkStruct_800DC5EC*); diff --git a/src/spawn_players.c b/src/spawn_players.c index 2cf6237b4..6cc12aa53 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -301,10 +301,10 @@ void spawn_player(Player *player, s8 playerIndex, f32 startingRow, f32 startingC player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceFlags = 0; player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceMapIndex = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceMapIndex = 0; - player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceMapIndex = 0; - player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceMapIndex = 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->boundingBoxCorners[FRONT_RIGHT_TYRE].unk_14 = 0; player->boundingBoxCorners[FRONT_LEFT_TYRE].unk_14 = 0;