From d309e298e161afc8e0b07e6bbef8286dbea09827 Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Thu, 20 Oct 2016 17:11:33 -0700 Subject: [PATCH 1/3] Update fontstash.cpp use free instead of 'delete' for the tex->m_texels memory --- examples/OpenGLWindow/fontstash.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/OpenGLWindow/fontstash.cpp b/examples/OpenGLWindow/fontstash.cpp index 56eaeb3a8..4f144095b 100644 --- a/examples/OpenGLWindow/fontstash.cpp +++ b/examples/OpenGLWindow/fontstash.cpp @@ -793,7 +793,7 @@ void sth_delete(struct sth_stash* stash) tex = stash->textures; while(tex != NULL) { curtex = tex; - delete tex->m_texels; + free(tex->m_texels); tex->m_texels=0; tex = tex->next; stash->m_renderCallbacks->updateTexture(curtex,0,0,0); From 79d9e6b15e8cbb558238661f579a34cb54153364 Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Sat, 22 Oct 2016 13:50:08 -0700 Subject: [PATCH 2/3] move CommonTimeWarpBase.h to Evolution/NN3DWalkersTimeWarpBase, it is not a common interface. --- examples/Evolution/NN3DWalkers.cpp | 8 ++++---- .../NN3DWalkersTimeWarpBase.h} | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) rename examples/{CommonInterfaces/CommonTimeWarpBase.h => Evolution/NN3DWalkersTimeWarpBase.h} (98%) mode change 100755 => 100644 diff --git a/examples/Evolution/NN3DWalkers.cpp b/examples/Evolution/NN3DWalkers.cpp index 148017857..148ebee0c 100755 --- a/examples/Evolution/NN3DWalkers.cpp +++ b/examples/Evolution/NN3DWalkers.cpp @@ -29,7 +29,7 @@ struct btCollisionAlgorithmCreateFunc; class btDefaultCollisionConfiguration; class NNWalker; -#include "../CommonInterfaces/CommonTimeWarpBase.h" +#include "NN3DWalkersTimeWarpBase.h" #include "../CommonInterfaces/CommonParameterInterface.h" #include "../Utils/b3ReferenceFrameHelper.hpp" @@ -99,7 +99,7 @@ static btScalar gParallelEvaluations = 10.0f; void* GROUND_ID = (void*)1; -class NN3DWalkersExample : public CommonTimeWarpBase +class NN3DWalkersExample : public NN3DWalkersTimeWarpBase { btScalar m_Time; btScalar m_SpeedupTimestamp; @@ -115,7 +115,7 @@ class NN3DWalkersExample : public CommonTimeWarpBase public: NN3DWalkersExample(struct GUIHelperInterface* helper) - :CommonTimeWarpBase(helper), + :NN3DWalkersTimeWarpBase(helper), m_Time(0), m_SpeedupTimestamp(0), m_motorStrength(0.5f), @@ -771,7 +771,7 @@ bool NN3DWalkersExample::keyboardCallback(int key, int state) break; } - return CommonTimeWarpBase::keyboardCallback(key,state); + return NN3DWalkersTimeWarpBase::keyboardCallback(key,state); } void NN3DWalkersExample::exitPhysics() diff --git a/examples/CommonInterfaces/CommonTimeWarpBase.h b/examples/Evolution/NN3DWalkersTimeWarpBase.h old mode 100755 new mode 100644 similarity index 98% rename from examples/CommonInterfaces/CommonTimeWarpBase.h rename to examples/Evolution/NN3DWalkersTimeWarpBase.h index dde06b417..6db8fadd1 --- a/examples/CommonInterfaces/CommonTimeWarpBase.h +++ b/examples/Evolution/NN3DWalkersTimeWarpBase.h @@ -13,8 +13,8 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifndef COMMON_TIME_WARP_BASE_H -#define COMMON_TIME_WARP_BASE_H +#ifndef NN3D_WALKERS_TIME_WARP_BASE_H +#define NN3D_WALKERS_TIME_WARP_BASE_H #include "btBulletDynamicsCommon.h" #include "LinearMath/btVector3.h" @@ -207,9 +207,9 @@ inline void setApplicationTick(float frequency){ // set internal application tic /** * @link: Gaffer on Games - Fix your timestep: http://gafferongames.com/game-physics/fix-your-timestep/ */ -struct CommonTimeWarpBase: public CommonRigidBodyBase { +struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase { - CommonTimeWarpBase(struct GUIHelperInterface* helper): + NN3DWalkersTimeWarpBase(struct GUIHelperInterface* helper): CommonRigidBodyBase(helper), mPhysicsStepsPerSecondUpdated(false), mFramesPerSecondUpdated(false), @@ -250,7 +250,7 @@ struct CommonTimeWarpBase: public CommonRigidBodyBase { mLoopTimer.reset(); } - ~CommonTimeWarpBase(){ + ~NN3DWalkersTimeWarpBase(){ } @@ -753,7 +753,7 @@ struct CommonTimeWarpBase: public CommonRigidBodyBase { } void performTrueSteps(btScalar timeStep){ // physics stepping without interpolated substeps - int subSteps = round(timeStep / fixedPhysicsStepSizeSec); /**!< Calculate the number of full normal time steps we can take */ + int subSteps = floor((timeStep / fixedPhysicsStepSizeSec)+0.5); /**!< Calculate the number of full normal time steps we can take */ for (int i = 0; i < subSteps; i++) { /**!< Perform the number of substeps to reach the timestep*/ if (timeStep && m_dynamicsWorld) { @@ -767,7 +767,7 @@ struct CommonTimeWarpBase: public CommonRigidBodyBase { } void performInterpolatedSteps(btScalar timeStep){ // physics stepping with interpolated substeps - int subSteps = 1 + round(timeStep / fixedPhysicsStepSizeSec); /**!< Calculate the number of full normal time steps we can take, plus 1 for safety of not losing time */ + int subSteps = 1 + floor((timeStep / fixedPhysicsStepSizeSec)+0.5); /**!< Calculate the number of full normal time steps we can take, plus 1 for safety of not losing time */ if (timeStep && m_dynamicsWorld) { m_dynamicsWorld->stepSimulation(btScalar(timeStep), btScalar(subSteps), @@ -899,5 +899,5 @@ struct CommonTimeWarpBase: public CommonRigidBodyBase { bool mIsHeadless; }; -#endif //COMMON_TIME_WARP_BASE_H +#endif //NN3D_WALKERS_TIME_WARP_BASE_H From 2c6237abdada5ddcebf0d67d4b5322f429eb03d8 Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Sat, 22 Oct 2016 13:53:44 -0700 Subject: [PATCH 3/3] process todo in CMakeLists.txt --- examples/ExampleBrowser/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/ExampleBrowser/CMakeLists.txt b/examples/ExampleBrowser/CMakeLists.txt index 8c18bb845..024d928d3 100644 --- a/examples/ExampleBrowser/CMakeLists.txt +++ b/examples/ExampleBrowser/CMakeLists.txt @@ -133,7 +133,7 @@ SET(ExtendedTutorialsSources ) SET(BulletExampleBrowser_SRCS - ../CommonInterfaces/CommonTimeWarpBase.h #TODO: This is wrong here, where should it go? + ../TinyRenderer/geometry.cpp ../TinyRenderer/model.cpp ../TinyRenderer/tgaimage.cpp @@ -179,6 +179,7 @@ SET(BulletExampleBrowser_SRCS ../Tutorial/Dof6ConstraintTutorial.h ../Evolution/NN3DWalkers.cpp ../Evolution/NN3DWalkers.h + ../Evolution/NN3DWalkersTimeWarpBase.h ../ExtendedTutorials/NewtonsRopeCradle.cpp ../ExtendedTutorials/NewtonsRopeCradle.h ../Collision/CollisionSdkC_Api.cpp