Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h @ 9327

Last change on this file since 9327 was 8393, checked in by rgrieder, 14 years ago

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16
17#ifndef BT_DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
18#define BT_DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
19
20#include "LinearMath/btTransform.h"
21#include "LinearMath/btVector3.h"
22class btStackAlloc;
23
24/// This interface is made to be used by an iterative approach to do TimeOfImpact calculations
25/// This interface allows to query for closest points and penetration depth between two (convex) objects
26/// the closest point is on the second object (B), and the normal points from the surface on B towards A.
27/// distance is between closest points on B and closest point on A. So you can calculate closest point on A
28/// by taking closestPointInA = closestPointInB + m_distance * m_normalOnSurfaceB
29struct btDiscreteCollisionDetectorInterface
30{
31       
32        struct Result
33        {
34       
35                virtual ~Result(){}     
36
37                ///setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material combiner
38                virtual void setShapeIdentifiersA(int partId0,int index0)=0;
39                virtual void setShapeIdentifiersB(int partId1,int index1)=0;
40                virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)=0;
41        };
42
43        struct ClosestPointInput
44        {
45                ClosestPointInput()
46                        :m_maximumDistanceSquared(btScalar(BT_LARGE_FLOAT)),
47                        m_stackAlloc(0)
48                {
49                }
50
51                btTransform m_transformA;
52                btTransform m_transformB;
53                btScalar        m_maximumDistanceSquared;
54                btStackAlloc* m_stackAlloc;
55        };
56
57        virtual ~btDiscreteCollisionDetectorInterface() {};
58
59        //
60        // give either closest points (distance > 0) or penetration (distance)
61        // the normal always points from B towards A
62        //
63        virtual void    getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false) = 0;
64
65};
66
67struct btStorageResult : public btDiscreteCollisionDetectorInterface::Result
68{
69                btVector3       m_normalOnSurfaceB;
70                btVector3       m_closestPointInB;
71                btScalar        m_distance; //negative means penetration !
72
73                btStorageResult() : m_distance(btScalar(BT_LARGE_FLOAT))
74                {
75
76                }
77                virtual ~btStorageResult() {};
78
79                virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
80                {
81                        if (depth < m_distance)
82                        {
83                                m_normalOnSurfaceB = normalOnBInWorld;
84                                m_closestPointInB = pointInWorld;
85                                m_distance = depth;
86                        }
87                }
88};
89
90#endif //BT_DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
91
Note: See TracBrowser for help on using the repository browser.