Back to index

supertuxkart  0.5+dfsg1
btDiscreteCollisionDetectorInterface.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 
00017 #ifndef DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
00018 #define DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
00019 #include "LinearMath/btTransform.h"
00020 #include "LinearMath/btVector3.h"
00021 class btStackAlloc;
00022 
00028 struct btDiscreteCollisionDetectorInterface
00029 {
00030        
00031        struct Result
00032        {
00033        
00034               virtual ~Result(){}  
00035 
00037               virtual void setShapeIdentifiers(int partId0,int index0,       int partId1,int index1)=0;
00038               virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)=0;
00039        };
00040 
00041        struct ClosestPointInput
00042        {
00043               ClosestPointInput()
00044                      :m_maximumDistanceSquared(btScalar(1e30)),
00045                      m_stackAlloc(0)
00046               {
00047               }
00048 
00049               btTransform m_transformA;
00050               btTransform m_transformB;
00051               btScalar      m_maximumDistanceSquared;
00052               btStackAlloc* m_stackAlloc;
00053        };
00054 
00055        virtual ~btDiscreteCollisionDetectorInterface() {};
00056 
00057        //
00058        // give either closest points (distance > 0) or penetration (distance)
00059        // the normal always points from B towards A
00060        //
00061        virtual void  getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) = 0;
00062 
00063 };
00064 
00065 struct btStorageResult : public btDiscreteCollisionDetectorInterface::Result
00066 {
00067               btVector3     m_normalOnSurfaceB;
00068               btVector3     m_closestPointInB;
00069               btScalar      m_distance; //negative means penetration !
00070 
00071               btStorageResult() : m_distance(btScalar(1e30))
00072               {
00073 
00074               }
00075               virtual ~btStorageResult() {};
00076 
00077               virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
00078               {
00079                      if (depth < m_distance)
00080                      {
00081                             m_normalOnSurfaceB = normalOnBInWorld;
00082                             m_closestPointInB = pointInWorld;
00083                             m_distance = depth;
00084                      }
00085               }
00086 };
00087 
00088 #endif //DISCRETE_COLLISION_DETECTOR_INTERFACE1_H