Browse Source

Add scene attribute animation update event.

aster2013 11 years ago
parent
commit
f9107d4fed

+ 4 - 4
Source/Engine/Scene/Component.cpp

@@ -202,13 +202,13 @@ void Component::MarkNetworkUpdate()
 void Component::OnAttributeAnimationAdded()
 {
     if (attributeAnimationInstances_.Size() == 1)
-        SubscribeToEvent(GetScene(), E_SCENEPOSTUPDATE, HANDLER(Component, HandleScenePostUpdate));        
+        SubscribeToEvent(GetScene(), E_ATTRIBUTEANIMATIONUPDATE, HANDLER(Component, HandleAttributeAnimationUpdate));        
 }
 
 void Component::OnAttributeAnimationRemoved()
 {
     if (attributeAnimationInstances_.Empty())
-        UnsubscribeFromEvent(GetScene(), E_SCENEPOSTUPDATE);
+        UnsubscribeFromEvent(GetScene(), E_ATTRIBUTEANIMATIONUPDATE);
 }
 
 void Component::SetID(unsigned id)
@@ -240,9 +240,9 @@ void Component::GetComponents(PODVector<Component*>& dest, ShortStringHash type)
         dest.Clear();
 }
 
-void Component::HandleScenePostUpdate(StringHash eventType, VariantMap& eventData)
+void Component::HandleAttributeAnimationUpdate(StringHash eventType, VariantMap& eventData)
 {
-    using namespace ScenePostUpdate;
+    using namespace AttributeAnimationUpdate;
 
     UpdateAttributeAnimations(eventData[P_TIMESTEP].GetFloat());
 }

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

@@ -109,8 +109,8 @@ protected:
     void SetID(unsigned id);
     /// Set scene node. Called by Node when creating the component.
     void SetNode(Node* node);
-    /// Handle scene post-update event.
-    void HandleScenePostUpdate(StringHash eventType, VariantMap& eventData);
+    /// Handle scene attribute animation update event.
+    void HandleAttributeAnimationUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene node.
     Node* node_;

+ 5 - 5
Source/Engine/Scene/Node.cpp

@@ -1454,13 +1454,13 @@ unsigned Node::GetNumPersistentComponents() const
 void Node::OnAttributeAnimationAdded()
 {
     if (attributeAnimationInstances_.Size() == 1)
-        SubscribeToEvent(GetScene(), E_SCENEPOSTUPDATE, HANDLER(Node, HandleScenePostUpdate));        
+        SubscribeToEvent(GetScene(), E_ATTRIBUTEANIMATIONUPDATE, HANDLER(Node, HandleAttributeAnimationUpdate));        
 }
 
 void Node::OnAttributeAnimationRemoved()
 {
     if (attributeAnimationInstances_.Empty())
-        UnsubscribeFromEvent(GetScene(), E_SCENEPOSTUPDATE);
+        UnsubscribeFromEvent(GetScene(), E_ATTRIBUTEANIMATIONUPDATE);
 }
 
 Component* Node::SafeCreateComponent(const String& typeName, ShortStringHash type, CreateMode mode, unsigned id)
@@ -1635,10 +1635,10 @@ void Node::RemoveComponent(Vector<SharedPtr<Component> >::Iterator i)
         componentWeak->SetNode(0);
 }
 
-void Node::HandleScenePostUpdate(StringHash eventType, VariantMap& eventData)
+void Node::HandleAttributeAnimationUpdate(StringHash eventType, VariantMap& eventData)
 {
-    using namespace ScenePostUpdate;
-    
+    using namespace AttributeAnimationUpdate;
+
     UpdateAttributeAnimations(eventData[P_TIMESTEP].GetFloat());
 }
 

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

@@ -404,8 +404,8 @@ private:
     Node* CloneRecursive(Node* parent, SceneResolver& resolver, CreateMode mode);
     /// Remove a component from this node with the specified iterator.
     void RemoveComponent(Vector<SharedPtr<Component> >::Iterator i);
-    /// Handle scene post-update event.
-    void HandleScenePostUpdate(StringHash eventType, VariantMap& eventData);
+    /// Handle attribute animation update event.
+    void HandleAttributeAnimationUpdate(StringHash eventType, VariantMap& eventData);
 
     /// World-space transform matrix.
     mutable Matrix3x4 worldTransform_;

+ 3 - 0
Source/Engine/Scene/Scene.cpp

@@ -538,6 +538,9 @@ void Scene::Update(float timeStep)
     // Update variable timestep logic
     SendEvent(E_SCENEUPDATE, eventData);
 
+    // Update scene attribute animation.
+    SendEvent(E_ATTRIBUTEANIMATIONUPDATE, eventData);
+
     // Update scene subsystems. If a physics world is present, it will be updated, triggering fixed timestep logic updates
     SendEvent(E_SCENESUBSYSTEMUPDATE, eventData);
 

+ 7 - 0
Source/Engine/Scene/SceneEvents.h

@@ -65,6 +65,13 @@ EVENT(E_TARGETROTATION, TargetRotationChanged)
 {
 }
 
+/// Scene attribute animation update.
+EVENT(E_ATTRIBUTEANIMATIONUPDATE, AttributeAnimationUpdate)
+{
+    PARAM(P_SCENE, Scene);                  // Scene pointer
+    PARAM(P_TIMESTEP, TimeStep);            // float
+}
+
 /// Variable timestep scene post-update.
 EVENT(E_SCENEPOSTUPDATE, ScenePostUpdate)
 {