Browse Source

Ignore network update when update animations.

aster2013 11 years ago
parent
commit
dcbd1a3d7c

+ 5 - 2
Source/Engine/Scene/Component.cpp

@@ -37,7 +37,8 @@ Component::Component(Context* context) :
     node_(0),
     id_(0),
     networkUpdate_(false),
-    enabled_(true)
+    enabled_(true),
+    ignoreNetworkUpdate_(false)
 {
 }
 
@@ -184,7 +185,7 @@ void Component::CleanupConnection(Connection* connection)
 
 void Component::MarkNetworkUpdate()
 {
-    if (!networkUpdate_ && id_ < FIRST_LOCAL_ID)
+    if (!ignoreNetworkUpdate_ &&  !networkUpdate_ && id_ < FIRST_LOCAL_ID)
     {
         Scene* scene = GetScene();
         if (scene)
@@ -240,6 +241,8 @@ void Component::HandleScenePostUpdate(StringHash eventType, VariantMap& eventDat
 {
     using namespace ScenePostUpdate;
 
+    ignoreNetworkUpdate_ = true;
     UpdateAttributeAnimations(eventData[P_TIMESTEP].GetFloat());
+    ignoreNetworkUpdate_ = false;
 }
 }

+ 2 - 0
Source/Engine/Scene/Component.h

@@ -120,6 +120,8 @@ protected:
     bool networkUpdate_;
     /// Enabled flag.
     bool enabled_;
+    /// Ignore network update.
+    bool ignoreNetworkUpdate_;
 };
 
 template <class T> T* Component::GetComponent() const { return static_cast<T*>(GetComponent(T::GetTypeStatic())); }

+ 6 - 3
Source/Engine/Scene/Node.cpp

@@ -52,7 +52,8 @@ Node::Node(Context* context) :
     rotation_(Quaternion::IDENTITY),
     scale_(Vector3::ONE),
     worldRotation_(Quaternion::IDENTITY),
-    owner_(0)
+    owner_(0),
+    ignoreNetworkUpdate_(false)
 {
 }
 
@@ -1332,7 +1333,7 @@ void Node::CleanupConnection(Connection* connection)
 
 void Node::MarkNetworkUpdate()
 {
-    if (!networkUpdate_ && scene_ && id_ < FIRST_LOCAL_ID)
+    if (!ignoreNetworkUpdate_ && !networkUpdate_ && scene_ && id_ < FIRST_LOCAL_ID)
     {
         scene_->MarkNetworkUpdate(this);
         networkUpdate_ = true;
@@ -1653,8 +1654,10 @@ void Node::RemoveComponent(Vector<SharedPtr<Component> >::Iterator i)
 void Node::HandleScenePostUpdate(StringHash eventType, VariantMap& eventData)
 {
     using namespace ScenePostUpdate;
-
+    
+    ignoreNetworkUpdate_ = true;
     UpdateAttributeAnimations(eventData[P_TIMESTEP].GetFloat());
+    ignoreNetworkUpdate_ = false;
 }
 
 }

+ 2 - 0
Source/Engine/Scene/Node.h

@@ -449,6 +449,8 @@ private:
     StringHash nameHash_;
     /// Attribute buffer for network updates.
     mutable VectorBuffer attrBuffer_;
+    /// Ignore network update.
+    bool ignoreNetworkUpdate_;
 };
 
 template <class T> T* Node::CreateComponent(CreateMode mode, unsigned id) { return static_cast<T*>(CreateComponent(T::GetTypeStatic(), mode, id)); }