summaryrefslogtreecommitdiff
path: root/examples/HelloWorld
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2016-05-01 15:45:03 +0200
committerCiro Santilli <ciro.santilli@gmail.com>2016-05-01 15:48:03 +0200
commit3c5b4af1c3421139720b17806ab352d7736cc8b5 (patch)
treebc1fc6a0fba45242d1fd820ae9806ee8363d089b /examples/HelloWorld
parent5351b20f9daedd5f6a38893707f63d55b063b70b (diff)
downloadbullet3-3c5b4af1c3421139720b17806ab352d7736cc8b5.tar.gz
Improve HelloWorld
- explain in comments the shape of the ground and better group that code - give enough time for the sphere to hit the ground - don't ask for confirmation to exit, it's annoying
Diffstat (limited to 'examples/HelloWorld')
-rw-r--r--examples/HelloWorld/HelloWorld.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/examples/HelloWorld/HelloWorld.cpp b/examples/HelloWorld/HelloWorld.cpp
index f7a195746..e51e6d541 100644
--- a/examples/HelloWorld/HelloWorld.cpp
+++ b/examples/HelloWorld/HelloWorld.cpp
@@ -44,20 +44,24 @@ int main(int argc, char** argv)
///-----initialization_end-----
- ///create a few basic rigid bodies
- btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
-
//keep track of the shapes, we release memory at exit.
//make sure to re-use collision shapes among rigid bodies whenever possible!
btAlignedObjectArray<btCollisionShape*> collisionShapes;
- collisionShapes.push_back(groundShape);
- btTransform groundTransform;
- groundTransform.setIdentity();
- groundTransform.setOrigin(btVector3(0,-56,0));
+ ///create a few basic rigid bodies
+ //the ground is a cube of side 100 at position y = -56.
+ //the sphere will hit it at y = -6, with center at -5
{
+ btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
+
+ collisionShapes.push_back(groundShape);
+
+ btTransform groundTransform;
+ groundTransform.setIdentity();
+ groundTransform.setOrigin(btVector3(0,-56,0));
+
btScalar mass(0.);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
@@ -113,7 +117,7 @@ int main(int argc, char** argv)
///-----stepsimulation_start-----
- for (i=0;i<100;i++)
+ for (i=0;i<150;i++)
{
dynamicsWorld->stepSimulation(1.f/60.f,10);
@@ -178,9 +182,5 @@ int main(int argc, char** argv)
//next line is optional: it will be cleared by the destructor when the array goes out of scope
collisionShapes.clear();
-
- ///-----cleanup_end-----
- printf("Press a key to exit\n");
- getchar();
}