• 沒有找到結果。

Implementation on CPUs

Algorithm 3 Algorithm of self-collision detection with the view-based approach

4.3 Boundary Handling

For unclosed meshes with self-collision, boundary handling is performed. In the step of boundary handling, we collect the triangles which are violated to the view-based ap-proach, and then further checks are performed for the violated triangles in the step of traversal.

We employ ghost triangles to collect violated triangles. Traversal between the BVHs of ghost triangles and the whole object is performed to collect the violated triangles. At first, we collect potentially colliding pairs between ghost triangles and the whole object.

Then, elementary tests are performed for the potentially colliding pairs to get the exactly colliding triangles. We assign the violated triangles to the view set Vv. The process is performed sequentially according to the holes of the object. The violated triangles are collected until the model is self-collision free. In other words, the violated triangles keep their types until the model is self-collision free. When the model is self-collision free, the view set Vvis released, and the violated triangles are set to be positively oriented. In short, the set Vv contains the triangles which overlap with or pass through ghost triangles.

4.4 Traversal

After performing view tests and boundary handling, we get several view sets. If a deformable object is not self-collision free, further checks are performed for some pairs of the view sets. Suppose that U is the union set of all triangle of the deformable object.

• For closed objects with the view-point scheme, there are three view sets, Vp+, Vp, and Vp0. If the deformable object is not self-collision free, further checks are per-formed for the pairs of (Vp+, Vp) and (U, Vp0).

• For unclosed objects with the view-point scheme, there are four view sets, Vp+, Vp, Vp0, and Vpv. If the deformable object is not self-collision free, further checks are performed for the pairs of (Vp+, Vp), (U, Vp0), and (U, Vpv).

• For closed objects with the view-line scheme, there are three view sets, Vl+, Vl, and

Vl0. If the deformable object is not self-collision free, further checks are performed for the pairs of (Vl+, Vl) and (U, Vl0).

• For unclosed objects with the view-line scheme, there are four view sets, Vl+, Vl, Vl0, and Vlv. If the deformable object is not self-collision free, further checks are performed for the pairs of (Vl+, Vl), (U, Vl0), and (U, Vlv).

However, traversal is performed for the BVHs of the view sets. We do not construct new BVHs of all view sets, but extract partial BVHs of the original BVH by marking the nodes of the original BVH. For example, if a node of the BVH contains a triangle, which is assigned to the view set Vp+, then the node is marked for the view set Vp+. The partial BVHs are called vBVHs. For each view set, there is a related vBVH, and nodes in the vBVHs of different view sets may be repeated. Traversal is performed for the vBVHs to collect potentially colliding pairs.

For closed meshes, there are three types of flags, P , N , and Z, in a node of the original BVH. For unclosed meshes, there are four types of flags, P , N , Z, and V , in a node of the

We mark the flags of a node of the BVH according to the kinds of triangles within the node. Initially, the flag P of all nodes are set to be true, and other kinds of flags are set to be false. We mark all the nodes according to the different view sets sequentially. For

a view set, the marking process starts from the leaf nodes of the BVH, and bottom-up traversal is performed recursively. When the process reaches a node, which is already marked with same feature, then the recursion is terminal. So, we have three vBVHs for closed meshes and four vBVHs for unclosed meshes. For example, Figure 4.3(a) shows the original BVH, and Figure 4.3(b) shows the marking results of two different view sets.

In other words, we now have two vBVHs, as shown in Figure 4.3(c) and (d). Actually, the cost of marking process is low. At first, we extract the triangles whose types are changed between two consecutive frames, and update the vBVHs according to these triangles in the runtime phase. For example, if a triangle changes its type and it is assigned from Vp+ to Vp, then we need to update the vBVHs of the view sets Vp+ and Vp according to the triangle.

Figure 4.3: Marking process of vBVHs.

After getting the vBVHs, we compress the vBVHs further to improve performing traversal for these vBVHs. For example, Figure 4.4(c) and (d) are the results of the com-pact vBVHs simplifying from the original vBVHs, which are shown by Figure 4.4(c) and

(d). We implement the process of compression by the following method. Traversal is per-formed after getting the vBVHs and started from the root of the vBVHs. When the process of traversal encounters a node, which only has a single child, we skip the node instead of performing overlap tests, and then check its child directly, as shown in Figure 4.4. The cost of checking the number of children of a node is less than performing bounding vol-ume overlap tests. The checking process is performed until a node with two children or a leaf node is reached. The number of overlap tests for the vBVHs is much less than full traversal for the original BVH.

Figure 4.4: Skipped nodes in the vBVHs are adopted in order to compress the vBVHs.