CPC G06F 30/20 (2020.01) [G06F 2111/04 (2020.01); G06F 2111/10 (2020.01); G06T 2210/21 (2013.01); Y10S 345/958 (2013.01)] | 21 Claims |
1. A computing device, comprising:
a processor configured to execute a physics engine to simulate real-time rigid body dynamics of a simulated physical system including a plurality of bodies, wherein the physics engine is deterministic and does not maintain state data other than respective positions and velocities of the plurality of bodies between successive timesteps, the physics engine being configured to:
iteratively loop through a collision detection phase, an iterative solving phase, updating phase, and display phase;
in a current collision detection phase:
identify colliding pairs of bodies of the plurality of bodies;
determine collision information including a plurality of position or velocity constraints for the identified colliding pairs of bodies; and
store initial velocities for the colliding pairs of bodies;
in a current iterative solving phase:
for each solver iteration:
for one or more colliding pairs of bodies:
for one or more position or velocity constraints between that colliding pair of bodies:
solve that position or velocity constraint;
apply a force or impulse to each of the colliding pair of bodies at a contact point of the colliding pair of bodies based on the solving of each position or velocity constraint; and
accumulate results of constraint solving by accumulating the applied forces or impulses;
determine intermediate solver velocities at the contact point between the colliding pair of bodies based on the accumulated results of constraint solving;
calculate friction velocities for that colliding pair of bodies based on the stored initial velocities and the intermediate solver velocities at the contact point between that colliding pair of bodies using a minimization function, wherein the minimization function selects a smaller of the stored initial velocities and the intermediate solver velocities to compute the friction velocities; and
apply a friction force or impulse based on the calculated friction velocities for that colliding pair of bodies;
in an updating phase:
update positions of the colliding pairs of bodies based on a result of the current iterative solving phase; and
in a display phase:
output data representations of the plurality of bodies to a display associated with the computing device.
|