more work on Bullet serialization (added support for btConvexHullSupport)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "bullet_btConvexInternalShapeData.h"
|
||||
#include "bullet_btPositionAndRadius.h"
|
||||
#include "bullet_btMultiSphereShapeData.h"
|
||||
#include "bullet_btConvexHullShapeData.h"
|
||||
#include "bullet_btCollisionObjectData.h"
|
||||
#include "bullet_btRigidBodyData.h"
|
||||
#endif//__BULLET_H__
|
||||
@@ -36,6 +36,7 @@ namespace Bullet {
|
||||
class btConvexInternalShapeData;
|
||||
class btPositionAndRadius;
|
||||
class btMultiSphereShapeData;
|
||||
class btConvexHullShapeData;
|
||||
class btCollisionObjectData;
|
||||
class btRigidBodyData;
|
||||
}
|
||||
|
||||
@@ -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_BTCONVEXHULLSHAPEDATA__H__
|
||||
#define __BULLET_BTCONVEXHULLSHAPEDATA__H__
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
#include "bullet_Common.h"
|
||||
#include "bullet_btConvexInternalShapeData.h"
|
||||
|
||||
namespace Bullet {
|
||||
|
||||
|
||||
// ---------------------------------------------- //
|
||||
class btConvexHullShapeData
|
||||
{
|
||||
public:
|
||||
btConvexInternalShapeData m_convexInternalShapeData;
|
||||
btVector3Data *m_unscaledPointsPtr;
|
||||
int m_numUnscaledPoints;
|
||||
char m_padding[4];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif//__BULLET_BTCONVEXHULLSHAPEDATA__H__
|
||||
@@ -65,6 +65,7 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
|
||||
case BOX_SHAPE_PROXYTYPE:
|
||||
case SPHERE_SHAPE_PROXYTYPE:
|
||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btConvexInternalShapeData* bsd = (btConvexInternalShapeData*)shapeData;
|
||||
btVector3 implicitShapeDimensions;
|
||||
@@ -97,7 +98,6 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
|
||||
}
|
||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
#if 1
|
||||
btMultiSphereShapeData* mss = (btMultiSphereShapeData*)bsd;
|
||||
int numSpheres = mss->m_localPositionArraySize;
|
||||
|
||||
@@ -105,16 +105,26 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
|
||||
btAlignedObjectArray<btScalar> radii;
|
||||
radii.resize(numSpheres);
|
||||
tmpPos.resize(numSpheres);
|
||||
|
||||
for (int i=0;i<numSpheres;i++)
|
||||
{
|
||||
tmpPos[i].deSerialize(mss->m_localPositionArrayPtr[i].m_pos);
|
||||
radii[i] = mss->m_localPositionArrayPtr[i].m_radius;
|
||||
}
|
||||
|
||||
|
||||
shape = new btMultiSphereShape(&tmpPos[0],&radii[0],numSpheres);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btConvexHullShapeData* convexData = (btConvexHullShapeData*)bsd;
|
||||
int numPoints = convexData->m_numUnscaledPoints;
|
||||
|
||||
btAlignedObjectArray<btVector3> tmpPoints;
|
||||
tmpPoints.resize(numPoints);
|
||||
for (int i=0;i<numPoints;i++)
|
||||
{
|
||||
tmpPoints[i].deSerialize(convexData->m_unscaledPointsPtr[i]);
|
||||
}
|
||||
shape = new btConvexHullShape(&tmpPoints[0].getX(),numPoints,sizeof(btVector3));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user