From 6265be4dbcd84e3f1db3b7f748c945b0924dbc76 Mon Sep 17 00:00:00 2001
From: "Sven (Sbte)" <svenb.linux@gmail.com>
Date: Sun, 24 Feb 2013 15:59:54 +0100
Subject: Don't reinterpolate if the position of a component does not change
---
source/simulation2/components/CCmpPosition.cpp | 5 +++++
source/simulation2/components/CCmpVisualActor.cpp | 5 +++++
source/simulation2/components/ICmpPosition.cpp | 1 +
source/simulation2/components/ICmpPosition.h | 2 ++
source/simulation2/components/tests/test_RangeManager.h | 1 +
source/simulation2/system/ComponentManager.cpp | 1 +
6 files changed, 15 insertions(+)
diff --git a/source/simulation2/components/CCmpPosition.cpp b/source/simulation2/components/CCmpPosition.cpp
index 80c72d9..04f2e09 100644
a
|
b
|
public:
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
| 462 | virtual bool GetReinterpolate() |
| 463 | { |
| 464 | return (m_LastX != m_X && m_LastZ != m_Z); |
| 465 | } |
| 466 | |
462 | 467 | private: |
463 | 468 | void AdvertisePositionChanges() |
464 | 469 | { |
diff --git a/source/simulation2/components/CCmpVisualActor.cpp b/source/simulation2/components/CCmpVisualActor.cpp
index 376ddbb..d5fb6cd 100644
a
|
b
|
void CCmpVisualActor::Interpolate(float frameTime, float frameOffset)
|
728 | 728 | CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), GetEntityId()); |
729 | 729 | if (!cmpPosition || !cmpPosition->IsInWorld()) |
730 | 730 | return; |
| 731 | else if (!cmpPosition->GetReinterpolate() && m_PreviouslyRendered) |
| 732 | { |
| 733 | m_Unit->UpdateModel(frameTime); |
| 734 | return; |
| 735 | } |
731 | 736 | else if (!m_PreviouslyRendered) |
732 | 737 | { |
733 | 738 | UpdateVisibility(); |
diff --git a/source/simulation2/components/ICmpPosition.cpp b/source/simulation2/components/ICmpPosition.cpp
index 9aaeecc..4b73667 100644
a
|
b
|
DEFINE_INTERFACE_METHOD_1("TurnTo", void, ICmpPosition, TurnTo, entity_angle_t)
|
38 | 38 | DEFINE_INTERFACE_METHOD_1("SetYRotation", void, ICmpPosition, SetYRotation, entity_angle_t) |
39 | 39 | DEFINE_INTERFACE_METHOD_2("SetXZRotation", void, ICmpPosition, SetXZRotation, entity_angle_t, entity_angle_t) |
40 | 40 | DEFINE_INTERFACE_METHOD_0("GetRotation", CFixedVector3D, ICmpPosition, GetRotation) |
| 41 | DEFINE_INTERFACE_METHOD_0("GetReinterpolate", bool, ICmpPosition, GetReinterpolate) |
41 | 42 | // Excluded: GetInterpolatedTransform (not safe for scripts) |
42 | 43 | END_INTERFACE_WRAPPER(Position) |
diff --git a/source/simulation2/components/ICmpPosition.h b/source/simulation2/components/ICmpPosition.h
index 3e454ce..39c9a0e 100644
a
|
b
|
public:
|
168 | 168 | */ |
169 | 169 | virtual CMatrix3D GetInterpolatedTransform(float frameOffset, bool forceFloating) = 0; |
170 | 170 | |
| 171 | virtual bool GetReinterpolate() = 0; |
| 172 | |
171 | 173 | DECLARE_INTERFACE_TYPE(Position) |
172 | 174 | }; |
173 | 175 | |
diff --git a/source/simulation2/components/tests/test_RangeManager.h b/source/simulation2/components/tests/test_RangeManager.h
index cf2ee71..f8328dc 100644
a
|
b
|
public:
|
59 | 59 | virtual fixed GetDistanceTravelled() { return fixed::Zero(); } |
60 | 60 | virtual void GetInterpolatedPosition2D(float UNUSED(frameOffset), float& x, float& z, float& rotY) { x = z = rotY = 0; } |
61 | 61 | virtual CMatrix3D GetInterpolatedTransform(float UNUSED(frameOffset), bool UNUSED(forceFloating)) { return CMatrix3D(); } |
| 62 | virtual bool GetReinterpolate() { return true; } |
62 | 63 | }; |
63 | 64 | |
64 | 65 | class TestCmpRangeManager : public CxxTest::TestSuite |
diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp
index 2105d37..f0aca7b 100644
a
|
b
|
void CComponentManager::PostMessage(entity_id_t ent, const CMessage& msg) const
|
813 | 813 | |
814 | 814 | void CComponentManager::BroadcastMessage(const CMessage& msg) const |
815 | 815 | { |
| 816 | PROFILE("BroadcastMessage"); |
816 | 817 | // Send the message to components of all entities that subscribed locally to this message |
817 | 818 | std::map<MessageTypeId, std::vector<ComponentTypeId> >::const_iterator it; |
818 | 819 | it = m_LocalMessageSubscriptions.find(msg.GetType()); |