Add COS defines

This commit is contained in:
Arceveti
2021-09-28 12:36:26 -07:00
parent 92ae326cf6
commit 79d7b7e4b9
8 changed files with 55 additions and 26 deletions

View File

@@ -533,15 +533,15 @@ s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw) {
u32 mario_floor_is_slippery(struct MarioState *m) {
f32 normY;
if ((m->area->terrainType & TERRAIN_MASK) == TERRAIN_SLIDE && m->floor->normal.y < 0.9998477f) { //~cos(1 deg)
if ((m->area->terrainType & TERRAIN_MASK) == TERRAIN_SLIDE && m->floor->normal.y < COS1) {
return TRUE;
}
switch (mario_get_floor_class(m)) {
case SURFACE_VERY_SLIPPERY: normY = 0.9848077f; break; //~cos(10 deg)
case SURFACE_SLIPPERY: normY = 0.9396926f; break; //~cos(20 deg)
default: normY = 0.7880108f; break; //~cos(38 deg)
case SURFACE_NOT_SLIPPERY: normY = 0.0f; break;
case SURFACE_VERY_SLIPPERY: normY = COS10; break;
case SURFACE_SLIPPERY: normY = COS20; break;
default: normY = COS38; break;
case SURFACE_NOT_SLIPPERY: normY = 0.0f; break;
}
return m->floor->normal.y <= normY;
@@ -554,15 +554,15 @@ s32 mario_floor_is_slope(struct MarioState *m) {
f32 normY;
if ((m->area->terrainType & TERRAIN_MASK) == TERRAIN_SLIDE
&& m->floor->normal.y < 0.9998477f) { // ~cos(1 deg)
&& m->floor->normal.y < COS1) {
return TRUE;
}
switch (mario_get_floor_class(m)) {
case SURFACE_VERY_SLIPPERY: normY = 0.9961947f; break; // ~cos(5 deg)
case SURFACE_SLIPPERY: normY = 0.9848077f; break; // ~cos(10 deg)
default: normY = 0.9659258f; break; // ~cos(15 deg)
case SURFACE_NOT_SLIPPERY: normY = 0.9396926f; break; // ~cos(20 deg)
case SURFACE_VERY_SLIPPERY: normY = COS5; break;
case SURFACE_SLIPPERY: normY = COS10; break;
default: normY = COS15; break;
case SURFACE_NOT_SLIPPERY: normY = COS20; break;
}
return m->floor->normal.y <= normY;
@@ -586,10 +586,10 @@ s32 mario_floor_is_steep(struct MarioState *m) {
// This does not matter in vanilla game practice.
if (!mario_facing_downhill(m, FALSE)) {
switch (mario_get_floor_class(m)) {
case SURFACE_VERY_SLIPPERY: normY = 0.9659258f; break; // ~cos(15 deg)
case SURFACE_SLIPPERY: normY = 0.9396926f; break; // ~cos(20 deg)
default: normY = 0.8660254f; break; // ~cos(30 deg)
case SURFACE_NOT_SLIPPERY: normY = 0.8660254f; break; // ~cos(30 deg)
case SURFACE_VERY_SLIPPERY: normY = COS15; break;
case SURFACE_SLIPPERY: normY = COS20; break;
default: normY = COS30; break;
case SURFACE_NOT_SLIPPERY: normY = COS30; break;
}
result = m->floor->normal.y <= normY;

View File

@@ -128,7 +128,7 @@ s32 should_get_stuck_in_ground(struct MarioState *m) {
#else
if (floor != NULL && (terrainType == TERRAIN_SNOW || terrainType == TERRAIN_SAND)
&& type != SURFACE_BURNING && SURFACE_IS_NOT_HARD(type)) {
if (!(flags & 0x01) && m->peakHeight - m->pos[1] > 1000.0f && floor->normal.y >= 0.8660254f) {
if (!(flags & 0x01) && m->peakHeight - m->pos[1] > 1000.0f && floor->normal.y >= COS30) {
return TRUE;
}
}
@@ -1445,7 +1445,7 @@ s32 act_butt_slide_air(struct MarioState *m) {
switch (perform_air_step(m, 0)) {
case AIR_STEP_LANDED:
if (m->actionState == 0 && m->vel[1] < 0.0f && m->floor->normal.y >= 0.9848077f) {
if (m->actionState == 0 && m->vel[1] < 0.0f && m->floor->normal.y >= COS10) {
m->vel[1] = -m->vel[1] / 2.0f;
m->actionState = 1;
} else {
@@ -1484,7 +1484,7 @@ s32 act_hold_butt_slide_air(struct MarioState *m) {
switch (perform_air_step(m, 0)) {
case AIR_STEP_LANDED:
if (m->actionState == 0 && m->vel[1] < 0.0f && m->floor->normal.y >= 0.9848077f) {
if (m->actionState == 0 && m->vel[1] < 0.0f && m->floor->normal.y >= COS10) {
m->vel[1] = -m->vel[1] / 2.0f;
m->actionState = 1;
} else {

View File

@@ -561,7 +561,7 @@ s32 act_ledge_grab(struct MarioState *m) {
m->actionTimer++;
}
#ifndef NO_FALSE_LEDGEGRABS
if (m->floor->normal.y < 0.9063078f) {
if (m->floor->normal.y < COS25) {
return let_go_of_ledge(m);
}
#endif

View File

@@ -538,7 +538,7 @@ s32 begin_braking_action(struct MarioState *m) {
return set_mario_action(m, ACT_STANDING_AGAINST_WALL, 0);
}
if (m->forwardVel >= 16.0f && m->floor->normal.y >= 0.17364818f) {
if (m->forwardVel >= 16.0f && m->floor->normal.y >= COS80) {
return set_mario_action(m, ACT_BRAKING, 0);
}
@@ -1784,7 +1784,7 @@ s32 common_landing_cancels(struct MarioState *m, struct LandingAction *landingAc
//! Everything here, including floor steepness, is checked before checking
// if Mario is actually on the floor. This leads to e.g. remote sliding.
if (m->floor->normal.y < 0.2923717f) {
if (m->floor->normal.y < COS73) {
return mario_push_off_steep_floor(m, landingAction->verySteepAction, 0);
}

View File

@@ -19,7 +19,7 @@
s32 check_common_idle_cancels(struct MarioState *m) {
mario_drop_held_object(m);
if (m->floor->normal.y < 0.29237169f) {
if (m->floor->normal.y < COS73) {
return mario_push_off_steep_floor(m, ACT_FREEFALL, 0);
}
@@ -60,7 +60,7 @@ s32 check_common_idle_cancels(struct MarioState *m) {
}
s32 check_common_hold_idle_cancels(struct MarioState *m) {
if (m->floor->normal.y < 0.29237169f) {
if (m->floor->normal.y < COS73) {
return mario_push_off_steep_floor(m, ACT_HOLD_FREEFALL, 0);
}

View File

@@ -519,8 +519,7 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
set_mario_floor(m, floor, ledgePos[1]);
m->faceAngle[0] = 0;
m->faceAngle[1] = atan2s(grabbedWall->normal.z, grabbedWall->normal.x) + 0x8000;
}
else {
} else {
vec3f_copy(m->pos, nextPos);
set_mario_floor(m, floor, floorHeight);
}

View File

@@ -1652,8 +1652,13 @@ void cur_obj_move_standard(s16 steepSlopeAngleDegrees) {
careAboutEdgesAndSteepSlopes = TRUE; steepSlopeAngleDegrees = -steepSlopeAngleDegrees;
// clang-format on
}
steepSlopeNormalY = coss(steepSlopeAngleDegrees * (0x10000 / 360));
if (steepSlopeAngleDegrees == 78) {
steepSlopeNormalY = COS78;
} else if (steepSlopeAngleDegrees == -78) {
steepSlopeNormalY = -COS78;
} else {
steepSlopeNormalY = coss(DEGREES(steepSlopeAngleDegrees));
}
cur_obj_compute_vel_xz();
cur_obj_apply_drag_xz(dragStrength);