From 21d1827c9f7953065fc9dfd20bedcaa9901175f7 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 23 Mar 2017 17:30:59 -0700 Subject: [PATCH] revert previous cmake copy->symlink (doesn't work on Windows) fix timing issues at small timestep, disable default linear damping for btMultiBody --- examples/ExampleBrowser/CMakeLists.txt | 3 ++- examples/SharedMemory/PhysicsServerExample.cpp | 11 ++++++++++- src/BulletDynamics/Featherstone/btMultiBody.cpp | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/ExampleBrowser/CMakeLists.txt b/examples/ExampleBrowser/CMakeLists.txt index de69074ed..127ab11f5 100644 --- a/examples/ExampleBrowser/CMakeLists.txt +++ b/examples/ExampleBrowser/CMakeLists.txt @@ -378,11 +378,12 @@ ADD_EXECUTABLE(App_ExampleBrowser ${BulletExampleBrowser_SRCS} ) +FILE( MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/data" ) ADD_CUSTOM_COMMAND( TARGET App_ExampleBrowser POST_BUILD - COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink ${BULLET_PHYSICS_SOURCE_DIR}/data ${PROJECT_BINARY_DIR}/data + COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${BULLET_PHYSICS_SOURCE_DIR}/data ${PROJECT_BINARY_DIR}/data ) IF (BULLET2_MULTITHREADED_TBB_DEMO AND WIN32) diff --git a/examples/SharedMemory/PhysicsServerExample.cpp b/examples/SharedMemory/PhysicsServerExample.cpp index 970b209d3..7ca002b8d 100644 --- a/examples/SharedMemory/PhysicsServerExample.cpp +++ b/examples/SharedMemory/PhysicsServerExample.cpp @@ -305,7 +305,8 @@ void MotionThreadFunc(void* userPtr,void* lsMemory) double deltaTimeInSeconds = 0; int numCmdSinceSleep1ms = 0; - + unsigned long long int prevTime = clock.getTimeMicroseconds(); + do { BT_PROFILE("loop"); @@ -330,8 +331,16 @@ void MotionThreadFunc(void* userPtr,void* lsMemory) sleepClock.reset(); numCmdSinceSleep1ms = 0; } + + unsigned long long int curTime = clock.getTimeMicroseconds(); + unsigned long long int dtMicro = curTime - prevTime; + prevTime = curTime; +#if 1 + double dt = double(dtMicro)/1000000.; +#else double dt = double(clock.getTimeMicroseconds())/1000000.; clock.reset(); +#endif deltaTimeInSeconds+= dt; { diff --git a/src/BulletDynamics/Featherstone/btMultiBody.cpp b/src/BulletDynamics/Featherstone/btMultiBody.cpp index c14aa2aea..07b2fcddb 100644 --- a/src/BulletDynamics/Featherstone/btMultiBody.cpp +++ b/src/BulletDynamics/Featherstone/btMultiBody.cpp @@ -112,7 +112,7 @@ btMultiBody::btMultiBody(int n_links, m_userObjectPointer(0), m_userIndex2(-1), m_userIndex(-1), - m_linearDamping(0.04f), + m_linearDamping(0.0f), m_angularDamping(0.04f), m_useGyroTerm(true), m_maxAppliedImpulse(1000.f),