diff --git a/source/simulation2/components/CCmpPosition.cpp b/source/simulation2/components/CCmpPosition.cpp index 57fcb1b394..f9ee21cf73 100644 --- a/source/simulation2/components/CCmpPosition.cpp +++ b/source/simulation2/components/CCmpPosition.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2013 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -73,7 +73,7 @@ public: bool m_RelativeToGround; // whether m_YOffset is relative to terrain/water plane, or an absolute height entity_angle_t m_RotX, m_RotY, m_RotZ; - float m_InterpolatedRotY; // not serialized + float m_InterpolatedRotY, m_PrevInterpolatedRotY; // not serialized static std::string GetSchema() { @@ -122,7 +122,7 @@ public: m_RotYSpeed = paramNode.GetChild("TurnRate").ToFixed().ToFloat(); m_RotX = m_RotY = m_RotZ = entity_angle_t::FromInt(0); - m_InterpolatedRotY = 0; + m_InterpolatedRotY = m_PrevInterpolatedRotY = 0; } virtual void Deinit() @@ -328,6 +328,7 @@ public: { m_RotY = y; m_InterpolatedRotY = m_RotY.ToFloat(); + m_PrevInterpolatedRotY = m_InterpolatedRotY; AdvertisePositionChanges(); } @@ -442,6 +443,13 @@ public: m_LastX = m_X; m_LastZ = m_Z; + // HACK: Rotation interpolation can take a long time, so advertise position + // changes again to force recomputation of the transformation matrix + // if the rotation was not done yet. + if (fabs(m_PrevInterpolatedRotY - m_InterpolatedRotY) > 0.001f) + AdvertisePositionChanges(); + m_PrevInterpolatedRotY = m_InterpolatedRotY; + break; } }