diff --git a/Demos/AllBulletDemos/Main.cpp b/Demos/AllBulletDemos/Main.cpp index d3e7629d9..b8bb5dd23 100644 --- a/Demos/AllBulletDemos/Main.cpp +++ b/Demos/AllBulletDemos/Main.cpp @@ -52,6 +52,9 @@ namespace int gDrawAabb; int gWireFrame; int gDebugContacts; + int gDrawTextures=1; + int gDrawShadows=0; + int gDrawClusters=0; int gDebugNoDeactivation; int gUseWarmstarting; int gRandomizeConstraints; @@ -75,6 +78,10 @@ void setDefaultSettings() gDrawAabb=0; gWireFrame=0; gDebugContacts=0; + gDrawTextures=1; + gDrawShadows=0; + gDrawClusters=0; + gDebugNoDeactivation = 0; gUseSplitImpulse = 0; gUseWarmstarting = 1; @@ -135,6 +142,10 @@ DemoApplication* CreatDemo(btDemoEntry* entry) if (demo->getDynamicsWorld()) { demo->getDynamicsWorld()->setDebugDrawer(new GLDebugDrawer()); + gDrawTextures = demo->getTexturing(); + gDrawShadows = demo->getShadows(); + if (glui) + glui->sync_live(); } #ifndef BT_NO_PROFILE @@ -194,6 +205,9 @@ void SimulationLoop() demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawContactPoints)); } + demo->setTexturing(0!=gDrawTextures); + demo->setShadows(0!=gDrawShadows); + demo->setDrawClusters(0!=gDrawClusters); if (gDebugNoDeactivation) { @@ -203,6 +217,9 @@ void SimulationLoop() demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_NoDeactivation)); } + + + if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getWorldType() == BT_DISCRETE_DYNAMICS_WORLD) { btDiscreteDynamicsWorld* discreteWorld = (btDiscreteDynamicsWorld*) demo->getDynamicsWorld(); @@ -285,7 +302,7 @@ void Keyboard(unsigned char key, int x, int y) // Press 'r' to reset. case 'r': - if (demo->getDynamicsWorld()->getDebugDrawer()) + if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getDebugDrawer()) delete demo->getDynamicsWorld()->getDebugDrawer(); delete demo; demo = CreatDemo(entry); @@ -413,6 +430,13 @@ int main(int argc, char** argv) glui->add_checkbox_to_panel(drawPanel, "AABBs", &gDrawAabb); glui->add_checkbox_to_panel(drawPanel, "Wireframe", &gWireFrame); glui->add_checkbox_to_panel(drawPanel, "Contacts", &gDebugContacts); + glui->add_checkbox_to_panel(drawPanel, "Textures", &gDrawTextures); + 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); diff --git a/Demos/OpenGL/DemoApplication.h b/Demos/OpenGL/DemoApplication.h index 0dd4e15a9..881daa680 100644 --- a/Demos/OpenGL/DemoApplication.h +++ b/Demos/OpenGL/DemoApplication.h @@ -96,12 +96,26 @@ public: { return m_dynamicsWorld; } - + + virtual void setDrawClusters(bool drawClusters) + { + + } + void setOrthographicProjection(); void resetPerspectiveProjection(); bool setTexturing(bool enable) { return(m_shapeDrawer.enableTexture(enable)); } bool setShadows(bool enable) { bool p=m_enableshadows;m_enableshadows=enable;return(p); } + bool getTexturing() const + { + return m_shapeDrawer.hasTextureEnabled(); + } + bool getShadows() const + { + return m_enableshadows; + } + int getDebugMode() { @@ -110,6 +124,10 @@ public: void setDebugMode(int mode); + void setAzi(float azi) + { + m_azi = azi; + } void setCameraUp(const btVector3& camUp) { diff --git a/Demos/OpenGL/GL_ShapeDrawer.h b/Demos/OpenGL/GL_ShapeDrawer.h index f979a4a57..30eb7a6ca 100644 --- a/Demos/OpenGL/GL_ShapeDrawer.h +++ b/Demos/OpenGL/GL_ShapeDrawer.h @@ -51,6 +51,10 @@ class GL_ShapeDrawer void drawShadow(btScalar* m, const btVector3& extrusion,const btCollisionShape* shape,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax); bool enableTexture(bool enable) { bool p=m_textureenabled;m_textureenabled=enable;return(p); } + bool hasTextureEnabled() const + { + return m_textureenabled; + } static void drawCylinder(float radius,float halfHeight, int upAxis); static void drawCoordSystem(); diff --git a/Demos/RagdollDemo/main.cpp b/Demos/RagdollDemo/main.cpp index 7c0ad9d1e..13d29e7c2 100644 --- a/Demos/RagdollDemo/main.cpp +++ b/Demos/RagdollDemo/main.cpp @@ -1,17 +1,17 @@ - -#include "RagdollDemo.h" -#include "GlutStuff.h" + +#include "RagdollDemo.h" +#include "GlutStuff.h" #include "GLDebugDrawer.h" #include "btBulletDynamicsCommon.h" -GLDebugDrawer gDebugDrawer; - -int main(int argc,char* argv[]) -{ - RagdollDemo demoApp; - - demoApp.initPhysics(); - demoApp.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer); - - return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&demoApp); -} +GLDebugDrawer gDebugDrawer; + +int main(int argc,char* argv[]) +{ + RagdollDemo demoApp; + + demoApp.initPhysics(); + demoApp.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer); + + return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&demoApp); +} diff --git a/Demos/SliderConstraintDemo/SliderConstraintDemo.cpp b/Demos/SliderConstraintDemo/SliderConstraintDemo.cpp index 834d43f7f..636a2fed9 100755 --- a/Demos/SliderConstraintDemo/SliderConstraintDemo.cpp +++ b/Demos/SliderConstraintDemo/SliderConstraintDemo.cpp @@ -134,6 +134,9 @@ static void drawSlider(btSliderConstraint* pSlider) void SliderConstraintDemo::initPhysics() { + setTexturing(true); + setShadows(true); + setCameraDistance(26.f); // init world @@ -154,7 +157,8 @@ void SliderConstraintDemo::initPhysics() m_dynamicsWorld = wp; // add floor - btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); + //btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); + btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.))); m_collisionShapes.push_back(groundShape); btTransform groundTransform; groundTransform.setIdentity(); diff --git a/Demos/SoftDemo/SoftDemo.cpp b/Demos/SoftDemo/SoftDemo.cpp index f10af9167..896334a3e 100644 --- a/Demos/SoftDemo/SoftDemo.cpp +++ b/Demos/SoftDemo/SoftDemo.cpp @@ -1108,6 +1108,7 @@ psb0->appendLinearJoint(lj,psb1); // static void Init_ClusterCar(SoftDemo* pdemo) { + pdemo->setAzi(270); const btVector3 origin(100,80,0); const btQuaternion orientation(-SIMD_PI/2,0,0); const btScalar widthf=8; @@ -1446,6 +1447,19 @@ void SoftDemo::renderme() } +void SoftDemo::setDrawClusters(bool drawClusters) +{ + if (drawClusters) + { + getSoftDynamicsWorld()->setDrawFlags(getSoftDynamicsWorld()->getDrawFlags()|fDrawFlags::Clusters); + } else + { + getSoftDynamicsWorld()->setDrawFlags(getSoftDynamicsWorld()->getDrawFlags()& (~fDrawFlags::Clusters)); + } +} + + + void SoftDemo::keyboardCallback(unsigned char key, int x, int y) { switch(key) @@ -1580,6 +1594,10 @@ void SoftDemo::initPhysics() { ///create concave ground mesh + //reset and disable motorcontrol at the start + motorcontrol.goal = 0; + motorcontrol.maxtorque = 0; + m_azi = 0; btCollisionShape* groundShape = 0; bool useConcaveMesh = false;//not ready yet true; diff --git a/Demos/SoftDemo/SoftDemo.h b/Demos/SoftDemo/SoftDemo.h index caf050212..3726527a7 100644 --- a/Demos/SoftDemo/SoftDemo.h +++ b/Demos/SoftDemo/SoftDemo.h @@ -110,14 +110,16 @@ public: return demo; } - const btSoftRigidDynamicsWorld* getSoftDynamicsWorld() const + virtual void setDrawClusters(bool drawClusters); + + virtual const btSoftRigidDynamicsWorld* getSoftDynamicsWorld() const { ///just make it a btSoftRigidDynamicsWorld please ///or we will add type checking return (btSoftRigidDynamicsWorld*) m_dynamicsWorld; } - btSoftRigidDynamicsWorld* getSoftDynamicsWorld() + virtual btSoftRigidDynamicsWorld* getSoftDynamicsWorld() { ///just make it a btSoftRigidDynamicsWorld please ///or we will add type checking