From 3bb0ee69a17354e9b807bb6d2c1d74f680bea20d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 3 Oct 2022 22:28:37 +0200 Subject: [PATCH] - initialize SOP angles to 0. The memset to -1 turns them into NANs. --- source/games/sw/src/sector.cpp | 4 ++++ source/games/sw/src/track.cpp | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index ff5afe4b3..21de6de33 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -380,6 +380,10 @@ void SectorSetup(void) SectorObject[ndx].op_main_sector = nullptr; SectorObject[ndx].morph_wall_point = nullptr; SectorObject[ndx].pmid.X = MAXSO; + SectorObject[ndx].ang = SectorObject[ndx].ang_moving = SectorObject[ndx].ang_tgt = + SectorObject[ndx].ang_orig = SectorObject[ndx].last_ang = SectorObject[ndx].old_ang = + SectorObject[ndx].spin_speed = SectorObject[ndx].save_spin_speed = SectorObject[ndx].spin_ang = nullAngle; + } memset(SineWaveFloor, 0, sizeof(SineWaveFloor)); diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index f757d373c..79be6b2b7 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -1754,7 +1754,8 @@ PlayerPart: void RefreshPoints(SECTOR_OBJECT* sop, const DVector2& move, bool dynamic) { - short wallcount = 0, delta_ang_from_orig; + short wallcount = 0; + DAngle delta_ang_from_orig; // do scaling if (dynamic && sop->PreMoveAnimator) @@ -1811,23 +1812,23 @@ void RefreshPoints(SECTOR_OBJECT* sop, const DVector2& move, bool dynamic) } } - if (sop->int_i_spin_speed()) + if (sop->spin_speed != nullAngle) { // same as below - ignore the objects angle // last_ang is the last true angle before SO started spinning - delta_ang_from_orig = NORM_ANGLE(sop->int_i_last_ang() + sop->int_i_spin_ang() - sop->int_i_ang_orig()); + delta_ang_from_orig = (sop->last_ang + sop->spin_ang - sop->ang_orig).Normalized360(); } else { // angle traveling + the new spin angle all offset from the original // angle - delta_ang_from_orig = NORM_ANGLE(sop->int_i_ang() + sop->int_i_spin_ang() - sop->int_i_ang_orig()); + delta_ang_from_orig = (sop->ang + sop->spin_ang - sop->ang_orig).Normalized360(); } // Note that this delta angle is from the original angle // nx,ny are 0 so the points are not moved, just rotated - MovePoints(sop, DAngle::fromBuild(delta_ang_from_orig), move); + MovePoints(sop, delta_ang_from_orig, move); // do morphing - angle independent if (dynamic && sop->PostMoveAnimator)