diff --git a/Demos/CMakeLists.txt b/Demos/CMakeLists.txt index 7d6686c8b..eb1b50e3b 100644 --- a/Demos/CMakeLists.txt +++ b/Demos/CMakeLists.txt @@ -1,4 +1,4 @@ -SUBDIRS( OpenGL BasicDemo Benchmarks Box2dDemo ConstraintDemo ConvexDecompositionDemo SerializeDemo ) +SUBDIRS( OpenGL BasicDemo Benchmarks Box2dDemo ConcaveDemo ConstraintDemo ConvexDecompositionDemo SerializeDemo ) #todo: re-enable the rest of the demos again diff --git a/Demos/ConcaveDemo/CMakeLists.txt b/Demos/ConcaveDemo/CMakeLists.txt index 12179d255..50569384a 100644 --- a/Demos/ConcaveDemo/CMakeLists.txt +++ b/Demos/ConcaveDemo/CMakeLists.txt @@ -9,17 +9,36 @@ # You shouldn't have to modify anything below this line ######################################################## +IF (USE_GLUT) + INCLUDE_DIRECTORIES( + ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL + ) -INCLUDE_DIRECTORIES( -${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL -) + LINK_LIBRARIES( + OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} + ) -LINK_LIBRARIES( -OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} -) + ADD_EXECUTABLE(AppConcaveDemo + ConcavePhysicsDemo.cpp + main.cpp + ) +ELSE (USE_GLUT) + + INCLUDE_DIRECTORIES( + ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL + ) -ADD_EXECUTABLE(AppConcaveDemo - ConcavePhysicsDemo.cpp - main.cpp -) + LINK_LIBRARIES( + OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} + ) + + ADD_EXECUTABLE(AppConcaveDemo + WIN32 + ../OpenGL/Win32AppMain.cpp + ConcavePhysicsDemo.cpp + ConcaveDemo.h + Win32ConcaveDemo.cpp + ) + +ENDIF (USE_GLUT) diff --git a/Demos/ConcaveDemo/ConcaveDemo.h b/Demos/ConcaveDemo/ConcaveDemo.h index 8a472d004..f317cf255 100644 --- a/Demos/ConcaveDemo/ConcaveDemo.h +++ b/Demos/ConcaveDemo/ConcaveDemo.h @@ -15,7 +15,14 @@ subject to the following restrictions: #ifndef CONCAVE_DEMO_H #define CONCAVE_DEMO_H +#ifdef _WINDOWS +#include "Win32DemoApplication.h" +#define PlatformDemoApplication Win32DemoApplication +#else #include "GlutDemoApplication.h" +#define PlatformDemoApplication GlutDemoApplication +#endif + #include "LinearMath/btAlignedObjectArray.h" class btBroadphaseInterface; @@ -29,7 +36,7 @@ class btTriangleIndexVertexArray; ///ConcaveDemo shows usage of static concave triangle meshes ///It also shows per-triangle material (friction/restitution) through CustomMaterialCombinerCallback -class ConcaveDemo : public GlutDemoApplication +class ConcaveDemo : public PlatformDemoApplication { //keep the collision shapes, for deletion/cleanup diff --git a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp index 4e72be908..68775710e 100644 --- a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp +++ b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp @@ -321,6 +321,7 @@ void ConcaveDemo::initPhysics() //enable custom material callback staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); + } @@ -377,7 +378,7 @@ void ConcaveDemo::clientMoveAndDisplay() renderme(); glFlush(); - glutSwapBuffers(); + swapBuffers(); } @@ -396,7 +397,7 @@ void ConcaveDemo::displayCallback(void) { glFlush(); - glutSwapBuffers(); + swapBuffers(); } diff --git a/Demos/ConcaveDemo/Win32ConcaveDemo.cpp b/Demos/ConcaveDemo/Win32ConcaveDemo.cpp new file mode 100644 index 000000000..a0c718e5d --- /dev/null +++ b/Demos/ConcaveDemo/Win32ConcaveDemo.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 "ConcaveDemo.h" + +///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo +DemoApplication* createDemo() +{ + return new ConcaveDemo(); +} + +#endif diff --git a/Demos/OpenGL/DemoApplication.cpp b/Demos/OpenGL/DemoApplication.cpp index f8ee33b0b..1ec6af165 100644 --- a/Demos/OpenGL/DemoApplication.cpp +++ b/Demos/OpenGL/DemoApplication.cpp @@ -28,7 +28,7 @@ subject to the following restrictions: #include "GL_ShapeDrawer.h" #include "LinearMath/btQuickprof.h" #include "LinearMath/btDefaultMotionState.h" - +#include "LinearMath/btSerializer.h" #include "GLDebugFont.h" @@ -369,6 +369,19 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y) m_debugMode |= btIDebugDraw::DBG_ProfileTimings; break; + case '=': + { + 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); + delete serializer; + break; + + } + case 'm': if (m_debugMode & btIDebugDraw::DBG_EnableSatComparison) m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableSatComparison); diff --git a/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/src/BulletCollision/CollisionShapes/btCompoundShape.cpp index d73207e69..22fb2c981 100644 --- a/src/BulletCollision/CollisionShapes/btCompoundShape.cpp +++ b/src/BulletCollision/CollisionShapes/btCompoundShape.cpp @@ -304,6 +304,13 @@ const char* btCompoundShape::serialize(void* dataBuffer, btSerializer* serialize { memPtr->m_childMargin = float(m_children[i].m_childMargin); memPtr->m_childShape = (btCollisionShapeData*)m_children[i].m_childShape; + + { + btChunk* chunk = serializer->allocate(m_children[i].m_childShape->calculateSerializeBufferSize(),1); + const char* structType = m_children[i].m_childShape->serialize(chunk->m_oldPtr,serializer); + serializer->finalizeChunk(chunk,structType,BT_SHAPE_CODE,m_children[i].m_childShape); + } + memPtr->m_childShapeType = m_children[i].m_childShapeType; m_children[i].m_transform.serializeFloat(memPtr->m_transform); } diff --git a/src/btBulletCollisionCommon.h b/src/btBulletCollisionCommon.h index 4b14f6d00..9a7bffbb9 100644 --- a/src/btBulletCollisionCommon.h +++ b/src/btBulletCollisionCommon.h @@ -61,6 +61,8 @@ subject to the following restrictions: #include "LinearMath/btDefaultMotionState.h" #include "LinearMath/btQuickprof.h" #include "LinearMath/btIDebugDraw.h" +#include "LinearMath/btSerializer.h" + #endif //BULLET_COLLISION_COMMON_H