Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleInfoMap.h @ 10066

Last change on this file since 10066 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 7.9 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2010 Erwin Coumans  http://bulletphysics.org
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#ifndef _BT_TRIANGLE_INFO_MAP_H
17#define _BT_TRIANGLE_INFO_MAP_H
18
19
20#include "LinearMath/btHashMap.h"
21#include "LinearMath/btSerializer.h"
22
23
24///for btTriangleInfo m_flags
25#define TRI_INFO_V0V1_CONVEX 1
26#define TRI_INFO_V1V2_CONVEX 2
27#define TRI_INFO_V2V0_CONVEX 4
28
29#define TRI_INFO_V0V1_SWAP_NORMALB 8
30#define TRI_INFO_V1V2_SWAP_NORMALB 16
31#define TRI_INFO_V2V0_SWAP_NORMALB 32
32
33
34///The btTriangleInfo structure stores information to adjust collision normals to avoid collisions against internal edges
35///it can be generated using
36struct  btTriangleInfo
37{
38        btTriangleInfo()
39        {
40                m_edgeV0V1Angle = SIMD_2_PI;
41                m_edgeV1V2Angle = SIMD_2_PI;
42                m_edgeV2V0Angle = SIMD_2_PI;
43                m_flags=0;
44        }
45
46        int                     m_flags;
47
48        btScalar        m_edgeV0V1Angle;
49        btScalar        m_edgeV1V2Angle;
50        btScalar        m_edgeV2V0Angle;
51
52};
53
54typedef btHashMap<btHashInt,btTriangleInfo> btInternalTriangleInfoMap;
55
56
57///The btTriangleInfoMap stores edge angle information for some triangles. You can compute this information yourself or using btGenerateInternalEdgeInfo.
58struct  btTriangleInfoMap : public btInternalTriangleInfoMap
59{
60        btScalar        m_convexEpsilon;///used to determine if an edge or contact normal is convex, using the dot product
61        btScalar        m_planarEpsilon; ///used to determine if a triangle edge is planar with zero angle
62        btScalar        m_equalVertexThreshold; ///used to compute connectivity: if the distance between two vertices is smaller than m_equalVertexThreshold, they are considered to be 'shared'
63        btScalar        m_edgeDistanceThreshold; ///used to determine edge contacts: if the closest distance between a contact point and an edge is smaller than this distance threshold it is considered to "hit the edge"
64        btScalar        m_zeroAreaThreshold; ///used to determine if a triangle is degenerate (length squared of cross product of 2 triangle edges < threshold)
65       
66       
67        btTriangleInfoMap()
68        {
69                m_convexEpsilon = 0.00f;
70                m_planarEpsilon = 0.0001f;
71                m_equalVertexThreshold = btScalar(0.0001)*btScalar(0.0001);
72                m_edgeDistanceThreshold = btScalar(0.1);
73                m_zeroAreaThreshold = btScalar(0.0001)*btScalar(0.0001);
74        }
75        virtual ~btTriangleInfoMap() {}
76
77        virtual int     calculateSerializeBufferSize() const;
78
79        ///fills the dataBuffer and returns the struct name (and 0 on failure)
80        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
81
82        void    deSerialize(struct btTriangleInfoMapData& data);
83
84};
85
86struct  btTriangleInfoData
87{
88        int                     m_flags;
89        float   m_edgeV0V1Angle;
90        float   m_edgeV1V2Angle;
91        float   m_edgeV2V0Angle;
92};
93
94struct  btTriangleInfoMapData
95{
96        int                                     *m_hashTablePtr;
97        int                                     *m_nextPtr;
98        btTriangleInfoData      *m_valueArrayPtr;
99        int                                     *m_keyArrayPtr;
100
101        float   m_convexEpsilon;
102        float   m_planarEpsilon;
103        float   m_equalVertexThreshold; 
104        float   m_edgeDistanceThreshold;
105        float   m_zeroAreaThreshold;
106
107        int             m_nextSize;
108        int             m_hashTableSize;
109        int             m_numValues;
110        int             m_numKeys;
111        char    m_padding[4];
112};
113
114SIMD_FORCE_INLINE       int     btTriangleInfoMap::calculateSerializeBufferSize() const
115{
116        return sizeof(btTriangleInfoMapData);
117}
118
119///fills the dataBuffer and returns the struct name (and 0 on failure)
120SIMD_FORCE_INLINE       const char*     btTriangleInfoMap::serialize(void* dataBuffer, btSerializer* serializer) const
121{
122        btTriangleInfoMapData* tmapData = (btTriangleInfoMapData*) dataBuffer;
123        tmapData->m_convexEpsilon = m_convexEpsilon;
124        tmapData->m_planarEpsilon = m_planarEpsilon;
125        tmapData->m_equalVertexThreshold = m_equalVertexThreshold;
126        tmapData->m_edgeDistanceThreshold = m_edgeDistanceThreshold;
127        tmapData->m_zeroAreaThreshold = m_zeroAreaThreshold;
128       
129        tmapData->m_hashTableSize = m_hashTable.size();
130
131        tmapData->m_hashTablePtr = tmapData->m_hashTableSize ? (int*)serializer->getUniquePointer((void*)&m_hashTable[0]) : 0;
132        if (tmapData->m_hashTablePtr)
133        { 
134                //serialize an int buffer
135                int sz = sizeof(int);
136                int numElem = tmapData->m_hashTableSize;
137                btChunk* chunk = serializer->allocate(sz,numElem);
138                int* memPtr = (int*)chunk->m_oldPtr;
139                for (int i=0;i<numElem;i++,memPtr++)
140                {
141                        *memPtr = m_hashTable[i];
142                }
143                serializer->finalizeChunk(chunk,"int",BT_ARRAY_CODE,(void*)&m_hashTable[0]);
144
145        }
146
147        tmapData->m_nextSize = m_next.size();
148        tmapData->m_nextPtr = tmapData->m_nextSize? (int*)serializer->getUniquePointer((void*)&m_next[0]): 0;
149        if (tmapData->m_nextPtr)
150        {
151                int sz = sizeof(int);
152                int numElem = tmapData->m_nextSize;
153                btChunk* chunk = serializer->allocate(sz,numElem);
154                int* memPtr = (int*)chunk->m_oldPtr;
155                for (int i=0;i<numElem;i++,memPtr++)
156                {
157                        *memPtr = m_next[i];
158                }
159                serializer->finalizeChunk(chunk,"int",BT_ARRAY_CODE,(void*)&m_next[0]);
160        }
161       
162        tmapData->m_numValues = m_valueArray.size();
163        tmapData->m_valueArrayPtr = tmapData->m_numValues ? (btTriangleInfoData*)serializer->getUniquePointer((void*)&m_valueArray[0]): 0;
164        if (tmapData->m_valueArrayPtr)
165        {
166                int sz = sizeof(btTriangleInfoData);
167                int numElem = tmapData->m_numValues;
168                btChunk* chunk = serializer->allocate(sz,numElem);
169                btTriangleInfoData* memPtr = (btTriangleInfoData*)chunk->m_oldPtr;
170                for (int i=0;i<numElem;i++,memPtr++)
171                {
172                        memPtr->m_edgeV0V1Angle = m_valueArray[i].m_edgeV0V1Angle;
173                        memPtr->m_edgeV1V2Angle = m_valueArray[i].m_edgeV1V2Angle;
174                        memPtr->m_edgeV2V0Angle = m_valueArray[i].m_edgeV2V0Angle;
175                        memPtr->m_flags = m_valueArray[i].m_flags;
176                }
177                serializer->finalizeChunk(chunk,"btTriangleInfoData",BT_ARRAY_CODE,(void*) &m_valueArray[0]);
178        }
179       
180        tmapData->m_numKeys = m_keyArray.size();
181        tmapData->m_keyArrayPtr = tmapData->m_numKeys ? (int*)serializer->getUniquePointer((void*)&m_keyArray[0]) : 0;
182        if (tmapData->m_keyArrayPtr)
183        {
184                int sz = sizeof(int);
185                int numElem = tmapData->m_numValues;
186                btChunk* chunk = serializer->allocate(sz,numElem);
187                int* memPtr = (int*)chunk->m_oldPtr;
188                for (int i=0;i<numElem;i++,memPtr++)
189                {
190                        *memPtr = m_keyArray[i].getUid1();
191                }
192                serializer->finalizeChunk(chunk,"int",BT_ARRAY_CODE,(void*) &m_keyArray[0]);
193
194        }
195        return "btTriangleInfoMapData";
196}
197
198
199
200///fills the dataBuffer and returns the struct name (and 0 on failure)
201SIMD_FORCE_INLINE       void    btTriangleInfoMap::deSerialize(btTriangleInfoMapData& tmapData )
202{
203
204
205        m_convexEpsilon = tmapData.m_convexEpsilon;
206        m_planarEpsilon = tmapData.m_planarEpsilon;
207        m_equalVertexThreshold = tmapData.m_equalVertexThreshold;
208        m_edgeDistanceThreshold = tmapData.m_edgeDistanceThreshold;
209        m_zeroAreaThreshold = tmapData.m_zeroAreaThreshold;
210        m_hashTable.resize(tmapData.m_hashTableSize);
211        int i =0;
212        for (i=0;i<tmapData.m_hashTableSize;i++)
213        {
214                m_hashTable[i] = tmapData.m_hashTablePtr[i];
215        }
216        m_next.resize(tmapData.m_nextSize);
217        for (i=0;i<tmapData.m_nextSize;i++)
218        {
219                m_next[i] = tmapData.m_nextPtr[i];
220        }
221        m_valueArray.resize(tmapData.m_numValues);
222        for (i=0;i<tmapData.m_numValues;i++)
223        {
224                m_valueArray[i].m_edgeV0V1Angle = tmapData.m_valueArrayPtr[i].m_edgeV0V1Angle;
225                m_valueArray[i].m_edgeV1V2Angle = tmapData.m_valueArrayPtr[i].m_edgeV1V2Angle;
226                m_valueArray[i].m_edgeV2V0Angle = tmapData.m_valueArrayPtr[i].m_edgeV2V0Angle;
227                m_valueArray[i].m_flags = tmapData.m_valueArrayPtr[i].m_flags;
228        }
229       
230        m_keyArray.resize(tmapData.m_numKeys,btHashInt(0));
231        for (i=0;i<tmapData.m_numKeys;i++)
232        {
233                m_keyArray[i].setUid1(tmapData.m_keyArrayPtr[i]);
234        }
235}
236
237
238#endif //_BT_TRIANGLE_INFO_MAP_H
Note: See TracBrowser for help on using the repository browser.