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>2014-05-16 21:40:23 +0400
committerMitchell Stokes <mogurijin@gmail.com>2014-05-16 21:44:01 +0400
commit2e20c1689798b84fd63d84cd6fc7fb282af05588 (patch)
treef2e32c15187994fbefb279260b54ff6dea231774 /source/gameengine
parent1923a8f23a174c343601771ab5136f2a7d38fc47 (diff)
Fix T38895: Unstable behavior using VehicleWrapper after Bullet 2.82 update
The Bullet 2.82 update uses a different method for ray casting that seems incompatible with our older files. So, for now we just force the vehicle physics to use the older ray casting method.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index ce6eb221e8d..8a8a8d33f09 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -296,6 +296,44 @@ public:
};
+
+class BlenderVehicleRaycaster: public btDefaultVehicleRaycaster
+{
+ btDynamicsWorld* m_dynamicsWorld;
+public:
+ BlenderVehicleRaycaster(btDynamicsWorld* world)
+ :btDefaultVehicleRaycaster(world), m_dynamicsWorld(world)
+ {
+ }
+
+ virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result)
+ {
+ // RayResultCallback& resultCallback;
+
+ btCollisionWorld::ClosestRayResultCallback rayCallback(from,to);
+
+ // We override btDefaultVehicleRaycaster so we can set this flag, otherwise our
+ // vehicles go crazy (http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=9662)
+ rayCallback.m_flags |= btTriangleRaycastCallback::kF_UseSubSimplexConvexCastRaytest;
+
+ m_dynamicsWorld->rayTest(from, to, rayCallback);
+
+ if (rayCallback.hasHit())
+ {
+
+ const btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
+ if (body && body->hasContactResponse())
+ {
+ result.m_hitPointInWorld = rayCallback.m_hitPointWorld;
+ result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld;
+ result.m_hitNormalInWorld.normalize();
+ result.m_distFraction = rayCallback.m_closestHitFraction;
+ return (void*)body;
+ }
+ }
+ return 0;
+ }
+};
#endif //NEW_BULLET_VEHICLE_SUPPORT
class CcdOverlapFilterCallBack : public btOverlapFilterCallback
@@ -2824,7 +2862,7 @@ int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl
{
btRaycastVehicle::btVehicleTuning* tuning = new btRaycastVehicle::btVehicleTuning();
btRigidBody* chassis = rb0;
- btDefaultVehicleRaycaster* raycaster = new btDefaultVehicleRaycaster(m_dynamicsWorld);
+ btDefaultVehicleRaycaster* raycaster = new BlenderVehicleRaycaster(m_dynamicsWorld);
btRaycastVehicle* vehicle = new btRaycastVehicle(*tuning,chassis,raycaster);
WrapperVehicle* wrapperVehicle = new WrapperVehicle(vehicle,ctrl0);
m_wrapperVehicles.push_back(wrapperVehicle);