From ff343bda8663aa1d60ac888ca2b17be34c976991 Mon Sep 17 00:00:00 2001
From: Erin Catto Results
Solver2D is not optimized, so it is not appropriate to compare absolute performance numbers for all the solvers. However, I think it is meaningful to compare the number of body and constraint traversals each solver must perform for the 4/2 iteration limits. The actual number of traversals in Solver2D may be higher as these numbers account for loops that could be easily merged. For example, constraint preparation can often be merged with warm starting, but I didn't write it that way in order to allow for more code sharing. There are some loops that could probably be merged with some extra effort, but that is not reflected in this table.
+Solver | +Body Loops | +Constraint Loops | +
---|---|---|
PGS | +2 | +6 | +
PGS NGS | +3 | +8 | +
PGS NGS Block | +3 | +8 | +
PGS Soft | +3 | +8 | +
TGS Sticky | +11 | +8 | +
TGS Soft | +9 | +10 | +
TGS NGS | +9 | +10 | +
XPBD | +9 | +10 | +
Constraint loops are much more expensive than body loops. Constraints do more math and they also have more cache misses when a constraint accesses the connected bodies. So if we want to compare solvers at a somewhat equal performance level, I would add more primary iterations to solvers with lower constraint loop counts to bring them up to par. Here's what I suggest:
+Solver | +Added Primary Iterations | +Total | +
---|---|---|
PGS | +4 | +8 | +
PGS NGS | +2 | +6 | +
PGS NGS Block | +2 | +6 | +
PGS Soft | +2 | +6 | +
TGS Sticky | +2 | +6 | +
TGS Soft | +0 | +4 | +
TGS NGS | +0 | +4 | +
XPBD | +0 | +4 | +
Here's the result for the large pyramid test: + +
+There are certainly more solver variations than I've tried so far. Here are some future options to try:
I've also thought about adding a joint coordinate solver, like Featherstone's algorithm. However, this is not a complete solver because it does not address contact. Still it might be interesting to see it for ragdolls and other samples with joints.
However, I should probably get back to finishing Box2D version 3.0!
@@ -301,7 +413,7 @@3632 words
+3893 words
2024-02-04 16:00 -0800