You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Remove redundant function/struct
This commit is contained in:
@@ -108,8 +108,6 @@
|
||||
#define FIX_SHADOW_TRANSPARENCY
|
||||
// Automatically calculate the optimal collision distance for an object based on its vertices.
|
||||
#define AUTO_COLLISION_DISTANCE
|
||||
// Makes obj_resolve_object_collisions work consistently
|
||||
#define FIX_RESOLVE_OBJ_COLLISIONS
|
||||
|
||||
|
||||
// HACKER QOL
|
||||
|
||||
@@ -948,7 +948,7 @@ void audio_init() {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
u8 buf[0x10];
|
||||
#endif
|
||||
s32 i, j, k;
|
||||
s32 i, /*j,*/ k;
|
||||
UNUSED s32 lim1; // lim1 unused in EU
|
||||
#if defined(VERSION_EU)
|
||||
UNUSED u8 buf[0x10];
|
||||
|
||||
@@ -367,35 +367,6 @@ f32 unused_obj_find_floor_height(struct Object *obj) {
|
||||
return floorHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basically a local variable that passes through floor geo info.
|
||||
*/
|
||||
struct FloorGeometry sFloorGeo;
|
||||
|
||||
UNUSED static u8 unused8038BE50[0x40];
|
||||
|
||||
/**
|
||||
* Return the floor height underneath (xPos, yPos, zPos) and populate `floorGeo`
|
||||
* with data about the floor's normal vector and origin offset. Also update
|
||||
* sFloorGeo.
|
||||
*/
|
||||
f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometry **floorGeo) {
|
||||
struct Surface *floor;
|
||||
f32 floorHeight = find_floor(xPos, yPos, zPos, &floor);
|
||||
|
||||
*floorGeo = NULL;
|
||||
|
||||
if (floor != NULL) {
|
||||
sFloorGeo.normalX = floor->normal.x;
|
||||
sFloorGeo.normalY = floor->normal.y;
|
||||
sFloorGeo.normalZ = floor->normal.z;
|
||||
sFloorGeo.originOffset = floor->originOffset;
|
||||
|
||||
*floorGeo = &sFloorGeo;
|
||||
}
|
||||
return floorHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through the list of floors and find the first floor under a given point.
|
||||
*/
|
||||
|
||||
@@ -25,19 +25,9 @@ struct WallCollisionData
|
||||
/*0x18*/ struct Surface *walls[4];
|
||||
};
|
||||
|
||||
struct FloorGeometry
|
||||
{
|
||||
f32 unused[4]; // possibly position data?
|
||||
f32 normalX;
|
||||
f32 normalY;
|
||||
f32 normalZ;
|
||||
f32 originOffset;
|
||||
};
|
||||
|
||||
s32 f32_find_wall_collision(f32 *xPtr, f32 *yPtr, f32 *zPtr, f32 offsetY, f32 radius);
|
||||
s32 find_wall_collisions(struct WallCollisionData *colData);
|
||||
f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil);
|
||||
f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometry **floorGeo);
|
||||
f32 find_floor_height(f32 x, f32 y, f32 z);
|
||||
f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor);
|
||||
s32 find_water_level_and_floor(s32 x, s32 z, struct Surface **pfloor);
|
||||
|
||||
@@ -233,11 +233,11 @@ void bhv_bob_pit_bowling_ball_init(void) {
|
||||
}
|
||||
|
||||
void bhv_bob_pit_bowling_ball_loop(void) {
|
||||
struct FloorGeometry *sp1c;
|
||||
UNUSED s16 collisionFlags = object_step();
|
||||
struct Surface *floor;
|
||||
object_step();
|
||||
|
||||
find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &sp1c);
|
||||
if ((sp1c->normalX == 0) && (sp1c->normalZ == 0))
|
||||
find_floor(o->oPosX, o->oPosY, o->oPosZ, &floor);
|
||||
if ((floor->normal.x == 0) && (floor->normal.z == 0))
|
||||
o->oForwardVel = 28.0f;
|
||||
|
||||
bowling_ball_set_hitbox();
|
||||
|
||||
@@ -11,7 +11,6 @@ void bhv_butterfly_init(void) {
|
||||
}
|
||||
|
||||
void butterfly_step(s32 speed) {
|
||||
struct FloorGeometry *sp24;
|
||||
s16 yaw = o->oMoveAngleYaw;
|
||||
s16 pitch = o->oMoveAnglePitch;
|
||||
s16 yPhase = o->oButterflyYPhase;
|
||||
@@ -29,7 +28,7 @@ void butterfly_step(s32 speed) {
|
||||
else
|
||||
o->oPosY -= o->oVelY;
|
||||
|
||||
floorY = find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &sp24);
|
||||
floorY = find_floor_height(o->oPosX, o->oPosY, o->oPosZ);
|
||||
|
||||
if (o->oPosY < floorY + 2.0f)
|
||||
o->oPosY = floorY + 2.0f;
|
||||
|
||||
@@ -11,25 +11,24 @@ void bhv_hoot_init(void) {
|
||||
cur_obj_become_intangible();
|
||||
}
|
||||
|
||||
f32 hoot_find_next_floor(struct FloorGeometry **floor, f32 dist) {
|
||||
f32 hoot_find_next_floor(f32 dist) {
|
||||
f32 nextX = dist * sins(o->oMoveAngleYaw) + o->oPosX;
|
||||
f32 nextZ = dist * coss(o->oMoveAngleYaw) + o->oPosZ;
|
||||
return find_floor_height_and_data(nextX, 10000.0f, nextZ, floor);
|
||||
return find_floor_height(nextX, 10000.0f, nextZ);
|
||||
}
|
||||
|
||||
void hoot_floor_bounce(void) {
|
||||
struct FloorGeometry *sp1c;
|
||||
f32 floorY;
|
||||
|
||||
floorY = hoot_find_next_floor(&sp1c, 375.0f);
|
||||
floorY = hoot_find_next_floor(375.0f);
|
||||
if (floorY + 75.0f > o->oPosY)
|
||||
o->oMoveAnglePitch -= 3640.8888;
|
||||
|
||||
floorY = hoot_find_next_floor(&sp1c, 200.0f);
|
||||
floorY = hoot_find_next_floor(200.0f);
|
||||
if (floorY + 125.0f > o->oPosY)
|
||||
o->oMoveAnglePitch -= 7281.7776;
|
||||
|
||||
floorY = hoot_find_next_floor(&sp1c, 0);
|
||||
floorY = hoot_find_next_floor(0.0f);
|
||||
if (floorY + 125.0f > o->oPosY)
|
||||
o->oPosY = floorY + 125.0f;
|
||||
if (o->oMoveAnglePitch < -21845.3328)
|
||||
@@ -37,7 +36,7 @@ void hoot_floor_bounce(void) {
|
||||
}
|
||||
|
||||
void hoot_free_step(s16 fastOscY, s32 speed) {
|
||||
struct FloorGeometry *floor;
|
||||
struct Surface *floor;
|
||||
s16 yaw = o->oMoveAngleYaw;
|
||||
s16 pitch = o->oMoveAnglePitch;
|
||||
s16 animFrame = o->header.gfx.animInfo.animFrame;
|
||||
@@ -57,7 +56,7 @@ void hoot_free_step(s16 fastOscY, s32 speed) {
|
||||
o->oPosY -= o->oVelY + coss((s32)(animFrame * 6553.6)) * 50.0f / 4;
|
||||
o->oPosZ += o->oVelZ;
|
||||
|
||||
find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &floor);
|
||||
find_floor(o->oPosX, o->oPosY, o->oPosZ, &floor);
|
||||
if (floor == NULL) {
|
||||
o->oPosX = xPrev;
|
||||
o->oPosZ = zPrev;
|
||||
@@ -98,7 +97,7 @@ void hoot_carry_step(s32 speed, UNUSED f32 xPrev, UNUSED f32 zPrev) {
|
||||
}
|
||||
|
||||
void hoot_surface_collision(f32 xPrev, UNUSED f32 yPrev, f32 zPrev) {
|
||||
struct FloorGeometry *floor;
|
||||
struct Surface *floor;
|
||||
struct WallCollisionData hitbox;
|
||||
f32 floorY;
|
||||
|
||||
@@ -115,7 +114,7 @@ void hoot_surface_collision(f32 xPrev, UNUSED f32 yPrev, f32 zPrev) {
|
||||
gMarioObject->oInteractStatus |= INT_STATUS_MARIO_UNK7; /* bit 7 */
|
||||
}
|
||||
|
||||
floorY = find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &floor);
|
||||
floorY = find_floor(o->oPosX, o->oPosY, o->oPosZ, &floor);
|
||||
if (floor == NULL) {
|
||||
o->oPosX = xPrev;
|
||||
o->oPosZ = zPrev;
|
||||
|
||||
@@ -72,11 +72,9 @@ s32 random_flower_offset(void) {
|
||||
*/
|
||||
void envfx_update_flower(Vec3s centerPos) {
|
||||
s32 i;
|
||||
struct FloorGeometry *floorGeo; // unused
|
||||
s32 timer = gGlobalTimer;
|
||||
|
||||
s16 centerX = centerPos[0];
|
||||
UNUSED s16 centerY = centerPos[1];
|
||||
s16 centerZ = centerPos[2];
|
||||
|
||||
for (i = 0; i < sBubbleParticleMaxCount; i++) {
|
||||
@@ -84,8 +82,7 @@ void envfx_update_flower(Vec3s centerPos) {
|
||||
if ((gEnvFxBuffer + i)->isAlive == 0) {
|
||||
(gEnvFxBuffer + i)->xPos = random_flower_offset() + centerX;
|
||||
(gEnvFxBuffer + i)->zPos = random_flower_offset() + centerZ;
|
||||
(gEnvFxBuffer + i)->yPos = find_floor_height_and_data((gEnvFxBuffer + i)->xPos, 10000.0f,
|
||||
(gEnvFxBuffer + i)->zPos, &floorGeo);
|
||||
(gEnvFxBuffer + i)->yPos = find_floor_height((gEnvFxBuffer + i)->xPos, 10000.0f, (gEnvFxBuffer + i)->zPos);
|
||||
(gEnvFxBuffer + i)->isAlive = 1;
|
||||
(gEnvFxBuffer + i)->animFrame = random_float() * 5.0f;
|
||||
} else if ((timer & 0x03) == 0) {
|
||||
|
||||
@@ -38,9 +38,7 @@
|
||||
#define INTERACT_IGLOO_BARRIER /* 0x40000000 */ (1 << 30)
|
||||
#define INTERACT_UNKNOWN_31 /* 0x80000000 */ (1 << 31)
|
||||
|
||||
#ifdef FIX_RESOLVE_OBJ_COLLISIONS
|
||||
#define INTERACT_MASK_NO_OBJ_COLLISIONS (INTERACT_COIN | INTERACT_CAP | INTERACT_STRONG_WIND | INTERACT_STAR_OR_KEY | INTERACT_WARP | INTERACT_WATER_RING | INTERACT_FLAME)
|
||||
#endif
|
||||
|
||||
// INTERACT_WARP
|
||||
#define INT_SUBTYPE_FADING_WARP 0x00000001
|
||||
|
||||
@@ -64,7 +64,7 @@ void butterfly_act_follow_mario(void);
|
||||
void butterfly_act_return_home(void);
|
||||
void bhv_butterfly_loop(void);
|
||||
void bhv_hoot_init(void);
|
||||
f32 hoot_find_next_floor(struct FloorGeometry **arg0, f32 arg1);
|
||||
f32 hoot_find_next_floor(f32 dist);
|
||||
void hoot_floor_bounce(void);
|
||||
void hoot_free_step(s16 fastOscY, s32 speed);
|
||||
void hoot_player_set_yaw(void);
|
||||
|
||||
@@ -548,7 +548,6 @@ static s32 obj_resolve_object_collisions(s32 *targetYaw) {
|
||||
f32 radius, otherRadius, relativeRadius;
|
||||
|
||||
if (o->numCollidedObjs != 0) {
|
||||
#ifdef FIX_RESOLVE_OBJ_COLLISIONS
|
||||
s32 i;
|
||||
for ((i = 0); (i < o->numCollidedObjs); (i++)) {
|
||||
otherObject = o->collidedObjs[i];
|
||||
@@ -568,38 +567,6 @@ static s32 obj_resolve_object_collisions(s32 *targetYaw) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
f32 newCenterX, newCenterZ;
|
||||
otherObject = o->collidedObjs[0];
|
||||
if (otherObject != gMarioObject) {
|
||||
//! If one object moves after collisions are detected and this code
|
||||
// runs, the objects can move toward each other (transport cloning)
|
||||
|
||||
dx = otherObject->oPosX - o->oPosX;
|
||||
dz = otherObject->oPosZ - o->oPosZ;
|
||||
angle = atan2s(dx, dz); //! This should be atan2s(dz, dx)
|
||||
|
||||
radius = o->hitboxRadius;
|
||||
otherRadius = otherObject->hitboxRadius;
|
||||
relativeRadius = radius / (radius + otherRadius);
|
||||
|
||||
newCenterX = o->oPosX + dx * relativeRadius;
|
||||
newCenterZ = o->oPosZ + dz * relativeRadius;
|
||||
|
||||
o->oPosX = newCenterX - radius * coss(angle);
|
||||
o->oPosZ = newCenterZ - radius * sins(angle);
|
||||
|
||||
otherObject->oPosX = newCenterX + otherRadius * coss(angle);
|
||||
otherObject->oPosZ = newCenterZ + otherRadius * sins(angle);
|
||||
|
||||
if (targetYaw != NULL && abs_angle_diff(o->oMoveAngleYaw, angle) < 0x4000) {
|
||||
// Bounce off object (or it would, if the above atan2s bug
|
||||
// were fixed)
|
||||
*targetYaw = (s16)(angle - o->oMoveAngleYaw + angle + 0x8000);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
@@ -205,14 +205,14 @@ f32 get_water_level_below_shadow(struct Shadow *s, struct Surface **waterFloor)
|
||||
s8 init_shadow(struct Shadow *s, f32 xPos, f32 yPos, f32 zPos, s16 shadowScale, u8 overwriteSolidity) {
|
||||
f32 waterLevel;
|
||||
f32 floorSteepness;
|
||||
struct FloorGeometry *floorGeometry;
|
||||
struct Surface *floor;
|
||||
struct Surface *waterFloor = NULL;
|
||||
|
||||
s->parentX = xPos;
|
||||
s->parentY = yPos;
|
||||
s->parentZ = zPos;
|
||||
|
||||
s->floorHeight = find_floor_height_and_data(s->parentX, s->parentY, s->parentZ, &floorGeometry);
|
||||
s->floorHeight = find_floor(s->parentX, s->parentY, s->parentZ, &floor);
|
||||
|
||||
waterLevel = get_water_level_below_shadow(s, &waterFloor);
|
||||
|
||||
@@ -244,14 +244,14 @@ s8 init_shadow(struct Shadow *s, f32 xPos, f32 yPos, f32 zPos, s16 shadowScale,
|
||||
} else {
|
||||
// Don't draw a shadow if the floor is lower than expected possible,
|
||||
// or if the y-normal is negative (an unexpected result).
|
||||
if (s->floorHeight < FLOOR_LOWER_LIMIT_SHADOW || floorGeometry->normalY <= 0.0) {
|
||||
if (s->floorHeight < FLOOR_LOWER_LIMIT_SHADOW || floor->normal.y <= 0.0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
s->floorNormalX = floorGeometry->normalX;
|
||||
s->floorNormalY = floorGeometry->normalY;
|
||||
s->floorNormalZ = floorGeometry->normalZ;
|
||||
s->floorOriginOffset = floorGeometry->originOffset;
|
||||
s->floorNormalX = floor->normal.x;
|
||||
s->floorNormalY = floor->normal.y;
|
||||
s->floorNormalZ = floor->normal.z;
|
||||
s->floorOriginOffset = floor->originOffset;
|
||||
}
|
||||
|
||||
if (overwriteSolidity) {
|
||||
@@ -383,7 +383,6 @@ void calculate_vertex_xyz(s8 index, struct Shadow s, f32 *xPosVtx, f32 *yPosVtx,
|
||||
f32 halfTiltedScale;
|
||||
s8 xCoordUnit;
|
||||
s8 zCoordUnit;
|
||||
struct FloorGeometry *dummy;
|
||||
|
||||
// This makes xCoordUnit and yCoordUnit each one of -1, 0, or 1.
|
||||
get_vertex_coords(index, shadowVertexType, &xCoordUnit, &zCoordUnit);
|
||||
@@ -406,7 +405,7 @@ void calculate_vertex_xyz(s8 index, struct Shadow s, f32 *xPosVtx, f32 *yPosVtx,
|
||||
// Clamp this vertex's y-position to that of the floor directly
|
||||
// below it, which may differ from the floor below the center
|
||||
// vertex.
|
||||
*yPosVtx = find_floor_height_and_data(*xPosVtx, s.parentY, *zPosVtx, &dummy);
|
||||
*yPosVtx = find_floor_height(*xPosVtx, s.parentY, *zPosVtx);
|
||||
break;
|
||||
case SHADOW_WITH_4_VERTS:
|
||||
// Do not clamp. Instead, extrapolate the y-position of this
|
||||
@@ -426,8 +425,7 @@ void calculate_vertex_xyz(s8 index, struct Shadow s, f32 *xPosVtx, f32 *yPosVtx,
|
||||
* perpendicular, meaning the ground is locally flat. It returns nonzero
|
||||
* in most cases where `vtxY` is on a different floor triangle from the
|
||||
* center vertex, as in the case with SHADOW_WITH_9_VERTS, which sets
|
||||
* the y-value from `find_floor_height_and_data`. (See the bottom of
|
||||
* `calculate_vertex_xyz`.)
|
||||
* the y-value from `find_floor`. (See the bottom of `calculate_vertex_xyz`.)
|
||||
*/
|
||||
s16 floor_local_tilt(struct Shadow s, f32 vtxX, f32 vtxY, f32 vtxZ) {
|
||||
f32 relX = vtxX - s.parentX;
|
||||
@@ -458,9 +456,8 @@ void make_shadow_vertex(Vtx *vertices, s8 index, struct Shadow s, s8 shadowVerte
|
||||
* GameShark code in this video: https://youtu.be/MSIh4rtNGF0. The code in
|
||||
* the video makes `extrapolate_vertex_y_position` return the same value as
|
||||
* the last-called function that returns a float; in this case, that's
|
||||
* `find_floor_height_and_data`, which this if-statement was designed to
|
||||
* overwrite in the first place. Thus, this if-statement is disabled by that
|
||||
* code.
|
||||
* `find_floor`, which this if-statement was designed to overwrite in the
|
||||
* first place. Thus, this if-statement is disabled by that code.
|
||||
*
|
||||
* The last condition here means the y-position calculated previously
|
||||
* was probably on a different floor triangle from the center vertex.
|
||||
@@ -721,9 +718,8 @@ Gfx *create_shadow_circle_assuming_flat_ground(f32 xPos, f32 yPos, f32 zPos, s16
|
||||
u8 solidity) {
|
||||
Vtx *verts;
|
||||
Gfx *displayList;
|
||||
struct FloorGeometry *dummy; // only for calling find_floor_height_and_data
|
||||
f32 distBelowFloor;
|
||||
f32 floorHeight = find_floor_height_and_data(xPos, yPos, zPos, &dummy);
|
||||
f32 floorHeight = find_floor_height(xPos, yPos, zPos);
|
||||
f32 radius = shadowScale / 2;
|
||||
|
||||
if (floorHeight < FLOOR_LOWER_LIMIT_SHADOW) {
|
||||
@@ -781,9 +777,8 @@ Gfx *create_shadow_rectangle(f32 halfWidth, f32 halfLength, f32 relY, u8 solidit
|
||||
* value is 200. Return 0 if a shadow should be drawn, 1 if not.
|
||||
*/
|
||||
s32 get_shadow_height_solidity(f32 xPos, f32 yPos, f32 zPos, f32 *shadowHeight, u8 *solidity) {
|
||||
struct FloorGeometry *dummy;
|
||||
f32 waterLevel;
|
||||
*shadowHeight = find_floor_height_and_data(xPos, yPos, zPos, &dummy);
|
||||
*shadowHeight = find_floor_height(xPos, yPos, zPos);
|
||||
|
||||
if (*shadowHeight < FLOOR_LOWER_LIMIT_SHADOW) {
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user