by Julio Jerez » Thu Apr 22, 2010 3:45 pm
I am thinking about the and the more I think the less I like the idea of the aspect ratio.
Delfy and rvangaal pleas ignore 2.20
This saturday I will re work that as fallow.
I will save the max face size as data member of each face. then in the contact solver I will add a Bin click routine that will make sure excessive parts of a face are clipped with the face is teacher from the collision tree.
I have sevaral reason for this.
-The nopnbe of bad face is always realisably small.
- Clipping is always proportional to the face area, and sine face can be very large, this leads to very large trees wish increases the queries time unnecessarily.
- I so not have a good metric to determine a good aspect ratio, and fix aspect ratio can still leave faces that can be too big compares to a small colliding shape, and also too large compared to large colliding face.
a Bin clipping can adjust routine to the side of the colliding shape and the face size
- an Bin clipping routine will be much faster than letting large faces in the collision tree.
the reason for this is that contact solver is a Gradient decent algorithm. basically it build a partial convex hull of the two faces,
by using the Minkousky difference of two convex shape
Minkousky difference of two convex shape is another convex shapes, so searching for a contact is nothing but a steeper decent search in a convex shape.
Here is the problem, when the sizes of the two shape are very different, say one is very big and the other is very large,
and if the very large have a very too oblond, what you get is a shape with very large flat faces,
the minkousky sum is very close to the shape of the large collision shape and it should be convex,
however the problems is that since the other shape is too small the contributions to the resulting mink convex are also very small.
The vertices of the Mink shape are created by subtractiing very large values from very small values,
and because of the lost of precision it just happen that the steeper decent rules breaks down,
by this I mean there are surfaces in the Mink shape that are not longer flat convex,
instead they have small perturbation and the search terminate in a local minima.
When the search terminate in a local minima we get what Rvangaal is seeing, a collision penetration or even an explosion.
However this is not the worse, the worse is that the collision becomes many time over slower.
This is because the combined Mink shape have very litle gradients and each step in the search for the lowest
point do not make good progress, it just decend a to a vertex that is just a little lower than the previous.
To make and comparison for two normal shapes the inner look for the closest point that about 6 to 11 iterations
when the two shapes collide the first time, after that if the faces move very litle from the previous frame it takes from
2 to 6 iterations, a box resting on a plane usually find the minimum in 1 or 2 iterations after the first collision.
when the aspect ratio is over 100, then the number of iteration goes as high as 128,
and this is because the inner loop bail out at that number and from there is uses and alternate algorithm.
when minum point is found found it is usually 40, 60, or even 80 iterations, and ther is not quaretee thsi si a teh lower point,
it could be a local minimal.
so if I can clip the face using a Bin that originates at the center of the colliding shape parallel
to the face normal and cut the polygon around, then this will guarantee that the two faces will be more or less equal sized,
and the steeper decent method will terminate in less than 10 iterations.
It is my believe that this will make the collision system way more reliable.
I am taking 2.20 down.