Blender V2.61 - r43446

btTriangleIndexVertexArray.cpp

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
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 : m_hasAabb(0)
00020 {
00021     btIndexedMesh mesh;
00022 
00023     mesh.m_numTriangles = numTriangles;
00024     mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase;
00025     mesh.m_triangleIndexStride = triangleIndexStride;
00026     mesh.m_numVertices = numVertices;
00027     mesh.m_vertexBase = (const unsigned char *)vertexBase;
00028     mesh.m_vertexStride = vertexStride;
00029 
00030     addIndexedMesh(mesh);
00031 
00032 }
00033 
00034 btTriangleIndexVertexArray::~btTriangleIndexVertexArray()
00035 {
00036 
00037 }
00038 
00039 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)
00040 {
00041     btAssert(subpart< getNumSubParts() );
00042 
00043     btIndexedMesh& mesh = m_indexedMeshes[subpart];
00044 
00045     numverts = mesh.m_numVertices;
00046     (*vertexbase) = (unsigned char *) mesh.m_vertexBase;
00047 
00048    type = mesh.m_vertexType;
00049 
00050     vertexStride = mesh.m_vertexStride;
00051 
00052     numfaces = mesh.m_numTriangles;
00053 
00054     (*indexbase) = (unsigned char *)mesh.m_triangleIndexBase;
00055     indexstride = mesh.m_triangleIndexStride;
00056     indicestype = mesh.m_indexType;
00057 }
00058 
00059 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
00060 {
00061     const btIndexedMesh& mesh = m_indexedMeshes[subpart];
00062 
00063     numverts = mesh.m_numVertices;
00064     (*vertexbase) = (const unsigned char *)mesh.m_vertexBase;
00065 
00066    type = mesh.m_vertexType;
00067    
00068     vertexStride = mesh.m_vertexStride;
00069 
00070     numfaces = mesh.m_numTriangles;
00071     (*indexbase) = (const unsigned char *)mesh.m_triangleIndexBase;
00072     indexstride = mesh.m_triangleIndexStride;
00073     indicestype = mesh.m_indexType;
00074 }
00075 
00076 bool    btTriangleIndexVertexArray::hasPremadeAabb() const
00077 {
00078     return (m_hasAabb == 1);
00079 }
00080 
00081 
00082 void    btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
00083 {
00084     m_aabbMin = aabbMin;
00085     m_aabbMax = aabbMax;
00086     m_hasAabb = 1; // this is intentionally an int see notes in header
00087 }
00088 
00089 void    btTriangleIndexVertexArray::getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const
00090 {
00091     *aabbMin = m_aabbMin;
00092     *aabbMax = m_aabbMax;
00093 }
00094 
00095