Ticket #1906: 0001-Reinterpolate-when-rotation-is-not-done-after-one-tu.patch

File 0001-Reinterpolate-when-rotation-is-not-done-after-one-tu.patch, 1.8 KB (added by sbte, 11 years ago)
  • source/simulation2/components/CCmpPosition.cpp

    From dbf0ae763aadec5e973079bfafc5d8e3b85b23ae Mon Sep 17 00:00:00 2001
    From: "Sven (Sbte)" <svenb.linux@gmail.com>
    Date: Thu, 11 Apr 2013 21:35:00 +0200
    Subject: Reinterpolate when rotation is not done after one turn
    
    ---
     source/simulation2/components/CCmpPosition.cpp | 12 ++++++++++--
     1 file changed, 10 insertions(+), 2 deletions(-)
    
    diff --git a/source/simulation2/components/CCmpPosition.cpp b/source/simulation2/components/CCmpPosition.cpp
    index 57fcb1b..5f836c5 100644
    a b public:  
    7373    bool m_RelativeToGround; // whether m_YOffset is relative to terrain/water plane, or an absolute height
    7474
    7575    entity_angle_t m_RotX, m_RotY, m_RotZ;
    76     float m_InterpolatedRotY; // not serialized
     76    float m_InterpolatedRotY, m_PrevInterpolatedRotY; // not serialized
    7777
    7878    static std::string GetSchema()
    7979    {
    public:  
    122122        m_RotYSpeed = paramNode.GetChild("TurnRate").ToFixed().ToFloat();
    123123
    124124        m_RotX = m_RotY = m_RotZ = entity_angle_t::FromInt(0);
    125         m_InterpolatedRotY = 0;
     125        m_InterpolatedRotY = m_PrevInterpolatedRotY = 0;
    126126    }
    127127
    128128    virtual void Deinit()
    public:  
    328328    {
    329329        m_RotY = y;
    330330        m_InterpolatedRotY = m_RotY.ToFloat();
     331        m_PrevInterpolatedRotY = m_InterpolatedRotY;
    331332
    332333        AdvertisePositionChanges();
    333334    }
    public:  
    442443            m_LastX = m_X;
    443444            m_LastZ = m_Z;
    444445
     446            // Rotation interpolation can take a long time, so advertise position
     447            // changes again to force recomputation of the transformation matrix
     448            // if the rotation was not done yet.
     449            if (fabs(m_PrevInterpolatedRotY - m_InterpolatedRotY) > 0.01)
     450                AdvertisePositionChanges();
     451            m_PrevInterpolatedRotY = m_InterpolatedRotY;
     452
    445453            break;
    446454        }
    447455        }