chandlerprall / GoblinPhysics

Collision Detection & Response in JavaScript
http://www.goblinphysics.com
Other
147 stars 18 forks source link

Bodys are nervous and unprecise #64

Closed weiserhei closed 8 years ago

weiserhei commented 8 years ago

Im trying to replace ammo.js in favor of goblin.js physics in my projects. I have set up a test case for comparison and experiencing problems with the rigid bodys in goblin. Im working with code copied from the examples/wiki.

http://i.imgur.com/B6IEiG4.png http://weiserhei.github.io/threejs-experiments/goblintest/index.html

Problems:

The same scene simulated with ammo.js, ie. what I want to see: http://weiserhei.github.io/threejs-experiments/goblintest/indexAmmo.html

chandlerprall commented 8 years ago

The first and third issues are caused by the GJK shape margins which aren't added to objects' bounding boxes. This will resolve for you: Goblin.GjkEpa.margins = 0;

The sphere rolling on the box is because the box's contact resolution with the floor is imperfect, leading to the box rotating slightly which changes how it interacts with the sphere. Ammo has a specific box-box collision routine that prevents this.

weiserhei commented 8 years ago

Goblin.GjkEpa.margins seems to do a good job, thanks! Couldnt find this in the docs, are there drawbacks when adding this?

And any plans for the future that goblin will handle box-box collision the same way?

chandlerprall commented 8 years ago

Having non-zero margins is an optimization which is only really visible when you have a large number of contacts. It's not currently documented, and can use some cleanup in the code to reduce it's impact on stability and visuals (avoid floating boxes).

I do plan on adding a BoxBox algorithm, been digging into the approach lately but am trying to knock out constraint limits & motors first.

weiserhei commented 8 years ago

Cool, thank you for your work. I consider this issue as answered and close it.