santarcade Posted September 15, 2016 Share Posted September 15, 2016 Hi guys, I upgraded to BabylonJS 2.4 and I think I've found a bug on the CannonJS plugin. It's line 32 of babylon.cannonJSPlugin.ts: this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta * 1000 : 0, 3); If I leave the default _useDeltaForWorldStep set to true, the game runs 1000 faster than normal, if I set it to false it works fine. By removing the delta*1000 works as expected, resulting in this patch: this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3); I can't do a PR at the moment, so I'm writing here... but I promise I will be able in the future! Cheers, Joez Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 15, 2016 Share Posted September 15, 2016 Hey! Do you reproduce the bug with Oimo? Quote Link to comment Share on other sites More sharing options...
santarcade Posted September 19, 2016 Author Share Posted September 19, 2016 Hi Deltakosh, I double checked: OimoJSPlugin does not have the useDeltaForWorldStep parameter. I created a small playground that shows the issue: http://www.babylonjs-playground.com/#2B84TV#4 I dug a little in the code, and in addition, I think that this accumulator done with time delta, could suffer on another bug when setting a different timeStep via setTimeStep(timeStep). Best, Joez Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 19, 2016 Share Posted September 19, 2016 Ok I'm trying to summon @RaananW Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 19, 2016 Share Posted September 19, 2016 Summoned, will take care of that later ☺ GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 20, 2016 Share Posted September 20, 2016 Hi Joez, I am trying to understand the comment regarding "1000" faster. I see the speed difference between the two, but it is certainly not 1000 faster. care to elaborate? maybe make a short screen capture so I can see how you see things? Quote Link to comment Share on other sites More sharing options...
santarcade Posted September 20, 2016 Author Share Posted September 20, 2016 Hi RaananW, you are right: the speed increase factor is not directly 1 thousand. I wrote some trajectory prediction code to estimate when a body launched with given velocity will hit the ground. If I keep just delta, the collision will be matching the prediction. If I keep delta*1000, the body will hit the ground way earlier than expected (physics is altered). This is indeed seen in the playground: same forces on same bodies end up in two different behaviors. What do you think? Thank you, Joez Quote Link to comment Share on other sites More sharing options...
santarcade Posted September 20, 2016 Author Share Posted September 20, 2016 I've been playing even with setting different timeSteps: if useDeltaForWorldStep is true, after a while it seems the world simulation losses sync (I guess the accumulator jumps in, feeling the need to recover steps). So far, I have been able to achieve a stable and consistent results changing the line with this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta*(this._fixedTimeStep/(1/60)) : 0, 3); Does it make sense to you? Best, Joez Quote Link to comment Share on other sites More sharing options...
santarcade Posted September 21, 2016 Author Share Posted September 21, 2016 Hi guys, I tested even OimoJS and my conclusion is that there is definitively something wrong with physics in version 2.4. Check this demo up: http://www.babylonjs-playground.com/#2B84TV#5 The timeStep in Oimo is inconsistent: so fast to the point that after a few bounces on the plane, the sphere will pass through it. I tried to check the code, but could not find a reason for this: any idea? The only consistent version seems to be the first commented line: var physEngine = new BABYLON.CannonJSPlugin(true); Joez Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.