checkBounds static method
Check if the bounds of two bodies overlap, along the given SAP axis.
Implementation
static bool checkBounds(Body bi,Body bj, AxisIndex axisIndex) {
late double biPos;
late double bjPos;
if (axisIndex == AxisIndex.x) {
biPos = bi.position.x;
bjPos = bj.position.x;
} else if (axisIndex == AxisIndex.y) {
biPos = bi.position.y;
bjPos = bj.position.y;
} else if (axisIndex == AxisIndex.z) {
biPos = bi.position.z;
bjPos = bj.position.z;
}
final ri = bi.boundingRadius;
final rj = bj.boundingRadius;
final boundA2 = biPos + ri;
final boundB1 = bjPos - rj;
return boundB1 < boundA2;
}