Back to index

supertuxkart  0.5+dfsg1
btTriangleIndexVertexArray.cpp
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose,
00008 including commercial applications, and to alter it and redistribute it freely,
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 #include "btTriangleIndexVertexArray.h"
00017 
00018 btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride)
00019 {
00020        btIndexedMesh mesh;
00021 
00022        mesh.m_numTriangles = numTriangles;
00023        mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase;
00024        mesh.m_triangleIndexStride = triangleIndexStride;
00025        mesh.m_numVertices = numVertices;
00026        mesh.m_vertexBase = (const unsigned char *)vertexBase;
00027        mesh.m_vertexStride = vertexStride;
00028 
00029        addIndexedMesh(mesh);
00030 
00031 }
00032 
00033 btTriangleIndexVertexArray::~btTriangleIndexVertexArray()
00034 {
00035 
00036 }
00037 
00038 void   btTriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart)
00039 {
00040        btAssert(subpart< getNumSubParts() );
00041 
00042        btIndexedMesh& mesh = m_indexedMeshes[subpart];
00043 
00044        numverts = mesh.m_numVertices;
00045        (*vertexbase) = (unsigned char *) mesh.m_vertexBase;
00046        #ifdef BT_USE_DOUBLE_PRECISION
00047        type = PHY_DOUBLE;
00048        #else
00049        type = PHY_FLOAT;
00050        #endif
00051        vertexStride = mesh.m_vertexStride;
00052 
00053        numfaces = mesh.m_numTriangles;
00054 
00055        (*indexbase) = (unsigned char *)mesh.m_triangleIndexBase;
00056        indexstride = mesh.m_triangleIndexStride;
00057        indicestype = mesh.m_indexType;
00058 }
00059 
00060 void   btTriangleIndexVertexArray::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const
00061 {
00062        const btIndexedMesh& mesh = m_indexedMeshes[subpart];
00063 
00064        numverts = mesh.m_numVertices;
00065        (*vertexbase) = (const unsigned char *)mesh.m_vertexBase;
00066        #ifdef BT_USE_DOUBLE_PRECISION
00067        type = PHY_DOUBLE;
00068        #else
00069        type = PHY_FLOAT;
00070        #endif
00071        vertexStride = mesh.m_vertexStride;
00072 
00073        numfaces = mesh.m_numTriangles;
00074        (*indexbase) = (const unsigned char *)mesh.m_triangleIndexBase;
00075        indexstride = mesh.m_triangleIndexStride;
00076        indicestype = mesh.m_indexType;
00077 }
00078