Collision detection bug/inaccuracy?

Posts that don't fit into other categories.
asantoso
Posts: 11
Joined: Thu Mar 02, 2017 12:18 am

Collision detection bug/inaccuracy?

Postby asantoso » Thu Oct 12, 2017 1:17 am

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 133 times

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

zoom
Posts: 141
Joined: Sun Mar 17, 2013 3:57 pm
Location: Stockholm, Sweden
Contact:

Re: Collision detection bug/inaccuracy?

Postby zoom » Thu Oct 12, 2017 8:13 am

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?

William
Site Admin
Posts: 345
Joined: Sat Feb 06, 2010 10:23 pm

Re: Collision detection bug/inaccuracy?

Postby William » Thu Oct 12, 2017 9:00 am

How is the player body controlled?

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

William

asantoso
Posts: 11
Joined: Thu Mar 02, 2017 12:18 am

Re: Collision detection bug/inaccuracy?

Postby asantoso » Fri Oct 13, 2017 12:28 am

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.

zoom
Posts: 141
Joined: Sun Mar 17, 2013 3:57 pm
Location: Stockholm, Sweden
Contact:

Re: Collision detection bug/inaccuracy?

Postby zoom » Fri Oct 13, 2017 1:36 am

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.

asantoso
Posts: 11
Joined: Thu Mar 02, 2017 12:18 am

Re: Collision detection bug/inaccuracy?

Postby asantoso » Fri Oct 13, 2017 8:56 am

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);

William
Site Admin
Posts: 345
Joined: Sat Feb 06, 2010 10:23 pm

Re: Collision detection bug/inaccuracy?

Postby William » Fri Oct 13, 2017 7:54 pm

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

asantoso
Posts: 11
Joined: Thu Mar 02, 2017 12:18 am

Re: Collision detection bug/inaccuracy?

Postby asantoso » Sat Oct 14, 2017 8:41 pm

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.

William
Site Admin
Posts: 345
Joined: Sat Feb 06, 2010 10:23 pm

Re: Collision detection bug/inaccuracy?

Postby William » Sun Oct 15, 2017 6:42 am

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

asantoso
Posts: 11
Joined: Thu Mar 02, 2017 12:18 am

Re: Collision detection bug/inaccuracy?

Postby asantoso » Sun Oct 15, 2017 10:50 am

The root cause turns out to be that the body is rotating and the rendering didn't reflect that.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests