Blender V2.61 - r43446

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 setShapeIdentifiersA(int partId0,int index0)=0;
00038         virtual void setShapeIdentifiersB(int partId1,int index1)=0;
00039         virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)=0;
00040     };
00041 
00042     struct ClosestPointInput
00043     {
00044         ClosestPointInput()
00045             :m_maximumDistanceSquared(btScalar(BT_LARGE_FLOAT)),
00046             m_stackAlloc(0)
00047         {
00048         }
00049 
00050         btTransform m_transformA;
00051         btTransform m_transformB;
00052         btScalar    m_maximumDistanceSquared;
00053         btStackAlloc* m_stackAlloc;
00054     };
00055 
00056     virtual ~btDiscreteCollisionDetectorInterface() {};
00057 
00058     //
00059     // give either closest points (distance > 0) or penetration (distance)
00060     // the normal always points from B towards A
00061     //
00062     virtual void    getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false) = 0;
00063 
00064 };
00065 
00066 struct btStorageResult : public btDiscreteCollisionDetectorInterface::Result
00067 {
00068         btVector3   m_normalOnSurfaceB;
00069         btVector3   m_closestPointInB;
00070         btScalar    m_distance; //negative means penetration !
00071 
00072         btStorageResult() : m_distance(btScalar(BT_LARGE_FLOAT))
00073         {
00074 
00075         }
00076         virtual ~btStorageResult() {};
00077 
00078         virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
00079         {
00080             if (depth < m_distance)
00081             {
00082                 m_normalOnSurfaceB = normalOnBInWorld;
00083                 m_closestPointInB = pointInWorld;
00084                 m_distance = depth;
00085             }
00086         }
00087 };
00088 
00089 #endif //DISCRETE_COLLISION_DETECTOR_INTERFACE1_H