From 2c3b57145a94ec5f8deb1c19822cc84d0b20605c Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 31 May 2012 03:40:28 +0000 Subject: [PATCH] - When scrolling rotated floors and ceilings, scroll as if the texture was unrotated. (That is, keep the scroll direction constant, no matter what the rotation.) SVN r3669 (trunk) --- src/p_spec.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 6b2f886a0..e27e49df0 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1461,9 +1461,29 @@ void P_SpawnSpecials (void) // This is the main scrolling code // killough 3/7/98 +// [RH] Compensate for rotated sector textures by rotating the scrolling +// in the opposite direction. +static void RotationComp(const sector_t *sec, int which, fixed_t dx, fixed_t dy, fixed_t &tdx, fixed_t &tdy) +{ + angle_t an = sec->GetAngle(which); + if (an == 0) + { + tdx = dx; + tdy = dy; + } + else + { + an = an >> ANGLETOFINESHIFT; + fixed_t ca = -finecosine[an]; + fixed_t sa = -finesine[an]; + tdx = DMulScale16(dx, ca, -dy, sa); + tdy = DMulScale16(dy, ca, dx, sa); + } +} + void DScroller::Tick () { - fixed_t dx = m_dx, dy = m_dy; + fixed_t dx = m_dx, dy = m_dy, tdx, tdy; if (m_Control != -1) { // compute scroll amounts based on a sector's height changes @@ -1507,13 +1527,15 @@ void DScroller::Tick () break; case sc_floor: // killough 3/7/98: Scroll floor texture - sectors[m_Affectee].AddXOffset(sector_t::floor, dx); - sectors[m_Affectee].AddYOffset(sector_t::floor, dy); + RotationComp(§ors[m_Affectee], sector_t::floor, dx, dy, tdx, tdy); + sectors[m_Affectee].AddXOffset(sector_t::floor, tdx); + sectors[m_Affectee].AddYOffset(sector_t::floor, tdy); break; case sc_ceiling: // killough 3/7/98: Scroll ceiling texture - sectors[m_Affectee].AddXOffset(sector_t::ceiling, dx); - sectors[m_Affectee].AddYOffset(sector_t::ceiling, dy); + RotationComp(§ors[m_Affectee], sector_t::ceiling, dx, dy, tdx, tdy); + sectors[m_Affectee].AddXOffset(sector_t::ceiling, tdx); + sectors[m_Affectee].AddYOffset(sector_t::ceiling, tdy); break; // [RH] Don't actually carry anything here. That happens later.