Added SoftBody demo, contribution by Nathanael Presson. Will integrate into Bullet broadphase.

Added very basic drawTriangle for btIDebugDraw, useful for basic softbody visualization.
Added btGjkEpa2, contribution by Nathanael Presson. Improved version of EPA penetration depth computation, more suitable for multi-core/SPU (less memory usage). Note: btGjkEpa2 is not enabled by default currently.
This commit is contained in:
erwin.coumans
2008-03-30 23:08:06 +00:00
parent 8d38ef49ef
commit d4698cb3d5
16 changed files with 4737 additions and 2 deletions

View File

@@ -1,2 +1,2 @@
SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld MultiThreadedDemo CcdPhysicsDemo ConstraintDemo GenericJointDemo RagdollDemo BasicDemo BspDemo MovingConcaveDemo VehicleDemo ColladaDemo UserCollisionAlgorithm CharacterDemo )
SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld MultiThreadedDemo CcdPhysicsDemo ConstraintDemo GenericJointDemo RagdollDemo BasicDemo BspDemo MovingConcaveDemo VehicleDemo ColladaDemo UserCollisionAlgorithm CharacterDemo SoftBodyDemo )

View File

@@ -82,6 +82,7 @@ SubInclude TOP Demos ConcaveDemo ;
SubInclude TOP Demos ConstraintDemo ;
SubInclude TOP Demos RagdollDemo ;
SubInclude TOP Demos GenericJointDemo ;
SubInclude TOP Demos SoftBodyDemo ;
SubInclude TOP Demos ContinuousConvexCollision ;
SubInclude TOP Demos GjkConvexCastDemo ;
SubInclude TOP Demos Raytracer ;

View File

@@ -24,7 +24,7 @@ GLDebugDrawer::GLDebugDrawer()
}
void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
{
if (m_debugMode > 0)
// if (m_debugMode > 0)
{
glBegin(GL_LINES);
glColor3f(color.getX(), color.getY(), color.getZ());

View File

@@ -0,0 +1,62 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
# This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system
# This should be the case.
INCLUDE (${CMAKE_ROOT}/Modules/FindGLU.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/FindGLUT.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
IF (WIN32)
# This is the Windows code for which Opengl, and Glut are not properly installed
# since I can't install them I must cheat and copy libraries around
INCLUDE_DIRECTORIES(${GLUT_ROOT})
# LINK_DIRECTORIES(${GLUT_ROOT}\\lib)
IF (${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut32.lib)
# LINK_LIBRARIES(${GLUT_ROOT}\\lib\\glut32 ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
# TARGET_LINK_LIBRARIES(table ${GLUT_ROOT}\\lib\\glut32)
#
# ADD_CUSTOM_COMMAND(TARGET table POST_BUILD COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs2005\\Debug
# COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs2003\\Debug
# COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs6\\Debug)
ELSE (${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
# LINK_LIBRARIES(${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
# TARGET_LINK_LIBRARIES(table ${GLUT_glut_LIBRARY})
ENDIF(${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
# TARGET_LINK_LIBRARIES(table ${OPENGL_gl_LIBRARY})
# TARGET_LINK_LIBRARIES(table ${OPENGL_glu_LIBRARY})
ELSE (WIN32)
# This is the lines for linux. This should always work if everything is installed and working fine.
# SET(CMAKE_BUILD_TYPE Debug)
# SET(CMAKE_CXX_FLAGS_DEBUG "-g")
INCLUDE_DIRECTORIES(/usr/include /usr/local/include ${GLUT_INCLUDE_DIR})
# TARGET_LINK_LIBRARIES(table ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
# TARGET_LINK_LIBRARIES(checker ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
ENDIF (WIN32)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL }
)
LINK_LIBRARIES(
LibOpenGLSupport LibConvexHull LibBulletDynamics LibBulletCollision LibLinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(SoftBodyDemo
main.cpp
SoftDemo.cpp
)

3
Demos/SoftDemo/Jamfile Normal file
View File

@@ -0,0 +1,3 @@
SubDir TOP Demos SoftBodyDemo ;
BulletDemo SoftBodyDemo : [ Wildcard *.h *.cpp ] ;

1286
Demos/SoftDemo/SoftDemo.cpp Normal file

File diff suppressed because it is too large Load Diff

116
Demos/SoftDemo/SoftDemo.h Normal file
View File

@@ -0,0 +1,116 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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.
*/
///btSoftBody implementation by Nathanael Presson
#ifndef SOFT_DEMO_H
#define SOFT_DEMO_H
#include "DemoApplication.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "BulletDynamics/SoftBody/btSoftBody.h"
#include "BulletDynamics/SoftBody/btSparseSDF.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
///CcdPhysicsDemo shows basic stacking using Bullet physics, and allows toggle of Ccd (using key '1')
class SoftDemo : public DemoApplication
{
public:
struct SoftBodyImpl : btSoftBody::ISoftBody
{
void Attach(btSoftBody*);
void Detach(btSoftBody*);
void StartCollide(const btVector3&,const btVector3&);
bool CheckContactPrecise(const btVector3&,
btSoftBody::ISoftBody::sCti&);
bool CheckContact( const btVector3&,
btSoftBody::ISoftBody::sCti&);
void EndCollide();
void EvaluateMedium( const btVector3&,
btSoftBody::ISoftBody::sMedium&);
SoftDemo* pdemo;
btScalar air_density;
btScalar water_density;
btScalar water_offset;
btVector3 water_normal;
} m_softbodyimpl;
btAlignedObjectArray<btSoftBody*> m_softbodies;
btSparseSdf<3> m_sparsesdf;
bool m_autocam;
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
#ifdef USE_PARALLEL_DISPATCHER
#ifdef WIN32
class Win32ThreadSupport* m_threadSupportCollision;
class Win32ThreadSupport* m_threadSupportSolver;
#endif
#endif
btConstraintSolver* m_solver;
btCollisionAlgorithmCreateFunc* m_boxBoxCF;
btDefaultCollisionConfiguration* m_collisionConfiguration;
public:
void initPhysics();
void exitPhysics();
virtual ~SoftDemo()
{
exitPhysics();
}
virtual void clientMoveAndDisplay();
virtual void displayCallback();
void createStack( btCollisionShape* boxShape, float halfCubeSize, int size, float zPos );
static DemoApplication* Create()
{
SoftDemo* demo = new SoftDemo;
demo->myinit();
demo->initPhysics();
return demo;
}
//
void clientResetScene();
void renderme();
void keyboardCallback(unsigned char key, int x, int y);
};
#endif //CCD_PHYSICS_DEMO_H

37
Demos/SoftDemo/main.cpp Normal file
View File

@@ -0,0 +1,37 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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 "SoftDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
GLDebugDrawer gDebugDrawer;
int main(int argc,char** argv)
{
SoftDemo* softDemo = new SoftDemo();
softDemo->initPhysics();
softDemo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",softDemo);
delete softDemo;
return 0;
}