diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-05-09 05:15:12 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-05-09 05:15:12 +0400 |
commit | e19fcdc6708582130753f31ae30ce05a544a4e9d (patch) | |
tree | a2a279f8d7093b83bbf72983f741fe367702e1f9 /source/gameengine/Physics | |
parent | 5f6a5f1b17da1d339de78e949f4e6e82e9eb56d1 (diff) |
fixed Bullet raycasting filtering issue
Diffstat (limited to 'source/gameengine/Physics')
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index d2559e88e10..8721ad008d9 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -348,7 +348,7 @@ m_enableSatCollisionDetection(false) } - setSolverType(1); + setSolverType(1);//issues with quickstep and memory allocations m_collisionWorld = new CollisionWorld(dispatcher,broadphase); @@ -1222,22 +1222,9 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId) } } -PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ) -{ - - - float minFraction = 1.f; - - SimdVector3 rayFrom(fromX,fromY,fromZ); - SimdVector3 rayTo(toX,toY,toZ); - - SimdVector3 hitPointWorld,normalWorld; - - CollisionWorld::ClosestRayResultCallback rayCallback(rayFrom,rayTo); - struct FilterClosestRayResultCallback : CollisionWorld::ClosestRayResultCallback + struct FilterClosestRayResultCallback : public CollisionWorld::ClosestRayResultCallback { PHY_IPhysicsController* m_ignoreClient; @@ -1248,6 +1235,10 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i } + virtual ~FilterClosestRayResultCallback() + { + } + virtual float AddSingleResult(const CollisionWorld::LocalRayResult& rayResult) { CcdPhysicsController* curHit = static_cast<CcdPhysicsController*>(rayResult.m_collisionObject->m_userPointer); @@ -1255,12 +1246,30 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i if (curHit != m_ignoreClient) { //if valid - return CollisionWorld::ClosestRayResultCallback::AddSingleResult(rayResult); + return ClosestRayResultCallback::AddSingleResult(rayResult); } + return m_closestHitFraction; } }; +PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, + float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ) +{ + + + float minFraction = 1.f; + + SimdVector3 rayFrom(fromX,fromY,fromZ); + SimdVector3 rayTo(toX,toY,toZ); + + SimdVector3 hitPointWorld,normalWorld; + + //Either Ray Cast with or without filtering + + //CollisionWorld::ClosestRayResultCallback rayCallback(rayFrom,rayTo); + FilterClosestRayResultCallback rayCallback(ignoreClient,rayFrom,rayTo); + PHY_IPhysicsController* nearestHit = 0; @@ -1520,7 +1529,6 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) if (bp) { -#ifdef WIN32 SimdVector3 color (1,1,0); if (m_debugDrawer) @@ -1554,7 +1562,6 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) DrawAabb(m_debugDrawer,minAabb,maxAabb,color); } } -#endif scene->SetAabb(bp,minAabb,maxAabb); @@ -1562,4 +1569,4 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) } } -}
\ No newline at end of file +} |