fix btCompoundShaps serialization of child shapes
added ConcaveDemo to cmake added LinearMath/btSerializer.h to btBulletCollisionCommon.h
This commit is contained in:
@@ -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
|
#todo: re-enable the rest of the demos again
|
||||||
|
|||||||
@@ -9,17 +9,36 @@
|
|||||||
# You shouldn't have to modify anything below this line
|
# 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(
|
LINK_LIBRARIES(
|
||||||
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
|
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
LINK_LIBRARIES(
|
ADD_EXECUTABLE(AppConcaveDemo
|
||||||
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
ConcavePhysicsDemo.cpp
|
||||||
)
|
main.cpp
|
||||||
|
)
|
||||||
|
ELSE (USE_GLUT)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
|
||||||
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE(AppConcaveDemo
|
LINK_LIBRARIES(
|
||||||
ConcavePhysicsDemo.cpp
|
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
||||||
main.cpp
|
)
|
||||||
)
|
|
||||||
|
ADD_EXECUTABLE(AppConcaveDemo
|
||||||
|
WIN32
|
||||||
|
../OpenGL/Win32AppMain.cpp
|
||||||
|
ConcavePhysicsDemo.cpp
|
||||||
|
ConcaveDemo.h
|
||||||
|
Win32ConcaveDemo.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
ENDIF (USE_GLUT)
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,14 @@ subject to the following restrictions:
|
|||||||
#ifndef CONCAVE_DEMO_H
|
#ifndef CONCAVE_DEMO_H
|
||||||
#define CONCAVE_DEMO_H
|
#define CONCAVE_DEMO_H
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#include "Win32DemoApplication.h"
|
||||||
|
#define PlatformDemoApplication Win32DemoApplication
|
||||||
|
#else
|
||||||
#include "GlutDemoApplication.h"
|
#include "GlutDemoApplication.h"
|
||||||
|
#define PlatformDemoApplication GlutDemoApplication
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
|
|
||||||
class btBroadphaseInterface;
|
class btBroadphaseInterface;
|
||||||
@@ -29,7 +36,7 @@ class btTriangleIndexVertexArray;
|
|||||||
|
|
||||||
///ConcaveDemo shows usage of static concave triangle meshes
|
///ConcaveDemo shows usage of static concave triangle meshes
|
||||||
///It also shows per-triangle material (friction/restitution) through CustomMaterialCombinerCallback
|
///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
|
//keep the collision shapes, for deletion/cleanup
|
||||||
|
|||||||
@@ -321,6 +321,7 @@ void ConcaveDemo::initPhysics()
|
|||||||
//enable custom material callback
|
//enable custom material callback
|
||||||
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -377,7 +378,7 @@ void ConcaveDemo::clientMoveAndDisplay()
|
|||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
glutSwapBuffers();
|
swapBuffers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,7 +397,7 @@ void ConcaveDemo::displayCallback(void) {
|
|||||||
|
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
glutSwapBuffers();
|
swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
25
Demos/ConcaveDemo/Win32ConcaveDemo.cpp
Normal file
25
Demos/ConcaveDemo/Win32ConcaveDemo.cpp
Normal 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
|
||||||
@@ -28,7 +28,7 @@ subject to the following restrictions:
|
|||||||
#include "GL_ShapeDrawer.h"
|
#include "GL_ShapeDrawer.h"
|
||||||
#include "LinearMath/btQuickprof.h"
|
#include "LinearMath/btQuickprof.h"
|
||||||
#include "LinearMath/btDefaultMotionState.h"
|
#include "LinearMath/btDefaultMotionState.h"
|
||||||
|
#include "LinearMath/btSerializer.h"
|
||||||
#include "GLDebugFont.h"
|
#include "GLDebugFont.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -369,6 +369,19 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y)
|
|||||||
m_debugMode |= btIDebugDraw::DBG_ProfileTimings;
|
m_debugMode |= btIDebugDraw::DBG_ProfileTimings;
|
||||||
break;
|
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':
|
case 'm':
|
||||||
if (m_debugMode & btIDebugDraw::DBG_EnableSatComparison)
|
if (m_debugMode & btIDebugDraw::DBG_EnableSatComparison)
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableSatComparison);
|
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableSatComparison);
|
||||||
|
|||||||
@@ -304,6 +304,13 @@ const char* btCompoundShape::serialize(void* dataBuffer, btSerializer* serialize
|
|||||||
{
|
{
|
||||||
memPtr->m_childMargin = float(m_children[i].m_childMargin);
|
memPtr->m_childMargin = float(m_children[i].m_childMargin);
|
||||||
memPtr->m_childShape = (btCollisionShapeData*)m_children[i].m_childShape;
|
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;
|
memPtr->m_childShapeType = m_children[i].m_childShapeType;
|
||||||
m_children[i].m_transform.serializeFloat(memPtr->m_transform);
|
m_children[i].m_transform.serializeFloat(memPtr->m_transform);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ subject to the following restrictions:
|
|||||||
#include "LinearMath/btDefaultMotionState.h"
|
#include "LinearMath/btDefaultMotionState.h"
|
||||||
#include "LinearMath/btQuickprof.h"
|
#include "LinearMath/btQuickprof.h"
|
||||||
#include "LinearMath/btIDebugDraw.h"
|
#include "LinearMath/btIDebugDraw.h"
|
||||||
|
#include "LinearMath/btSerializer.h"
|
||||||
|
|
||||||
|
|
||||||
#endif //BULLET_COLLISION_COMMON_H
|
#endif //BULLET_COLLISION_COMMON_H
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user