added basic serialization for several constraints including btPoint2PointConstraint, btHingeConstraint, btSliderConstraint, btConeTwistConstraint, btGeneric6DofConstraint

(no motor support or advanced settings yet)
added btStaticPlaneShape serialization
Added toggle in cmake for BenchmarksDemo to enable/disable graphics rendering
This commit is contained in:
erwin.coumans
2010-01-27 02:13:56 +00:00
parent 7003823bed
commit 00f58e5a91
38 changed files with 1873 additions and 342 deletions

View File

@@ -29,6 +29,7 @@
#include "bullet_btTransformFloatData.h"
#include "bullet_btTransformDoubleData.h"
#include "bullet_btCollisionShapeData.h"
#include "bullet_btStaticPlaneShapeData.h"
#include "bullet_btConvexInternalShapeData.h"
#include "bullet_btPositionAndRadius.h"
#include "bullet_btMultiSphereShapeData.h"
@@ -37,9 +38,22 @@
#include "bullet_btMeshPartData.h"
#include "bullet_btStridingMeshInterfaceData.h"
#include "bullet_btTriangleMeshShapeData.h"
#include "bullet_btCompoundShapeChildData.h"
#include "bullet_btCompoundShapeData.h"
#include "bullet_btCylinderShapeData.h"
#include "bullet_btCapsuleShapeData.h"
#include "bullet_btConvexHullShapeData.h"
#include "bullet_btCollisionObjectDoubleData.h"
#include "bullet_btCollisionObjectFloatData.h"
#include "bullet_btRigidBodyFloatData.h"
#include "bullet_btRigidBodyDoubleData.h"
#include "bullet_btConstraintInfo1.h"
#include "bullet_btTypedConstraintData.h"
#include "bullet_btPoint2PointConstraintFloatData.h"
#include "bullet_btPoint2PointConstraintDoubleData.h"
#include "bullet_btHingeConstraintDoubleData.h"
#include "bullet_btHingeConstraintFloatData.h"
#include "bullet_btConeTwistConstraintData.h"
#include "bullet_btGeneric6DofConstraintData.h"
#include "bullet_btSliderConstraintData.h"
#endif//__BULLET_H__

View File

@@ -36,6 +36,7 @@ namespace Bullet {
class btTransformFloatData;
class btTransformDoubleData;
class btCollisionShapeData;
class btStaticPlaneShapeData;
class btConvexInternalShapeData;
class btPositionAndRadius;
class btMultiSphereShapeData;
@@ -44,10 +45,23 @@ namespace Bullet {
class btMeshPartData;
class btStridingMeshInterfaceData;
class btTriangleMeshShapeData;
class btCompoundShapeChildData;
class btCompoundShapeData;
class btCylinderShapeData;
class btCapsuleShapeData;
class btConvexHullShapeData;
class btCollisionObjectDoubleData;
class btCollisionObjectFloatData;
class btRigidBodyFloatData;
class btRigidBodyDoubleData;
class btConstraintInfo1;
class btTypedConstraintData;
class btPoint2PointConstraintFloatData;
class btPoint2PointConstraintDoubleData;
class btHingeConstraintDoubleData;
class btHingeConstraintFloatData;
class btConeTwistConstraintData;
class btGeneric6DofConstraintData;
class btSliderConstraintData;
}
#endif//__BULLETCOMMON_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_BTCAPSULESHAPEDATA__H__
#define __BULLET_BTCAPSULESHAPEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btConvexInternalShapeData.h"
namespace Bullet {
// ---------------------------------------------- //
class btCapsuleShapeData
{
public:
btConvexInternalShapeData m_convexInternalShapeData;
int m_upAxis;
char m_padding[4];
};
}
#endif//__BULLET_BTCAPSULESHAPEDATA__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_BTCOMPOUNDSHAPECHILDDATA__H__
#define __BULLET_BTCOMPOUNDSHAPECHILDDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTransformFloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btCompoundShapeChildData
{
public:
btTransformFloatData m_transform;
btCollisionShapeData *m_childShape;
int m_childShapeType;
float m_childMargin;
};
}
#endif//__BULLET_BTCOMPOUNDSHAPECHILDDATA__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_BTCOMPOUNDSHAPEDATA__H__
#define __BULLET_BTCOMPOUNDSHAPEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btCollisionShapeData.h"
namespace Bullet {
// ---------------------------------------------- //
class btCompoundShapeData
{
public:
btCollisionShapeData m_collisionShapeData;
btCompoundShapeChildData *m_childShapePtr;
int m_numChildShapes;
float m_collisionMargin;
};
}
#endif//__BULLET_BTCOMPOUNDSHAPEDATA__H__

