Add FramePerfection's Better Wall Collision with rounded corners
This commit is contained in:
1 parent
97f6fa6959
commit
2927db262c
16 files changed
+369
-220
No files matched your search
+1
-1
@@ -4010,7 +4010,7 @@ s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius) {
|
||||
f32 originOffset;
|
||||
f32 offset;
|
||||
f32 offsetAbsolute;
|
||||
Vec3f newPos[4];
|
||||
Vec3f newPos[MAX_REFEREMCED_WALLS];
|
||||
s32 i;
|
||||
s32 numCollisions = 0;
|
||||
|
||||
|
||||
@@ -1771,12 +1771,14 @@ u32 interact_text(struct MarioState *m, UNUSED u32 interactType, struct Object *
|
||||
|
||||
void check_kick_or_punch_wall(struct MarioState *m) {
|
||||
if (m->flags & (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING)) {
|
||||
Vec3f detector;
|
||||
detector[0] = m->pos[0] + 50.0f * sins(m->faceAngle[1]);
|
||||
detector[2] = m->pos[2] + 50.0f * coss(m->faceAngle[1]);
|
||||
detector[1] = m->pos[1];
|
||||
struct WallCollisionData detector;
|
||||
detector.x = m->pos[0] + 50.0f * sins(m->faceAngle[1]);
|
||||
detector.z = m->pos[2] + 50.0f * coss(m->faceAngle[1]);
|
||||
detector.y = m->pos[1];
|
||||
detector.offsetY = 80.0f;
|
||||
detector.radius = 5.0f;
|
||||
|
||||
if (resolve_and_return_wall_collisions(detector, 80.0f, 5.0f) != NULL) {
|
||||
if (find_wall_collisions(&detector) > 0) {
|
||||
if (m->action != ACT_MOVE_PUNCHING || m->forwardVel >= 0.0f) {
|
||||
if (m->action == ACT_PUNCHING) {
|
||||
m->action = ACT_MOVE_PUNCHING;
|
||||
|
||||
+1
-36
@@ -515,41 +515,6 @@ u32 mario_get_terrain_sound_addend(struct MarioState *m) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collides with walls and returns the most recent wall.
|
||||
*/
|
||||
struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius) {
|
||||
struct WallCollisionData collisionData;
|
||||
struct Surface *wall = NULL;
|
||||
|
||||
collisionData.x = pos[0];
|
||||
collisionData.y = pos[1];
|
||||
collisionData.z = pos[2];
|
||||
collisionData.radius = radius;
|
||||
collisionData.offsetY = offset;
|
||||
|
||||
if (find_wall_collisions(&collisionData)) {
|
||||
wall = collisionData.walls[collisionData.numWalls - 1];
|
||||
}
|
||||
|
||||
pos[0] = collisionData.x;
|
||||
pos[1] = collisionData.y;
|
||||
pos[2] = collisionData.z;
|
||||
|
||||
// This only returns the most recent wall and can also return NULL
|
||||
// there are no wall collisions.
|
||||
return wall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the ceiling from a vec3f horizontally and a height (with 80 vertical buffer).
|
||||
*/
|
||||
f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil) {
|
||||
UNUSED f32 unused;
|
||||
|
||||
return find_ceil(pos[0], height + 3.0f, pos[2], ceil);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if Mario is facing "downhill."
|
||||
*/
|
||||
@@ -1370,7 +1335,7 @@ void update_mario_geometry_inputs(struct MarioState *m) {
|
||||
m->floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &m->floor);
|
||||
}
|
||||
|
||||
m->ceilHeight = vec3f_find_ceil(m->pos, m->pos[1], &m->ceil);
|
||||
m->ceilHeight = find_ceil(m->pos[0], m->pos[1] + 3.0f, m->pos[2], &m->ceil);
|
||||
gasLevel = find_poison_gas_level(m->pos[0], m->pos[2]);
|
||||
m->waterLevel = find_water_level(m->pos[0], m->pos[2]);
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySo
|
||||
void mario_set_forward_vel(struct MarioState *m, f32 speed);
|
||||
s32 mario_get_floor_class(struct MarioState *m);
|
||||
u32 mario_get_terrain_sound_addend(struct MarioState *m);
|
||||
struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius);
|
||||
f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil);
|
||||
s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw);
|
||||
u32 mario_floor_is_slippery(struct MarioState *m);
|
||||
s32 mario_floor_is_slope(struct MarioState *m);
|
||||
|
||||
@@ -81,7 +81,7 @@ s32 set_pole_position(struct MarioState *m, f32 offsetY) {
|
||||
collided = f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 60.0f, 50.0f);
|
||||
collided |= f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 30.0f, 24.0f);
|
||||
|
||||
ceilHeight = vec3f_find_ceil(m->pos, m->pos[1], &ceil);
|
||||
ceilHeight = find_ceil(m->pos[0], m->pos[1] + 3.0f, m->pos[2], &ceil);
|
||||
if (m->pos[1] > ceilHeight - 160.0f) {
|
||||
m->pos[1] = ceilHeight - 160.0f;
|
||||
marioObj->oMarioPolePos = m->pos[1] - m->usedObj->oPosY;
|
||||
@@ -307,10 +307,13 @@ s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos) {
|
||||
f32 ceilHeight;
|
||||
f32 floorHeight;
|
||||
f32 ceilOffset;
|
||||
struct WallCollisionData wallCollisionData;
|
||||
|
||||
resolve_and_return_wall_collisions(nextPos, 50.0f, 50.0f, &wallCollisionData);
|
||||
m->wall = wallCollisionData.numWalls == 0 ? NULL : wallCollisionData.walls[0];
|
||||
|
||||
m->wall = resolve_and_return_wall_collisions(nextPos, 50.0f, 50.0f);
|
||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||
ceilHeight = vec3f_find_ceil(nextPos, nextPos[1], &ceil);
|
||||
ceilHeight = find_ceil(nextPos[0], nextPos[1] + 3.0f, nextPos[2], &ceil);
|
||||
|
||||
if (floor == NULL) {
|
||||
return HANG_HIT_CEIL_OR_OOB;
|
||||
|
||||
@@ -534,6 +534,7 @@ s32 act_reading_sign(struct MarioState *m) {
|
||||
}
|
||||
|
||||
s32 act_debug_free_move(struct MarioState *m) {
|
||||
struct WallCollisionData wallData;
|
||||
struct Surface *surf;
|
||||
f32 floorHeight;
|
||||
Vec3f pos;
|
||||
@@ -561,7 +562,7 @@ s32 act_debug_free_move(struct MarioState *m) {
|
||||
pos[2] += 32.0f * speed * coss(m->intendedYaw);
|
||||
}
|
||||
|
||||
resolve_and_return_wall_collisions(pos, 60.0f, 50.0f);
|
||||
resolve_and_return_wall_collisions(pos, 60.0f, 50.0f, &wallData);
|
||||
|
||||
floorHeight = find_floor(pos[0], pos[1], pos[2], &surf);
|
||||
if (surf != NULL) {
|
||||
|
||||
@@ -68,15 +68,17 @@ static f32 get_buoyancy(struct MarioState *m) {
|
||||
}
|
||||
|
||||
static u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos) {
|
||||
struct WallCollisionData wallData;
|
||||
struct Surface *wall;
|
||||
struct Surface *ceil;
|
||||
struct Surface *floor;
|
||||
f32 ceilHeight;
|
||||
f32 floorHeight;
|
||||
|
||||
wall = resolve_and_return_wall_collisions(nextPos, 10.0f, 110.0f);
|
||||
resolve_and_return_wall_collisions(nextPos, 10.0f, 110.0f, &wallData);
|
||||
wall = wallData.numWalls == 0 ? NULL : wallData.walls[0];
|
||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||
ceilHeight = vec3f_find_ceil(nextPos, nextPos[1], &ceil);
|
||||
ceilHeight = find_ceil(nextPos[0], nextPos[1] + 3.0f, nextPos[2], &ceil);
|
||||
|
||||
if (floor == NULL) {
|
||||
return WATER_STEP_CANCELLED;
|
||||
|
||||
+131
-65
@@ -73,7 +73,7 @@ void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollision
|
||||
//! Bully battery
|
||||
}
|
||||
|
||||
BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ,
|
||||
void init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ,
|
||||
f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius) {
|
||||
if (forwardVel < 0.0f) {
|
||||
forwardVel *= -1.0f;
|
||||
@@ -258,24 +258,27 @@ s32 stationary_ground_step(struct MarioState *m) {
|
||||
}
|
||||
|
||||
static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
|
||||
UNUSED struct Surface *lowerWall;
|
||||
struct Surface *upperWall;
|
||||
struct WallCollisionData lowerWall;
|
||||
struct WallCollisionData upperWall;
|
||||
struct Surface *ceil;
|
||||
struct Surface *floor;
|
||||
f32 ceilHeight;
|
||||
f32 floorHeight;
|
||||
f32 waterLevel;
|
||||
|
||||
lowerWall = resolve_and_return_wall_collisions(nextPos, 30.0f, 24.0f);
|
||||
upperWall = resolve_and_return_wall_collisions(nextPos, 60.0f, 50.0f);
|
||||
s16 i;
|
||||
s16 wallDYaw;
|
||||
s32 oldWallDYaw;
|
||||
s32 absWallDYaw;
|
||||
|
||||
resolve_and_return_wall_collisions(nextPos, 30.0f, 24.0f, &lowerWall);
|
||||
resolve_and_return_wall_collisions(nextPos, 60.0f, 50.0f, &upperWall);
|
||||
|
||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||
ceilHeight = vec3f_find_ceil(nextPos, nextPos[1], &ceil);
|
||||
ceilHeight = find_ceil(nextPos[0], nextPos[1] + 3.0f, nextPos[2], &ceil);
|
||||
|
||||
waterLevel = find_water_level(nextPos[0], nextPos[2]);
|
||||
|
||||
m->wall = upperWall;
|
||||
|
||||
if (floor == NULL) {
|
||||
return GROUND_STEP_HIT_WALL_STOP_QSTEPS;
|
||||
}
|
||||
@@ -305,14 +308,25 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
|
||||
m->floor = floor;
|
||||
m->floorHeight = floorHeight;
|
||||
|
||||
if (upperWall != NULL) {
|
||||
s16 wallDYaw = atan2s(upperWall->normal.z, upperWall->normal.x) - m->faceAngle[1];
|
||||
if (m->wall != NULL) {
|
||||
oldWallDYaw = atan2s(m->wall->normal.z, m->wall->normal.x) - m->faceAngle[1];
|
||||
oldWallDYaw = oldWallDYaw < 0 ? -oldWallDYaw : oldWallDYaw;
|
||||
} else {
|
||||
oldWallDYaw = 0;
|
||||
}
|
||||
for (i = 0; i < upperWall.numWalls; i++) {
|
||||
wallDYaw = atan2s(upperWall.walls[i]->normal.z, upperWall.walls[i]->normal.x) - m->faceAngle[1];
|
||||
absWallDYaw = wallDYaw < 0 ? -wallDYaw : wallDYaw;
|
||||
if (absWallDYaw > oldWallDYaw) {
|
||||
oldWallDYaw = absWallDYaw;
|
||||
m->wall = upperWall.walls[i];
|
||||
}
|
||||
|
||||
if (wallDYaw >= 0x2AAA && wallDYaw <= 0x5555) {
|
||||
return GROUND_STEP_NONE;
|
||||
continue;
|
||||
}
|
||||
if (wallDYaw <= -0x2AAA && wallDYaw >= -0x5555) {
|
||||
return GROUND_STEP_NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
return GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS;
|
||||
@@ -326,6 +340,8 @@ s32 perform_ground_step(struct MarioState *m) {
|
||||
u32 stepResult;
|
||||
Vec3f intendedPos;
|
||||
|
||||
m->wall = NULL;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
intendedPos[0] = m->pos[0] + m->floor->normal.y * (m->vel[0] / 4.0f);
|
||||
intendedPos[2] = m->pos[2] + m->floor->normal.y * (m->vel[2] / 4.0f);
|
||||
@@ -347,9 +363,7 @@ s32 perform_ground_step(struct MarioState *m) {
|
||||
return stepResult;
|
||||
}
|
||||
|
||||
u32 check_ledge_grab(struct MarioState *m, struct Surface *wall, Vec3f intendedPos, Vec3f nextPos) {
|
||||
struct Surface *ledgeFloor;
|
||||
Vec3f ledgePos;
|
||||
struct Surface *check_ledge_grab(struct MarioState *m, struct Surface *grabbedWall, struct Surface *wall, Vec3f intendedPos, Vec3f nextPos, Vec3f ledgePos, struct Surface **ledgeFloor) {
|
||||
f32 displacementX;
|
||||
f32 displacementZ;
|
||||
|
||||
@@ -357,54 +371,99 @@ u32 check_ledge_grab(struct MarioState *m, struct Surface *wall, Vec3f intendedP
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Return the already grabbed wall if Mario is moving into it more than the newly tested wall
|
||||
if (grabbedWall != NULL &&
|
||||
grabbedWall->normal.x * m->vel[0] + grabbedWall->normal.z * m->vel[2] < wall->normal.x * m->vel[0] + wall->normal.z * m->vel[2])
|
||||
return grabbedWall;
|
||||
|
||||
displacementX = nextPos[0] - intendedPos[0];
|
||||
displacementZ = nextPos[2] - intendedPos[2];
|
||||
|
||||
// Only ledge grab if the wall displaced Mario in the opposite direction of
|
||||
// his velocity.
|
||||
if (displacementX * m->vel[0] + displacementZ * m->vel[2] > 0.0f) {
|
||||
return FALSE;
|
||||
return grabbedWall;
|
||||
}
|
||||
|
||||
//! Since the search for floors starts at y + 160, we will sometimes grab
|
||||
// a higher ledge than expected (glitchy ledge grab)
|
||||
ledgePos[0] = nextPos[0] - wall->normal.x * 60.0f;
|
||||
ledgePos[2] = nextPos[2] - wall->normal.z * 60.0f;
|
||||
ledgePos[1] = find_floor(ledgePos[0], nextPos[1] + 160.0f, ledgePos[2], &ledgeFloor);
|
||||
ledgePos[1] = find_floor(ledgePos[0], nextPos[1] + 160.0f, ledgePos[2], ledgeFloor);
|
||||
|
||||
if (ledgePos[1] - nextPos[1] <= 100.0f) {
|
||||
return FALSE;
|
||||
return grabbedWall;
|
||||
}
|
||||
return wall;
|
||||
}
|
||||
|
||||
vec3f_copy(m->pos, ledgePos);
|
||||
m->floor = ledgeFloor;
|
||||
m->floorHeight = ledgePos[1];
|
||||
s32 bonk_or_hit_lava_wall(struct MarioState *m, struct WallCollisionData *wallData) {
|
||||
s16 i;
|
||||
s16 wallDYaw;
|
||||
s32 oldWallDYaw;
|
||||
s32 absWallDYaw;
|
||||
s32 result;
|
||||
result = AIR_STEP_NONE;
|
||||
|
||||
m->floorAngle = atan2s(ledgeFloor->normal.z, ledgeFloor->normal.x);
|
||||
if (m->wall != NULL) {
|
||||
oldWallDYaw = atan2s(m->wall->normal.z, m->wall->normal.x) - m->faceAngle[1];
|
||||
oldWallDYaw = oldWallDYaw < 0 ? -oldWallDYaw : oldWallDYaw;
|
||||
}
|
||||
else
|
||||
oldWallDYaw = 0;
|
||||
|
||||
m->faceAngle[0] = 0;
|
||||
m->faceAngle[1] = atan2s(wall->normal.z, wall->normal.x) + 0x8000;
|
||||
return TRUE;
|
||||
for (i = 0; i < wallData->numWalls; i++) {
|
||||
if (wallData->walls[i] != NULL) {
|
||||
wallDYaw = atan2s(wallData->walls[i]->normal.z, wallData->walls[i]->normal.x) - m->faceAngle[1];
|
||||
if (wallData->walls[i]->type == SURFACE_BURNING) {
|
||||
m->wall = wallData->walls[i];
|
||||
return AIR_STEP_HIT_LAVA_WALL;
|
||||
}
|
||||
|
||||
//Update wall reference (bonked wall) only if the new wall has a better facing angle
|
||||
absWallDYaw = wallDYaw < 0 ? -wallDYaw : wallDYaw;
|
||||
if (absWallDYaw > oldWallDYaw) {
|
||||
oldWallDYaw = absWallDYaw;
|
||||
m->wall = wallData->walls[i];
|
||||
|
||||
if (wallDYaw < -0x6000 || wallDYaw > 0x6000) {
|
||||
m->flags |= MARIO_UNKNOWN_30;
|
||||
result = AIR_STEP_HIT_WALL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepArg) {
|
||||
s16 wallDYaw;
|
||||
s16 i;
|
||||
s32 stepResult;
|
||||
|
||||
Vec3f nextPos;
|
||||
struct Surface *upperWall;
|
||||
struct Surface *lowerWall;
|
||||
Vec3f ledgePos;
|
||||
struct WallCollisionData upperWall;
|
||||
struct WallCollisionData lowerWall;
|
||||
struct Surface *ceil;
|
||||
struct Surface *floor;
|
||||
struct Surface *grabbedWall;
|
||||
struct Surface *ledgeFloor;
|
||||
f32 ceilHeight;
|
||||
f32 floorHeight;
|
||||
f32 waterLevel;
|
||||
|
||||
grabbedWall = NULL;
|
||||
stepResult = AIR_STEP_NONE;
|
||||
|
||||
vec3f_copy(nextPos, intendedPos);
|
||||
|
||||
upperWall = resolve_and_return_wall_collisions(nextPos, 150.0f, 50.0f);
|
||||
lowerWall = resolve_and_return_wall_collisions(nextPos, 30.0f, 50.0f);
|
||||
resolve_and_return_wall_collisions(nextPos, 150.0f, 50.0f, &upperWall);
|
||||
resolve_and_return_wall_collisions(nextPos, 30.0f, 50.0f, &lowerWall);
|
||||
|
||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||
ceilHeight = vec3f_find_ceil(nextPos, nextPos[1], &ceil);
|
||||
ceilHeight = find_ceil(nextPos[0], nextPos[1] + 3.0f, nextPos[2], &ceil);
|
||||
|
||||
waterLevel = find_water_level(nextPos[0], nextPos[2]);
|
||||
|
||||
@@ -469,44 +528,44 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
|
||||
}
|
||||
|
||||
m->pos[1] = nextPos[1];
|
||||
return AIR_STEP_HIT_WALL;
|
||||
return AIR_STEP_HIT_CEILING;
|
||||
}
|
||||
|
||||
//! When the wall is not completely vertical or there is a slight wall
|
||||
// misalignment, you can activate these conditions in unexpected situations
|
||||
if ((stepArg & AIR_STEP_CHECK_LEDGE_GRAB) && upperWall == NULL && lowerWall != NULL) {
|
||||
if (check_ledge_grab(m, lowerWall, intendedPos, nextPos)) {
|
||||
return AIR_STEP_GRABBED_LEDGE;
|
||||
}
|
||||
|
||||
vec3f_copy(m->pos, nextPos);
|
||||
m->floor = floor;
|
||||
m->floorHeight = floorHeight;
|
||||
return AIR_STEP_NONE;
|
||||
if ((stepArg & AIR_STEP_CHECK_LEDGE_GRAB) && upperWall.numWalls == 0) {
|
||||
for (i = 0; i < lowerWall.numWalls; i++)
|
||||
if ((grabbedWall = check_ledge_grab(m, grabbedWall, lowerWall.walls[i], intendedPos, nextPos, ledgePos, &ledgeFloor)))
|
||||
stepResult = AIR_STEP_GRABBED_LEDGE;
|
||||
if (stepResult == AIR_STEP_GRABBED_LEDGE)
|
||||
{
|
||||
vec3f_copy(m->pos, ledgePos);
|
||||
m->floor = ledgeFloor;
|
||||
m->floorHeight = ledgePos[1];
|
||||
|
||||
m->floorAngle = atan2s(ledgeFloor->normal.z, ledgeFloor->normal.x);
|
||||
|
||||
m->faceAngle[0] = 0;
|
||||
m->faceAngle[1] = atan2s(grabbedWall->normal.z, grabbedWall->normal.x) + 0x8000;
|
||||
}
|
||||
else {
|
||||
vec3f_copy(m->pos, nextPos);
|
||||
m->floor = floor;
|
||||
m->floorHeight = floorHeight;
|
||||
}
|
||||
return stepResult;
|
||||
}
|
||||
|
||||
vec3f_copy(m->pos, nextPos);
|
||||
m->floor = floor;
|
||||
m->floorHeight = floorHeight;
|
||||
|
||||
if (upperWall != NULL || lowerWall != NULL) {
|
||||
m->wall = upperWall != NULL ? upperWall : lowerWall;
|
||||
wallDYaw = atan2s(m->wall->normal.z, m->wall->normal.x) - m->faceAngle[1];
|
||||
stepResult = bonk_or_hit_lava_wall(m, &upperWall);
|
||||
if (stepResult != AIR_STEP_NONE)
|
||||
return stepResult;
|
||||
|
||||
if (m->wall->type == SURFACE_BURNING) {
|
||||
return AIR_STEP_HIT_LAVA_WALL;
|
||||
}
|
||||
#ifdef WALLKICKS_46_DEGREES
|
||||
if (wallDYaw < -0x5F00 || wallDYaw > 0x5700) {
|
||||
#else
|
||||
if (wallDYaw < -0x6000 || wallDYaw > 0x6000) {
|
||||
#endif
|
||||
m->flags |= MARIO_UNKNOWN_30;
|
||||
return AIR_STEP_HIT_WALL;
|
||||
}
|
||||
}
|
||||
|
||||
return AIR_STEP_NONE;
|
||||
return bonk_or_hit_lava_wall(m, &lowerWall);
|
||||
}
|
||||
|
||||
void apply_twirl_gravity(struct MarioState *m) {
|
||||
@@ -550,7 +609,7 @@ void apply_gravity(struct MarioState *m) {
|
||||
m->vel[1] = -75.0f;
|
||||
}
|
||||
} else if (m->action == ACT_LONG_JUMP || m->action == ACT_SLIDE_KICK
|
||||
|| m->action == ACT_BBH_ENTER_SPIN) {
|
||||
|| m->action == ACT_BBH_ENTER_SPIN) {
|
||||
m->vel[1] -= 2.0f;
|
||||
if (m->vel[1] < -75.0f) {
|
||||
m->vel[1] = -75.0f;
|
||||
@@ -617,7 +676,9 @@ void apply_vertical_wind(struct MarioState *m) {
|
||||
}
|
||||
|
||||
s32 perform_air_step(struct MarioState *m, u32 stepArg) {
|
||||
// s16 wallDYaw;
|
||||
Vec3f intendedPos;
|
||||
const f32 numSteps = 4.0f; /* max(4.0f, (s32)(sqrtf(m->vel[0] * m->vel[0] + m->vel[1] * m->vel[1] + m->vel[2] * m->vel[2]) / 50.0f));*/
|
||||
s32 i;
|
||||
s32 quarterStepResult;
|
||||
s32 stepResult = AIR_STEP_NONE;
|
||||
@@ -625,16 +686,12 @@ s32 perform_air_step(struct MarioState *m, u32 stepArg) {
|
||||
m->wall = NULL;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
intendedPos[0] = m->pos[0] + m->vel[0] / 4.0f;
|
||||
intendedPos[1] = m->pos[1] + m->vel[1] / 4.0f;
|
||||
intendedPos[2] = m->pos[2] + m->vel[2] / 4.0f;
|
||||
intendedPos[0] = m->pos[0] + m->vel[0] / numSteps;
|
||||
intendedPos[1] = m->pos[1] + m->vel[1] / numSteps;
|
||||
intendedPos[2] = m->pos[2] + m->vel[2] / numSteps;
|
||||
|
||||
quarterStepResult = perform_air_quarter_step(m, intendedPos, stepArg);
|
||||
|
||||
//! On one qf, hit OOB/ceil/wall to store the 2 return value, and continue
|
||||
// getting 0s until your last qf. Graze a wall on your last qf, and it will
|
||||
// return the stored 2 with a sharply angled reference wall. (some gwks)
|
||||
|
||||
if (quarterStepResult != AIR_STEP_NONE) {
|
||||
stepResult = quarterStepResult;
|
||||
}
|
||||
@@ -660,6 +717,15 @@ s32 perform_air_step(struct MarioState *m, u32 stepArg) {
|
||||
vec3f_copy(m->marioObj->header.gfx.pos, m->pos);
|
||||
vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
|
||||
|
||||
/*if (stepResult == AIR_STEP_HIT_WALL && m->wall != NULL) {
|
||||
wallDYaw = atan2s(m->wall->normal.z, m->wall->normal.x) - m->faceAngle[1];
|
||||
if ((stepArg & AIR_STEP_CHECK_BONK) && (wallDYaw < -0x6000 || wallDYaw > 0x6000))
|
||||
{
|
||||
if (m->forwardVel > 16.0f)
|
||||
mario_bonk_reflection(m, (stepArg & AIR_STEP_BONK_NEGATE_SPEED), m->wall);
|
||||
}
|
||||
}*/
|
||||
|
||||
return stepResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -1446,6 +1446,7 @@ static void puppycam_script(void)
|
||||
//Handles collision detection using ray casting.
|
||||
static void puppycam_collision(void)
|
||||
{
|
||||
struct WallCollisionData wall0, wall1;
|
||||
struct Surface *surf[2];
|
||||
Vec3f camdir[2];
|
||||
Vec3f hitpos[2];
|
||||
@@ -1475,8 +1476,8 @@ static void puppycam_collision(void)
|
||||
|
||||
find_surface_on_ray(target[0], camdir[0], &surf[0], hitpos[0], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL);
|
||||
find_surface_on_ray(target[1], camdir[1], &surf[1], hitpos[1], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL);
|
||||
resolve_and_return_wall_collisions(hitpos[0], 0.0f, 25.0f);
|
||||
resolve_and_return_wall_collisions(hitpos[1], 0.0f, 25.0f);
|
||||
resolve_and_return_wall_collisions(hitpos[0], 0.0f, 25.0f, &wall0);
|
||||
resolve_and_return_wall_collisions(hitpos[1], 0.0f, 25.0f, &wall1);
|
||||
dist[0] = ((target[0][0] - hitpos[0][0]) * (target[0][0] - hitpos[0][0]) + (target[0][1] - hitpos[0][1]) * (target[0][1] - hitpos[0][1]) + (target[0][2] - hitpos[0][2]) * (target[0][2] - hitpos[0][2]));
|
||||
dist[1] = ((target[1][0] - hitpos[1][0]) * (target[1][0] - hitpos[1][0]) + (target[1][1] - hitpos[1][1]) * (target[1][1] - hitpos[1][1]) + (target[1][2] - hitpos[1][2]) * (target[1][2] - hitpos[1][2]));
|
||||
|
||||
|
||||
Reference in new issue
Block a user