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>2013-07-10 00:50:15 +0400
committerMitchell Stokes <mogurijin@gmail.com>2013-07-10 00:50:15 +0400
commit19dee5e413453cc4a2a98c17aaf39f00e04f7619 (patch)
treeb4bae82512c48c2116c800e0785407c60468403c /source/gameengine/Ketsji/KX_Scene.cpp
parent83e9f32382810437bf113fee3b5c32881d7e67ec (diff)
BGE: Adding animation culling. Armature objects will only have their poses updated if their children meshes have not already been culled. Regular object animations will always be updated since they are cheap.
Diffstat (limited to 'source/gameengine/Ketsji/KX_Scene.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index c12fda8912e..35084061ab0 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -1578,9 +1578,37 @@ void KX_Scene::AddAnimatedObject(CValue* gameobj)
void KX_Scene::UpdateAnimations(double curtime)
{
- // Update any animations
- for (int i=0; i<m_animatedlist->GetCount(); ++i)
- ((KX_GameObject*)m_animatedlist->GetValue(i))->UpdateActionManager(curtime);
+ KX_GameObject *gameobj;
+ bool needs_update;
+
+ for (int i=0; i<m_animatedlist->GetCount(); ++i) {
+ gameobj = (KX_GameObject*)m_animatedlist->GetValue(i);
+
+ // Non-armature updates are fast enough, so just update them
+ needs_update = gameobj->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE;
+
+ if (!needs_update) {
+ // If we got here, we're looking to update an armature, so check its children meshes
+ // to see if we need to bother with a more expensive pose update
+ CListValue *children = gameobj->GetChildren();
+ KX_GameObject *child;
+
+ // Check for meshes that haven't been culled
+ for (int j=0; j<children->GetCount(); ++j) {
+ child = (KX_GameObject*)children->GetValue(j);
+
+ if (child->GetMeshCount() > 0 && !child->GetCulled()) {
+ needs_update = true;
+ break;
+ }
+ }
+
+ children->Release();
+ }
+
+ if (needs_update)
+ gameobj->UpdateActionManager(curtime);
+ }
}
void KX_Scene::LogicUpdateFrame(double curtime, bool frame)