Page 1 of 1

Collision detection bug/inaccuracy?

Posted: Thu Oct 12, 2017 1:17 am
by asantoso
The collision detection has some inaccuracy/error around the edges of Rectangular fixture.
Please see picture, yellow box is controlled by player and it is moving toward blue spheres.
As blue spheres slide toward the edge of the box, the error (penetration) increases.

Yellow box is created by Geometry.createRectangle(width, height);

Here's my world settings:
settings.setAutoSleepingEnabled(true);
settings.setSleepTime(1);
settings.setSleepLinearVelocity(10);
settings.setMaximumTranslation(100);
settings.setMaximumRotation(Math.PI);
settings.setContinuousDetectionMode(ContinuousDetectionMode.NONE);
settings.setStepFrequency(1/60f);
settings.setPositionConstraintSolverIterations(1000);

no change on RaycastDetector
no change on ManifoldSolver
no change on NarrowphaseDetector

No world listeners are set.

The Rectangular body is never rotated, the fixture once created is never changed.

detection1.png
detection1.png (7.28 KiB) Viewed 241 times

detection2.png
detection2.png (12.8 KiB) Viewed 241 times

Re: Collision detection bug/inaccuracy?

Posted: Thu Oct 12, 2017 8:13 am
by zoom
I don't understand the pictures. All I see is a number and some overlap. The larger the overlap the larger the number but where does that number come from?

Re: Collision detection bug/inaccuracy?

Posted: Thu Oct 12, 2017 9:00 am
by William
How is the player body controlled?

Can you supply the sizes and coordinates for the shapes when they are overlapping like this?

William

Re: Collision detection bug/inaccuracy?

Posted: Fri Oct 13, 2017 12:28 am
by asantoso
William wrote:How is the player body controlled?

Can you supply the sizes and coordinates for the shapes when they are overlapping like this?

William


I am calling setLinearVelocity to control the player body.

Go to this page and test directly:
http://li1625-165.members.linode.com/ga ... DPvbTds1Lm

Seems like fixture created by Geometry.createRectangle behaves like Geometry.createCircle.

Re: Collision detection bug/inaccuracy?

Posted: Fri Oct 13, 2017 1:36 am
by zoom
asantoso wrote:Seems like fixture created by Geometry.createRectangle behaves like Geometry.createCircle.


https://github.com/wnbittle/dyn4j/blob/ ... .java#L589

There must be something else going on. It would be really helpful if you could put together a junit-test or a simple app with full source code to duplicate your problem.

Re: Collision detection bug/inaccuracy?

Posted: Fri Oct 13, 2017 8:56 am
by asantoso
zoom wrote:
asantoso wrote:Seems like fixture created by Geometry.createRectangle behaves like Geometry.createCircle.


https://github.com/wnbittle/dyn4j/blob/ ... .java#L589

There must be something else going on. It would be really helpful if you could put together a junit-test or a simple app with full source code to duplicate your problem.



I gave up. This library is really hard to use. I did try using same configuration values from Shapes.xml in the sandbox.
Changed all spheres to Rectangular fixtures, problem still exists.
Code is all single threaded, no fancy stuffs.
The spheres are still overlapping the box, the wider the box the worse the problem becomes.

All bodies config: density=1, friction=0.5, restitution=0
Mass = NORMAL

Settings settings = world.getSettings();
settings.setAutoSleepingEnabled(true);
settings.setSleepTime(2);
settings.setSleepLinearVelocity(1);
settings.setMaximumTranslation(200.0f);
settings.setMaximumRotation(Math.PI);
settings.setContinuousDetectionMode(ContinuousDetectionMode.ALL);
settings.setStepFrequency(60.0f);

settings.setPositionConstraintSolverIterations(10);
settings.setVelocityConstraintSolverIterations(10);

settings.setBaumgarte(0.2f);
settings.setWarmStartDistance(0.02f);
settings.setLinearTolerance(0.050f);
settings.setAngularTolerance(0.050f);
settings.setMaximumLinearCorrection(0.5f);
settings.setMaximumAngularCorrection(0.5f);

world.setTimeOfImpactDetector(new ConservativeAdvancement());
world.setManifoldSolver(new ClippingManifoldSolver());
world.setGravity(World.ZERO_GRAVITY);

Re: Collision detection bug/inaccuracy?

Posted: Fri Oct 13, 2017 7:54 pm
by William
I understand you may be frustrated, but it's difficult for us to offer help without more information. Zoom is correct, we need some way to replicate and the best way to do so would be through a code sample.

Have you tried to run any of the samples here?

https://github.com/wnbittle/dyn4j/tree/ ... 4j/samples

If you are new to the library I would recommend you start there. If you can get one of those working - as is - then modify one thing at a time to get to where you want to be. It's quite possible that you've just missed something trivial, yet critical.

Thanks,
William

Re: Collision detection bug/inaccuracy?

Posted: Sat Oct 14, 2017 8:41 pm
by asantoso
Yes I use the sample code.

The issue dissapears if I set MassType of the non-player bodies to INFINITY. Thus i am restricted with non-moving rectangular object.
Not sure if this issue only occurs with Rectangle, haven't tried creating Convex object using triangles.

Re: Collision detection bug/inaccuracy?

Posted: Sun Oct 15, 2017 6:42 am
by William
Can u post the code that doesn't work please? Which sample did you start with? Does the sample work before you modify it? What version of the library are you using?

We can only speculate what is wrong right now.

William

Re: Collision detection bug/inaccuracy?

Posted: Sun Oct 15, 2017 10:50 am
by asantoso
The root cause turns out to be that the body is rotating and the rendering didn't reflect that.