more work on serialization, initial for btTriangleMeshShape/btBvhTriangleMeshShape (only for floating point vertices, integer indices) work-in-progress

This commit is contained in:
erwin.coumans
2010-01-23 20:59:41 +00:00
parent e459145b91
commit 9d7d1c3983
11 changed files with 342 additions and 100 deletions

View File

@@ -29,6 +29,10 @@
#include "bullet_btConvexInternalShapeData.h"
#include "bullet_btPositionAndRadius.h"
#include "bullet_btMultiSphereShapeData.h"
#include "bullet_btIntIndexData.h"
#include "bullet_btMeshPartData.h"
#include "bullet_btStridingMeshInterfaceData.h"
#include "bullet_btTriangleMeshShapeData.h"
#include "bullet_btConvexHullShapeData.h"
#include "bullet_btCollisionObjectData.h"
#include "bullet_btRigidBodyData.h"

View File

@@ -36,6 +36,10 @@ namespace Bullet {
class btConvexInternalShapeData;
class btPositionAndRadius;
class btMultiSphereShapeData;
class btIntIndexData;
class btMeshPartData;
class btStridingMeshInterfaceData;
class btTriangleMeshShapeData;
class btConvexHullShapeData;
class btCollisionObjectData;
class btRigidBodyData;

View File

@@ -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_BTINTINDEXDATA__H__
#define __BULLET_BTINTINDEXDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
namespace Bullet {
// ---------------------------------------------- //
class btIntIndexData
{
public:
int m_value;
};
}
#endif//__BULLET_BTINTINDEXDATA__H__

View File

@@ -0,0 +1,42 @@
/* 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_BTMESHPARTDATA__H__
#define __BULLET_BTMESHPARTDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
namespace Bullet {
// ---------------------------------------------- //
class btMeshPartData
{
public:
btVector3Data *m_vertices;
btIntIndexData *m_indices;
int m_numTriangles;
int m_numVertices;
};
}
#endif//__BULLET_BTMESHPARTDATA__H__

View File

@@ -0,0 +1,43 @@
/* 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_BTSTRIDINGMESHINTERFACEDATA__H__
#define __BULLET_BTSTRIDINGMESHINTERFACEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btVector3Data.h"
namespace Bullet {
// ---------------------------------------------- //
class btStridingMeshInterfaceData
{
public:
btMeshPartData *m_meshPartsPtr;
int m_numMeshParts;
btVector3Data m_scaling;
char m_padding[4];
};
}
#endif//__BULLET_BTSTRIDINGMESHINTERFACEDATA__H__

View File

@@ -0,0 +1,43 @@
/* 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_BTTRIANGLEMESHSHAPEDATA__H__
#define __BULLET_BTTRIANGLEMESHSHAPEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btStridingMeshInterfaceData.h"
namespace Bullet {
// ---------------------------------------------- //
class btTriangleMeshShapeData
{
public:
bInvalidHandle btCollisionShapeData;
bInvalidHandle m_collisionShapeData;
btStridingMeshInterfaceData m_meshInterface;
btScalar m_collisionMargin;
};
}
#endif//__BULLET_BTTRIANGLEMESHSHAPEDATA__H__

View File

@@ -144,6 +144,31 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
}
break;
}
case TRIANGLE_MESH_SHAPE_PROXYTYPE:
{
btTriangleMeshShapeData* trimesh = (btTriangleMeshShapeData*)shapeData;
btTriangleIndexVertexArray* meshInterface = new btTriangleIndexVertexArray();
for (int i=0;i<trimesh->m_meshInterface.m_numMeshParts;i++)
{
btIndexedMesh meshPart;
meshPart.m_triangleIndexStride = 3*sizeof(int);
meshPart.m_vertexStride = sizeof(btVector3Data);
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);
meshInterface->setScaling(scaling);
btBvhTriangleMeshShape* trimeshShape = new btBvhTriangleMeshShape(meshInterface,true);
trimeshShape->setMargin(trimesh->m_collisionMargin);
shapeMap.insert(shapeData,trimeshShape);
//printf("trimesh->m_collisionMargin=%f\n",trimesh->m_collisionMargin);
break;
}
default:
{
printf("unsupported shape type (%d)\n",shapeData->m_shapeType);