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:
|
73 | 73 | bool m_RelativeToGround; // whether m_YOffset is relative to terrain/water plane, or an absolute height |
74 | 74 | |
75 | 75 | entity_angle_t m_RotX, m_RotY, m_RotZ; |
76 | | float m_InterpolatedRotY; // not serialized |
| 76 | float m_InterpolatedRotY, m_PrevInterpolatedRotY; // not serialized |
77 | 77 | |
78 | 78 | static std::string GetSchema() |
79 | 79 | { |
… |
… |
public:
|
122 | 122 | m_RotYSpeed = paramNode.GetChild("TurnRate").ToFixed().ToFloat(); |
123 | 123 | |
124 | 124 | m_RotX = m_RotY = m_RotZ = entity_angle_t::FromInt(0); |
125 | | m_InterpolatedRotY = 0; |
| 125 | m_InterpolatedRotY = m_PrevInterpolatedRotY = 0; |
126 | 126 | } |
127 | 127 | |
128 | 128 | virtual void Deinit() |
… |
… |
public:
|
328 | 328 | { |
329 | 329 | m_RotY = y; |
330 | 330 | m_InterpolatedRotY = m_RotY.ToFloat(); |
| 331 | m_PrevInterpolatedRotY = m_InterpolatedRotY; |
331 | 332 | |
332 | 333 | AdvertisePositionChanges(); |
333 | 334 | } |
… |
… |
public:
|
442 | 443 | m_LastX = m_X; |
443 | 444 | m_LastZ = m_Z; |
444 | 445 | |
| 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 | |
445 | 453 | break; |
446 | 454 | } |
447 | 455 | } |