Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2014-04-07 03:30:59 +0400
committerMitchell Stokes <mogurijin@gmail.com>2014-04-07 03:30:59 +0400
commitfe05f97841c0ee3e2a6e15f2252ad160fefc3509 (patch)
tree2a672e5d82448f43471ddb529a95fa547d5c311e /source/gameengine/Converter/BL_ShapeDeformer.cpp
parentbe8b4b8b0c4d4fdeed6ebf88d8a3bd480e4c48ce (diff)
BGE: Multi-threading animation updates and skinning.
This required BL_ArmatureObject to have tighter control over armatures and poses. Also, (Blender) armature objects are now copied instead of shared between BL_ArmatureObjects to avoid race conditions. Also, due to the armature copy, shape key drivers need a bit of extra fiddling to get the correct armature copy. Initially OpenMP was used for threading, but then BLI_task was used due to being less compiler dependent. This commit also places time spent on skinning updates in the Animation profiler category (was previously under the Rasterizer category).
Diffstat (limited to 'source/gameengine/Converter/BL_ShapeDeformer.cpp')
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp
index ca5b26079b1..43f719d80c4 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.cpp
+++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp
@@ -51,6 +51,7 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_key.h"
+#include "BKE_fcurve.h"
#include "BKE_ipo.h"
#include "BKE_library.h"
#include "MT_Point3.h"
@@ -119,8 +120,29 @@ void BL_ShapeDeformer::ProcessReplica()
m_key = BKE_key_copy(m_key);
}
-bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
+bool BL_ShapeDeformer::LoadShapeDrivers(KX_GameObject* parent)
{
+ // Fix drivers since BL_ArmatureObject makes copies
+ if (parent->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
+ BL_ArmatureObject *arma = (BL_ArmatureObject*)parent;
+ FCurve *fcu;
+
+ for (fcu = (FCurve*)GetKey()->adt->drivers.first; fcu; fcu = (FCurve*)fcu->next) {
+
+ DriverVar *dvar;
+ for (dvar = (DriverVar*)fcu->driver->variables.first; dvar; dvar = (DriverVar*)dvar->next) {
+ DRIVER_TARGETS_USED_LOOPER(dvar)
+ {
+ if (dtar->id) {
+ if ((Object*)dtar->id == arma->GetOrigArmatureObject())
+ dtar->id = (ID*)arma->GetArmatureObject();
+ }
+ }
+ DRIVER_TARGETS_LOOPER_END
+ }
+ }
+ }
+
// This used to check if we had drivers from this armature,
// now we just assume we want to use shape drivers
// and let the animsys handle things.
@@ -132,15 +154,10 @@ bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
bool BL_ShapeDeformer::ExecuteShapeDrivers(void)
{
if (m_useShapeDrivers && PoseUpdated()) {
- // the shape drivers use the bone matrix as input. Must
- // update the matrix now
- m_armobj->ApplyPose();
-
// We don't need an actual time, just use 0
BKE_animsys_evaluate_animdata(NULL, &GetKey()->id, GetKey()->adt, 0.f, ADT_RECALC_DRIVERS);
ForceUpdate();
- m_armobj->RestorePose();
m_bDynamic = true;
return true;
}