~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/bullet/src/BulletCollision/CollisionDispatch/btManifoldResult.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Bullet Continuous Collision Detection and Physics Library
 
3
Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
 
4
 
 
5
This software is provided 'as-is', without any express or implied warranty.
 
6
In no event will the authors be held liable for any damages arising from the use of this software.
 
7
Permission is granted to anyone to use this software for any purpose, 
 
8
including commercial applications, and to alter it and redistribute it freely, 
 
9
subject to the following restrictions:
 
10
 
 
11
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.
 
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
 
13
3. This notice may not be removed or altered from any source distribution.
 
14
*/
 
15
 
 
16
 
 
17
#ifndef BT_MANIFOLD_RESULT_H
 
18
#define BT_MANIFOLD_RESULT_H
 
19
 
 
20
class btCollisionObject;
 
21
#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
 
22
class btManifoldPoint;
 
23
 
 
24
#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
 
25
 
 
26
#include "LinearMath/btTransform.h"
 
27
 
 
28
typedef bool (*ContactAddedCallback)(btManifoldPoint& cp,       const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1);
 
29
extern ContactAddedCallback             gContactAddedCallback;
 
30
 
 
31
// XXX Emscripten: Uncomment the next line, to prevent SAFE_HEAP warnings
 
32
#define DEBUG_PART_INDEX 1
 
33
 
 
34
 
 
35
///btManifoldResult is a helper class to manage  contact results.
 
36
class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result
 
37
{
 
38
protected:
 
39
 
 
40
        btPersistentManifold* m_manifoldPtr;
 
41
 
 
42
        //we need this for compounds
 
43
        btTransform     m_rootTransA;
 
44
        btTransform     m_rootTransB;
 
45
 
 
46
        btCollisionObject* m_body0;
 
47
        btCollisionObject* m_body1;
 
48
        int     m_partId0;
 
49
        int m_partId1;
 
50
        int m_index0;
 
51
        int m_index1;
 
52
        
 
53
 
 
54
public:
 
55
 
 
56
        btManifoldResult()
 
57
#ifdef DEBUG_PART_INDEX
 
58
                :
 
59
        m_partId0(-1),
 
60
        m_partId1(-1),
 
61
        m_index0(-1),
 
62
        m_index1(-1)
 
63
#endif //DEBUG_PART_INDEX
 
64
        {
 
65
        }
 
66
 
 
67
        btManifoldResult(btCollisionObject* body0,btCollisionObject* body1);
 
68
 
 
69
        virtual ~btManifoldResult() {};
 
70
 
 
71
        void    setPersistentManifold(btPersistentManifold* manifoldPtr)
 
72
        {
 
73
                m_manifoldPtr = manifoldPtr;
 
74
        }
 
75
 
 
76
        const btPersistentManifold*     getPersistentManifold() const
 
77
        {
 
78
                return m_manifoldPtr;
 
79
        }
 
80
        btPersistentManifold*   getPersistentManifold()
 
81
        {
 
82
                return m_manifoldPtr;
 
83
        }
 
84
 
 
85
        virtual void setShapeIdentifiersA(int partId0,int index0)
 
86
        {
 
87
                m_partId0=partId0;
 
88
                m_index0=index0;
 
89
        }
 
90
 
 
91
        virtual void setShapeIdentifiersB(      int partId1,int index1)
 
92
        {
 
93
                m_partId1=partId1;
 
94
                m_index1=index1;
 
95
        }
 
96
 
 
97
 
 
98
        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
 
99
 
 
100
        SIMD_FORCE_INLINE       void refreshContactPoints()
 
101
        {
 
102
                btAssert(m_manifoldPtr);
 
103
                if (!m_manifoldPtr->getNumContacts())
 
104
                        return;
 
105
 
 
106
                bool isSwapped = m_manifoldPtr->getBody0() != m_body0;
 
107
 
 
108
                if (isSwapped)
 
109
                {
 
110
                        m_manifoldPtr->refreshContactPoints(m_rootTransB,m_rootTransA);
 
111
                } else
 
112
                {
 
113
                        m_manifoldPtr->refreshContactPoints(m_rootTransA,m_rootTransB);
 
114
                }
 
115
        }
 
116
 
 
117
        const btCollisionObject* getBody0Internal() const
 
118
        {
 
119
                return m_body0;
 
120
        }
 
121
 
 
122
        const btCollisionObject* getBody1Internal() const
 
123
        {
 
124
                return m_body1;
 
125
        }
 
126
        
 
127
};
 
128
 
 
129
#endif //BT_MANIFOLD_RESULT_H