Explorar el Código

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 hace 13 años
padre
commit
bb8d2437fa
Se han modificado 2 ficheros con 21 adiciones y 0 borrados
  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 "Octree.h"
 #include "Scene.h"
+#include "SceneEvents.h"
 #include "Sort.h"
 #include "WorkQueue.h"
 
@@ -386,6 +387,19 @@ void Octree::Resize(const BoundingBox& box, unsigned numLevels)
 void Octree::Update(const FrameInfo& 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);
 }
 

+ 7 - 0
Engine/Scene/SceneEvents.h

@@ -49,6 +49,13 @@ EVENT(E_UPDATESMOOTHING, UpdateSmoothing)
     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.
 EVENT(E_TARGETPOSITION, TargetPositionChanged)
 {