Open tomaspietravallo opened 2 years ago
Idea. This is just going from vibes, proof that this is correct for most situations remains to be found. From visual tests within Spark AR Studio it seems to hold for collisions in two axis.
const { overlap, axis } = obbA.againstOBB(obbA);
objA.pos.add(objA.vel.copy().mul(objA.vel.copy().normalize().dot(axis) * -overlap));
objB.pos.add(objB.vel.copy().mul(objB.vel.copy().normalize().dot(axis) * -overlap));
The idea above works well enough, but the current methods for solveCollision
don't look realistic. Whether the overlap correction is needed after fixing this COR issue remains to be seen
https://en.wikipedia.org/wiki/Coefficient_of_restitution#Derivation
Side note: testAxis
s can be reduced and optimized
Find MTV from axis overlap. Can be found within the
againstOBB
method, so that the axis do not need to be all tested againhttps://github.com/tomaspietravallo/sparkar-volts/blob/7983ce36995540d0b53e95f0aa5a4238cb591037/volts.ts#L2087-L2094