improved btTriangleMeshShape/btBvhTriangleMeshShape serialization
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include "bullet_btPhysicsSystem.h"
|
||||
#include "bullet_ListBase.h"
|
||||
#include "bullet_btVector3Data.h"
|
||||
#include "bullet_btVector3FloatData.h"
|
||||
#include "bullet_btVector3DoubleData.h"
|
||||
#include "bullet_btMatrix3x3Data.h"
|
||||
#include "bullet_btTransformData.h"
|
||||
#include "bullet_btCollisionShapeData.h"
|
||||
@@ -30,6 +32,7 @@
|
||||
#include "bullet_btPositionAndRadius.h"
|
||||
#include "bullet_btMultiSphereShapeData.h"
|
||||
#include "bullet_btIntIndexData.h"
|
||||
#include "bullet_btShortIntIndexData.h"
|
||||
#include "bullet_btMeshPartData.h"
|
||||
#include "bullet_btStridingMeshInterfaceData.h"
|
||||
#include "bullet_btTriangleMeshShapeData.h"
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace Bullet {
|
||||
class btPhysicsSystem;
|
||||
class ListBase;
|
||||
class btVector3Data;
|
||||
class btVector3FloatData;
|
||||
class btVector3DoubleData;
|
||||
class btMatrix3x3Data;
|
||||
class btTransformData;
|
||||
class btCollisionShapeData;
|
||||
@@ -37,6 +39,7 @@ namespace Bullet {
|
||||
class btPositionAndRadius;
|
||||
class btMultiSphereShapeData;
|
||||
class btIntIndexData;
|
||||
class btShortIntIndexData;
|
||||
class btMeshPartData;
|
||||
class btStridingMeshInterfaceData;
|
||||
class btTriangleMeshShapeData;
|
||||
|
||||
@@ -31,8 +31,10 @@ namespace Bullet {
|
||||
class btMeshPartData
|
||||
{
|
||||
public:
|
||||
btVector3Data *m_vertices;
|
||||
btIntIndexData *m_indices;
|
||||
btVector3FloatData *m_vertices3f;
|
||||
btVector3DoubleData *m_vertices3d;
|
||||
btIntIndexData *m_indices32;
|
||||
btShortIntIndexData *m_indices16;
|
||||
int m_numTriangles;
|
||||
int m_numVertices;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 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.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
// Auto generated from makesdna dna.c
|
||||
#ifndef __BULLET_BTSHORTINTINDEXDATA__H__
|
||||
#define __BULLET_BTSHORTINTINDEXDATA__H__
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
#include "bullet_Common.h"
|
||||
|
||||
namespace Bullet {
|
||||
|
||||
|
||||
// ---------------------------------------------- //
|
||||
class btShortIntIndexData
|
||||
{
|
||||
public:
|
||||
short int;
|
||||
short m_value;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif//__BULLET_BTSHORTINTINDEXDATA__H__
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 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.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
// Auto generated from makesdna dna.c
|
||||
#ifndef __BULLET_BTVECTOR3DOUBLEDATA__H__
|
||||
#define __BULLET_BTVECTOR3DOUBLEDATA__H__
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
#include "bullet_Common.h"
|
||||
|
||||
namespace Bullet {
|
||||
|
||||
|
||||
// ---------------------------------------------- //
|
||||
class btVector3DoubleData
|
||||
{
|
||||
public:
|
||||
double m_floats[4];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif//__BULLET_BTVECTOR3DOUBLEDATA__H__
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 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.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
// Auto generated from makesdna dna.c
|
||||
#ifndef __BULLET_BTVECTOR3FLOATDATA__H__
|
||||
#define __BULLET_BTVECTOR3FLOATDATA__H__
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
#include "bullet_Common.h"
|
||||
|
||||
namespace Bullet {
|
||||
|
||||
|
||||
// ---------------------------------------------- //
|
||||
class btVector3FloatData
|
||||
{
|
||||
public:
|
||||
float m_floats[4];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif//__BULLET_BTVECTOR3FLOATDATA__H__
|
||||
@@ -151,12 +151,32 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
|
||||
for (int i=0;i<trimesh->m_meshInterface.m_numMeshParts;i++)
|
||||
{
|
||||
btIndexedMesh meshPart;
|
||||
meshPart.m_triangleIndexStride = 3*sizeof(int);
|
||||
meshPart.m_vertexStride = sizeof(btVector3Data);
|
||||
if (trimesh->m_meshInterface.m_meshPartsPtr[i].m_indices32)
|
||||
{
|
||||
meshPart.m_indexType = PHY_INTEGER;
|
||||
meshPart.m_triangleIndexStride = 3*sizeof(int);
|
||||
meshPart.m_triangleIndexBase = (const unsigned char*)trimesh->m_meshInterface.m_meshPartsPtr[i].m_indices32;
|
||||
} else
|
||||
{
|
||||
meshPart.m_indexType = PHY_SHORT;
|
||||
meshPart.m_triangleIndexStride = 3*sizeof(short int);
|
||||
meshPart.m_triangleIndexBase = (const unsigned char*)trimesh->m_meshInterface.m_meshPartsPtr[i].m_indices16;
|
||||
}
|
||||
|
||||
if (trimesh->m_meshInterface.m_meshPartsPtr[i].m_vertices3f)
|
||||
{
|
||||
meshPart.m_vertexType = PHY_FLOAT;
|
||||
meshPart.m_vertexStride = sizeof(btVector3FloatData);
|
||||
meshPart.m_vertexBase = (const unsigned char*)trimesh->m_meshInterface.m_meshPartsPtr[i].m_vertices3f;
|
||||
} else
|
||||
{
|
||||
meshPart.m_vertexType = PHY_DOUBLE;
|
||||
meshPart.m_vertexStride = sizeof(btVector3DoubleData);
|
||||
meshPart.m_vertexBase = (const unsigned char*)trimesh->m_meshInterface.m_meshPartsPtr[i].m_vertices3d;
|
||||
}
|
||||
meshPart.m_numTriangles = trimesh->m_meshInterface.m_meshPartsPtr[i].m_numTriangles;
|
||||
meshPart.m_numVertices = trimesh->m_meshInterface.m_meshPartsPtr[i].m_numVertices;
|
||||
meshPart.m_triangleIndexBase = (const unsigned char*)trimesh->m_meshInterface.m_meshPartsPtr[i].m_indices;
|
||||
meshPart.m_vertexBase = (const unsigned char*)trimesh->m_meshInterface.m_meshPartsPtr[i].m_vertices;
|
||||
|
||||
meshInterface->addIndexedMesh(meshPart);
|
||||
}
|
||||
btVector3 scaling; scaling.deSerialize(trimesh->m_meshInterface.m_scaling);
|
||||
|
||||
Reference in New Issue
Block a user