View File

@@ -0,0 +1,51 @@
/* 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_BTCONETWISTCONSTRAINTDATA__H__
#define __BULLET_BTCONETWISTCONSTRAINTDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTransformFloatData.h"
#include "bullet_btTypedConstraintData.h"
namespace Bullet {
// ---------------------------------------------- //
class btConeTwistConstraintData
{
public:
btTypedConstraintData m_typeConstraintData;
btTransformFloatData m_rbAFrame;
btTransformFloatData m_rbBFrame;
float m_swingSpan1;
float m_swingSpan2;
float m_twistSpan;
float m_limitSoftness;
float m_biasFactor;
float m_relaxationFactor;
float m_damping;
char m_pad[4];
};
}
#endif//__BULLET_BTCONETWISTCONSTRAINTDATA__H__

View File

@@ -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_BTCONSTRAINTINFO1__H__
#define __BULLET_BTCONSTRAINTINFO1__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
namespace Bullet {
// ---------------------------------------------- //
class btConstraintInfo1
{
public:
int m_numConstraintRows;
int nub;
};
}
#endif//__BULLET_BTCONSTRAINTINFO1__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_BTCYLINDERSHAPEDATA__H__
#define __BULLET_BTCYLINDERSHAPEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btConvexInternalShapeData.h"
namespace Bullet {
// ---------------------------------------------- //
class btCylinderShapeData
{
public:
btConvexInternalShapeData m_convexInternalShapeData;
int m_upAxis;
char m_padding[4];
};
}
#endif//__BULLET_BTCYLINDERSHAPEDATA__H__

View File

@@ -0,0 +1,50 @@
/* 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_BTGENERIC6DOFCONSTRAINTDATA__H__
#define __BULLET_BTGENERIC6DOFCONSTRAINTDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTransformFloatData.h"
#include "bullet_btTypedConstraintData.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btGeneric6DofConstraintData
{
public:
btTypedConstraintData m_typeConstraintData;
btTransformFloatData m_rbAFrame;
btTransformFloatData m_rbBFrame;
btVector3FloatData m_linearUpperLimit;
btVector3FloatData m_linearLowerLimit;
btVector3FloatData m_angularUpperLimit;
btVector3FloatData m_angularLowerLimit;
int m_useLinearReferenceFrameA;
int m_useOffsetForConstraintFrame;
};
}
#endif//__BULLET_BTGENERIC6DOFCONSTRAINTDATA__H__

View File

@@ -0,0 +1,53 @@
/* 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_BTHINGECONSTRAINTDOUBLEDATA__H__
#define __BULLET_BTHINGECONSTRAINTDOUBLEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTransformDoubleData.h"
#include "bullet_btTypedConstraintData.h"
namespace Bullet {
// ---------------------------------------------- //
class btHingeConstraintDoubleData
{
public:
btTypedConstraintData m_typeConstraintData;
btTransformDoubleData m_rbAFrame;
btTransformDoubleData m_rbBFrame;
int m_useReferenceFrameA;
int m_angularOnly;
int m_enableAngularMotor;
float m_motorTargetVelocity;
float m_maxMotorImpulse;
float m_lowerLimit;
float m_upperLimit;
float m_limitSoftness;
float m_biasFactor;
float m_relaxationFactor;
};
}
#endif//__BULLET_BTHINGECONSTRAINTDOUBLEDATA__H__

View File

@@ -0,0 +1,53 @@
/* 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_BTHINGECONSTRAINTFLOATDATA__H__
#define __BULLET_BTHINGECONSTRAINTFLOATDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTransformFloatData.h"
#include "bullet_btTypedConstraintData.h"
namespace Bullet {
// ---------------------------------------------- //
class btHingeConstraintFloatData
{
public:
btTypedConstraintData m_typeConstraintData;
btTransformFloatData m_rbAFrame;
btTransformFloatData m_rbBFrame;
int m_useReferenceFrameA;
int m_angularOnly;
int m_enableAngularMotor;
float m_motorTargetVelocity;
float m_maxMotorImpulse;
float m_lowerLimit;
float m_upperLimit;
float m_limitSoftness;
float m_biasFactor;
float m_relaxationFactor;
};
}
#endif//__BULLET_BTHINGECONSTRAINTFLOATDATA__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_BTPOINT2POINTCONSTRAINTDOUBLEDATA__H__
#define __BULLET_BTPOINT2POINTCONSTRAINTDOUBLEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTypedConstraintData.h"
#include "bullet_btVector3DoubleData.h"
namespace Bullet {
// ---------------------------------------------- //
class btPoint2PointConstraintDoubleData
{
public:
btTypedConstraintData m_typeConstraintData;
btVector3DoubleData m_pivotInA;
btVector3DoubleData m_pivotInB;
};
}
#endif//__BULLET_BTPOINT2POINTCONSTRAINTDOUBLEDATA__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_BTPOINT2POINTCONSTRAINTFLOATDATA__H__
#define __BULLET_BTPOINT2POINTCONSTRAINTFLOATDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTypedConstraintData.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btPoint2PointConstraintFloatData
{
public:
btTypedConstraintData m_typeConstraintData;
btVector3FloatData m_pivotInA;
btVector3FloatData m_pivotInB;
};
}
#endif//__BULLET_BTPOINT2POINTCONSTRAINTFLOATDATA__H__

View File

@@ -0,0 +1,49 @@
/* 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_BTSLIDERCONSTRAINTDATA__H__
#define __BULLET_BTSLIDERCONSTRAINTDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTransformFloatData.h"
#include "bullet_btTypedConstraintData.h"
namespace Bullet {
// ---------------------------------------------- //
class btSliderConstraintData
{
public:
btTypedConstraintData m_typeConstraintData;
btTransformFloatData m_rbAFrame;
btTransformFloatData m_rbBFrame;
float m_linearUpperLimit;
float m_linearLowerLimit;
float m_angularUpperLimit;
float m_angularLowerLimit;
int m_useLinearReferenceFrameA;
int m_useOffsetForConstraintFrame;
};
}
#endif//__BULLET_BTSLIDERCONSTRAINTDATA__H__

View File

@@ -0,0 +1,45 @@
/* 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_BTSTATICPLANESHAPEDATA__H__
#define __BULLET_BTSTATICPLANESHAPEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btCollisionShapeData.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btStaticPlaneShapeData
{
public:
btCollisionShapeData m_collisionShapeData;
btVector3FloatData m_localScaling;
btVector3FloatData m_planeNormal;
float m_planeConstant;
char m_pad[4];
};
}
#endif//__BULLET_BTSTATICPLANESHAPEDATA__H__

View File

@@ -0,0 +1,52 @@
/* 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_BTTYPEDCONSTRAINTDATA__H__
#define __BULLET_BTTYPEDCONSTRAINTDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btTypedConstraintData
{
public:
bInvalidHandle *m_rbA;
bInvalidHandle *m_rbB;
btVector3FloatData m_appliedLinearImpulse;
btVector3FloatData m_appliedAngularImpulseA;
btVector3FloatData m_appliedAngularImpulseB;
int m_objectType;
int m_userConstraintType;
int m_userConstraintId;
int m_needsFeedback;
float m_appliedImpulse;
float m_dbgDrawSize;
int m_disableCollisionsBetweenLinkedBodies;
char m_pad[4];
};
}
#endif//__BULLET_BTTYPEDCONSTRAINTDATA__H__

View File

@@ -423,6 +423,7 @@ void bFile::parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bo
}
}
// ----------------------------------------------------- //
static void getElement(int arrayLen, const char *cur, const char *old, char *oldPtr, char *curData)
{
@@ -436,7 +437,7 @@ static void getElement(int arrayLen, const char *cur, const char *old, char *old
#define setEle(value, current, type, cast, size, ptr)\
if (strcmp(current, type)==0)\
{\
(*(cast*)ptr) = value;\
(*(cast*)ptr) = (cast)value;\
ptr += size;\
}
double value = 0.0;

View File

@@ -121,7 +121,12 @@ void btBulletFile::parseData()
{
m_rigidBodies.push_back((bStructHandle*) id);
}
if (dataChunk.code == BT_CONSTRAINT_CODE)
{
m_constraints.push_back((bStructHandle*) id);
}
if (dataChunk.code == BT_COLLISIONOBJECT_CODE)
{
m_collisionObjects.push_back((bStructHandle*) id);

View File

@@ -23,6 +23,7 @@ subject to the following restrictions:
#define BT_COLLISIONOBJECT_CODE MAKE_ID('C','O','B','J')
#define BT_RIGIDBODY_CODE MAKE_ID('R','B','D','Y')
#define BT_CONSTRAINT_CODE MAKE_ID('C','O','N','S')
#define BT_BOXSHAPE_CODE MAKE_ID('B','O','X','S')
#define BT_SHAPE_CODE MAKE_ID('S','H','A','P')
@@ -44,6 +45,8 @@ namespace bParse {
btAlignedObjectArray<bStructHandle*> m_collisionShapes;
btAlignedObjectArray<bStructHandle*> m_constraints;
btBulletFile();
btBulletFile(const char* fileName);

View File

@@ -42,6 +42,18 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
switch (shapeData->m_shapeType)
{
case STATIC_PLANE_PROXYTYPE:
{
btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*)shapeData;
btVector3 planeNormal,localScaling;
planeNormal.deSerializeFloat(planeData->m_planeNormal);
localScaling.deSerializeFloat(planeData->m_localScaling);
shape = new btStaticPlaneShape(planeNormal,btScalar(planeData->m_planeConstant));
shape->setLocalScaling(localScaling);
break;
}
case CYLINDER_SHAPE_PROXYTYPE:
case CAPSULE_SHAPE_PROXYTYPE:
case BOX_SHAPE_PROXYTYPE:
@@ -294,6 +306,9 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil
if (shape)
shapeMap.insert(shapeData,shape);
}
btHashMap<btHashPtr,btRigidBody*> bodyMap;
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
{
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
@@ -314,7 +329,8 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil
shape->calculateLocalInertia(mass,localInertia);
}
bool isDynamic = mass!=0.f;
createRigidBody(isDynamic,mass,startTransform,shape);
btRigidBody* body = createRigidBody(isDynamic,mass,startTransform,shape);
bodyMap.insert(colObjData,body);
} else
{
printf("error: no shape found\n");
@@ -338,7 +354,8 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil
shape->calculateLocalInertia(mass,localInertia);
}
bool isDynamic = mass!=0.f;
createRigidBody(isDynamic,mass,startTransform,shape);
btRigidBody* body = createRigidBody(isDynamic,mass,startTransform,shape);
bodyMap.insert(colObjData,body);
} else
{
printf("error: no shape found\n");
@@ -351,6 +368,206 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil
btCollisionObjectData* colObjData = (btCollisionObjectData*)bulletFile2->m_collisionObjects[i];
printf("bla");
}
for (i=0;i<bulletFile2->m_constraints.size();i++)
{
btTypedConstraintData* constraintData = (btTypedConstraintData*)bulletFile2->m_constraints[i];
btRigidBody** rbAptr = bodyMap.find(constraintData->m_rbA);
btRigidBody** rbBptr = bodyMap.find(constraintData->m_rbB);
switch (constraintData->m_objectType)
{
case POINT2POINT_CONSTRAINT_TYPE:
{
btPoint2PointConstraint* constraint = 0;
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
{
btPoint2PointConstraintDoubleData* p2pData = (btPoint2PointConstraintDoubleData*)constraintData;
if (rbAptr && rbBptr)
{
btVector3 pivotInA,pivotInB;
pivotInA.deSerializeDouble(p2pData->m_pivotInA);
pivotInB.deSerializeDouble(p2pData->m_pivotInB);
constraint = new btPoint2PointConstraint(**rbAptr,**rbBptr,pivotInA,pivotInB);
} else
{
btVector3 pivotInA;
pivotInA.deSerializeDouble(p2pData->m_pivotInA);
constraint = new btPoint2PointConstraint(**rbAptr,pivotInA);
}
} else
{
btPoint2PointConstraintFloatData* p2pData = (btPoint2PointConstraintFloatData*)constraintData;
if (rbAptr && rbBptr)
{
btVector3 pivotInA,pivotInB;
pivotInA.deSerializeFloat(p2pData->m_pivotInA);
pivotInB.deSerializeFloat(p2pData->m_pivotInB);
constraint = new btPoint2PointConstraint(**rbAptr,**rbBptr,pivotInA,pivotInB);
} else
{
btVector3 pivotInA;
pivotInA.deSerializeFloat(p2pData->m_pivotInA);
constraint = new btPoint2PointConstraint(**rbAptr,pivotInA);
}
}
m_dynamicsWorld->addConstraint(constraint,constraintData->m_disableCollisionsBetweenLinkedBodies!=0);
constraint->setDbgDrawSize(constraintData->m_dbgDrawSize);
break;
}
case HINGE_CONSTRAINT_TYPE:
{
btHingeConstraint* hinge = 0;
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
{
btHingeConstraintDoubleData* hingeData = (btHingeConstraintDoubleData*)constraintData;
if (rbAptr && rbBptr)
{
btTransform rbAFrame,rbBFrame;
rbAFrame.deSerializeDouble(hingeData->m_rbAFrame);
rbBFrame.deSerializeDouble(hingeData->m_rbBFrame);
hinge = new btHingeConstraint(**rbAptr,**rbBptr,rbAFrame,rbBFrame,hingeData->m_useReferenceFrameA!=0);
} else
{
btTransform rbAFrame;
rbAFrame.deSerializeDouble(hingeData->m_rbAFrame);
hinge = new btHingeConstraint(**rbAptr,rbAFrame,hingeData->m_useReferenceFrameA!=0);
}
if (hingeData->m_enableAngularMotor)
{
hinge->enableAngularMotor(true,hingeData->m_motorTargetVelocity,hingeData->m_maxMotorImpulse);
}
hinge->setAngularOnly(hingeData->m_angularOnly!=0);
hinge->setLimit(btScalar(hingeData->m_lowerLimit),btScalar(hingeData->m_upperLimit),btScalar(hingeData->m_limitSoftness),btScalar(hingeData->m_biasFactor),btScalar(hingeData->m_relaxationFactor));
} else
{
btHingeConstraintFloatData* hingeData = (btHingeConstraintFloatData*)constraintData;
if (rbAptr && rbBptr)
{
btTransform rbAFrame,rbBFrame;
rbAFrame.deSerializeFloat(hingeData->m_rbAFrame);
rbBFrame.deSerializeFloat(hingeData->m_rbBFrame);
hinge = new btHingeConstraint(**rbAptr,**rbBptr,rbAFrame,rbBFrame,hingeData->m_useReferenceFrameA!=0);
} else
{
btTransform rbAFrame;
rbAFrame.deSerializeFloat(hingeData->m_rbAFrame);
hinge = new btHingeConstraint(**rbAptr,rbAFrame,hingeData->m_useReferenceFrameA!=0);
}
if (hingeData->m_enableAngularMotor)
{
hinge->enableAngularMotor(true,hingeData->m_motorTargetVelocity,hingeData->m_maxMotorImpulse);
}
hinge->setAngularOnly(hingeData->m_angularOnly!=0);
hinge->setLimit(btScalar(hingeData->m_lowerLimit),btScalar(hingeData->m_upperLimit),btScalar(hingeData->m_limitSoftness),btScalar(hingeData->m_biasFactor),btScalar(hingeData->m_relaxationFactor));
}
m_dynamicsWorld->addConstraint(hinge,constraintData->m_disableCollisionsBetweenLinkedBodies!=0);
hinge->setDbgDrawSize(constraintData->m_dbgDrawSize);
break;
}
case CONETWIST_CONSTRAINT_TYPE:
{
btConeTwistConstraintData* coneData = (btConeTwistConstraintData*)constraintData;
btConeTwistConstraint* coneTwist = 0;
if (rbAptr && rbBptr)
{
btTransform rbAFrame,rbBFrame;
rbAFrame.deSerializeFloat(coneData->m_rbAFrame);
rbBFrame.deSerializeFloat(coneData->m_rbBFrame);
coneTwist = new btConeTwistConstraint(**rbAptr,**rbBptr,rbAFrame,rbBFrame);
} else
{
btTransform rbAFrame;
rbAFrame.deSerializeFloat(coneData->m_rbAFrame);
coneTwist = new btConeTwistConstraint(**rbAptr,rbAFrame);
}
coneTwist->setLimit(coneData->m_swingSpan1,coneData->m_swingSpan2,coneData->m_twistSpan,coneData->m_limitSoftness,coneData->m_biasFactor,coneData->m_relaxationFactor);
coneTwist->setDamping(coneData->m_damping);
m_dynamicsWorld->addConstraint(coneTwist,constraintData->m_disableCollisionsBetweenLinkedBodies!=0);
coneTwist->setDbgDrawSize(constraintData->m_dbgDrawSize);
break;
}
case D6_CONSTRAINT_TYPE:
{
btGeneric6DofConstraintData* dofData = (btGeneric6DofConstraintData*)constraintData;
btGeneric6DofConstraint* dof = 0;
if (rbAptr && rbBptr)
{
btTransform rbAFrame,rbBFrame;
rbAFrame.deSerializeFloat(dofData->m_rbAFrame);
rbBFrame.deSerializeFloat(dofData->m_rbBFrame);
dof = new btGeneric6DofConstraint(**rbAptr,**rbBptr,rbAFrame,rbBFrame,dofData->m_useLinearReferenceFrameA!=0);
} else
{
btTransform rbBFrame;
rbBFrame.deSerializeFloat(dofData->m_rbBFrame);
dof = new btGeneric6DofConstraint(**rbBptr,rbBFrame,dofData->m_useLinearReferenceFrameA!=0);
}
btVector3 angLowerLimit,angUpperLimit, linLowerLimit,linUpperlimit;
angLowerLimit.deSerializeFloat(dofData->m_angularLowerLimit);
angUpperLimit.deSerializeFloat(dofData->m_angularUpperLimit);
linLowerLimit.deSerializeFloat(dofData->m_linearLowerLimit);
linUpperlimit.deSerializeFloat(dofData->m_linearUpperLimit);
dof->setAngularLowerLimit(angLowerLimit);
dof->setAngularUpperLimit(angUpperLimit);
dof->setLinearLowerLimit(linLowerLimit);
dof->setLinearUpperLimit(linUpperlimit);
m_dynamicsWorld->addConstraint(dof,constraintData->m_disableCollisionsBetweenLinkedBodies!=0);
dof->setDbgDrawSize(constraintData->m_dbgDrawSize);
break;
}
case SLIDER_CONSTRAINT_TYPE:
{
btSliderConstraintData* sliderData = (btSliderConstraintData*)constraintData;
btSliderConstraint* slider = 0;
if (rbAptr && rbBptr)
{
btTransform rbAFrame,rbBFrame;
rbAFrame.deSerializeFloat(sliderData->m_rbAFrame);
rbBFrame.deSerializeFloat(sliderData->m_rbBFrame);
slider = new btSliderConstraint(**rbAptr,**rbBptr,rbAFrame,rbBFrame,sliderData->m_useLinearReferenceFrameA!=0);
} else
{
btTransform rbBFrame;
rbBFrame.deSerializeFloat(sliderData->m_rbBFrame);
slider = new btSliderConstraint(**rbBptr,rbBFrame,sliderData->m_useLinearReferenceFrameA!=0);
}
slider->setLowerLinLimit(sliderData->m_linearLowerLimit);
slider->setUpperLinLimit(sliderData->m_linearUpperLimit);
slider->setLowerAngLimit(sliderData->m_angularLowerLimit);
slider->setUpperAngLimit(sliderData->m_angularUpperLimit);
slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame!=0);
m_dynamicsWorld->addConstraint(slider,constraintData->m_disableCollisionsBetweenLinkedBodies!=0);
slider->setDbgDrawSize(constraintData->m_dbgDrawSize);
break;
}
default:
{
printf("unknown constraint type\n");
}
};
}
return false;
}

View File

@@ -123,6 +123,7 @@ typedef unsigned long uintptr_t;
#include "LinearMath/btMatrix3x3.h"
#include "LinearMath/btTransform.h"
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
#include "BulletCollision/CollisionShapes/btConvexInternalShape.h"
#include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
@@ -132,6 +133,13 @@ typedef unsigned long uintptr_t;
#include "BulletCollision/CollisionShapes/btCylinderShape.h"
#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
#include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h"
#include "BulletDynamics/ConstraintSolver/btHingeConstraint.h"
#include "BulletDynamics/ConstraintSolver/btConeTwistConstraint.h"
#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"
#include "BulletDynamics/ConstraintSolver/btSliderConstraint.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
@@ -152,6 +160,7 @@ char *includefiles[] = {
"../../../src/LinearMath/btMatrix3x3.h",
"../../../src/LinearMath/btTransform.h",
"../../../src/BulletCollision/CollisionShapes/btCollisionShape.h",
"../../../src/BulletCollision/CollisionShapes/btStaticPlaneShape.h",
"../../../src/BulletCollision/CollisionShapes/btConvexInternalShape.h",
"../../../src/BulletCollision/CollisionShapes/btMultiSphereShape.h",
"../../../src/BulletCollision/CollisionShapes/btStridingMeshInterface.h",
@@ -162,6 +171,13 @@ char *includefiles[] = {
"../../../src/BulletCollision/CollisionShapes/btConvexHullShape.h",
"../../../src/BulletCollision/CollisionDispatch/btCollisionObject.h",
"../../../src/BulletDynamics/Dynamics/btRigidBody.h",
"../../../src/BulletDynamics/ConstraintSolver/btTypedConstraint.h",
"../../../src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h",
"../../../src/BulletDynamics/ConstraintSolver/btHingeConstraint.h",
"../../../src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h",
"../../../src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h",
"../../../src/BulletDynamics/ConstraintSolver/btSliderConstraint.h",
// empty string to indicate end of includefiles
""
};
@@ -539,6 +555,8 @@ const char* skipStructTypes[]=
{
"btRigidBodyConstructionInfo",
"Euler",
"btConstraintInfo2",
"btConstraintSetting",
""
};