Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hudHS14/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp @ 10222

Last change on this file since 10222 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: 4.3 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2009 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
17#include "btTriangleMesh.h"
18
19
20
21btTriangleMesh::btTriangleMesh (bool use32bitIndices,bool use4componentVertices)
22:m_use32bitIndices(use32bitIndices),
23m_use4componentVertices(use4componentVertices),
24m_weldingThreshold(0.0)
25{
26        btIndexedMesh meshIndex;
27        meshIndex.m_numTriangles = 0;
28        meshIndex.m_numVertices = 0;
29        meshIndex.m_indexType = PHY_INTEGER;
30        meshIndex.m_triangleIndexBase = 0;
31        meshIndex.m_triangleIndexStride = 3*sizeof(int);
32        meshIndex.m_vertexBase = 0;
33        meshIndex.m_vertexStride = sizeof(btVector3);
34        m_indexedMeshes.push_back(meshIndex);
35
36        if (m_use32bitIndices)
37        {
38                m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
39                m_indexedMeshes[0].m_triangleIndexBase = 0;
40                m_indexedMeshes[0].m_indexType = PHY_INTEGER;
41                m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int);
42        } else
43        {
44                m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3;
45                m_indexedMeshes[0].m_triangleIndexBase = 0;
46                m_indexedMeshes[0].m_indexType = PHY_SHORT;
47                m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int);
48        }
49
50        if (m_use4componentVertices)
51        {
52                m_indexedMeshes[0].m_numVertices = m_4componentVertices.size();
53                m_indexedMeshes[0].m_vertexBase = 0;
54                m_indexedMeshes[0].m_vertexStride = sizeof(btVector3);
55        } else
56        {
57                m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3;
58                m_indexedMeshes[0].m_vertexBase = 0;
59                m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
60        }
61
62
63}
64
65void    btTriangleMesh::addIndex(int index)
66{
67        if (m_use32bitIndices)
68        {
69                m_32bitIndices.push_back(index);
70                m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
71        } else
72        {
73                m_16bitIndices.push_back(index);
74                m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
75        }
76}
77
78
79int     btTriangleMesh::findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices)
80{
81        //return index of new/existing vertex
82        ///@todo: could use acceleration structure for this
83        if (m_use4componentVertices)
84        {
85                if (removeDuplicateVertices)
86                        {
87                        for (int i=0;i< m_4componentVertices.size();i++)
88                        {
89                                if ((m_4componentVertices[i]-vertex).length2() <= m_weldingThreshold)
90                                {
91                                        return i;
92                                }
93                        }
94                }
95                m_indexedMeshes[0].m_numVertices++;
96                m_4componentVertices.push_back(vertex);
97                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
98
99                return m_4componentVertices.size()-1;
100               
101        } else
102        {
103               
104                if (removeDuplicateVertices)
105                {
106                        for (int i=0;i< m_3componentVertices.size();i+=3)
107                        {
108                                btVector3 vtx(m_3componentVertices[i],m_3componentVertices[i+1],m_3componentVertices[i+2]);
109                                if ((vtx-vertex).length2() <= m_weldingThreshold)
110                                {
111                                        return i/3;
112                                }
113                        }
114        }
115                m_3componentVertices.push_back((float)vertex.getX());
116                m_3componentVertices.push_back((float)vertex.getY());
117                m_3componentVertices.push_back((float)vertex.getZ());
118                m_indexedMeshes[0].m_numVertices++;
119                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
120                return (m_3componentVertices.size()/3)-1;
121        }
122
123}
124               
125void    btTriangleMesh::addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,bool removeDuplicateVertices)
126{
127        m_indexedMeshes[0].m_numTriangles++;
128        addIndex(findOrAddVertex(vertex0,removeDuplicateVertices));
129        addIndex(findOrAddVertex(vertex1,removeDuplicateVertices));
130        addIndex(findOrAddVertex(vertex2,removeDuplicateVertices));
131}
132
133int btTriangleMesh::getNumTriangles() const
134{
135        if (m_use32bitIndices)
136        {
137                return m_32bitIndices.size() / 3;
138        }
139        return m_16bitIndices.size() / 3;
140}
Note: See TracBrowser for help on using the repository browser.