Skip to content

Commit

Permalink
Add instant plane mover interpolation check
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Nov 7, 2024
1 parent 966969a commit 0beb6fe
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions source_files/edge/p_plane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ static bool MovePlane(PlaneMover *plane)

Sector *sec = plane->sector;

// track if move went from start to dest in one move; if so
// do not interpolate the sector height
bool maybe_instant = false;

if (plane->is_ceiling || plane->is_elevator)
sec->old_ceiling_height = sec->ceiling_height;
if (!plane->is_ceiling)
Expand All @@ -336,9 +340,34 @@ static bool MovePlane(PlaneMover *plane)
break;

case kPlaneDirectionDown:
if (plane->is_ceiling || plane->is_elevator)
{
if (AlmostEquals(plane->start_height, sec->ceiling_height))
maybe_instant = true;
}
if (!plane->is_ceiling)
{
if (AlmostEquals(plane->start_height, sec->floor_height))
maybe_instant = true;
}

res = AttemptMoveSector(sec, plane, HMM_MIN(plane->start_height, plane->destination_height),
plane->is_ceiling ? plane->crush : 0);

if (maybe_instant)
{
if (plane->is_ceiling || plane->is_elevator)
{
if (AlmostEquals(plane->destination_height, sec->ceiling_height))
sec->old_ceiling_height = sec->ceiling_height;
}
if (!plane->is_ceiling)
{
if (AlmostEquals(plane->destination_height, sec->floor_height))
sec->old_floor_height = sec->floor_height;
}
}

if (!AlmostEquals(plane->destination_height, plane->start_height))
{
MakeMovingSound(&plane->sound_effect_started, plane->type->sfxdown_, &sec->sound_effects_origin);
Expand Down Expand Up @@ -445,9 +474,35 @@ static bool MovePlane(PlaneMover *plane)
break;

case kPlaneDirectionUp:
if (plane->is_ceiling || plane->is_elevator)
{
if (AlmostEquals(plane->start_height, sec->ceiling_height))
maybe_instant = true;
}
if (!plane->is_ceiling)
{
if (AlmostEquals(plane->start_height, sec->floor_height))
maybe_instant = true;
}


res = AttemptMoveSector(sec, plane, HMM_MAX(plane->start_height, plane->destination_height),
plane->is_ceiling ? 0 : plane->crush);

if (maybe_instant)
{
if (plane->is_ceiling || plane->is_elevator)
{
if (AlmostEquals(plane->destination_height, sec->ceiling_height))
sec->old_ceiling_height = sec->ceiling_height;
}
if (!plane->is_ceiling)
{
if (AlmostEquals(plane->destination_height, sec->floor_height))
sec->old_floor_height = sec->floor_height;
}
}

if (!AlmostEquals(plane->destination_height, plane->start_height))
{
MakeMovingSound(&plane->sound_effect_started, plane->type->sfxup_, &sec->sound_effects_origin);
Expand Down

0 comments on commit 0beb6fe

Please sign in to comment.