Add the old Bullet 2.x obsolete demos, and CMake buildsystem files, and gradually move them to newer Bullet 3.x structure
Use statically linked freeglut, instead of dynamic glut for the obsolete Bullet 2.x demos Add the 'reset' method to b3GpuDynamicsWorld, and use it in the BasicGpuDemo (pretty slow in debug mode, use release mode) Don't crash in btCollisionWorld, if there is no collision dispatcher
This commit is contained in:
32
ObsoleteDemos/GjkConvexCastDemo/CMakeLists.txt
Normal file
32
ObsoleteDemos/GjkConvexCastDemo/CMakeLists.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
# You shouldn't have to modify anything below this line
|
||||
########################################################
|
||||
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/src
|
||||
../OpenGL
|
||||
)
|
||||
|
||||
LINK_LIBRARIES(
|
||||
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(AppLinearConvexCastDemo
|
||||
LinearConvexCastDemo.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
|
||||
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
||||
SET_TARGET_PROPERTIES(AppLinearConvexCastDemo PROPERTIES DEBUG_POSTFIX "_Debug")
|
||||
SET_TARGET_PROPERTIES(AppLinearConvexCastDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
|
||||
SET_TARGET_PROPERTIES(AppLinearConvexCastDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
|
||||
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
||||
188
ObsoleteDemos/GjkConvexCastDemo/LinearConvexCastDemo.cpp
Normal file
188
ObsoleteDemos/GjkConvexCastDemo/LinearConvexCastDemo.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies.
|
||||
* Erwin Coumans makes no representations about the suitability
|
||||
* of this software for any purpose.
|
||||
* It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
LinearConvexCastDemo implements an efficient continuous collision detection algorithm.
|
||||
Both linear and angular velocities are supported. Gjk or Simplex based methods.
|
||||
Motion using Exponential Map.
|
||||
Comparison with Screwing Motion.
|
||||
Also comparision with Algebraic CCD and Interval Arithmetic methods (Stephane Redon)
|
||||
*/
|
||||
|
||||
|
||||
///Low level demo, doesn't include btBulletCollisionCommon.h
|
||||
#include "LinearMath/btQuaternion.h"
|
||||
#include "LinearMath/btTransform.h"
|
||||
|
||||
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h"
|
||||
|
||||
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
|
||||
|
||||
|
||||
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btTetrahedronShape.h"
|
||||
|
||||
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
|
||||
|
||||
|
||||
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#include "LinearConvexCastDemo.h"
|
||||
#include "GlutStuff.h"
|
||||
|
||||
static btVoronoiSimplexSolver sVoronoiSimplexSolver;
|
||||
btSimplexSolverInterface& gGjkSimplexSolver = sVoronoiSimplexSolver;
|
||||
|
||||
static float yaw=0.f,pitch=0.f,roll=0.f;
|
||||
static const int maxNumObjects = 4;
|
||||
static const int numObjects = 2;
|
||||
|
||||
static btPolyhedralConvexShape* shapePtr[maxNumObjects];
|
||||
|
||||
static btTransform tr[numObjects];
|
||||
|
||||
|
||||
|
||||
void LinearConvexCastDemo::initPhysics()
|
||||
{
|
||||
|
||||
setCameraDistance(10.f);
|
||||
|
||||
tr[0].setIdentity();
|
||||
tr[0].setOrigin( btVector3( 0.0f, 5.5f, 0.0f ) );
|
||||
|
||||
tr[1].setIdentity();
|
||||
tr[1].setOrigin( btVector3( 0.0f, 0.0f, 0.0f ) );
|
||||
|
||||
// Pyramide
|
||||
float r = 1.0f;
|
||||
float h = 2.0f;
|
||||
|
||||
btConvexHullShape* shapeA = new btConvexHullShape;
|
||||
shapeA->addPoint( btVector3( 0.0f, 0.75f * h, 0.0f ) );
|
||||
shapeA->addPoint( btVector3( -r, -0.25f * h, r ) );
|
||||
shapeA->addPoint( btVector3( r, -0.25f * h, r ) );
|
||||
shapeA->addPoint( btVector3( r, -0.25f * h, -r ) );
|
||||
shapeA->addPoint( btVector3( -r, -0.25f * h, -r ) );
|
||||
|
||||
|
||||
|
||||
// Triangle
|
||||
btConvexHullShape* shapeB = new btConvexHullShape;
|
||||
shapeB->addPoint( btVector3( 0.0f, 1.0f, 0.0f ) );
|
||||
shapeB->addPoint( btVector3( 1.0f, -1.0f, 0.0f ) );
|
||||
shapeB->addPoint( btVector3( -1.0f, -1.0f, 0.0f ) );
|
||||
|
||||
shapePtr[0] = shapeA;
|
||||
shapePtr[1] = shapeB;
|
||||
|
||||
shapePtr[0]->setMargin( 0.01f );
|
||||
shapePtr[1]->setMargin( 0.01f );
|
||||
}
|
||||
|
||||
//to be implemented by the demo
|
||||
void LinearConvexCastDemo::clientMoveAndDisplay()
|
||||
{
|
||||
displayCallback();
|
||||
}
|
||||
|
||||
LinearConvexCastDemo::~LinearConvexCastDemo()
|
||||
{
|
||||
delete shapePtr[0];
|
||||
delete shapePtr[1];
|
||||
}
|
||||
|
||||
void LinearConvexCastDemo::displayCallback(void)
|
||||
{
|
||||
updateCamera();
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
|
||||
|
||||
static btScalar angle = 0.f;
|
||||
angle+=getDeltaTimeMicroseconds()/1000000.0;
|
||||
|
||||
tr[1].setRotation(btQuaternion(btVector3(1,0,0),angle));
|
||||
|
||||
btTransform toA, toB;
|
||||
toA = tr[0];
|
||||
toA.setOrigin( btVector3( 0.0f, 0.f, 0.0f ) );
|
||||
toB = tr[1];
|
||||
toB.setOrigin( btVector3( 0.0f, 0.0f, 0.0f ) );
|
||||
|
||||
|
||||
gGjkSimplexSolver.reset();
|
||||
|
||||
|
||||
btVector3 worldBoundsMin(-1000,-1000,-1000);
|
||||
btVector3 worldBoundsMax(1000,1000,1000);
|
||||
|
||||
|
||||
//btGjkConvexCast convexCaster(shapePtr[ 0 ], shapePtr[ 1 ], &gGjkSimplexSolver );
|
||||
btSubsimplexConvexCast convexCaster( shapePtr[ 0 ], shapePtr[ 1 ], &gGjkSimplexSolver );
|
||||
|
||||
btConvexCast::CastResult result;
|
||||
|
||||
result.m_hitPoint.setValue(0,0,0);
|
||||
|
||||
convexCaster.calcTimeOfImpact( tr[ 0 ], toA, tr[ 1 ], toB, result );
|
||||
|
||||
ATTRIBUTE_ALIGNED16(btScalar) m1[16];
|
||||
ATTRIBUTE_ALIGNED16(btScalar) m2[16];
|
||||
ATTRIBUTE_ALIGNED16(btScalar) m3[16];
|
||||
|
||||
tr[ 0 ].getOpenGLMatrix( m1 );
|
||||
tr[ 1 ].getOpenGLMatrix( m2 );
|
||||
|
||||
btSphereShape sphere(0.2);
|
||||
|
||||
btTransform tmp = tr[0];
|
||||
tmp.setOrigin(result.m_hitPoint);
|
||||
tmp.getOpenGLMatrix(m3);
|
||||
m_shapeDrawer->drawOpenGL( m3, &sphere, btVector3( 1, 0, 1 ), getDebugMode() ,worldBoundsMin,worldBoundsMax);
|
||||
|
||||
|
||||
m_shapeDrawer->drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 0, 0 ), getDebugMode() ,worldBoundsMin,worldBoundsMax);
|
||||
m_shapeDrawer->drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 0, 0 ), getDebugMode() ,worldBoundsMin,worldBoundsMax);
|
||||
|
||||
btVector3 originA, originB;
|
||||
originA.setInterpolate3( tr[ 0 ].getOrigin(), toA.getOrigin(), result.m_fraction );
|
||||
originB.setInterpolate3( tr[ 1 ].getOrigin(), toB.getOrigin(), result.m_fraction );
|
||||
|
||||
btTransform A = tr[ 0 ];
|
||||
A.setOrigin( originA );
|
||||
|
||||
btTransform B = tr[ 1 ];
|
||||
B.setOrigin( originB );
|
||||
|
||||
A.getOpenGLMatrix( m1 );
|
||||
B.getOpenGLMatrix( m2 );
|
||||
|
||||
m_shapeDrawer->drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 1, 0 ), getDebugMode() ,worldBoundsMin,worldBoundsMax);
|
||||
m_shapeDrawer->drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 1, 0 ), getDebugMode() ,worldBoundsMin,worldBoundsMax);
|
||||
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
44
ObsoleteDemos/GjkConvexCastDemo/LinearConvexCastDemo.h
Normal file
44
ObsoleteDemos/GjkConvexCastDemo/LinearConvexCastDemo.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
#ifndef LINEAR_CONVEX_CAST_DEMO_H
|
||||
#define LINEAR_CONVEX_CAST_DEMO_H
|
||||
|
||||
#include "GlutDemoApplication.h"
|
||||
|
||||
///LinearConvexCastDemo shows the working of the object sweep / pure-linear continuous collision detection query
|
||||
class LinearConvexCastDemo : public GlutDemoApplication
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~LinearConvexCastDemo();
|
||||
|
||||
void initPhysics();
|
||||
|
||||
virtual void clientMoveAndDisplay();
|
||||
|
||||
virtual void displayCallback();
|
||||
|
||||
static DemoApplication* Create()
|
||||
{
|
||||
LinearConvexCastDemo* demo = new LinearConvexCastDemo();
|
||||
demo->myinit();
|
||||
demo->initPhysics();
|
||||
return demo;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //LINEAR_CONVEX_CAST_DEMO_H
|
||||
|
||||
17
ObsoleteDemos/GjkConvexCastDemo/main.cpp
Normal file
17
ObsoleteDemos/GjkConvexCastDemo/main.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
#include "LinearConvexCastDemo.h"
|
||||
#include "GlutStuff.h"
|
||||
|
||||
int screenWidth = 640;
|
||||
int screenHeight = 480;
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
|
||||
LinearConvexCastDemo* linearCastDemo = new LinearConvexCastDemo();
|
||||
|
||||
linearCastDemo->initPhysics();
|
||||
|
||||
|
||||
return glutmain(argc, argv,screenWidth,screenHeight,"Linear Convex Cast Demo",linearCastDemo);
|
||||
}
|
||||
Reference in New Issue
Block a user