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:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-05-04 02:29:00 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-05-04 02:29:00 +0400
commit3abb8e8e68c824db7cecdf2360e8e1daaff00413 (patch)
tree8f4fea6f267ce2d268cb82e9121c5208eeea8d8a /source/gameengine/SceneGraph/SG_Spatial.cpp
parent2aa3c932d00977a70bc299bd709fa505c48518d8 (diff)
BGE performance: second round of scenegraph improvement.
Use dynamic linked list to handle scenegraph rather than dumb scan of the whole tree. The performance improvement depends on the fraction of moving objects. If most objects are static, the speed up is considerable. The following table compares the time spent on scenegraph before and after this commit on a scene with 10000 objects in various configuratons: Scenegraph time (ms) Before After (includes culling) All objects static, 8.8 1.7 all visible but small fraction in the view frustrum All objects static, 7,5 0.01 all invisible. All objects moving, 14.1 8.4 all visible but small fraction in the view frustrum This tables shows that static and invisible objects take no CPU at all for scenegraph and culling. In the general case, this commit will speed up the scenegraph between 2x and 5x. Compared to 2.48a, it should be between 4x and 10x faster. Further speed up is possible by making the scenegraph cache-friendly. Next round of performance improvement will be on the rasterizer: use the same dynamic linked list technique for the mesh slots.
Diffstat (limited to 'source/gameengine/SceneGraph/SG_Spatial.cpp')
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.cpp147
1 files changed, 6 insertions, 141 deletions
diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp
index 2f3176816c6..97b15bdf376 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.cpp
+++ b/source/gameengine/SceneGraph/SG_Spatial.cpp
@@ -40,7 +40,7 @@ SG_Spatial::
SG_Spatial(
void* clientobj,
void* clientinfo,
- SG_Callbacks callbacks
+ SG_Callbacks& callbacks
):
SG_IObject(clientobj,clientinfo,callbacks),
@@ -56,8 +56,9 @@ SG_Spatial(
m_bbox(MT_Point3(-1.0, -1.0, -1.0), MT_Point3(1.0, 1.0, 1.0)),
m_radius(1.0),
- m_modified(true)
+ m_modified(false)
{
+ SetModified();
}
SG_Spatial::
@@ -88,13 +89,6 @@ SG_Spatial::
delete (m_parent_relation);
}
- SG_ParentRelation *
-SG_Spatial::
-GetParentRelation(
-){
- return m_parent_relation;
-}
-
void
SG_Spatial::
SetParentRelation(
@@ -102,7 +96,7 @@ SetParentRelation(
){
delete (m_parent_relation);
m_parent_relation = relation;
- m_modified = true;
+ SetModified();
}
@@ -143,11 +137,6 @@ UpdateSpatialData(
return bComputesWorldTransform;
}
-bool SG_Spatial::ComputeWorldTransforms(const SG_Spatial *parent, bool& parentUpdated)
-{
- return m_parent_relation->UpdateChildCoordinates(this,parent,parentUpdated);
-}
-
/**
* Position and translation methods
*/
@@ -169,56 +158,14 @@ RelativeTranslate(
m_localPosition += trans;
}
}
- m_modified = true;
+ SetModified();
}
- void
-SG_Spatial::
-SetLocalPosition(
- const MT_Point3& trans
-){
- m_localPosition = trans;
- m_modified = true;
-}
-
- void
-SG_Spatial::
-SetWorldPosition(
- const MT_Point3& trans
-) {
- m_worldPosition = trans;
-}
/**
* Scaling methods.
*/
- void
-SG_Spatial::
-RelativeScale(
- const MT_Vector3& scale
-){
- m_localScaling = m_localScaling * scale;
- m_modified = true;
-}
-
- void
-SG_Spatial::
-SetLocalScale(
- const MT_Vector3& scale
-){
- m_localScaling = scale;
- m_modified = true;
-}
-
-
- void
-SG_Spatial::
-SetWorldScale(
- const MT_Vector3& scale
-){
- m_worldScaling = scale;
-}
/**
* Orientation and rotation methods.
@@ -236,93 +183,11 @@ RelativeRotate(
rot
:
(GetWorldOrientation().inverse() * rot * GetWorldOrientation()));
- m_modified = true;
-}
-
- void
-SG_Spatial::
-SetLocalOrientation(const MT_Matrix3x3& rot)
-{
- m_localRotation = rot;
- m_modified = true;
+ SetModified();
}
- void
-SG_Spatial::
-SetWorldOrientation(
- const MT_Matrix3x3& rot
-) {
- m_worldRotation = rot;
-}
-
-const
- MT_Point3&
-SG_Spatial::
-GetLocalPosition(
-) const {
- return m_localPosition;
-}
-
-const
- MT_Matrix3x3&
-SG_Spatial::
-GetLocalOrientation(
-) const {
- return m_localRotation;
-}
-
-const
- MT_Vector3&
-SG_Spatial::
-GetLocalScale(
-) const{
- return m_localScaling;
-}
-
-
-const
- MT_Point3&
-SG_Spatial::
-GetWorldPosition(
-) const {
- return m_worldPosition;
-}
-
-const
- MT_Matrix3x3&
-SG_Spatial::
-GetWorldOrientation(
-) const {
- return m_worldRotation;
-}
-
-const
- MT_Vector3&
-SG_Spatial::
-GetWorldScaling(
-) const {
- return m_worldScaling;
-}
-
-void SG_Spatial::SetWorldFromLocalTransform()
-{
- m_worldPosition= m_localPosition;
- m_worldScaling= m_localScaling;
- m_worldRotation= m_localRotation;
-}
-
-SG_BBox& SG_Spatial::BBox()
-{
- return m_bbox;
-}
-
-void SG_Spatial::SetBBox(SG_BBox& bbox)
-{
- m_bbox = bbox;
-}
-
MT_Transform SG_Spatial::GetWorldTransform() const
{
return MT_Transform(m_worldPosition,