浏览代码

Send a per-scene event when the threaded drawable update is done. This can be used for per-scene custom animation (eg. IK) instead of using the global PostRenderUpdate event. Furthermore this event is sent before nodes are reinserted to octree, so it is potentially more correct.

Lasse Öörni 13 年之前
父节点
当前提交
bb8d2437fa
共有 2 个文件被更改,包括 21 次插入0 次删除
  1. 14 0
      Engine/Graphics/Octree.cpp
  2. 7 0
      Engine/Scene/SceneEvents.h

+ 14 - 0
Engine/Graphics/Octree.cpp

@@ -27,6 +27,7 @@
 #include "Profiler.h"
 #include "Profiler.h"
 #include "Octree.h"
 #include "Octree.h"
 #include "Scene.h"
 #include "Scene.h"
+#include "SceneEvents.h"
 #include "Sort.h"
 #include "Sort.h"
 #include "WorkQueue.h"
 #include "WorkQueue.h"
 
 
@@ -386,6 +387,19 @@ void Octree::Resize(const BoundingBox& box, unsigned numLevels)
 void Octree::Update(const FrameInfo& frame)
 void Octree::Update(const FrameInfo& frame)
 {
 {
     UpdateDrawables(frame);
     UpdateDrawables(frame);
+    
+    // Notify drawable update being finished. Custom animation (eg. IK) can be done at this point
+    Scene* scene = GetScene();
+    if (scene)
+    {
+        using namespace SceneDrawableUpdateFinished;
+        
+        VariantMap eventData;
+        eventData[P_SCENE] = (void*)scene;
+        eventData[P_TIMESTEP] = frame.timeStep_;
+        scene->SendEvent(E_SCENEDRAWABLEUPDATEFINISHED, eventData);
+    }
+    
     ReinsertDrawables(frame);
     ReinsertDrawables(frame);
 }
 }
 
 

+ 7 - 0
Engine/Scene/SceneEvents.h

@@ -49,6 +49,13 @@ EVENT(E_UPDATESMOOTHING, UpdateSmoothing)
     PARAM(P_SQUAREDSNAPTHRESHOLD, SquaredSnapThreshold);  // float
     PARAM(P_SQUAREDSNAPTHRESHOLD, SquaredSnapThreshold);  // float
 }
 }
 
 
+/// Scene drawable update finished. Custom animation (eg. IK) can be done at this point.
+EVENT(E_SCENEDRAWABLEUPDATEFINISHED, SceneDrawableUpdateFinished)
+{
+    PARAM(P_SCENE, Scene);                  // Scene pointer
+    PARAM(P_TIMESTEP, TimeStep);            // float
+}
+
 /// SmoothedTransform target position changed.
 /// SmoothedTransform target position changed.
 EVENT(E_TARGETPOSITION, TargetPositionChanged)
 EVENT(E_TARGETPOSITION, TargetPositionChanged)
 {
 {