fix btCompoundShaps serialization of child shapes

added ConcaveDemo to cmake
added LinearMath/btSerializer.h to btBulletCollisionCommon.h
This commit is contained in:
erwin.coumans
2010-01-27 23:37:46 +00:00
parent 7a445d70b7
commit 485d1a338e
8 changed files with 89 additions and 15 deletions

View File

@@ -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

View File

@@ -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
ADD_EXECUTABLE(AppConcaveDemo
ConcavePhysicsDemo.cpp
main.cpp
)
)
ELSE (USE_GLUT)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
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)

View File

@@ -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

View File

@@ -323,6 +323,7 @@ void ConcaveDemo::initPhysics()
}
void ConcaveDemo::clientMoveAndDisplay()
@@ -377,7 +378,7 @@ void ConcaveDemo::clientMoveAndDisplay()
renderme();
glFlush();
glutSwapBuffers();
swapBuffers();
}
@@ -396,7 +397,7 @@ void ConcaveDemo::displayCallback(void) {
glFlush();
glutSwapBuffers();
swapBuffers();
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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