410 likes | 541 Vues
This paper by Brian Mirtich, presented at SIGGRAPH 2000, explores the factors contributing to the slow performance of rigid body simulations. It details key stages in simulations including integration, collision checking, and force computation, as well as the challenges posed by discontinuities caused by collisions. The Timewarp algorithm is proposed as a solution, utilizing optimistic simulation and local virtual time to enhance responsiveness and scalability. This work paves the way for improved performance in complex simulations by managing event-driven simulations across multiple processes.
E N D
AnimationCS 551 / 651 Rigid-body SimulationMirtich Paper Mirtich, 2000
Timewarp Rigid Body Simulation • Presented at SIGGRAPH 2000 • Brian Mirtich • MERL, A Mitsubishi Electric Research Lab (Cambridge, MA)
What stages are in a simulation? • Integration • Collision checking (impacts) • Force computation • Constraints (non penetration) • Control • What is this?
How much time do they take? • What’s so slow? • Why do multibodies exacerbate this?
Big Idea • Simulations are slow • What part is so slow??? • Simulations are discontinuous • What’s the source of discontinuities? • Collisions, contacts, rolling sliding, etc. • But not discontinuities are unpredictable and only affect parts of simulation
A simple game of Pong • What goes on in this sim? • Integration • Collision checking • Collision resolution • Would this scale well if balls didn’t collide with each other?
General rigid body simulator • Nontrivial geometries • All pairs can potentially collide • Second-order physics equations of motion • Could be deployed on multiprocessor (simulation farm)
Discontinuities • When do they occur? • When the state or equations of motion change • Collisions • New contacts • Changing from rolling to sliding dynamics
Discontinuities • From §2.1 Root finding method localizes the exact moment of a discontinuity • What is a root? • How do we find the roots?
Newton-Raphson • Find the zero of an equation (where it crosses the x-axis) • If pn is close to pn-1then return pn • else set pn-1 = pn and repeat
Newton-Raphson • Why set • y-intercept equation of line: y = mx + b • let y-intercept, b = f (pn-1) • let slope, m = f’(pn-1) • we want to find x-value where y-value = 0 • let y = 0 • 0 = f’(pn-1) * x + f(pn-1) • solve for x: -f(pn-1) / f’(pn-1)
Newton-Raphson • Be aware that Newton-Raphson could set pn to a value not defined by curve • f’(pn-1) could be 0 (cannot divide by 0)
Discontinuities • What trouble do they cause? • Integrator must be stopped and restarted with new state, forces, or equations • Main control loop constantly checking for discontinuities so appropriate handling takes place • Two common methods • Retroactive detection and conservative advancement
A general simulation problem • §3 references DES, Discrete Event Simulations • Much more than graphics simulations encounter these challenges • Many simulations are represented as DES and thus this technology is relevant
Retroactive Detection • Catch discontinuities after the happen • Detect when two objects go through one another • Use root finding to detect exact time of impact • Roll back the clock to time of impact • All objects or just some? • Continue simulation only up to impact
Retroactive Detection • What’s bad about this algorithm? • You’re repeating work • Simulate, back up, simulate again • Additional collisions may be encountered during subsequent smaller simulation timesteps (and others won’t take place after all) • Synchronization requires repeated simulation of all objects if they are involved in collision or not • Doesn’t scale well in number of discontinuities
Conservative Advancement • Don’t simulate past discontinuities • Heuristics predict future discontinuities and impending events are stored in a priority queue • Upon approaching time of event in priority queue, take small steps
Conservative Advancement • What’s bad about this method? • Conservative, but slow as number of discontinuities increases • All simulated objects move forward at small timestep • Difficult to compute tight bounds on discontinuities
Timewarp Algorithm • Derived from a 1985 paper by David Jefferson • Be optimistic • Each object simulates as quickly as possible • Be responsive • If an object is informed of an event in the past, it must reset its state to that previous time
What is STATE? • What is the state in the rigid body sims?
Timewarp • Multiple processes • Each models part of the system • Each has its own “time” called Local Virtual Time (LVT) • Process clocks are not synchronized
Timewarp • Message Passing • When a process experiences an event • message is sent to all processes with timestamp = LVT of sending process • When a process receives a message • If (message time > recipient’s LVT) • Message is placed on time-based queue • Process will advance clock to next event on queue • What if (message time < recipient’s LVT)?
Rollback • Occurs when a recipient has simulated “past” the time at which another process has generated an event • Go back in time (how?) • Put all processed events back on queue • “unsend” events sent to other processes • For each message sent, an antimessage is stored on a queue that can be easily flushed
Rollback • Overhead • Keeping track of previous states • Keeping track of processed events • Keeping track of submitted events • Global Virtual Time (GVT) • The minimum of all LVTs and safe times (why?) • All states before GVT can be purged • Monotonically increasing
Timewarp for rigid body sim • Every simulated body is a process • The state = position & velocity • Global event queue stores all bodies’ events • Event = timestamp and list of affected bodies • Main loop • Pull front item from event queue • Simulate affected bodies to that time • This can be put on a uniprocessor
Types of events • Collision Check • Between pairs of bodies • Group Check • Collision check for contacting bodies • Splitting groups of bodies when no longer contacting • Redraw • At every new rendered frame, copy positions to buffer • Callback • User-defined functions to be executed
Collisions • Safe-time • Each body keeps track of the last time it was known not to be in collision with other bodies • This helps limit how far a body must roll back upon detection of a collision • Safe-time is included in collision/group check events • Upon collision checking, safe-time is updated
Collisions (A collides with B) • Vertical connections join post-collision states • Gray states are new states after A-B collision check event
Multibodies • Jointed (articulated) bodies like a human • All bodies must be treated in unison • Easily integrated into their system
Contact Groups • Bodies in persistent contact • Simulated as a unit • Membership of group is dynamic • Complicated state keeping so, upon rollback, a body can be detached from its group and simulated
Collision checks • Active Pairs • The set of all bodies that must be checked for potential collisions • We want to keep this set small
Active Pairs • Looking for collisions • Each body has an axis-aligned bounding box • For each timestep between GVT and LVT • Record location of bounding box • Compute bounding box (swept volume) of all bounding boxes over time • Using six heaps for max/min {x, y, z} • GVT increment causes volume to shrink
Looking for collisions • If swept volumes do not intersect • Collision free between [GVT, tmin (A, B)] • Depending on LVT of A and B • A and B not an active pair
Looking for collisions • If newest timestep for B causes overlapping swept volume with A • Collision check at time tmin (A, B) • B, before integration (last known free time) • Rollback will resolve collisions
Results • Applications • Atoms: 200 spheres and 100 water molecules in divided box • Cars: 4 multibody vehicles and 400 pendula • Robots: 20 eight-link manipulators throwing blocks • Avalanche: 300 rocks tumbling down mountainside
Results • Note average integration step vs. time between discontinuities • Look at cars vs. robots
Results • Atoms for 2 seconds • Average integration step • Conservative advancement slows down
Results • Atoms for 2 seconds • Total “work done” per simulated object • Retroactive detection repeats a lot of work
Results • Total time • 100 atoms • RD-1/30 = 0.142, TW = 0.147, CA = 1.15 • 200 atoms • RD -1/30 = 2.61, TW = .388, CA = 4.74
Discussion • §4.2 – If rollback time is between safe time and current time, nothing is done… • Jefferson proved this was what? • Figure 2 • No global state