diff --git a/source_files/edge/p_action.cc b/source_files/edge/p_action.cc index 59da58b1b..eb1278b5c 100644 --- a/source_files/edge/p_action.cc +++ b/source_files/edge/p_action.cc @@ -1081,9 +1081,6 @@ void A_TurnRandom(MapObject *mo) } - - - void A_MoveFwd(MapObject *mo) { const State *st = mo->state_; @@ -1095,8 +1092,7 @@ void A_MoveFwd(MapObject *mo) float dx = epi::BAMCos(mo->angle_); float dy = epi::BAMSin(mo->angle_); - mo->momentum_.X += dx * amount; - mo->momentum_.Y += dy * amount; + mo->AddMomentum(dx * amount, dy * amount, 0); } } @@ -1111,8 +1107,7 @@ void A_MoveRight(MapObject *mo) float dx = epi::BAMCos(mo->angle_ - kBAMAngle90); float dy = epi::BAMSin(mo->angle_ - kBAMAngle90); - mo->momentum_.X += dx * amount; - mo->momentum_.Y += dy * amount; + mo->AddMomentum(dx * amount, dy * amount, 0); } } @@ -1121,7 +1116,9 @@ void A_MoveUp(MapObject *mo) const State *st = mo->state_; if (st && st->action_par) - mo->momentum_.Z += *(float *)st->action_par; + { + mo->AddMomentum(0, 0, *(float *)st->action_par); + } } void A_StopMoving(MapObject *mo) diff --git a/source_files/edge/p_enemy.cc b/source_files/edge/p_enemy.cc index c1adfe84e..dbefb517a 100644 --- a/source_files/edge/p_enemy.cc +++ b/source_files/edge/p_enemy.cc @@ -44,6 +44,8 @@ #include "s_sound.h" #include "w_wad.h" +extern ConsoleVariable uncapped_frames; + DirectionType opposite[] = {kDirectionWest, kDirectionSouthwest, kDirectionSouth, kDirectionSoutheast, kDirectionEast, kDirectionNorthEast, kDirectionNorth, kDirectionNorthWest, kDirectionNone}; @@ -271,10 +273,17 @@ bool DoMove(MapObject *actor, bool path) // -AJA- 2008/01/16: position interpolation if ((actor->state_->flags & kStateFrameFlagModel) || (actor->flags_ & kMapObjectFlagFloat)) { - actor->interpolation_number_ = HMM_Clamp(2, actor->state_->tics, 10); - actor->interpolation_position_ = 1; + if (!uncapped_frames.d_ || actor->old_x_ != kInvalidPosition) + { + actor->interpolation_number_ = HMM_Clamp(2, actor->state_->tics, 10); + actor->interpolation_position_ = 1; - actor->interpolation_from_ = orig_pos; + actor->interpolation_from_ = orig_pos; + } + else + { + actor->interpolation_number_ = 0; + } } return true; @@ -517,8 +526,8 @@ bool LookForPlayers(MapObject *actor, BAMAngle range, bool ToSupport) actor->SetSupportObject(player->map_object_); else // target the player actor->SetTarget(player->map_object_); - - return true; + + return true; } diff --git a/source_files/edge/p_mobj.cc b/source_files/edge/p_mobj.cc index 943ac9c7a..96e090443 100644 --- a/source_files/edge/p_mobj.cc +++ b/source_files/edge/p_mobj.cc @@ -137,6 +137,28 @@ bool MapObject::IsRemoved() const return state_ == nullptr; } +bool MapObject::IsSpawning() +{ + if (!info_ || !info_->spawn_state_) + { + return false; + } + + return state_ == &states[info_->spawn_state_]; +} + +void MapObject::AddMomentum(float xm, float ym, float zm) +{ + momentum_.X += xm; + momentum_.Y += ym; + momentum_.Z += zm; + + if (IsSpawning()) + { + old_x_ = old_y_ = old_z_ = kInvalidPosition; + } +} + #if 1 // DEBUGGING void P_DumpMobjs(void) { @@ -1354,15 +1376,7 @@ static void P_MobjThinker(MapObject *mobj) if (!(mobj->player_ != NULL && mobj == mobj->player_->map_object_)) { - // Assume we can interpolate at the beginning - // of the tic unless mid-teleport - if (mobj->teleport_tic_) - { - mobj->teleport_tic_--; - mobj->interpolate_ = false; - } - else - mobj->interpolate_ = true; + mobj->interpolate_ = mobj->old_x_ == kInvalidPosition ? false : true; // Store starting position for mobj interpolation. mobj->old_x_ = mobj->x; diff --git a/source_files/edge/p_mobj.h b/source_files/edge/p_mobj.h index 2f38481fe..19df80429 100644 --- a/source_files/edge/p_mobj.h +++ b/source_files/edge/p_mobj.h @@ -175,6 +175,8 @@ struct DynamicLightState bool bad_wall_glow = false; }; +constexpr float kInvalidPosition = -999999.0f; + // Map Object definition. struct Position { @@ -378,8 +380,6 @@ class MapObject : public Position bool slope_sight_hit_ = false; - int teleport_tic_ = 0; - // Uncapped test - Dasho bool interpolate_ = false; @@ -394,6 +394,10 @@ class MapObject : public Position void SetBelowObject(MapObject *ref); void SetRealSource(MapObject *ref); + bool IsSpawning(); + + void AddMomentum(float xm, float ym, float zm); + void ClearStaleReferences(); // Stores what this mobj was before being MORPHed/BECOMEing diff --git a/source_files/edge/p_telept.cc b/source_files/edge/p_telept.cc index 4de2470ca..067b32c20 100644 --- a/source_files/edge/p_telept.cc +++ b/source_files/edge/p_telept.cc @@ -256,7 +256,9 @@ bool TeleportMapObject(Line *line, int tag, MapObject *thing, const TeleportDefi player->delta_view_height_ = 0; } else - thing->teleport_tic_ = 18; + { + thing->old_x_ = thing->old_y_ = thing->old_z_ = kInvalidPosition; + } /* --- Momentum handling --- */ diff --git a/source_files/edge/r_things.cc b/source_files/edge/r_things.cc index ba5dd1c0e..2b5726d7f 100644 --- a/source_files/edge/r_things.cc +++ b/source_files/edge/r_things.cc @@ -843,10 +843,6 @@ void BSPWalkThing(DrawSubsector *dsub, MapObject *mo) if (AlmostEquals(mo->visibility_, 0.0f)) return; - // ignore things that are mid-teleport - if (mo->teleport_tic_ > 0) - return; - bool is_model = (mo->state_->flags & kStateFrameFlagModel) ? true : false; // transform the origin point @@ -868,6 +864,7 @@ void BSPWalkThing(DrawSubsector *dsub, MapObject *mo) fz = mo->floor_z_; } + // This applies to kStateFrameFlagModel and kMapObjectFlagFloat if (mo->interpolation_number_ > 1) { float along = mo->interpolation_position_ / (float)mo->interpolation_number_;