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-04-08 02:14:06 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-04-08 02:14:06 +0400
commit51b4145841293d4a695b7bbe88e90ebd98443fc8 (patch)
tree61818fb3a50e0891b630680b203c3fe80fe149bb /source/gameengine/Physics/Bullet/CcdGraphicController.h
parent486985762aa71b75ec1d1d0e7bbf0f777065f3a3 (diff)
BGE Scenegraph and View frustrum culling improvement.
This commit contains a number of performance improvements for the BGE in the Scenegraph (parent relation between objects in the scene) and view frustrum culling. The scenegraph improvement consists in avoiding position update if the object has not moved since last update and the removal of redundant updates and synchronization with the physics engine. The view frustrum culling improvement consists in using the DBVT broadphase facility of Bullet to build a tree of graphical objects in the scene. The elements of the tree are Aabb boxes (Aligned Axis Bounding Boxes) enclosing the objects. This provides good precision in closed and opened scenes. This new culling system is enabled by default but just in case, it can be disabled with a button in the World settings. There is no do_version in this commit but it will be added before the 2.49 release. For now you must manually enable the DBVT culling option in World settings when you open an old file. The above improvements speed up scenegraph and culling up to 5x. However, this performance improvement is only visible when you have hundreds or thousands of objects. The main interest of the DBVT tree is to allow easy occlusion culling and automatic LOD system. This will be the object of further improvements.
Diffstat (limited to 'source/gameengine/Physics/Bullet/CcdGraphicController.h')
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h
new file mode 100644
index 00000000000..8faa0944313
--- /dev/null
+++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h
@@ -0,0 +1,74 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef BULLET2_GRAPHICCONTROLLER_H
+#define BULLET2_GRAPHICCONTROLLER_H
+
+#include "PHY_IGraphicController.h"
+
+#include "btBulletDynamicsCommon.h"
+#include "LinearMath/btTransform.h"
+
+#include "PHY_IMotionState.h"
+#include "MT_Point3.h"
+
+class CcdPhysicsEnvironment;
+class btCollisionObject;
+
+///CcdGraphicController is a graphic object that supports view frustrum culling and occlusion
+class CcdGraphicController : public PHY_IGraphicController
+{
+public:
+ CcdGraphicController(CcdPhysicsEnvironment* phyEnv, PHY_IMotionState* motionState);
+
+ virtual ~CcdGraphicController();
+
+ void setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax);
+ void setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax);
+
+ PHY_IMotionState* GetMotionState() { return m_motionState; }
+ void getAabb(btVector3& aabbMin, btVector3& aabbMax);
+
+ virtual void setBroadphaseHandle(btBroadphaseProxy* handle) { m_handle = handle; }
+ virtual btBroadphaseProxy* getBroadphaseHandle() { return m_handle; }
+
+ ////////////////////////////////////
+ // PHY_IGraphicController interface
+ ////////////////////////////////////
+
+ /**
+ * Updates the Aabb based on the motion state
+ */
+ virtual bool SetGraphicTransform();
+
+ // client info for culling
+ virtual void* getNewClientInfo() { return m_newClientInfo; }
+ virtual void setNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; }
+ virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate);
+
+private:
+ // unscaled aabb corner
+ btVector3 m_localAabbMin;
+ btVector3 m_localAabbMax;
+
+ PHY_IMotionState* m_motionState;
+ CcdPhysicsEnvironment* m_phyEnv;
+ btBroadphaseProxy* m_handle;
+ void* m_newClientInfo;
+
+};
+
+#endif //BULLET2_PHYSICSCONTROLLER_H