@@ -30,7 +30,31 @@ namespace Box2D.NET
3030 // according to substep progress. Contacts have reduced stability when anchors are rotated during substeps, especially for
3131 // round shapes.
3232
33- // 32 bytes
33+ // Body State
34+ // The body state is designed for fast conversion to and from SIMD via scatter-gather.
35+ // Only awake dynamic and kinematic bodies have a body state.
36+ // This is used in the performance critical constraint solver
37+ //
38+ // The solver operates on the body state. The body state array does not hold static bodies. Static bodies are shared
39+ // across worker threads. It would be okay to read their states, but writing to them would cause cache thrashing across
40+ // workers, even if the values don't change.
41+ // This causes some trouble when computing anchors. I rotate joint anchors using the body rotation every sub-step. For static
42+ // bodies the anchor doesn't rotate. Body A or B could be static and this can lead to lots of branching. This branching
43+ // should be minimized.
44+ //
45+ // Solution 1:
46+ // Use delta rotations. This means anchors need to be prepared in world space. The delta rotation for static bodies will be
47+ // identity using a dummy state. Base separation and angles need to be computed. Manifolds will be behind a frame, but that
48+ // is probably best if bodies move fast.
49+ //
50+ // Solution 2:
51+ // Use full rotation. The anchors for static bodies will be in world space while the anchors for dynamic bodies will be in local
52+ // space. Potentially confusing and bug prone.
53+ //
54+ // Note:
55+ // I rotate joint anchors each sub-step but not contact anchors. Joint stability improves a lot by rotating joint anchors
56+ // according to substep progress. Contacts have reduced stability when anchors are rotated during substeps, especially for
57+ // round shapes.
3458 public class B2BodyState
3559 {
3660 public B2Vec2 linearVelocity ; // 8
@@ -75,4 +99,4 @@ public void CopyFrom(B2BodyState other)
7599 deltaRotation = other . deltaRotation ;
76100 }
77101 }
78- }
102+ }
0 commit comments