Back to index

supertuxkart  0.5+dfsg1
btTetrahedronShape.cpp
Go to the documentation of this file.
00001 
00002 /*
00003 Bullet Continuous Collision Detection and Physics Library
00004 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00005 
00006 This software is provided 'as-is', without any express or implied warranty.
00007 In no event will the authors be held liable for any damages arising from the use of this software.
00008 Permission is granted to anyone to use this software for any purpose, 
00009 including commercial applications, and to alter it and redistribute it freely, 
00010 subject to the following restrictions:
00011 
00012 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.
00013 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00014 3. This notice may not be removed or altered from any source distribution.
00015 */
00016 #include "btTetrahedronShape.h"
00017 #include "LinearMath/btMatrix3x3.h"
00018 
00019 btBU_Simplex1to4::btBU_Simplex1to4()
00020 :m_numVertices(0)
00021 {
00022 }
00023 
00024 btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0)
00025 :m_numVertices(0)
00026 {
00027        addVertex(pt0);
00028 }
00029 
00030 btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1)
00031 :m_numVertices(0)
00032 {
00033        addVertex(pt0);
00034        addVertex(pt1);
00035 }
00036 
00037 btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2)
00038 :m_numVertices(0)
00039 {
00040        addVertex(pt0);
00041        addVertex(pt1);
00042        addVertex(pt2);
00043 }
00044 
00045 btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2,const btPoint3& pt3)
00046 :m_numVertices(0)
00047 {
00048        addVertex(pt0);
00049        addVertex(pt1);
00050        addVertex(pt2);
00051        addVertex(pt3);
00052 }
00053 
00054 
00055 
00056 
00057 
00058 void btBU_Simplex1to4::addVertex(const btPoint3& pt)
00059 {
00060        m_vertices[m_numVertices++] = pt;
00061 
00062        recalcLocalAabb();
00063 }
00064 
00065 
00066 int    btBU_Simplex1to4::getNumVertices() const
00067 {
00068        return m_numVertices;
00069 }
00070 
00071 int btBU_Simplex1to4::getNumEdges() const
00072 {
00073        //euler formula, F-E+V = 2, so E = F+V-2
00074 
00075        switch (m_numVertices)
00076        {
00077        case 0:
00078               return 0;
00079        case 1: return 0;
00080        case 2: return 1;
00081        case 3: return 3;
00082        case 4: return 6;
00083 
00084 
00085        }
00086 
00087        return 0;
00088 }
00089 
00090 void btBU_Simplex1to4::getEdge(int i,btPoint3& pa,btPoint3& pb) const
00091 {
00092        
00093     switch (m_numVertices)
00094        {
00095 
00096        case 2: 
00097               pa = m_vertices[0];
00098               pb = m_vertices[1];
00099               break;
00100        case 3:  
00101               switch (i)
00102               {
00103               case 0:
00104                      pa = m_vertices[0];
00105                      pb = m_vertices[1];
00106                      break;
00107               case 1:
00108                      pa = m_vertices[1];
00109                      pb = m_vertices[2];
00110                      break;
00111               case 2:
00112                      pa = m_vertices[2];
00113                      pb = m_vertices[0];
00114                      break;
00115 
00116               }
00117               break;
00118        case 4: 
00119               switch (i)
00120               {
00121               case 0:
00122                      pa = m_vertices[0];
00123                      pb = m_vertices[1];
00124                      break;
00125               case 1:
00126                      pa = m_vertices[1];
00127                      pb = m_vertices[2];
00128                      break;
00129               case 2:
00130                      pa = m_vertices[2];
00131                      pb = m_vertices[0];
00132                      break;
00133               case 3:
00134                      pa = m_vertices[0];
00135                      pb = m_vertices[3];
00136                      break;
00137               case 4:
00138                      pa = m_vertices[1];
00139                      pb = m_vertices[3];
00140                      break;
00141               case 5:
00142                      pa = m_vertices[2];
00143                      pb = m_vertices[3];
00144                      break;
00145               }
00146 
00147        }
00148 
00149 
00150 
00151 
00152 }
00153 
00154 void btBU_Simplex1to4::getVertex(int i,btPoint3& vtx) const
00155 {
00156        vtx = m_vertices[i];
00157 }
00158 
00159 int    btBU_Simplex1to4::getNumPlanes() const
00160 {
00161        switch (m_numVertices)
00162        {
00163        case 0:
00164                      return 0;
00165        case 1:
00166                      return 0;
00167        case 2:
00168                      return 0;
00169        case 3:
00170                      return 2;
00171        case 4:
00172                      return 4;
00173        default:
00174               {
00175               }
00176        }
00177        return 0;
00178 }
00179 
00180 
00181 void btBU_Simplex1to4::getPlane(btVector3&, btPoint3& ,int ) const
00182 {
00183        
00184 }
00185 
00186 int btBU_Simplex1to4::getIndex(int ) const
00187 {
00188        return 0;
00189 }
00190 
00191 bool btBU_Simplex1to4::isInside(const btPoint3& ,btScalar ) const
00192 {
00193        return false;
00194 }
00195