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>2011-09-04 00:48:47 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-09-04 00:48:47 +0400
commit1f8291f78d6eb3e02414cc7801fe5ba9ad524e4b (patch)
tree8d038bfb9129ae4c2d708f0abfd6c7644000dc4c
parent8295480bbeee2aafa0ea70d19836b3ab094ee08e (diff)
BGE animations: Adding a separate list to KX_Scene for animated objects. This makes scenes with a lot of non-animated objects faster. In my test scene with 8000 static, non-animated cubes my time spent on animations went from 1.5~1.7ms to 0.001ms.
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp16
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h5
3 files changed, 23 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 3f6f4bb9099..6adaea2d6ad 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -159,6 +159,7 @@ KX_GameObject::~KX_GameObject()
}
if (m_actionManager)
{
+ KX_GetActiveScene()->RemoveAnimatedObject(this);
delete m_actionManager;
}
#ifdef WITH_PYTHON
@@ -355,8 +356,8 @@ BL_ActionManager* KX_GameObject::GetActionManager()
{
// We only want to create an action manager if we need it
if (!m_actionManager)
- m_actionManager = new BL_ActionManager(this);
-
+ { KX_GetActiveScene()->AddAnimatedObject(this); m_actionManager = new BL_ActionManager(this);
+ }
return m_actionManager;
}
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index a49c1bf4b4c..06e343cedb2 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -168,6 +168,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
m_lightlist= new CListValue();
m_inactivelist = new CListValue();
m_euthanasyobjects = new CListValue();
+ m_animatedlist = new CListValue();
m_logicmgr = new SCA_LogicManager();
@@ -253,6 +254,9 @@ KX_Scene::~KX_Scene()
if (m_euthanasyobjects)
m_euthanasyobjects->Release();
+ if (m_animatedlist)
+ m_animatedlist->Release();
+
if (m_logicmgr)
delete m_logicmgr;
@@ -1502,10 +1506,20 @@ void KX_Scene::LogicBeginFrame(double curtime)
m_logicmgr->BeginFrame(curtime, 1.0/KX_KetsjiEngine::GetTicRate());
}
+void KX_Scene::AddAnimatedObject(CValue* gameobj)
+{
+ m_animatedlist->Add(gameobj);
+}
+
+void KX_Scene::RemoveAnimatedObject(CValue* gameobj)
+{
+ m_animatedlist->RemoveValue(gameobj);
+}
+
void KX_Scene::UpdateAnimations(double curtime)
{
// Update any animations
- for (int i=0; i<GetObjectList()->GetCount(); ++i)
+ for (int i=0; i<m_animatedlist->GetCount(); ++i)
((KX_GameObject*)GetObjectList()->GetValue(i))->UpdateActionManager(curtime);
}
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
index da9cc12c76a..499861bce50 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -130,6 +130,7 @@ protected:
CListValue* m_parentlist; // all 'root' parents
CListValue* m_lightlist;
CListValue* m_inactivelist; // all objects that are not in the active layer
+ CListValue* m_animatedlist; // all animated objects
SG_QList m_sghead; // list of nodes that needs scenegraph update
// the Dlist is not object that must be updated
@@ -334,6 +335,10 @@ public:
int NewRemoveObject(CValue* gameobj);
void ReplaceMesh(CValue* gameobj,
void* meshob, bool use_gfx, bool use_phys);
+
+ void AddAnimatedObject(CValue* gameobj);
+ void RemoveAnimatedObject(CValue* gameobj);
+
/**
* @section Logic stuff
* Initiate an update of the logic system.