From 44565d20f4acdcc241dc760eda2ddfc160e8b332 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Tue, 26 Jan 2010 02:24:03 +0000 Subject: [PATCH] added serialization support for btCompoundShape, btCapsuleShapeX/Z, btCylinderShapeX,Z make some serialization methods const prepare for constraint serialization --- Demos/CMakeLists.txt | 2 +- Demos/ConstraintDemo/CMakeLists.txt | 36 ++- Demos/ConstraintDemo/ConstraintDemo.cpp | 82 +++++-- Demos/ConstraintDemo/ConstraintDemo.h | 12 +- Demos/ConstraintDemo/Win32ConstraintDemo.cpp | 25 ++ .../ConvexDecompositionDemo.cpp | 10 +- Demos/OpenGL/GL_DialogWindow.cpp | 2 +- Demos/OpenGL/GL_ShapeDrawer.cpp | 5 +- Demos/SerializeDemo/SerializeDemo.cpp | 6 +- .../btBulletWorldImporter.cpp | 166 +++++++++++--- .../btBulletWorldImporter.h | 15 +- Extras/Serialize/makesdna/makesdna.cpp | 6 + .../CollisionShapes/btCapsuleShape.h | 32 +++ .../CollisionShapes/btCollisionShape.h | 4 +- .../CollisionShapes/btCompoundShape.cpp | 34 ++- .../CollisionShapes/btCompoundShape.h | 46 +++- .../CollisionShapes/btConvexHullShape.h | 4 +- .../CollisionShapes/btConvexInternalShape.h | 4 +- .../CollisionShapes/btCylinderShape.h | 31 +++ .../CollisionShapes/btMultiSphereShape.h | 4 +- .../CollisionShapes/btStridingMeshInterface.h | 4 +- .../CollisionShapes/btTriangleMeshShape.h | 4 +- src/LinearMath/btMatrix3x3.h | 9 + src/LinearMath/btSerializer.cpp | 216 ++++++++++-------- src/LinearMath/btSerializer.h | 16 +- src/LinearMath/btTransform.h | 9 + 26 files changed, 594 insertions(+), 190 deletions(-) create mode 100644 Demos/ConstraintDemo/Win32ConstraintDemo.cpp diff --git a/Demos/CMakeLists.txt b/Demos/CMakeLists.txt index 55aa0fe17..7d6686c8b 100644 --- a/Demos/CMakeLists.txt +++ b/Demos/CMakeLists.txt @@ -1,4 +1,4 @@ -SUBDIRS( OpenGL BasicDemo Benchmarks Box2dDemo ConvexDecompositionDemo SerializeDemo ) +SUBDIRS( OpenGL BasicDemo Benchmarks Box2dDemo ConstraintDemo ConvexDecompositionDemo SerializeDemo ) #todo: re-enable the rest of the demos again diff --git a/Demos/ConstraintDemo/CMakeLists.txt b/Demos/ConstraintDemo/CMakeLists.txt index cb28c5eec..4d7471399 100644 --- a/Demos/ConstraintDemo/CMakeLists.txt +++ b/Demos/ConstraintDemo/CMakeLists.txt @@ -12,15 +12,35 @@ INCLUDE_DIRECTORIES( -${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL +${BULLET_PHYSICS_SOURCE_DIR}/src +${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL +${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader +${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter ) -LINK_LIBRARIES( -OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} -) -ADD_EXECUTABLE(AppConstraintDemo + + + +IF (USE_GLUT) + LINK_LIBRARIES( + OpenGLSupport BulletWorldImporter BulletDynamics BulletCollision LinearMath BulletFileLoader ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} + ) + + ADD_EXECUTABLE(AppConstraintDemo + ConstraintDemo.cpp + main.cpp + ) +ELSE (USE_GLUT) + LINK_LIBRARIES( + OpenGLSupport BulletWorldImporter BulletDynamics BulletCollision LinearMath BulletFileLoader ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} + ) + + ADD_EXECUTABLE(AppConstraintDemo + WIN32 + ../OpenGL/Win32AppMain.cpp + Win32ConstraintDemo.cpp ConstraintDemo.cpp - main.cpp -) - + ConstraintDemo.h + ) +ENDIF (USE_GLUT) diff --git a/Demos/ConstraintDemo/ConstraintDemo.cpp b/Demos/ConstraintDemo/ConstraintDemo.cpp index e32190785..b11653cfd 100644 --- a/Demos/ConstraintDemo/ConstraintDemo.cpp +++ b/Demos/ConstraintDemo/ConstraintDemo.cpp @@ -13,6 +13,7 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ +//#define TEST_SERIALIZATION 1 @@ -28,6 +29,13 @@ subject to the following restrictions: #include "GL_ShapeDrawer.h" #include "GlutStuff.h" +#ifdef TEST_SERIALIZATION +#include "LinearMath/btSerializer.h" +#include "btBulletFile.h" +#include "btBulletWorldImporter.h" +#endif //TEST_SERIALIZATION + + const int numObjects = 3; #define ENABLE_ALL_DEMOS 1 @@ -74,6 +82,15 @@ void drawLimit() } +void ConstraintDemo::setupEmptyDynamicsWorld() +{ + m_collisionConfiguration = new btDefaultCollisionConfiguration(); + m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); + m_overlappingPairCache = new btDbvtBroadphase(); + m_constraintSolver = new btSequentialImpulseConstraintSolver(); + m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_constraintSolver,m_collisionConfiguration); + +} void ConstraintDemo::initPhysics() { @@ -83,14 +100,7 @@ void ConstraintDemo::initPhysics() setCameraDistance(26.f); m_Time = 0; - m_collisionConfiguration = new btDefaultCollisionConfiguration(); - m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); - btVector3 worldMin(-1000,-1000,-1000); - btVector3 worldMax(1000,1000,1000); - m_overlappingPairCache = new btAxisSweep3(worldMin,worldMax); - m_constraintSolver = new btSequentialImpulseConstraintSolver(); - m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_constraintSolver,m_collisionConfiguration); - + setupEmptyDynamicsWorld(); btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(40.),btScalar(50.))); m_collisionShapes.push_back(groundShape); @@ -338,7 +348,7 @@ void ConstraintDemo::initPhysics() btHingeConstraint* pHinge = new btHingeConstraint( *pBody, btPivotA, btAxisA ); // pHinge->enableAngularMotor(true, -1.0, 0.165); // use for the old solver - pHinge->enableAngularMotor(true, -1.0, 1.65); // use for the new SIMD solver + pHinge->enableAngularMotor(true, -1.0f, 1.65f); // use for the new SIMD solver m_dynamicsWorld->addConstraint(pHinge); pHinge->setDbgDrawSize(btScalar(5.f)); } @@ -471,13 +481,35 @@ void ConstraintDemo::initPhysics() spHingeDynAB->setDbgDrawSize(btScalar(5.f)); } #endif + +#ifdef TEST_SERIALIZATION + + int maxSerializeBufferSize = 1024*1024*5; + + btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize); + m_dynamicsWorld->serialize(serializer); + + FILE* f2 = fopen("testFile.bullet","wb"); + fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1,f2); + fclose(f2); + + + exitPhysics(); + + setupEmptyDynamicsWorld(); + + btBulletWorldImporter* fileLoader = new btBulletWorldImporter(m_dynamicsWorld); + + fileLoader->loadFile("testFile.bullet"); + +#endif //TEST_SERIALIZATION + } -ConstraintDemo::~ConstraintDemo() +void ConstraintDemo::exitPhysics() { - //cleanup in the reverse order of creation/initialization - int i; + int i; //removed/delete constraints for (i=m_dynamicsWorld->getNumConstraints()-1; i>=0 ;i--) @@ -511,6 +543,8 @@ ConstraintDemo::~ConstraintDemo() delete shape; } + m_collisionShapes.clear(); + //delete dynamics world delete m_dynamicsWorld; @@ -525,6 +559,13 @@ ConstraintDemo::~ConstraintDemo() delete m_collisionConfiguration; +} + +ConstraintDemo::~ConstraintDemo() +{ + //cleanup in the reverse order of creation/initialization + + exitPhysics(); } @@ -550,7 +591,7 @@ void ConstraintDemo::clientMoveAndDisplay() // build twist target //btQuaternion q2(0,0,0); //btQuaternion q2(btVehictor3(1,0,0), -0.3*sin(m_Time)); - btQuaternion q2(btVector3(1,0,0), -1.49*sin(1.5*m_Time)); + btQuaternion q2(btVector3(1,0,0), -1.49f*btSin(1.5f*m_Time)); // compose cone + twist and set target q1 = q1 * q2; @@ -558,12 +599,21 @@ void ConstraintDemo::clientMoveAndDisplay() m_ctc->setMotorTargetInConstraintSpace(q1); } + { + static bool once = false; + if (m_dynamicsWorld->getDebugDrawer()) + { + m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawConstraints+btIDebugDraw::DBG_DrawConstraintLimits); + once=false; + } + } + { //during idle mode, just run 1 simulation step maximum int maxSimSubSteps = m_idle ? 1 : 1; if (m_idle) - dt = 1.0/420.f; + dt = 1.0f/420.f; int numSimSteps = m_dynamicsWorld->stepSimulation(dt,maxSimSubSteps); @@ -593,7 +643,7 @@ void ConstraintDemo::clientMoveAndDisplay() // drawLimit(); glFlush(); - glutSwapBuffers(); + swapBuffers(); } @@ -611,7 +661,7 @@ void ConstraintDemo::displayCallback(void) { renderme(); glFlush(); - glutSwapBuffers(); + swapBuffers(); } diff --git a/Demos/ConstraintDemo/ConstraintDemo.h b/Demos/ConstraintDemo/ConstraintDemo.h index b7fde5916..8696a5d5c 100644 --- a/Demos/ConstraintDemo/ConstraintDemo.h +++ b/Demos/ConstraintDemo/ConstraintDemo.h @@ -15,10 +15,16 @@ subject to the following restrictions: #ifndef CONSTRAINT_DEMO_H #define CONSTRAINT_DEMO_H +#ifdef _WINDOWS +#include "Win32DemoApplication.h" +#define PlatformDemoApplication Win32DemoApplication +#else #include "GlutDemoApplication.h" +#define PlatformDemoApplication GlutDemoApplication +#endif ///ConstraintDemo shows how to create a constraint, like Hinge or btGenericD6constraint -class ConstraintDemo : public GlutDemoApplication +class ConstraintDemo : public PlatformDemoApplication { //keep track of variables to delete memory at the end btAlignedObjectArray m_collisionShapes; @@ -31,6 +37,8 @@ class ConstraintDemo : public GlutDemoApplication class btDefaultCollisionConfiguration* m_collisionConfiguration; + void setupEmptyDynamicsWorld(); + public: @@ -38,6 +46,8 @@ class ConstraintDemo : public GlutDemoApplication void initPhysics(); + void exitPhysics(); + virtual void clientMoveAndDisplay(); virtual void displayCallback(); diff --git a/Demos/ConstraintDemo/Win32ConstraintDemo.cpp b/Demos/ConstraintDemo/Win32ConstraintDemo.cpp new file mode 100644 index 000000000..66abb66e1 --- /dev/null +++ b/Demos/ConstraintDemo/Win32ConstraintDemo.cpp @@ -0,0 +1,25 @@ +#ifdef _WINDOWS +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org + +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. +*/ + +#include "ConstraintDemo.h" + +///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo +DemoApplication* createDemo() +{ + return new ConstraintDemo(); +} + +#endif diff --git a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp index fd61d31d5..23bb1e468 100644 --- a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp +++ b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp @@ -24,7 +24,7 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btShapeHull.h" #define TEST_SERIALIZATION -#define NO_OBJ_TO_BULLET +//#define NO_OBJ_TO_BULLET #ifdef TEST_SERIALIZATION #include "LinearMath/btSerializer.h" @@ -518,10 +518,10 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) btBulletWorldImporter* fileLoader = new btBulletWorldImporter(m_dynamicsWorld); //fileLoader->setVerboseMode(true); - //fileLoader->loadFileFromMemory("testFile.bullet"); - //fileLoader->loadFileFromMemory("testFile64Double.bullet"); - //fileLoader->loadFileFromMemory("testFile64Single.bullet"); - fileLoader->loadFileFromMemory("testFile32Single.bullet"); + fileLoader->loadFile("testFile.bullet"); + //fileLoader->loadFile("testFile64Double.bullet"); + //fileLoader->loadFile("testFile64Single.bullet"); + //fileLoader->loadFile("testFile32Single.bullet"); diff --git a/Demos/OpenGL/GL_DialogWindow.cpp b/Demos/OpenGL/GL_DialogWindow.cpp index 5de8d4ce9..0158845d3 100644 --- a/Demos/OpenGL/GL_DialogWindow.cpp +++ b/Demos/OpenGL/GL_DialogWindow.cpp @@ -181,7 +181,7 @@ void GL_DialogWindow::draw(btScalar deltaTime) int curVertPos = m_dialogVertPos; curVertPos += yInc; - GLDebugDrawString(m_dialogHorPos+m_dialogWidth/2-((strlen(m_dialogTitle)/2)*charWidth),m_dialogVertPos+yInc ,m_dialogTitle); + GLDebugDrawString(m_dialogHorPos+m_dialogWidth/2-((int(strlen(m_dialogTitle)/2))*charWidth),m_dialogVertPos+yInc ,m_dialogTitle); curVertPos += 20; diff --git a/Demos/OpenGL/GL_ShapeDrawer.cpp b/Demos/OpenGL/GL_ShapeDrawer.cpp index e05a47373..2b003d2b3 100644 --- a/Demos/OpenGL/GL_ShapeDrawer.cpp +++ b/Demos/OpenGL/GL_ShapeDrawer.cpp @@ -403,6 +403,7 @@ inline void glDrawVector(const btVector3& v) { glVertex3d(v[0], v[1], v[2]); } void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax) { + if (shape->getShapeType() == CUSTOM_CONVEX_SHAPE_TYPE) { btVector3 org(m[12], m[13], m[14]); @@ -795,7 +796,6 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons btVector3 v3 = vtx[index3]; btVector3 normal = (v3-v1).cross(v2-v1); normal.normalize (); - glNormal3f(normal.getX(),normal.getY(),normal.getZ()); glVertex3f (v1.x(), v1.y(), v1.z()); glVertex3f (v2.x(), v2.y(), v2.z()); @@ -813,7 +813,8 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons } - + glNormal3f(0,1,0); + /// for polyhedral shapes if (debugMode==btIDebugDraw::DBG_DrawFeaturesText && (shape->isPolyhedral())) diff --git a/Demos/SerializeDemo/SerializeDemo.cpp b/Demos/SerializeDemo/SerializeDemo.cpp index 44618de58..521b960d2 100644 --- a/Demos/SerializeDemo/SerializeDemo.cpp +++ b/Demos/SerializeDemo/SerializeDemo.cpp @@ -159,8 +159,8 @@ void SerializeDemo::initPhysics() //btMultiSphereShape* colShape = new btMultiSphereShape(positions,radii,numSpheres); - btCollisionShape* colShape = new btCapsuleShape(SCALING*1,SCALING*1); - //btCollisionShape* colShape = new btCylinderShape(btVector3(SCALING*1,SCALING*1,SCALING*1)); + btCollisionShape* colShape = new btCapsuleShapeZ(SCALING*1,SCALING*1); + //btCollisionShape* colShape = new btCylinderShapeZ(btVector3(SCALING*1,SCALING*1,SCALING*1)); //btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1)); //btCollisionShape* colShape = new btSphereShape(btScalar(1.)); m_collisionShapes.push_back(colShape); @@ -231,7 +231,7 @@ void SerializeDemo::initPhysics() btBulletWorldImporter* fileLoader = new btBulletWorldImporter(m_dynamicsWorld); - fileLoader->loadFileFromMemory("testFile.bullet"); + fileLoader->loadFile("testFile.bullet"); diff --git a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp index d95ef31dd..7053b89b9 100644 --- a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp +++ b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp @@ -11,7 +11,7 @@ m_verboseDumpAllTypes(false) { } -bool btBulletWorldImporter::loadFileFromMemory( const char* fileName) +bool btBulletWorldImporter::loadFile( const char* fileName) { bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(fileName); @@ -36,30 +36,11 @@ bool btBulletWorldImporter::loadFileFromMemory( char* memoryBuffer, int len) return result; } - -bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFile2) +btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShapeData* shapeData ) { - + btCollisionShape* shape = 0; - bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0; - - if (ok) - bulletFile2->parse(m_verboseDumpAllTypes); - else - return false; - - if (m_verboseDumpAllTypes) - { - bulletFile2->dumpChunks(bulletFile2->getFileDNA()); - } - - int i; - btHashMap shapeMap; - - for (i=0;im_collisionShapes.size();i++) - { - btCollisionShapeData* shapeData = (btCollisionShapeData*)bulletFile2->m_collisionShapes[i]; - switch (shapeData->m_shapeType) + switch (shapeData->m_shapeType) { case CYLINDER_SHAPE_PROXYTYPE: case CAPSULE_SHAPE_PROXYTYPE: @@ -72,7 +53,6 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil btVector3 implicitShapeDimensions; implicitShapeDimensions.deSerializeFloat(bsd->m_implicitShapeDimensions); btVector3 margin(bsd->m_collisionMargin,bsd->m_collisionMargin,bsd->m_collisionMargin); - btCollisionShape* shape = 0; switch (shapeData->m_shapeType) { case BOX_SHAPE_PROXYTYPE: @@ -87,14 +67,63 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil } case CAPSULE_SHAPE_PROXYTYPE: { - shape = createCapsuleShape(implicitShapeDimensions.getX(),implicitShapeDimensions.getY()); + btCapsuleShapeData* capData = (btCapsuleShapeData*)shapeData; + switch (capData->m_upAxis) + { + case 0: + { + shape = createCapsuleShapeX(implicitShapeDimensions.getY(),implicitShapeDimensions.getX()); + break; + } + case 1: + { + shape = createCapsuleShapeY(implicitShapeDimensions.getX(),implicitShapeDimensions.getY()); + break; + } + case 2: + { + shape = createCapsuleShapeZ(implicitShapeDimensions.getX(),implicitShapeDimensions.getZ()); + break; + } + default: + { + printf("error: wrong up axis for btCapsuleShape\n"); + } + + }; + break; } case CYLINDER_SHAPE_PROXYTYPE: { + btCylinderShapeData* cylData = (btCylinderShapeData*) shapeData; btVector3 halfExtents = implicitShapeDimensions+margin; + switch (cylData->m_upAxis) + { + case 0: + { + shape = createCylinderShapeX(halfExtents.getY(),halfExtents.getX()); + break; + } + case 1: + { + shape = createCylinderShapeY(halfExtents.getX(),halfExtents.getY()); + break; + } + case 2: + { + shape = createCylinderShapeZ(halfExtents.getX(),halfExtents.getZ()); + break; + } + default: + { + printf("unknown Cylinder up axis\n"); + } - shape = createCylinderShapeY(halfExtents.getX(),halfExtents.getY()); + }; + + + break; } case MULTI_SPHERE_SHAPE_PROXYTYPE: @@ -154,7 +183,6 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil localScaling.deSerializeFloat(bsd->m_localScaling); shape->setLocalScaling(localScaling); - shapeMap.insert(shapeData,shape); } break; } @@ -198,17 +226,73 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil btBvhTriangleMeshShape* trimeshShape = new btBvhTriangleMeshShape(meshInterface,true); trimeshShape->setMargin(trimesh->m_collisionMargin); - shapeMap.insert(shapeData,trimeshShape); + shape = trimeshShape; //printf("trimesh->m_collisionMargin=%f\n",trimesh->m_collisionMargin); break; } + case COMPOUND_SHAPE_PROXYTYPE: + { + btCompoundShapeData* compoundData = (btCompoundShapeData*)shapeData; + btCompoundShape* compoundShape = new btCompoundShape(); + + + btAlignedObjectArray childShapes; + for (int i=0;im_numChildShapes;i++) + { + btCollisionShape* childShape = convertCollisionShape(compoundData->m_childShapePtr[i].m_childShape); + if (childShape) + { + btTransform localTransform; + localTransform.deSerializeFloat(compoundData->m_childShapePtr[i].m_transform); + compoundShape->addChildShape(localTransform,childShape); + } else + { + printf("error: couldn't create childShape for compoundShape\n"); + } + + } + shape = compoundShape; + + break; + } default: { printf("unsupported shape type (%d)\n",shapeData->m_shapeType); } } - + + return shape; + +} + + + +bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFile2) +{ + + + bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0; + + if (ok) + bulletFile2->parse(m_verboseDumpAllTypes); + else + return false; + + if (m_verboseDumpAllTypes) + { + bulletFile2->dumpChunks(bulletFile2->getFileDNA()); + } + + int i; + btHashMap shapeMap; + + for (i=0;im_collisionShapes.size();i++) + { + btCollisionShapeData* shapeData = (btCollisionShapeData*)bulletFile2->m_collisionShapes[i]; + btCollisionShape* shape = convertCollisionShape(shapeData); + if (shape) + shapeMap.insert(shapeData,shape); } for (i=0;im_rigidBodies.size();i++) { @@ -311,17 +395,39 @@ btCollisionShape* btBulletWorldImporter::createSphereShape(btScalar radius) return new btSphereShape(radius); } -btCollisionShape* btBulletWorldImporter::createCapsuleShape(btScalar radius, btScalar height) + +btCollisionShape* btBulletWorldImporter::createCapsuleShapeX(btScalar radius, btScalar height) +{ + return new btCapsuleShapeX(radius,height); +} + +btCollisionShape* btBulletWorldImporter::createCapsuleShapeY(btScalar radius, btScalar height) { return new btCapsuleShape(radius,height); } +btCollisionShape* btBulletWorldImporter::createCapsuleShapeZ(btScalar radius, btScalar height) +{ + return new btCapsuleShapeZ(radius,height); +} + +btCollisionShape* btBulletWorldImporter::createCylinderShapeX(btScalar radius,btScalar height) +{ + return new btCylinderShapeX(btVector3(height,radius,radius)); +} + btCollisionShape* btBulletWorldImporter::createCylinderShapeY(btScalar radius,btScalar height) { return new btCylinderShape(btVector3(radius,height,radius)); } + +btCollisionShape* btBulletWorldImporter::createCylinderShapeZ(btScalar radius,btScalar height) +{ + return new btCylinderShapeZ(btVector3(radius,radius,height)); +} + btTriangleMesh* btBulletWorldImporter::createTriangleMeshContainer() { return 0; diff --git a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h index 60a72f720..f5941a025 100644 --- a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h +++ b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h @@ -29,24 +29,30 @@ class btTypedConstraint; class btDynamicsWorld; struct ConstraintInput; class btRigidBodyColladaInfo; +struct btCollisionShapeData; namespace bParse { class btBulletFile; + }; class btBulletWorldImporter { +protected: + btDynamicsWorld* m_dynamicsWorld; bool m_verboseDumpAllTypes; + btCollisionShape* convertCollisionShape( btCollisionShapeData* shapeData ); + public: btBulletWorldImporter(btDynamicsWorld* world); - bool loadFileFromMemory(const char* fileName); + bool loadFile(const char* fileName); ///the memoryBuffer might be modified (for example if endian swaps are necessary) bool loadFileFromMemory(char *memoryBuffer, int len); @@ -83,8 +89,13 @@ public: virtual btCollisionShape* createPlaneShape(const btVector3& planeNormal,btScalar planeConstant); virtual btCollisionShape* createBoxShape(const btVector3& halfExtents); virtual btCollisionShape* createSphereShape(btScalar radius); - virtual btCollisionShape* createCapsuleShape(btScalar radius, btScalar height); + virtual btCollisionShape* createCapsuleShapeX(btScalar radius, btScalar height); + virtual btCollisionShape* createCapsuleShapeY(btScalar radius, btScalar height); + virtual btCollisionShape* createCapsuleShapeZ(btScalar radius, btScalar height); + + virtual btCollisionShape* createCylinderShapeX(btScalar radius,btScalar height); virtual btCollisionShape* createCylinderShapeY(btScalar radius,btScalar height); + virtual btCollisionShape* createCylinderShapeZ(btScalar radius,btScalar height); virtual class btTriangleMesh* createTriangleMeshContainer(); virtual btCollisionShape* createBvhTriangleMeshShape(btTriangleMesh* trimesh); virtual btCollisionShape* createConvexTriangleMeshShape(btTriangleMesh* trimesh); diff --git a/Extras/Serialize/makesdna/makesdna.cpp b/Extras/Serialize/makesdna/makesdna.cpp index 77763627f..c9448dd55 100644 --- a/Extras/Serialize/makesdna/makesdna.cpp +++ b/Extras/Serialize/makesdna/makesdna.cpp @@ -128,6 +128,9 @@ typedef unsigned long uintptr_t; #include "BulletCollision/CollisionShapes/btConvexHullShape.h" #include "BulletCollision/CollisionShapes/btStridingMeshInterface.h" #include "BulletCollision/CollisionShapes/btTriangleMeshShape.h" +#include "BulletCollision/CollisionShapes/btCompoundShape.h" +#include "BulletCollision/CollisionShapes/btCylinderShape.h" +#include "BulletCollision/CollisionShapes/btCapsuleShape.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h" #include "BulletDynamics/Dynamics/btRigidBody.h" @@ -153,6 +156,9 @@ char *includefiles[] = { "../../../src/BulletCollision/CollisionShapes/btMultiSphereShape.h", "../../../src/BulletCollision/CollisionShapes/btStridingMeshInterface.h", "../../../src/BulletCollision/CollisionShapes/btTriangleMeshShape.h", + "../../../src/BulletCollision/CollisionShapes/btCompoundShape.h", + "../../../src/BulletCollision/CollisionShapes/btCylinderShape.h", + "../../../src/BulletCollision/CollisionShapes/btCapsuleShape.h", "../../../src/BulletCollision/CollisionShapes/btConvexHullShape.h", "../../../src/BulletCollision/CollisionDispatch/btCollisionObject.h", "../../../src/BulletDynamics/Dynamics/btRigidBody.h", diff --git a/src/BulletCollision/CollisionShapes/btCapsuleShape.h b/src/BulletCollision/CollisionShapes/btCapsuleShape.h index 782efb235..cb3edb92c 100644 --- a/src/BulletCollision/CollisionShapes/btCapsuleShape.h +++ b/src/BulletCollision/CollisionShapes/btCapsuleShape.h @@ -88,6 +88,13 @@ public: m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin; } + + virtual int calculateSerializeBufferSize() const; + + ///fills the dataBuffer and returns the struct name (and 0 on failure) + virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; + + }; ///btCapsuleShapeX represents a capsule around the Z axis @@ -125,5 +132,30 @@ public: }; +struct btCapsuleShapeData +{ + btConvexInternalShapeData m_convexInternalShapeData; + + int m_upAxis; + + char m_padding[4]; +}; + +SIMD_FORCE_INLINE int btCapsuleShape::calculateSerializeBufferSize() const +{ + return sizeof(btCapsuleShapeData); +} + + ///fills the dataBuffer and returns the struct name (and 0 on failure) +SIMD_FORCE_INLINE const char* btCapsuleShape::serialize(void* dataBuffer, btSerializer* serializer) const +{ + btCapsuleShapeData* shapeData = (btCapsuleShapeData*) dataBuffer; + + btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer); + + shapeData->m_upAxis = m_upAxis; + + return "btCapsuleShapeData"; +} #endif //BT_CAPSULE_SHAPE_H diff --git a/src/BulletCollision/CollisionShapes/btCollisionShape.h b/src/BulletCollision/CollisionShapes/btCollisionShape.h index afcd25193..8ef488d0d 100644 --- a/src/BulletCollision/CollisionShapes/btCollisionShape.h +++ b/src/BulletCollision/CollisionShapes/btCollisionShape.h @@ -118,7 +118,7 @@ public: return m_userPointer; } - virtual int calculateSerializeBufferSize(); + virtual int calculateSerializeBufferSize() const; ///fills the dataBuffer and returns the struct name (and 0 on failure) virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; @@ -133,7 +133,7 @@ struct btCollisionShapeData char m_padding[4]; }; -SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize() +SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize() const { return sizeof(btCollisionShapeData); } diff --git a/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/src/BulletCollision/CollisionShapes/btCompoundShape.cpp index 292dbbfbf..d73207e69 100644 --- a/src/BulletCollision/CollisionShapes/btCompoundShape.cpp +++ b/src/BulletCollision/CollisionShapes/btCompoundShape.cpp @@ -16,6 +16,7 @@ subject to the following restrictions: #include "btCompoundShape.h" #include "btCollisionShape.h" #include "BulletCollision/BroadphaseCollision/btDbvt.h" +#include "LinearMath/btSerializer.h" btCompoundShape::btCompoundShape(bool enableDynamicAabbTree) : m_localAabbMin(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)), @@ -278,5 +279,36 @@ void btCompoundShape::setLocalScaling(const btVector3& scaling) updateChildTransform(i, childTrans); recalculateLocalAabb(); } - } + + + + +///fills the dataBuffer and returns the struct name (and 0 on failure) +const char* btCompoundShape::serialize(void* dataBuffer, btSerializer* serializer) const +{ + + btCompoundShapeData* shapeData = (btCompoundShapeData*) dataBuffer; + btCollisionShape::serialize(&shapeData->m_collisionShapeData, serializer); + + shapeData->m_collisionMargin = float(m_collisionMargin); + shapeData->m_numChildShapes = m_children.size(); + shapeData->m_childShapePtr = 0; + if (shapeData->m_numChildShapes) + { + btChunk* chunk = serializer->allocate(sizeof(btCompoundShapeChildData),shapeData->m_numChildShapes); + btCompoundShapeChildData* memPtr = (btCompoundShapeChildData*)chunk->m_oldPtr; + shapeData->m_childShapePtr = memPtr; + + for (int i=0;im_numChildShapes;i++,memPtr++) + { + memPtr->m_childMargin = float(m_children[i].m_childMargin); + memPtr->m_childShape = (btCollisionShapeData*)m_children[i].m_childShape; + memPtr->m_childShapeType = m_children[i].m_childShapeType; + m_children[i].m_transform.serializeFloat(memPtr->m_transform); + } + serializer->finalizeChunk(chunk,"btCompoundShapeChildData",BT_ARRAY_CODE,chunk->m_oldPtr); + } + return "btCompoundShapeData"; +} + diff --git a/src/BulletCollision/CollisionShapes/btCompoundShape.h b/src/BulletCollision/CollisionShapes/btCompoundShape.h index eea1cac39..72de27c90 100644 --- a/src/BulletCollision/CollisionShapes/btCompoundShape.h +++ b/src/BulletCollision/CollisionShapes/btCompoundShape.h @@ -62,6 +62,11 @@ ATTRIBUTE_ALIGNED16(class) btCompoundShape : public btCollisionShape ///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated int m_updateRevision; + btScalar m_collisionMargin; + +protected: + btVector3 m_localScaling; + public: BT_DECLARE_ALIGNED_ALLOCATOR(); @@ -158,13 +163,46 @@ public: return m_updateRevision; } -private: - btScalar m_collisionMargin; -protected: - btVector3 m_localScaling; + virtual int calculateSerializeBufferSize() const; + + ///fills the dataBuffer and returns the struct name (and 0 on failure) + virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; + }; +struct btCompoundShapeChildData +{ + btTransformFloatData m_transform; + btCollisionShapeData *m_childShape; + int m_childShapeType; + float m_childMargin; +}; + + +struct btCompoundShapeData +{ + btCollisionShapeData m_collisionShapeData; + + btCompoundShapeChildData *m_childShapePtr; + + int m_numChildShapes; + + float m_collisionMargin; + +}; + + +SIMD_FORCE_INLINE int btCompoundShape::calculateSerializeBufferSize() const +{ + return sizeof(btCompoundShapeData); +} + + + + + + #endif //COMPOUND_SHAPE_H diff --git a/src/BulletCollision/CollisionShapes/btConvexHullShape.h b/src/BulletCollision/CollisionShapes/btConvexHullShape.h index dcdbbf40c..dc75917da 100644 --- a/src/BulletCollision/CollisionShapes/btConvexHullShape.h +++ b/src/BulletCollision/CollisionShapes/btConvexHullShape.h @@ -89,7 +89,7 @@ public: ///in case we receive negative scaling virtual void setLocalScaling(const btVector3& scaling); - virtual int calculateSerializeBufferSize(); + virtual int calculateSerializeBufferSize() const; ///fills the dataBuffer and returns the struct name (and 0 on failure) virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; @@ -110,7 +110,7 @@ struct btConvexHullShapeData }; -SIMD_FORCE_INLINE int btConvexHullShape::calculateSerializeBufferSize() +SIMD_FORCE_INLINE int btConvexHullShape::calculateSerializeBufferSize() const { return sizeof(btConvexHullShapeData); } diff --git a/src/BulletCollision/CollisionShapes/btConvexInternalShape.h b/src/BulletCollision/CollisionShapes/btConvexInternalShape.h index 8e187c6f9..b7a2c27c5 100644 --- a/src/BulletCollision/CollisionShapes/btConvexInternalShape.h +++ b/src/BulletCollision/CollisionShapes/btConvexInternalShape.h @@ -110,7 +110,7 @@ public: btAssert(0); } - virtual int calculateSerializeBufferSize(); + virtual int calculateSerializeBufferSize() const; ///fills the dataBuffer and returns the struct name (and 0 on failure) virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; @@ -135,7 +135,7 @@ struct btConvexInternalShapeData -SIMD_FORCE_INLINE int btConvexInternalShape::calculateSerializeBufferSize() +SIMD_FORCE_INLINE int btConvexInternalShape::calculateSerializeBufferSize() const { return sizeof(btConvexInternalShapeData); } diff --git a/src/BulletCollision/CollisionShapes/btCylinderShape.h b/src/BulletCollision/CollisionShapes/btCylinderShape.h index a92f9fc44..8bc4a9a47 100644 --- a/src/BulletCollision/CollisionShapes/btCylinderShape.h +++ b/src/BulletCollision/CollisionShapes/btCylinderShape.h @@ -106,7 +106,10 @@ public: return "CylinderY"; } + virtual int calculateSerializeBufferSize() const; + ///fills the dataBuffer and returns the struct name (and 0 on failure) + virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; }; @@ -157,5 +160,33 @@ public: }; +struct btCylinderShapeData +{ + btConvexInternalShapeData m_convexInternalShapeData; + + int m_upAxis; + + char m_padding[4]; +}; + +SIMD_FORCE_INLINE int btCylinderShape::calculateSerializeBufferSize() const +{ + return sizeof(btCylinderShapeData); +} + + ///fills the dataBuffer and returns the struct name (and 0 on failure) +SIMD_FORCE_INLINE const char* btCylinderShape::serialize(void* dataBuffer, btSerializer* serializer) const +{ + btCylinderShapeData* shapeData = (btCylinderShapeData*) dataBuffer; + + btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer); + + shapeData->m_upAxis = m_upAxis; + + return "btCylinderShapeData"; +} + + + #endif //CYLINDER_MINKOWSKI_H diff --git a/src/BulletCollision/CollisionShapes/btMultiSphereShape.h b/src/BulletCollision/CollisionShapes/btMultiSphereShape.h index afc92ce86..3db7e3208 100644 --- a/src/BulletCollision/CollisionShapes/btMultiSphereShape.h +++ b/src/BulletCollision/CollisionShapes/btMultiSphereShape.h @@ -63,7 +63,7 @@ public: return "MultiSphere"; } - virtual int calculateSerializeBufferSize(); + virtual int calculateSerializeBufferSize() const; ///fills the dataBuffer and returns the struct name (and 0 on failure) virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; @@ -89,7 +89,7 @@ struct btMultiSphereShapeData -SIMD_FORCE_INLINE int btMultiSphereShape::calculateSerializeBufferSize() +SIMD_FORCE_INLINE int btMultiSphereShape::calculateSerializeBufferSize() const { return sizeof(btMultiSphereShapeData); } diff --git a/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h b/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h index 5b9741cce..1c7c30a76 100644 --- a/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h +++ b/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h @@ -91,7 +91,7 @@ class btStridingMeshInterface m_scaling = scaling; } - virtual int calculateSerializeBufferSize(); + virtual int calculateSerializeBufferSize() const; ///fills the dataBuffer and returns the struct name (and 0 on failure) virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; @@ -132,7 +132,7 @@ struct btStridingMeshInterfaceData -SIMD_FORCE_INLINE int btStridingMeshInterface::calculateSerializeBufferSize() +SIMD_FORCE_INLINE int btStridingMeshInterface::calculateSerializeBufferSize() const { return sizeof(btStridingMeshInterfaceData); } diff --git a/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h b/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h index f74915431..b46d2e0bd 100644 --- a/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h +++ b/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h @@ -80,7 +80,7 @@ public: //debugging virtual const char* getName()const {return "TRIANGLEMESH";} - virtual int calculateSerializeBufferSize(); + virtual int calculateSerializeBufferSize() const; ///fills the dataBuffer and returns the struct name (and 0 on failure) virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; @@ -101,7 +101,7 @@ struct btTriangleMeshShapeData }; -SIMD_FORCE_INLINE int btTriangleMeshShape::calculateSerializeBufferSize() +SIMD_FORCE_INLINE int btTriangleMeshShape::calculateSerializeBufferSize() const { return sizeof(btTriangleMeshShapeData); } diff --git a/src/LinearMath/btMatrix3x3.h b/src/LinearMath/btMatrix3x3.h index 1032e6a5a..3c37f6e4f 100644 --- a/src/LinearMath/btMatrix3x3.h +++ b/src/LinearMath/btMatrix3x3.h @@ -503,6 +503,8 @@ public: void serialize(struct btMatrix3x3Data& dataOut) const; + void serializeFloat(struct btMatrix3x3FloatData& dataOut) const; + void deSerialize(const struct btMatrix3x3Data& dataIn); void deSerializeFloat(const struct btMatrix3x3FloatData& dataIn); @@ -650,12 +652,19 @@ struct btMatrix3x3DoubleData + SIMD_FORCE_INLINE void btMatrix3x3::serialize(struct btMatrix3x3Data& dataOut) const { for (int i=0;i<3;i++) m_el[i].serialize(dataOut.m_el[i]); } +SIMD_FORCE_INLINE void btMatrix3x3::serializeFloat(struct btMatrix3x3FloatData& dataOut) const +{ + for (int i=0;i<3;i++) + m_el[i].serializeFloat(dataOut.m_el[i]); +} + SIMD_FORCE_INLINE void btMatrix3x3::deSerialize(const struct btMatrix3x3Data& dataIn) { diff --git a/src/LinearMath/btSerializer.cpp b/src/LinearMath/btSerializer.cpp index 6eb43a8c0..74b3f1367 100644 --- a/src/LinearMath/btSerializer.cpp +++ b/src/LinearMath/btSerializer.cpp @@ -1,6 +1,5 @@ - unsigned char sBulletDNAstr64[]= { -83,68,78,65,78,65,77,69,85,0,0,0,109,95,115,105,122,101,0,109, +83,68,78,65,78,65,77,69,92,0,0,0,109,95,115,105,122,101,0,109, 95,99,97,112,97,99,105,116,121,0,42,109,95,100,97,116,97,0,109,95, 99,111,108,108,105,115,105,111,110,83,104,97,112,101,115,0,109,95,99,111, 108,108,105,115,105,111,110,79,98,106,101,99,116,115,0,109,95,99,111,110, @@ -25,7 +24,12 @@ unsigned char sBulletDNAstr64[]= { 0,109,95,110,117,109,86,101,114,116,105,99,101,115,0,42,109,95,109,101, 115,104,80,97,114,116,115,80,116,114,0,109,95,115,99,97,108,105,110,103, 0,109,95,110,117,109,77,101,115,104,80,97,114,116,115,0,109,95,109,101, -115,104,73,110,116,101,114,102,97,99,101,0,42,109,95,117,110,115,99,97, +115,104,73,110,116,101,114,102,97,99,101,0,109,95,116,114,97,110,115,102, +111,114,109,0,42,109,95,99,104,105,108,100,83,104,97,112,101,0,109,95, +99,104,105,108,100,83,104,97,112,101,84,121,112,101,0,109,95,99,104,105, +108,100,77,97,114,103,105,110,0,42,109,95,99,104,105,108,100,83,104,97, +112,101,80,116,114,0,109,95,110,117,109,67,104,105,108,100,83,104,97,112, +101,115,0,109,95,117,112,65,120,105,115,0,42,109,95,117,110,115,99,97, 108,101,100,80,111,105,110,116,115,70,108,111,97,116,80,116,114,0,42,109, 95,117,110,115,99,97,108,101,100,80,111,105,110,116,115,68,111,117,98,108, 101,80,116,114,0,109,95,110,117,109,85,110,115,99,97,108,101,100,80,111, @@ -75,7 +79,7 @@ unsigned char sBulletDNAstr64[]= { 110,101,97,114,83,108,101,101,112,105,110,103,84,104,114,101,115,104,111,108, 100,0,109,95,97,110,103,117,108,97,114,83,108,101,101,112,105,110,103,84, 104,114,101,115,104,111,108,100,0,109,95,97,100,100,105,116,105,111,110,97, -108,68,97,109,112,105,110,103,0,0,0,0,84,89,80,69,33,0,0,0, +108,68,97,109,112,105,110,103,0,0,0,0,84,89,80,69,37,0,0,0, 99,104,97,114,0,117,99,104,97,114,0,115,104,111,114,116,0,117,115,104, 111,114,116,0,105,110,116,0,108,111,110,103,0,117,108,111,110,103,0,102, 108,111,97,116,0,100,111,117,98,108,101,0,118,111,105,100,0,80,111,105, @@ -96,55 +100,62 @@ unsigned char sBulletDNAstr64[]= { 68,97,116,97,0,98,116,77,101,115,104,80,97,114,116,68,97,116,97,0, 98,116,83,116,114,105,100,105,110,103,77,101,115,104,73,110,116,101,114,102, 97,99,101,68,97,116,97,0,98,116,84,114,105,97,110,103,108,101,77,101, -115,104,83,104,97,112,101,68,97,116,97,0,98,116,67,111,110,118,101,120, -72,117,108,108,83,104,97,112,101,68,97,116,97,0,98,116,67,111,108,108, -105,115,105,111,110,79,98,106,101,99,116,68,111,117,98,108,101,68,97,116, -97,0,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,70, -108,111,97,116,68,97,116,97,0,98,116,82,105,103,105,100,66,111,100,121, -70,108,111,97,116,68,97,116,97,0,98,116,82,105,103,105,100,66,111,100, -121,68,111,117,98,108,101,68,97,116,97,0,84,76,69,78,1,0,1,0, -2,0,2,0,4,0,4,0,4,0,4,0,8,0,0,0,16,0,48,0, -16,0,16,0,32,0,48,0,96,0,64,0,-128,0,16,0,56,0,20,0, -72,0,4,0,4,0,40,0,32,0,56,0,80,0,-40,1,8,1,-16,1, --88,3,0,0,83,84,82,67,23,0,0,0,10,0,3,0,4,0,0,0, -4,0,1,0,9,0,2,0,11,0,3,0,10,0,3,0,10,0,4,0, -10,0,5,0,12,0,2,0,9,0,6,0,9,0,7,0,13,0,1,0, -7,0,8,0,14,0,1,0,8,0,8,0,15,0,1,0,13,0,9,0, -16,0,1,0,14,0,9,0,17,0,2,0,15,0,10,0,13,0,11,0, -18,0,2,0,16,0,10,0,14,0,11,0,19,0,3,0,9,0,12,0, -4,0,13,0,0,0,14,0,20,0,5,0,19,0,15,0,13,0,16,0, -13,0,17,0,7,0,18,0,4,0,19,0,21,0,2,0,13,0,20,0, -7,0,21,0,22,0,4,0,20,0,22,0,21,0,23,0,4,0,24,0, -0,0,14,0,23,0,1,0,4,0,25,0,24,0,2,0,2,0,26,0, -2,0,25,0,25,0,6,0,13,0,27,0,14,0,28,0,23,0,29,0, -24,0,30,0,4,0,31,0,4,0,32,0,26,0,4,0,25,0,33,0, -13,0,34,0,4,0,35,0,0,0,14,0,27,0,4,0,19,0,15,0, -26,0,36,0,7,0,18,0,0,0,14,0,28,0,5,0,20,0,22,0, -13,0,37,0,14,0,38,0,4,0,39,0,0,0,40,0,29,0,24,0, -9,0,41,0,9,0,42,0,19,0,43,0,9,0,44,0,18,0,45,0, -18,0,46,0,14,0,47,0,14,0,48,0,14,0,49,0,8,0,50,0, -8,0,51,0,8,0,52,0,8,0,53,0,8,0,54,0,8,0,55,0, -8,0,56,0,4,0,57,0,4,0,58,0,4,0,59,0,4,0,60,0, -4,0,61,0,4,0,62,0,4,0,63,0,0,0,14,0,30,0,23,0, -9,0,41,0,9,0,42,0,19,0,43,0,9,0,44,0,17,0,45,0, -17,0,46,0,13,0,47,0,13,0,48,0,13,0,49,0,7,0,50,0, -7,0,51,0,7,0,52,0,7,0,53,0,7,0,54,0,7,0,55,0, -7,0,56,0,4,0,57,0,4,0,58,0,4,0,59,0,4,0,60,0, -4,0,61,0,4,0,62,0,4,0,63,0,31,0,21,0,30,0,64,0, -15,0,65,0,13,0,66,0,13,0,67,0,13,0,68,0,13,0,69,0, -13,0,70,0,13,0,71,0,13,0,72,0,13,0,73,0,13,0,74,0, -7,0,75,0,7,0,76,0,7,0,77,0,7,0,78,0,7,0,79,0, -7,0,80,0,7,0,81,0,7,0,82,0,7,0,83,0,4,0,84,0, -32,0,22,0,29,0,64,0,16,0,65,0,14,0,66,0,14,0,67,0, -14,0,68,0,14,0,69,0,14,0,70,0,14,0,71,0,14,0,72,0, -14,0,73,0,14,0,74,0,8,0,75,0,8,0,76,0,8,0,77,0, -8,0,78,0,8,0,79,0,8,0,80,0,8,0,81,0,8,0,82,0, -8,0,83,0,4,0,84,0,0,0,14,0,}; +115,104,83,104,97,112,101,68,97,116,97,0,98,116,67,111,109,112,111,117, +110,100,83,104,97,112,101,67,104,105,108,100,68,97,116,97,0,98,116,67, +111,109,112,111,117,110,100,83,104,97,112,101,68,97,116,97,0,98,116,67, +121,108,105,110,100,101,114,83,104,97,112,101,68,97,116,97,0,98,116,67, +97,112,115,117,108,101,83,104,97,112,101,68,97,116,97,0,98,116,67,111, +110,118,101,120,72,117,108,108,83,104,97,112,101,68,97,116,97,0,98,116, +67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,68,111,117,98,108, +101,68,97,116,97,0,98,116,67,111,108,108,105,115,105,111,110,79,98,106, +101,99,116,70,108,111,97,116,68,97,116,97,0,98,116,82,105,103,105,100, +66,111,100,121,70,108,111,97,116,68,97,116,97,0,98,116,82,105,103,105, +100,66,111,100,121,68,111,117,98,108,101,68,97,116,97,0,84,76,69,78, +1,0,1,0,2,0,2,0,4,0,4,0,4,0,4,0,8,0,0,0, +16,0,48,0,16,0,16,0,32,0,48,0,96,0,64,0,-128,0,16,0, +56,0,20,0,72,0,4,0,4,0,40,0,32,0,56,0,80,0,32,0, +64,0,64,0,80,0,-40,1,8,1,-16,1,-88,3,0,0,83,84,82,67, +27,0,0,0,10,0,3,0,4,0,0,0,4,0,1,0,9,0,2,0, +11,0,3,0,10,0,3,0,10,0,4,0,10,0,5,0,12,0,2,0, +9,0,6,0,9,0,7,0,13,0,1,0,7,0,8,0,14,0,1,0, +8,0,8,0,15,0,1,0,13,0,9,0,16,0,1,0,14,0,9,0, +17,0,2,0,15,0,10,0,13,0,11,0,18,0,2,0,16,0,10,0, +14,0,11,0,19,0,3,0,9,0,12,0,4,0,13,0,0,0,14,0, +20,0,5,0,19,0,15,0,13,0,16,0,13,0,17,0,7,0,18,0, +4,0,19,0,21,0,2,0,13,0,20,0,7,0,21,0,22,0,4,0, +20,0,22,0,21,0,23,0,4,0,24,0,0,0,14,0,23,0,1,0, +4,0,25,0,24,0,2,0,2,0,26,0,2,0,25,0,25,0,6,0, +13,0,27,0,14,0,28,0,23,0,29,0,24,0,30,0,4,0,31,0, +4,0,32,0,26,0,4,0,25,0,33,0,13,0,34,0,4,0,35,0, +0,0,14,0,27,0,4,0,19,0,15,0,26,0,36,0,7,0,18,0, +0,0,14,0,28,0,4,0,17,0,37,0,19,0,38,0,4,0,39,0, +7,0,40,0,29,0,4,0,19,0,15,0,28,0,41,0,4,0,42,0, +7,0,18,0,30,0,3,0,20,0,22,0,4,0,43,0,0,0,14,0, +31,0,3,0,20,0,22,0,4,0,43,0,0,0,14,0,32,0,5,0, +20,0,22,0,13,0,44,0,14,0,45,0,4,0,46,0,0,0,47,0, +33,0,24,0,9,0,48,0,9,0,49,0,19,0,50,0,9,0,51,0, +18,0,52,0,18,0,53,0,14,0,54,0,14,0,55,0,14,0,56,0, +8,0,57,0,8,0,58,0,8,0,59,0,8,0,60,0,8,0,61,0, +8,0,62,0,8,0,63,0,4,0,64,0,4,0,65,0,4,0,66,0, +4,0,67,0,4,0,68,0,4,0,69,0,4,0,70,0,0,0,14,0, +34,0,23,0,9,0,48,0,9,0,49,0,19,0,50,0,9,0,51,0, +17,0,52,0,17,0,53,0,13,0,54,0,13,0,55,0,13,0,56,0, +7,0,57,0,7,0,58,0,7,0,59,0,7,0,60,0,7,0,61,0, +7,0,62,0,7,0,63,0,4,0,64,0,4,0,65,0,4,0,66,0, +4,0,67,0,4,0,68,0,4,0,69,0,4,0,70,0,35,0,21,0, +34,0,71,0,15,0,72,0,13,0,73,0,13,0,74,0,13,0,75,0, +13,0,76,0,13,0,77,0,13,0,78,0,13,0,79,0,13,0,80,0, +13,0,81,0,7,0,82,0,7,0,83,0,7,0,84,0,7,0,85,0, +7,0,86,0,7,0,87,0,7,0,88,0,7,0,89,0,7,0,90,0, +4,0,91,0,36,0,22,0,33,0,71,0,16,0,72,0,14,0,73,0, +14,0,74,0,14,0,75,0,14,0,76,0,14,0,77,0,14,0,78,0, +14,0,79,0,14,0,80,0,14,0,81,0,8,0,82,0,8,0,83,0, +8,0,84,0,8,0,85,0,8,0,86,0,8,0,87,0,8,0,88,0, +8,0,89,0,8,0,90,0,4,0,91,0,0,0,14,0,}; int sBulletDNAlen64= sizeof(sBulletDNAstr64); - unsigned char sBulletDNAstr[]= { -83,68,78,65,78,65,77,69,85,0,0,0,109,95,115,105,122,101,0,109, +83,68,78,65,78,65,77,69,92,0,0,0,109,95,115,105,122,101,0,109, 95,99,97,112,97,99,105,116,121,0,42,109,95,100,97,116,97,0,109,95, 99,111,108,108,105,115,105,111,110,83,104,97,112,101,115,0,109,95,99,111, 108,108,105,115,105,111,110,79,98,106,101,99,116,115,0,109,95,99,111,110, @@ -169,7 +180,12 @@ unsigned char sBulletDNAstr[]= { 0,109,95,110,117,109,86,101,114,116,105,99,101,115,0,42,109,95,109,101, 115,104,80,97,114,116,115,80,116,114,0,109,95,115,99,97,108,105,110,103, 0,109,95,110,117,109,77,101,115,104,80,97,114,116,115,0,109,95,109,101, -115,104,73,110,116,101,114,102,97,99,101,0,42,109,95,117,110,115,99,97, +115,104,73,110,116,101,114,102,97,99,101,0,109,95,116,114,97,110,115,102, +111,114,109,0,42,109,95,99,104,105,108,100,83,104,97,112,101,0,109,95, +99,104,105,108,100,83,104,97,112,101,84,121,112,101,0,109,95,99,104,105, +108,100,77,97,114,103,105,110,0,42,109,95,99,104,105,108,100,83,104,97, +112,101,80,116,114,0,109,95,110,117,109,67,104,105,108,100,83,104,97,112, +101,115,0,109,95,117,112,65,120,105,115,0,42,109,95,117,110,115,99,97, 108,101,100,80,111,105,110,116,115,70,108,111,97,116,80,116,114,0,42,109, 95,117,110,115,99,97,108,101,100,80,111,105,110,116,115,68,111,117,98,108, 101,80,116,114,0,109,95,110,117,109,85,110,115,99,97,108,101,100,80,111, @@ -219,7 +235,7 @@ unsigned char sBulletDNAstr[]= { 110,101,97,114,83,108,101,101,112,105,110,103,84,104,114,101,115,104,111,108, 100,0,109,95,97,110,103,117,108,97,114,83,108,101,101,112,105,110,103,84, 104,114,101,115,104,111,108,100,0,109,95,97,100,100,105,116,105,111,110,97, -108,68,97,109,112,105,110,103,0,0,0,0,84,89,80,69,33,0,0,0, +108,68,97,109,112,105,110,103,0,0,0,0,84,89,80,69,37,0,0,0, 99,104,97,114,0,117,99,104,97,114,0,115,104,111,114,116,0,117,115,104, 111,114,116,0,105,110,116,0,108,111,110,103,0,117,108,111,110,103,0,102, 108,111,97,116,0,100,111,117,98,108,101,0,118,111,105,100,0,80,111,105, @@ -240,48 +256,56 @@ unsigned char sBulletDNAstr[]= { 68,97,116,97,0,98,116,77,101,115,104,80,97,114,116,68,97,116,97,0, 98,116,83,116,114,105,100,105,110,103,77,101,115,104,73,110,116,101,114,102, 97,99,101,68,97,116,97,0,98,116,84,114,105,97,110,103,108,101,77,101, -115,104,83,104,97,112,101,68,97,116,97,0,98,116,67,111,110,118,101,120, -72,117,108,108,83,104,97,112,101,68,97,116,97,0,98,116,67,111,108,108, -105,115,105,111,110,79,98,106,101,99,116,68,111,117,98,108,101,68,97,116, -97,0,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,70, -108,111,97,116,68,97,116,97,0,98,116,82,105,103,105,100,66,111,100,121, -70,108,111,97,116,68,97,116,97,0,98,116,82,105,103,105,100,66,111,100, -121,68,111,117,98,108,101,68,97,116,97,0,84,76,69,78,1,0,1,0, -2,0,2,0,4,0,4,0,4,0,4,0,8,0,0,0,12,0,36,0, -8,0,16,0,32,0,48,0,96,0,64,0,-128,0,12,0,52,0,20,0, -64,0,4,0,4,0,24,0,28,0,48,0,68,0,-56,1,-8,0,-32,1, --104,3,0,0,83,84,82,67,23,0,0,0,10,0,3,0,4,0,0,0, -4,0,1,0,9,0,2,0,11,0,3,0,10,0,3,0,10,0,4,0, -10,0,5,0,12,0,2,0,9,0,6,0,9,0,7,0,13,0,1,0, -7,0,8,0,14,0,1,0,8,0,8,0,15,0,1,0,13,0,9,0, -16,0,1,0,14,0,9,0,17,0,2,0,15,0,10,0,13,0,11,0, -18,0,2,0,16,0,10,0,14,0,11,0,19,0,3,0,9,0,12,0, -4,0,13,0,0,0,14,0,20,0,5,0,19,0,15,0,13,0,16,0, -13,0,17,0,7,0,18,0,4,0,19,0,21,0,2,0,13,0,20,0, -7,0,21,0,22,0,4,0,20,0,22,0,21,0,23,0,4,0,24,0, -0,0,14,0,23,0,1,0,4,0,25,0,24,0,2,0,2,0,26,0, -2,0,25,0,25,0,6,0,13,0,27,0,14,0,28,0,23,0,29,0, -24,0,30,0,4,0,31,0,4,0,32,0,26,0,4,0,25,0,33,0, -13,0,34,0,4,0,35,0,0,0,14,0,27,0,4,0,19,0,15,0, -26,0,36,0,7,0,18,0,0,0,14,0,28,0,5,0,20,0,22,0, -13,0,37,0,14,0,38,0,4,0,39,0,0,0,40,0,29,0,24,0, -9,0,41,0,9,0,42,0,19,0,43,0,9,0,44,0,18,0,45,0, -18,0,46,0,14,0,47,0,14,0,48,0,14,0,49,0,8,0,50,0, -8,0,51,0,8,0,52,0,8,0,53,0,8,0,54,0,8,0,55,0, -8,0,56,0,4,0,57,0,4,0,58,0,4,0,59,0,4,0,60,0, -4,0,61,0,4,0,62,0,4,0,63,0,0,0,14,0,30,0,23,0, -9,0,41,0,9,0,42,0,19,0,43,0,9,0,44,0,17,0,45,0, -17,0,46,0,13,0,47,0,13,0,48,0,13,0,49,0,7,0,50,0, -7,0,51,0,7,0,52,0,7,0,53,0,7,0,54,0,7,0,55,0, -7,0,56,0,4,0,57,0,4,0,58,0,4,0,59,0,4,0,60,0, -4,0,61,0,4,0,62,0,4,0,63,0,31,0,21,0,30,0,64,0, -15,0,65,0,13,0,66,0,13,0,67,0,13,0,68,0,13,0,69,0, -13,0,70,0,13,0,71,0,13,0,72,0,13,0,73,0,13,0,74,0, -7,0,75,0,7,0,76,0,7,0,77,0,7,0,78,0,7,0,79,0, -7,0,80,0,7,0,81,0,7,0,82,0,7,0,83,0,4,0,84,0, -32,0,22,0,29,0,64,0,16,0,65,0,14,0,66,0,14,0,67,0, -14,0,68,0,14,0,69,0,14,0,70,0,14,0,71,0,14,0,72,0, -14,0,73,0,14,0,74,0,8,0,75,0,8,0,76,0,8,0,77,0, -8,0,78,0,8,0,79,0,8,0,80,0,8,0,81,0,8,0,82,0, -8,0,83,0,4,0,84,0,0,0,14,0,}; +115,104,83,104,97,112,101,68,97,116,97,0,98,116,67,111,109,112,111,117, +110,100,83,104,97,112,101,67,104,105,108,100,68,97,116,97,0,98,116,67, +111,109,112,111,117,110,100,83,104,97,112,101,68,97,116,97,0,98,116,67, +121,108,105,110,100,101,114,83,104,97,112,101,68,97,116,97,0,98,116,67, +97,112,115,117,108,101,83,104,97,112,101,68,97,116,97,0,98,116,67,111, +110,118,101,120,72,117,108,108,83,104,97,112,101,68,97,116,97,0,98,116, +67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,68,111,117,98,108, +101,68,97,116,97,0,98,116,67,111,108,108,105,115,105,111,110,79,98,106, +101,99,116,70,108,111,97,116,68,97,116,97,0,98,116,82,105,103,105,100, +66,111,100,121,70,108,111,97,116,68,97,116,97,0,98,116,82,105,103,105, +100,66,111,100,121,68,111,117,98,108,101,68,97,116,97,0,84,76,69,78, +1,0,1,0,2,0,2,0,4,0,4,0,4,0,4,0,8,0,0,0, +12,0,36,0,8,0,16,0,32,0,48,0,96,0,64,0,-128,0,12,0, +52,0,20,0,64,0,4,0,4,0,24,0,28,0,48,0,76,0,24,0, +60,0,60,0,68,0,-56,1,-8,0,-32,1,-104,3,0,0,83,84,82,67, +27,0,0,0,10,0,3,0,4,0,0,0,4,0,1,0,9,0,2,0, +11,0,3,0,10,0,3,0,10,0,4,0,10,0,5,0,12,0,2,0, +9,0,6,0,9,0,7,0,13,0,1,0,7,0,8,0,14,0,1,0, +8,0,8,0,15,0,1,0,13,0,9,0,16,0,1,0,14,0,9,0, +17,0,2,0,15,0,10,0,13,0,11,0,18,0,2,0,16,0,10,0, +14,0,11,0,19,0,3,0,9,0,12,0,4,0,13,0,0,0,14,0, +20,0,5,0,19,0,15,0,13,0,16,0,13,0,17,0,7,0,18,0, +4,0,19,0,21,0,2,0,13,0,20,0,7,0,21,0,22,0,4,0, +20,0,22,0,21,0,23,0,4,0,24,0,0,0,14,0,23,0,1,0, +4,0,25,0,24,0,2,0,2,0,26,0,2,0,25,0,25,0,6,0, +13,0,27,0,14,0,28,0,23,0,29,0,24,0,30,0,4,0,31,0, +4,0,32,0,26,0,4,0,25,0,33,0,13,0,34,0,4,0,35,0, +0,0,14,0,27,0,4,0,19,0,15,0,26,0,36,0,7,0,18,0, +0,0,14,0,28,0,4,0,17,0,37,0,19,0,38,0,4,0,39,0, +7,0,40,0,29,0,4,0,19,0,15,0,28,0,41,0,4,0,42,0, +7,0,18,0,30,0,3,0,20,0,22,0,4,0,43,0,0,0,14,0, +31,0,3,0,20,0,22,0,4,0,43,0,0,0,14,0,32,0,5,0, +20,0,22,0,13,0,44,0,14,0,45,0,4,0,46,0,0,0,47,0, +33,0,24,0,9,0,48,0,9,0,49,0,19,0,50,0,9,0,51,0, +18,0,52,0,18,0,53,0,14,0,54,0,14,0,55,0,14,0,56,0, +8,0,57,0,8,0,58,0,8,0,59,0,8,0,60,0,8,0,61,0, +8,0,62,0,8,0,63,0,4,0,64,0,4,0,65,0,4,0,66,0, +4,0,67,0,4,0,68,0,4,0,69,0,4,0,70,0,0,0,14,0, +34,0,23,0,9,0,48,0,9,0,49,0,19,0,50,0,9,0,51,0, +17,0,52,0,17,0,53,0,13,0,54,0,13,0,55,0,13,0,56,0, +7,0,57,0,7,0,58,0,7,0,59,0,7,0,60,0,7,0,61,0, +7,0,62,0,7,0,63,0,4,0,64,0,4,0,65,0,4,0,66,0, +4,0,67,0,4,0,68,0,4,0,69,0,4,0,70,0,35,0,21,0, +34,0,71,0,15,0,72,0,13,0,73,0,13,0,74,0,13,0,75,0, +13,0,76,0,13,0,77,0,13,0,78,0,13,0,79,0,13,0,80,0, +13,0,81,0,7,0,82,0,7,0,83,0,7,0,84,0,7,0,85,0, +7,0,86,0,7,0,87,0,7,0,88,0,7,0,89,0,7,0,90,0, +4,0,91,0,36,0,22,0,33,0,71,0,16,0,72,0,14,0,73,0, +14,0,74,0,14,0,75,0,14,0,76,0,14,0,77,0,14,0,78,0, +14,0,79,0,14,0,80,0,14,0,81,0,8,0,82,0,8,0,83,0, +8,0,84,0,8,0,85,0,8,0,86,0,8,0,87,0,8,0,88,0, +8,0,89,0,8,0,90,0,4,0,91,0,0,0,14,0,}; int sBulletDNAlen= sizeof(sBulletDNAstr); diff --git a/src/LinearMath/btSerializer.h b/src/LinearMath/btSerializer.h index ded3f3898..88fcee8e7 100644 --- a/src/LinearMath/btSerializer.h +++ b/src/LinearMath/btSerializer.h @@ -268,18 +268,18 @@ public: if (VOID_IS_8) { -//#if _WIN64 +#if _WIN64 initDNA((const char*)sBulletDNAstr64,sBulletDNAlen64); -//#else -// btAssert(0); -//#endif +#else + btAssert(0); +#endif } else { -//#ifndef _WIN64 +#ifndef _WIN64 initDNA((const char*)sBulletDNAstr,sBulletDNAlen); -//#else -// btAssert(0); -//#endif +#else + btAssert(0); +#endif } } diff --git a/src/LinearMath/btTransform.h b/src/LinearMath/btTransform.h index 916133f0f..187b09116 100644 --- a/src/LinearMath/btTransform.h +++ b/src/LinearMath/btTransform.h @@ -210,6 +210,8 @@ public: void serialize(struct btTransformData& dataOut) const; + void serializeFloat(struct btTransformFloatData& dataOut) const; + void deSerialize(const struct btTransformData& dataIn); void deSerializeDouble(const struct btTransformDoubleData& dataIn); @@ -270,6 +272,13 @@ SIMD_FORCE_INLINE void btTransform::serialize(btTransformData& dataOut) const m_origin.serialize(dataOut.m_origin); } +SIMD_FORCE_INLINE void btTransform::serializeFloat(btTransformFloatData& dataOut) const +{ + m_basis.serializeFloat(dataOut.m_basis); + m_origin.serializeFloat(dataOut.m_origin); +} + + SIMD_FORCE_INLINE void btTransform::deSerialize(const btTransformData& dataIn) { m_basis.deSerialize(dataIn.m_basis);