Spheres and triangle edges

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Spheres and triangle edges

Postby Sweenie » Fri Nov 28, 2014 10:58 am

Hi.

I'm having some problems with spheres rolling over triangle edges and gaining a pretty significant amount of momentum.

As you can see in the video below, the spheres roll over an edge on a flat floor and it looks like they start to roll down a slope although the floor is totally flat...

Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Spheres and triangle edges

Postby Julio Jerez » Fri Nov 28, 2014 11:13 am

Oh good test, that certainly looks wrong.
can you serialize that scene for me to try Is the demos?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Spheres and triangle edges

Postby Sweenie » Fri Nov 28, 2014 1:22 pm

Hi.

Try this ---> http://svenberra.net/spheres.bin

One thing I noticed though is that the problem goes away if I make the spheres bigger.
Right now they are kind of small, the big one has a radius of 0.2 and the small ones a radius of 0.1
When they were changed in size to 2.0 and 1.0 in radius I couldn't see the problem.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Spheres and triangle edges

Postby Julio Jerez » Fri Nov 28, 2014 1:55 pm

oh yes I see, that look really bad. two question
Is the floor suppose to be flat?
could be remove all the small balls and leave just one, and posted again?

maybe two files one the big ball and another with the small ball.
It make a lot easier to find out what the problem is
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Spheres and triangle edges

Postby Sweenie » Fri Nov 28, 2014 2:50 pm

The floor is supposed to be flat. It's a triangulated plane surrounded by four boxes as walls made into a TreeCollision.

Here are some different scenes with one sphere in each with the radius 1.0, 0.5, 0.2 and 0.1
--> http://www.svenberra.net/spheres.zip
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Spheres and triangle edges

Postby Julio Jerez » Fri Nov 28, 2014 11:11 pm

Ha thank you, I found the problem. It is easy to fix, but I first what to see what change I made the broke that.
I get done tomorrow
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Spheres and triangle edges

Postby Sweenie » Sat Nov 29, 2014 5:10 am

Awesome :D

I remember you fixed something similar a while ago but with cylinders. Could something have changed then?
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Spheres and triangle edges

Postby Julio Jerez » Sat Nov 29, 2014 6:32 pm

I am looking at this problem, and this has being a recurrent problem in since newton 2.0

basically it come from a mistake that made back when I have newton 1.0 in 2003
at the time I only have three collision primitive type.
Box, sphere, and polygonal soup.
at the time the collisions where base on intersection and clipping of geometric primitives.
because of that I set a constant to define the minimum penetration that can be considered zero penetration.
the when I move to newton 1.4, I move to a more general version not on clipping but on closet distance, between primitive.
I have being hacking solution at the contact solve level, but It is time to fix it for real.

Basically all collision routine should not be aware of default contact penetration, they should simple calculate the contacts and the contact joint should determine the penetration.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Spheres and triangle edges

Postby Julio Jerez » Sat Nov 29, 2014 10:06 pm

ok I added a general solution to that bug. it should be smooth all the time.

with you please test with cylinder, capsules and the other primitives.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Spheres and triangle edges

Postby Sweenie » Sun Nov 30, 2014 4:38 am

Sphere seems to be fine now.
Box is fine.
Cylinder behaves like the sphere did though, colliding with the edge.
Haven't tested capsule yet since I haven't implemented support for that shape in "my" engine yet.
Cone behaves a bit odd, hard to to test though as a cone doesn't really roll in a straight path, so you have to drag it around.
Chamfercylinder seems ok.

http://www.svenberra.net/world.bin

[EDIT]
By the way, in the lastest build, you have set "Scaled bodies" as the default demo and it seems to load a serialized collision called "rb" that I don't have so the sandbox crash.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Spheres and triangle edges

Postby Julio Jerez » Sun Nov 30, 2014 8:27 am

ok I fix he check in mistake.
My guess Is that cone will have the same problem because they are form the same family of shapes.
maybe the function that calculate the contact penetration still have the same bug.

the cylider is simpler to test,
to make it easier Can you remove the other shapes and leave only the cylinder.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Spheres and triangle edges

Postby Sweenie » Sun Nov 30, 2014 9:15 am

Sure thing, here it is ---> http://www.svenberra.net/cylinder.bin
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Spheres and triangle edges

Postby Julio Jerez » Mon Dec 01, 2014 12:00 pm

Oh I see what is the problem, this is related cylinders with small radius.

Cylinder are expensive to calculate the closest point, for performance I added a skin thickness that is subtracted for the radius. I set to 0.05 (that's about 2 index)

but is a cylinder has a radius that is comparable to the skin thickness, them some edge contact will not be close to he ideal contact on the cylinder surface.

In you test the cylinder radius is 0.1 why si 50% of the thickness and that make the contact solver find edge contacts that will be till more than 45 degree even when rolling on a flat surfaces

after lot of debugging I reliance that nothing was wrong, yes I was getting this estrange contacts far away from the outside form the cinder surface and they where never rejects, until I realize that all contact were very close. the I say tan the cylinder had a small radios compared to the tolerance.

so as a test I set the tolerance smaller, and the made it better at the expense of going to the more expensive contact routine each time.
I check it is like that. Late I will made the tolerance a member for the cylinder class, that way if can be a calculated and truncated value.

so that Large cylinder can have a larger tolerance and use the fast routine and small cylinder will have the smaller tolerance.
ironically had the cylinder being smaller than the tolerance it would work, because the code only use the tolerance on cylider with radius larger that the tolerance

Code: Select all
dgVector dgCollisionCylinder::ConvexConicSupporVertex (const dgVector& dir) const
{
   dgAssert (dgAbsf ((dir % dir - dgFloat32 (1.0f))) < dgFloat32 (1.0e-3f));

   dgFloat32 radius = (m_radius > DG_CYLINDER_SKIN_PADDING) ? m_radius - DG_CYLINDER_SKIN_PADDING : m_radius;
   dgFloat32 height = (m_height > DG_CYLINDER_SKIN_PADDING) ? m_height - DG_CYLINDER_SKIN_PADDING : m_height;

   dgFloat32 y0 = radius;


please try again. with the setting should be much better now. It will never be ideally perfect as long as the cylinder uses a skin tolerance. but I do no know of any algorithm that allow the calculation of the closest distance form a cylinder to some other primitive that does no requires a skin distance.

they can get the distance when the do not interpenetrate, or when the interpenetrate, but they fail when the primitive are simply touching. so you have to use hysteresis. make the cylinder smaller when testing for no intergeneration, and make the cylinder larger if the first test fail and test for interpenetration.
It on the gray area that the contact may not represent the ideal contact 100%.

when the distance tolerance is small relative to the size of the shapes, then is not problem but when the shape is comparable to the distance tolerance then the error become significant.

The other problem is that the error can no be made arvitrally small. because then when the tow shape are close the algorithm start losing floating point integrate too fast.

This is the biggest problem I have with JGK, it Is too numerically unstable, but on the other hand it I the best game in town for calculating distance between convex shapes.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Spheres and triangle edges

Postby Julio Jerez » Mon Dec 01, 2014 2:02 pm

Ok now I made the skin thickness for a cylinder part of the class.
Now each cylinder has its own valued calculate from its dimensions. this make that cylinder tha do no need the small value will run the faster routines.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Spheres and triangle edges

Postby Sweenie » Mon Dec 01, 2014 4:35 pm

Yep, now it rolls smoothly over the triangle edge. :D
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 4 guests

cron