10.08.2013 Views

thesis - Computer Graphics Group - Charles University - Univerzita ...

thesis - Computer Graphics Group - Charles University - Univerzita ...

thesis - Computer Graphics Group - Charles University - Univerzita ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

96 CHAPTER 7. SIMULATOR<br />

Simulation groups are advanced in contexts of chained transactions, where each transaction<br />

advances a corresponding simulation group to a desired time. If we have n simulation<br />

groups denoted G1, . . . , Gn then there are n chained transactions, where the i-th transaction<br />

advances Gi, the first transaction is triggered by the simulator and the j-th transaction<br />

(j ≥ 2) by the (j − 1)-th transaction.<br />

The chaining of transactions works as follows. The simulator triggers the first transaction<br />

to advance G1 (while advancing G1 the other simulation groups are not updated). If G1<br />

reaches the desired time, then the second transaction is triggered to advance G2 and the<br />

first transaction waits for the second transaction to complete. If the second transaction<br />

commits then the first transaction must commit too and if the second transaction aborts<br />

then the first transaction must abort. The same rule applies to the i-th and the (i + 1)-th<br />

transactions (the (i + 1)-th transaction is triggered by the i-th transaction when Gi reaches<br />

the desired time, the i-th transaction commits or aborts depending on the completion status<br />

of the (i + 1)-th transaction). As a result, either all transactions 1, . . . , n commit if all Gi<br />

reach the desired time or transactions 1 ≤ j ≤ i abort if Gi fails to advance.<br />

The transactional processing is required in order to ensure consistency and do proper individual<br />

rollbacks when certain ODE solver (due to Gi) can not advance to the desired time. It remains<br />

to show why transaction i can ever fail (besides the obvious reasons, such as numerical problems<br />

when penetration can not be avoided, for example). The reason is the need for simulation group<br />

merging. Although force object targets can not change while advancing the simulation, new<br />

geometry hull overlaps (and contacts) might emerge which requires the simulator to simulate the<br />

corresponding bodies within a common group in order to produce consistent results.<br />

To illustrate the problem, let us assume that we have two bodies A and B, so that the first<br />

body belongs to G1 and the second body to G2 and the corresponding geometry hulls do not<br />

overlap at time t. Now let us advance the simulation state. G1 is advanced first and while<br />

advancing G1, it can happen that the geometry hull of A will overlap the hull of B. The trouble<br />

is that when the overlap is detected, at time tcur = t, the geometry hull of A is valid with respect<br />

to time tcur but the geometry hull of B is valid with respect to t, because G2 was not updated<br />

yet. Even if we could merge the corresponding simulation groups straight in the middle of the<br />

transaction so that we could handle the overlap (which we can not), potential contacts would<br />

be inconsistent because they would be computed with respect to geometry states at different<br />

times — hence the inconsistency. The (chained) transaction is thus aborted, the simulation state<br />

restored to the state at time t, bodies merged to a common simulation group and the transaction<br />

rerun.<br />

Advancing Simulation <strong>Group</strong><br />

Simulation groups maintain lists of rigid bodies and force objects assigned to them so that<br />

they could build the ODE that determines the evolution of the group in time and compute the<br />

equation right-hand side (evaluate ODE state derivative) upon the request of the ODE solver<br />

that is specific to the simulation group. A particular simulation group is then advanced in terms<br />

of its ODE. We will now outline the steps taken by evaluate derivative,<br />

• Collision detection is performed<br />

Higher-level collision detection runs and the list of overlapping geometry hulls is updated.<br />

New geometry hull overlaps among bodies from different simulation groups indicate that<br />

the transaction should abort and bodies involved in the overlaps merged to common groups<br />

(the evaluation of the ODE state derivative ends with a request to abort the transaction).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!