diff --git a/Demos/AllBulletDemos/DemoEntries.cpp b/Demos/AllBulletDemos/DemoEntries.cpp index 33fa4a89c..585541cf3 100644 --- a/Demos/AllBulletDemos/DemoEntries.cpp +++ b/Demos/AllBulletDemos/DemoEntries.cpp @@ -102,49 +102,52 @@ public: btDemoEntry g_demoEntries[] = { - - {"SoftBody Cloth",SoftDemo0::Create}, - {"SoftBody Pressure",SoftDemo1::Create}, - {"SoftBody Volume",SoftDemo2::Create}, - {"SoftBody Ropes",SoftDemo3::Create}, + + + {"ForkLiftDemo",ForkLiftDemo::Create}, + {"RagdollDemo",RagdollDemo::Create}, + {"BasicDemo", BasicDemo::Create}, + {"ConvexDecomposition",ConvexDecompositionDemo::Create}, + {"Concave Moving", GimpactConcaveDemo::Create}, + {"DynamicControlDemo",MotorDemo::Create}, + {"ConcaveDemo",ConcaveDemo::Create}, + // {"SoftBody Cloth",SoftDemo0::Create}, +// {"SoftBody Pressure",SoftDemo1::Create}, {"SoftBody Ropes Attach",SoftDemo4::Create}, {"SoftBody Cloth Attach",SoftDemo5::Create}, - {"SoftBody Sticks",SoftDemo6::Create}, - {"SoftBody Collide",SoftDemo7::Create}, - {"SoftBody Collide2",SoftDemo8::Create}, - {"SoftBody Collide3",SoftDemo9::Create}, - {"SoftBody Impact",SoftDemo10::Create}, - {"SoftBody Aero",SoftDemo11::Create}, - {"SoftBody Friction",SoftDemo12::Create}, - {"SoftBody Torus",SoftDemo13::Create}, - {"SoftBody Torus Match",SoftDemo14::Create}, - {"SoftBody Bunny",SoftDemo15::Create}, - {"SoftBody Bunny Match",SoftDemo16::Create}, - {"SoftBody Init Cutting",SoftDemo17::Create}, - {"SoftBody Cluster Deform",SoftDemo18::Create}, {"SoftBody Cluster Collide1",SoftDemo19::Create}, - {"SoftBody Cluster Collide2",SoftDemo20::Create}, - {"SoftBody Cluster Socket",SoftDemo21::Create}, - {"SoftBody Cluster Hinge",SoftDemo22::Create}, - {"SoftBody Cluster Combine",SoftDemo23::Create}, + {"SoftBody Volume",SoftDemo2::Create}, {"SoftBody Cluster Car",SoftDemo24::Create}, {"SoftBody Cluster Robot",SoftDemo25::Create}, - {"SoftBody Cluster Stack Soft",SoftDemo26::Create}, + // {"SoftBody Ropes",SoftDemo3::Create}, + {"SoftBody Sticks",SoftDemo6::Create}, +// {"SoftBody Collide",SoftDemo7::Create}, +// {"SoftBody Collide2",SoftDemo8::Create}, +// {"SoftBody Collide3",SoftDemo9::Create}, +// {"SoftBody Impact",SoftDemo10::Create}, + {"SoftBody Aero",SoftDemo11::Create}, +// {"SoftBody Friction",SoftDemo12::Create}, +// {"SoftBody Torus",SoftDemo13::Create}, +// {"SoftBody Torus Match",SoftDemo14::Create}, +// {"SoftBody Bunny",SoftDemo15::Create}, +// {"SoftBody Bunny Match",SoftDemo16::Create}, + {"SoftBody Init Cutting",SoftDemo17::Create}, +// {"SoftBody Cluster Deform",SoftDemo18::Create}, + +// {"SoftBody Cluster Collide2",SoftDemo20::Create}, +// {"SoftBody Cluster Socket",SoftDemo21::Create}, +// {"SoftBody Cluster Hinge",SoftDemo22::Create}, +// {"SoftBody Cluster Combine",SoftDemo23::Create}, +// {"SoftBody Cluster Stack Soft",SoftDemo26::Create}, {"SoftBody Cluster Stack Mixed",SoftDemo27::Create}, - {"DynamicControlDemo",MotorDemo::Create}, - {"RagdollDemo",RagdollDemo::Create}, - {"SliderConstraint",SliderConstraintDemo::Create}, - {"BasicDemo", BasicDemo::Create}, - {"CcdPhysicsDemo", CcdPhysicsDemo::Create}, - {"ConcaveDemo",ConcaveDemo::Create}, - {"ConcaveRaycastDemo",ConcaveRaycastDemo::Create}, - {"ConcaveConvexcastDemo",ConcaveConvexcastDemo::Create}, - {"ConvexDecomposition",ConvexDecompositionDemo::Create}, - {"BspDemo", BspDemo::Create}, - {"Gimpact Test", GimpactConcaveDemo::Create}, - {"Raytracer Test",Raytracer::Create}, - {"GjkConvexCast",LinearConvexCastDemo::Create}, - {"ForkLiftDemo",ForkLiftDemo::Create}, + +// {"SliderConstraint",SliderConstraintDemo::Create}, +// {"CcdPhysicsDemo", CcdPhysicsDemo::Create}, +// {"ConcaveRaycastDemo",ConcaveRaycastDemo::Create}, +// {"ConcaveConvexcastDemo",ConcaveConvexcastDemo::Create}, + //{"BspDemo", BspDemo::Create}, +// {"Raytracer Test",Raytracer::Create}, +// {"GjkConvexCast",LinearConvexCastDemo::Create}, {"Benchmark 3000 FALL",BenchmarkDemo1::Create}, {"Benchmark 1000 STACK",BenchmarkDemo2::Create}, {"Benchmark 136 RAGDOLLS",BenchmarkDemo3::Create}, diff --git a/Demos/AllBulletDemos/Main.cpp b/Demos/AllBulletDemos/Main.cpp index b8bb5dd23..e740ab1ee 100644 --- a/Demos/AllBulletDemos/Main.cpp +++ b/Demos/AllBulletDemos/Main.cpp @@ -34,8 +34,8 @@ namespace { - int testIndex=0; - int testSelection=24; + int testIndex=1; + int testSelection=0; btDemoEntry* entry; DemoApplication* demo; int iterationCount; @@ -66,14 +66,15 @@ namespace } + void setDefaultSettings() { viewX = 0.0f; viewY = 0.0f; - framePeriod = 16;//todo: test if this value should be 0 + framePeriod = 16;//16;//todo: test if this value should be 0 - width = 640; - height = 480; + width = 800;//640; + height = 600;//1024;//480; iterationCount = 10; gDrawAabb=0; gWireFrame=0; @@ -87,7 +88,7 @@ void setDefaultSettings() gUseWarmstarting = 1; gRandomizeConstraints = 1; gErp = 0.2f; - gSlop=0.0f; + gSlop=0.01f; gErp2 = 0.1f; gWarmStartingParameter = 0.85f; @@ -317,6 +318,18 @@ void Keyboard(unsigned char key, int x, int y) } } +void KeyboardSpecialUp(int key, int x, int y) +{ + if (demo) + { + demo->specialKeyboardUp(key,x,y); + } + +} + + + + void KeyboardSpecial(int key, int x, int y) { @@ -380,6 +393,7 @@ int main(int argc, char** argv) GLUI_Master.set_glutReshapeFunc(Resize); GLUI_Master.set_glutKeyboardFunc(Keyboard); GLUI_Master.set_glutSpecialFunc(KeyboardSpecial); + GLUI_Master.set_glutSpecialUpFunc(KeyboardSpecialUp); GLUI_Master.set_glutMouseFunc(Mouse); glutMotionFunc(MouseMotion); @@ -410,14 +424,13 @@ int main(int argc, char** argv) GLUI_Spinner* spinner = 0; spinner = glui->add_spinner("ERP", GLUI_SPINNER_FLOAT, &gErp); - spinner->set_float_limits(0.f,1.f); - spinner = glui->add_spinner("ERP2", GLUI_SPINNER_FLOAT, &gErp2); +// spinner->set_float_limits(0.f,1.f); +// spinner = glui->add_spinner("ERP2", GLUI_SPINNER_FLOAT, &gErp2); spinner->set_float_limits(0.f,1.f); spinner = glui->add_spinner("Slop", GLUI_SPINNER_FLOAT, &gSlop); spinner->set_float_limits(0.f,1.f); - - spinner = glui->add_spinner("WSP", GLUI_SPINNER_FLOAT,&gWarmStartingParameter); - spinner->set_float_limits (0.f,1.0); +// spinner = glui->add_spinner("WSP", GLUI_SPINNER_FLOAT,&gWarmStartingParameter); +// spinner->set_float_limits (0.f,1.0); glui->add_checkbox("Warmstarting", &gUseWarmstarting); glui->add_checkbox("Randomize Constraints", &gRandomizeConstraints); @@ -434,14 +447,6 @@ int main(int argc, char** argv) glui->add_checkbox_to_panel(drawPanel, "Shadows", &gDrawShadows); glui->add_checkbox_to_panel(drawPanel, "Clusters", &gDrawClusters); - - - - -// glui->add_checkbox_to_panel(drawPanel, "Impulses", &settings.drawImpulses); -// glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats); - - int testCount = 0; btDemoEntry* e = g_demoEntries; while (e->createFcn) @@ -456,12 +461,12 @@ int main(int argc, char** argv) glui->add_button("Toggle Pause", 0,(GLUI_Update_CB)TogglePause); glui->add_button("Single Step", 0,(GLUI_Update_CB)SingleSimulationStep); - glui->add_button("Reset Scene", 0,(GLUI_Update_CB)ResetScene); +// glui->add_button("Reset Scene", 0,(GLUI_Update_CB)ResetScene); glui->add_button("Restart Scene", 0,(GLUI_Update_CB)RestartScene); glui->add_separator(); - glui->add_button("Exit", 0,(GLUI_Update_CB)exit); +// glui->add_button("Exit", 0,(GLUI_Update_CB)exit); glui->set_main_gfx_window( mainWindow ); diff --git a/Demos/BasicDemo/BasicDemo.cpp b/Demos/BasicDemo/BasicDemo.cpp index cb8851338..40daf6944 100644 --- a/Demos/BasicDemo/BasicDemo.cpp +++ b/Demos/BasicDemo/BasicDemo.cpp @@ -21,6 +21,8 @@ subject to the following restrictions: //maximum number of objects (and allow user to shoot additional boxes) #define MAX_PROXIES (ARRAY_SIZE_X*ARRAY_SIZE_Y*ARRAY_SIZE_Z + 1024) +///scaling of the objects (0.1 = 20 centimeter boxes ) +#define SCALING 0.1 #define START_POS_X -5 #define START_POS_Y -5 #define START_POS_Z -3 @@ -80,7 +82,7 @@ void BasicDemo::initPhysics() setTexturing(true); setShadows(true); - setCameraDistance(btScalar(50.)); + setCameraDistance(btScalar(SCALING*50.)); ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btDefaultCollisionConfiguration(); @@ -106,7 +108,7 @@ void BasicDemo::initPhysics() btTransform groundTransform; groundTransform.setIdentity(); - groundTransform.setOrigin(btVector3(0,-56,0)); + groundTransform.setOrigin(btVector3(0,-50,0)); //We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here: { @@ -133,7 +135,7 @@ void BasicDemo::initPhysics() //create a few dynamic rigidbodies // Re-using the same collision is better for memory usage and performance - btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1)); + btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1)); //btCollisionShape* colShape = new btSphereShape(btScalar(1.)); m_collisionShapes.push_back(colShape); @@ -160,9 +162,9 @@ void BasicDemo::initPhysics() { for(int j = 0;jgetMotionState()) { + + while (body->getNumConstraintRefs()) + { + btTypedConstraint* constraint = body->getConstraintRef(0); + m_dynamicsWorld->removeConstraint(constraint); + delete constraint; + } delete body->getMotionState(); + m_dynamicsWorld->removeRigidBody(body); + } else + { + m_dynamicsWorld->removeCollisionObject( obj ); } - m_dynamicsWorld->removeCollisionObject( obj ); delete obj; } @@ -348,7 +361,6 @@ const float TRIANGLE_SIZE=20.f; { btCollisionShape* suppShape = new btBoxShape(btVector3(0.5f,0.1f,0.5f)); - m_collisionShapes.push_back(chassisShape); btTransform suppLocalTrans; suppLocalTrans.setIdentity(); //localTrans effectively shifts the center of mass with respect to the chassis @@ -666,6 +678,9 @@ void ForkLiftDemo::displayCallback(void) void ForkLiftDemo::clientResetScene() { gVehicleSteering = 0.f; + gBreakingForce = defaultBreakingForce; + gEngineForce = 0.f; + m_carChassis->setCenterOfMassTransform(btTransform::getIdentity()); m_carChassis->setLinearVelocity(btVector3(0,0,0)); m_carChassis->setAngularVelocity(btVector3(0,0,0)); diff --git a/Extras/glui/GL/glui.h b/Extras/glui/GL/glui.h index e9b0ac0ff..0a5b2e25c 100644 --- a/Extras/glui/GL/glui.h +++ b/Extras/glui/GL/glui.h @@ -113,6 +113,7 @@ enum GLUI_Glut_CB_Types GLUI_GLUT_MOUSE, GLUI_GLUT_MOTION, GLUI_GLUT_SPECIAL, + GLUI_GLUT_SPECIAL_UP, GLUI_GLUT_PASSIVE_MOTION, GLUI_GLUT_ENTRY, GLUI_GLUT_VISIBILITY @@ -581,6 +582,8 @@ public: void set_glutReshapeFunc (void (*f)(int width, int height)); void set_glutKeyboardFunc(void (*f)(unsigned char key, int x, int y)); void set_glutSpecialFunc (void (*f)(int key, int x, int y)); + void set_glutSpecialUpFunc(void (*f)(int key, int x, int y)); + void set_glutMouseFunc (void (*f)(int, int, int, int )); void set_glutDisplayFunc(void (*f)(void)) {glutDisplayFunc(f);} @@ -649,6 +652,7 @@ public: /*********** Pointers to GLUT callthrough functions *****/ void (*glut_keyboard_CB)(unsigned char, int, int); void (*glut_special_CB)(int, int, int); + void (*glut_special_up_CB)(int, int, int); void (*glut_reshape_CB)(int, int); void (*glut_passive_motion_CB)(int,int); void (*glut_mouse_CB)(int,int,int,int); @@ -692,6 +696,7 @@ class GLUI_Main : public GLUI_Node friend void glui_mouse_func(int button, int state, int x, int y); friend void glui_keyboard_func(unsigned char key, int x, int y); friend void glui_special_func(int key, int x, int y); + friend void glui_special_up_func(int key, int x, int y); friend void glui_passive_motion_func(int x, int y); friend void glui_reshape_func( int w, int h ); friend void glui_visibility_func(int state); @@ -740,6 +745,7 @@ protected: void mouse(int button, int state, int x, int y); void keyboard(unsigned char key, int x, int y); void special(int key, int x, int y); + void special_up(int key, int x, int y); void passive_motion(int x, int y); void reshape( int w, int h ); void visibility(int state); @@ -905,6 +911,7 @@ public: virtual int mouse_held_down_handler( int local_x, int local_y, bool inside) { (void)local_x; (void)local_y; (void)inside; return false; } virtual int key_handler( unsigned char key, int modifiers ) { (void)key; (void)modifiers; return false; } virtual int special_handler( int key,int modifiers ) { (void)key; (void)modifiers; return false; } + virtual int special_up_handler( int key,int modifiers ) { (void)key; (void)modifiers; return false; } virtual void update_size( void ) { } virtual void idle( void ) { } diff --git a/Extras/glui/glui.cpp b/Extras/glui/glui.cpp index 993db364b..ecf769d02 100644 --- a/Extras/glui/glui.cpp +++ b/Extras/glui/glui.cpp @@ -310,6 +310,48 @@ void glui_keyboard_func(unsigned char key, int x, int y) } + + +void glui_special_up_func(int key, int x, int y) +{ + GLUI *glui; + int current_window; + GLUI_Glut_Window *glut_window; + + current_window = glutGetWindow(); + glut_window = GLUI_Master.find_glut_window( current_window ); + + if (glut_window) /** Was event in a GLUT window? **/ + { + if ( GLUI_Master.active_control_glui AND GLUI_Master.active_control ) + { + glutSetWindow( GLUI_Master.active_control_glui->get_glut_window_id() ); + + GLUI_Master.active_control_glui->special_up(key,x,y); + finish_drawing(); + + glutSetWindow( current_window ); + } + else + { + if (glut_window->glut_special_up_CB) + glut_window->glut_special_up_CB( key, x, y ); + } + } + else /*** Nope, event was in a standalone GLUI window **/ + { + glui = GLUI_Master.find_glui_by_window_id(glutGetWindow()); + + if ( glui ) + { + glui->special_up(key,x,y); + finish_drawing(); + } + } +} + + + /************************************************ glui_special_func() ********/ void glui_special_func(int key, int x, int y) @@ -731,6 +773,17 @@ void GLUI_Main::keyboard(unsigned char key, int x, int y) } + +void GLUI_Main::special_up(int key, int x, int y) +{ + curr_modifiers = glutGetModifiers(); + + /*** Pass the keystroke onto the active control, if any ***/ + if ( active_control != NULL ) + active_control->special_up_handler( key, glutGetModifiers() ); +} + + /****************************** GLUI_Main::special() **************/ void GLUI_Main::special(int key, int x, int y) @@ -1665,6 +1718,16 @@ void GLUI_Master_Object::set_glutKeyboardFunc(void (*f)(unsigned char key, /*********************** GLUI_Master_Object::set_glutSpecialFunc() **********/ + + +void GLUI_Master_Object::set_glutSpecialUpFunc(void (*f)(int key, + int x, int y)) +{ + glutSpecialUpFunc( glui_special_up_func ); + add_cb_to_glut_window( glutGetWindow(), GLUI_GLUT_SPECIAL_UP, (void*) f); +} + + void GLUI_Master_Object::set_glutSpecialFunc(void (*f)(int key, int x, int y)) { @@ -1865,6 +1928,9 @@ void GLUI_Master_Object::add_cb_to_glut_window(int window_id, case GLUI_GLUT_SPECIAL: window->glut_special_CB = (void(*)(int,int,int)) cb; break; + case GLUI_GLUT_SPECIAL_UP: + window->glut_special_up_CB = (void(*)(int,int,int)) cb; + break; case GLUI_GLUT_MOUSE: window->glut_mouse_CB = (void(*)(int,int,int,int)) cb; break;