raigan2 wrote:
This is something I may not properly understand; our current implementation simply extrapolates object states and generates "potential collision" constraints between pairs of features whose extrapolated states are in close proximity.
I don't see how you can determine "would penetrate in the next step" perfectly, but I'd like to know if there's a better method.
The term "would penetrate in the next step" is the goal. For ST, if you pick the super set of that list, it would hurt your application performance but wouldn't hurt the outcome (accuracy). So your cd implementation is one of the possible ways.
raigan2 wrote:
Not a single contact point, a single collision *constraint*, which internally is one or two contact points (which are solved together as a single block); this is how Box2D handles convex-convex collision AFAICR.
This is something I don't understand : you meant in Box2D, convex-convex can generate 2 contacts but only one row in the constraint Jacobian? How can you merge them?
raigan2 wrote:
The point is that a pair of convex shapes colliding generates a single row/block in the matrix of constraints, whereas in ST the number of constraints generated is based on the relative complexity of the shapes.
Ah, I see here you meant a convex-convex colliding can generate a block (i.e multiple rows) in the Jacobian. So how does it different from ST? You can as well do the same to those list of contacts between the two bodies. And the number of contacts ST generates scale with the complexity of two bodies's regions that in close proximity. And I think it should be that way. The main point here is if your shapes are complicated, you may have to pay more in order to have a stable simulation. Actually, no one ever compared the performance difference between ST and current popular methods. In my little 2D physics engine, I also have a wait-and-correct method implementation (based on Anitescu-Potra) and I dont see much difference in term of performance between the two. But the accuracy of ST is much better.
raigan2 wrote:
ST doesn't do narrow phase inside the solver loop at all. I don't know how you get that impression?
My understanding was that each ST potential collision is a vertex vs plane (or pair-of-planes) constraint; re-evaluating the constraint error at each (iterative solver) iteration is analogous to determining the signed distance between a point and a plane, which is exactly what happens during narrow-phase collision detection -- for example some implementations of SAT test extreme vertices on shape A vs the planes bounding shape B, i.e a point-vs-plane test, hence my likening the process to a SAT-based narrow-phase. Maybe it was a poor analogy
I bet narrow phase contains much more than just calculated vertex-plane signed distance. Moreover, that's like a magnitude of 10-ish floating points operation. I don't see why it can become a burden. Also, as I mentioned, I never tried GS/SOR to solve our problems as my main concerns are always accuracy and I've never dealt with thousands of objects cases. But I really don't think GS/SOR/etc is a good way. Take a look at those references I gave previously, you can see that they can solve them fast enough (at least to my taste). The demo I posted in this thread is another example. Even I'm using PATH, a direct solver and a very very naive collision detection, it does run fast enough in my tablet pc.
raigan2 wrote:
Consider box-box resting case, ST will need 4 contacts normally, but you can use 2 ( between the 2 lower points of upper body and the upper edge of lower one) if you can preprocess the case.
I'm unsure how you can determine this, since during the time step the configuration can go from (if we look at the box corners along the axis tangent to the contact normal) ABBA to ABAB for instance (i.e one box slides relative to the other).
Also box-box is almost the best case for ST (tri-tri would be best), my problem comes with rounded shapes where dozens of verts potentially collide with dozens of tiny edges; convex-convex methods scale nicely with such cases (almost constant if you exploit coherence) while ST requires huge numbers of constraints.
Would you explain how convex-convex handle such cases different from ST? In my view, ST doesn't have anything to do with features-features or shape-shape. It basically try to stop penetration before it happen so if you can write a constraint for convex-convex, ST should work for such constraint also. Anyway, if you have rounded shape vs tiny edges, then maybe using polygonal model is not a good choice. Maybe you need to consider implicit surfaces here.
raigan2 wrote:
I don't see how performance would be a big issue with ST. Sure, ST ask for more contacts than Box2D but it only more than a constant factor not scale with number of shapes features like you imagine.
Maybe it's a bounded constant factor but it can be rather large; I'm not imagining!
It's kind of waving-hand statement. I doubt the factor can be more than 2. On the other hand, look at the benefit of ST:
+ No need special treatment for high speed object
+ Stable (physically)
+ Can handle high weight ratio stacking
+ Much less penetrations
and very important thing is that you can mix Box2D/Bullet constraints with ST style constraints.
I also want to mention the theoretical advantage of ST. I will come back later on this point when I have time.
raigan2 wrote:
Perhaps my implementation isn't optimal; my experience is that the more vertices and edges of a shape, the more potential collision constraints you need to generate, and it's somewhat worse than linear: for box-vs-box two verts on each box can "see" (potentially collide with) two edges on the other box, but for octagon-vs-octagon it's 4-5 verts per shape which "see" 3-4 edges on the other shape.
I guess the problem is that, although two convex shapes will only collide in at most two points, the set of potential points (in which the two actual contact point will be contained) can be much larger.
There is also the problem of missed collisions due to the predicted state being only a guess, and thus failing to generate the proper set of potential collisions.
As mention above, when you deal with complex shape, you have to pay more than simple one. For the octagon-vs-octagon case, you wouldn't have 4-5 verts in one body "see" 3-4 edges in other if your time step is small enough. So you gotta slow it down until only 2 or 3 vertices "see" 1 or at most 2 edges. It also make me wonder, how Box2D handle this case? Doesn't it have to spend more time when dealing with complex shapes?