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-01 23:02:23 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-05-01 23:02:23 +0400
commite13a089d918cbe3709f544ccebbb718a452ac6fa (patch)
tree2b8d3e36659fe11591a981f6e12a9443bbfa2d57 /source/gameengine/Physics
parent672492f563e148dc608965c5d0011413fbfae0eb (diff)
BGE: work around a problem with DBVT culling when graphic objects are rescaled. This happens when objects with very diverse scale are instantiated with dupligroup. The problem remains when the objects are rescaled during the game. The effect of the problem is an inefficient culling: objects can have a bounding box larger than needed. Patch to fix the problem is filed at Bullet forum.
Diffstat (limited to 'source/gameengine/Physics')
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.cpp11
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.h4
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp2
-rw-r--r--source/gameengine/Physics/common/PHY_IGraphicController.h1
4 files changed, 16 insertions, 2 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
index 2d1f841af0c..2dbbb7fa4a0 100644
--- a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
@@ -118,8 +118,17 @@ PHY_IGraphicController* CcdGraphicController::GetReplica(class PHY_IMotionState*
replica->m_motionState = motionState;
replica->m_newClientInfo = NULL;
replica->m_handle = NULL;
- m_phyEnv->addCcdGraphicController(replica);
+ // don't add the graphic controller now: work around a bug in Bullet with rescaling,
+ // (the scale of the controller is not yet defined).
+ //m_phyEnv->addCcdGraphicController(replica);
return replica;
}
+void CcdGraphicController::Activate(bool active)
+{
+ if (active)
+ m_phyEnv->addCcdGraphicController(this);
+ else
+ m_phyEnv->removeCcdGraphicController(this);
+}
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h
index 8f44a623371..b0626f902c2 100644
--- a/source/gameengine/Physics/Bullet/CcdGraphicController.h
+++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h
@@ -55,6 +55,10 @@ public:
* Updates the Aabb based on the motion state
*/
virtual bool SetGraphicTransform();
+ /**
+ * Add/remove to environment
+ */
+ virtual void Activate(bool active);
// client info for culling
virtual void* getNewClientInfo() { return m_newClientInfo; }
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index bcf83e25d84..03c9d13a7dd 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -579,7 +579,7 @@ void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ct
void CcdPhysicsEnvironment::addCcdGraphicController(CcdGraphicController* ctrl)
{
- if (m_cullingTree)
+ if (m_cullingTree && !ctrl->getBroadphaseHandle())
{
btVector3 minAabb;
btVector3 maxAabb;
diff --git a/source/gameengine/Physics/common/PHY_IGraphicController.h b/source/gameengine/Physics/common/PHY_IGraphicController.h
index 8acc5c2f9d3..470d42cb84a 100644
--- a/source/gameengine/Physics/common/PHY_IGraphicController.h
+++ b/source/gameengine/Physics/common/PHY_IGraphicController.h
@@ -47,6 +47,7 @@ class PHY_IGraphicController : public PHY_IController
SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
*/
virtual bool SetGraphicTransform()=0;
+ virtual void Activate(bool active=true)=0;
virtual void setLocalAabb(const PHY__Vector3& aabbMin,const PHY__Vector3& aabbMax)=0;
virtual void setLocalAabb(const float* aabbMin,const float* aabbMax)=0;