Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h @ 1963

Last change on this file since 1963 was 1963, checked in by rgrieder, 16 years ago

Added Bullet physics engine.

  • Property svn:eol-style set to native
File size: 2.9 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 MANIFOLD_RESULT_H
18#define MANIFOLD_RESULT_H
19
20class btCollisionObject;
21#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
22class btManifoldPoint;
23
24#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
25
26#include "LinearMath/btTransform.h"
27
28typedef bool (*ContactAddedCallback)(btManifoldPoint& cp,       const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1);
29extern ContactAddedCallback             gContactAddedCallback;
30
31
32
33///btManifoldResult is a helper class to manage  contact results.
34class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result
35{
36        btPersistentManifold* m_manifoldPtr;
37
38        //we need this for compounds
39        btTransform     m_rootTransA;
40        btTransform     m_rootTransB;
41
42        btCollisionObject* m_body0;
43        btCollisionObject* m_body1;
44        int     m_partId0;
45        int m_partId1;
46        int m_index0;
47        int m_index1;
48public:
49
50        btManifoldResult()
51        {
52        }
53
54        btManifoldResult(btCollisionObject* body0,btCollisionObject* body1);
55
56        virtual ~btManifoldResult() {};
57
58        void    setPersistentManifold(btPersistentManifold* manifoldPtr)
59        {
60                m_manifoldPtr = manifoldPtr;
61        }
62
63        const btPersistentManifold*     getPersistentManifold() const
64        {
65                return m_manifoldPtr;
66        }
67        btPersistentManifold*   getPersistentManifold()
68        {
69                return m_manifoldPtr;
70        }
71
72        virtual void setShapeIdentifiers(int partId0,int index0,        int partId1,int index1)
73        {
74                        m_partId0=partId0;
75                        m_partId1=partId1;
76                        m_index0=index0;
77                        m_index1=index1;               
78        }
79
80        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
81
82        SIMD_FORCE_INLINE       void refreshContactPoints()
83        {
84                btAssert(m_manifoldPtr);
85                if (!m_manifoldPtr->getNumContacts())
86                        return;
87
88                bool isSwapped = m_manifoldPtr->getBody0() != m_body0;
89
90                if (isSwapped)
91                {
92                        m_manifoldPtr->refreshContactPoints(m_rootTransB,m_rootTransA);
93                } else
94                {
95                        m_manifoldPtr->refreshContactPoints(m_rootTransA,m_rootTransB);
96                }
97        }
98
99
100};
101
102#endif //MANIFOLD_RESULT_H
Note: See TracBrowser for help on using the repository browser.