segments have a common center which is numerically im- possible. 3.2. ... archy which they call cascade verification. It uses a com- ... the positions of the primitives can generate a higher degree ..... Las Vegas, 2005 (2005), pp. 244â250.
Workshop On Virtual Reality Interaction and Physical Simulation (2005), pp. 1–10 F. Ganovelli and C. Mendoza (Editors)
Efficient Bounding Volume Hierarchies for Hair Simulation G. Sobottka
A. Weber
Institut für Informatik II, Universität Bonn, Germany
Abstract We study the practicability and performance of different classes of bounding volume hierarchies for self collision detection in complex human hair styles with authentic geometrical properties. In particular, we focus on topology based hierarchies which allow for fast update schemes as well as conventional spatially adapted hierarchies. In this context, we introduce a parameterized k-DOP approach based on Grassmanian spaces which allows for a systematic generation of normal sets for arbitrary k. This enables us to empirically determine optimal values of k for collision detection based on DOP hierarchies. Keywords: collision detection; deformable objects; hair modeling; bounding volume hierarchies; k-DOPs Categories and Subject Descriptors (according to ACM CCS): I.3.6 [Computer Graphics]: Graphics data structures and data types
1. Introduction Collision detection is an essential part of physically based simulations. For collision detection among many objects two main approaches can be distinguished, namely, the space partitioning like grids, kd-trees, BSP-trees, octrees, and bounding volume hierarchies [Eri05]. As long as we consider static scenes traditional space partitioning shows excellent behavior but memory requirements can be huge. When objects are dynamically deformed the costly update schemes of such approaches become a major bottleneck. The intention of this paper is to give a systematic overview over the practicability and performance of different kinds of bounding volume hierarchies for self collision detection in the context of fiber based hair simulation. Here, self collision includes inter-fiber collisions as well as collisions of a single fiber with itself. While self collision detection in deformable objects is still an active research area it was shown that interference detection against the static environment can efficiently be done by using pre-computed implicit approximations of the objects surface, e.g., distance fields [FGL03] or meta-balls [VMT04]. One major advantage of the bounding volume approach persued herein is that memory requirements are only linear in the number of primitives they wrap. In particular, we examine two classes of hierarchies: the more recently developed topology based ones, which exploit the topology of the underlying structure, and the consubmitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
ventional spatially adapted hierarchies where spatial proximity is encoded. We consider the most popular instances, namely, hierarchies of spheres, axis-aligned bounding boxes (ABB), oriented bounding boxes (OBB), and discrete orientable polytopes (DOP). Our comparisons are based on complex test cases with millions of primitives, which are generated by synthesized hair strands resp. full hair styles with density parameters corresponding to values found in human hair styles (Fig. 1).
Our Contribution. We examine the practicability and performance of different classes of bounding volume hierarchies for self collision detection in complex human hair styles with authentic geometrical properties. In particular, we focus on topology based hierarchies as well as conventional spatially adapted hierarchies. We show that the topology based approach allows for fast updates and outperforms its spatially adapted counterpart by at least a factor of two when considering the times of a single collision detection cycle consisting of hierarchy update and collision detection. Moreover, we show that the most efficient bounding volume types along with all classes of hierarchies are ABBs and kDOPs. In this context, we introduce a parameterized k-DOP approach based on Grassmanian spaces which allows for a systematic generation of normal sets for arbitrary k. This enables us to empirically determine optimal values of k for col-
2
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation
Figure 1: Candidate models for the test program; from left to right the models names and their respective number of fibers and segments: Tress A (2.5k; 246k), Tress B (0.5k; 1M), Charming (49k; 2.4M), Curly (47k; 4.7M), Windy (60k; 3M), Longish (39k; 2.1M), Cloth (0.5k; 1.3M), filament soup (10k; 1M), random generated filaments in the unit cube. Note that authentic geometric properties are used: fiber density on scalp ≈ 200 / cm2 ; fiber diameter is 0.007cm.
lision detection based on k-DOP hierarchies. For our tests we let k range to values up to 200. Organization of the paper. We start by a discussion of related work in Sect. 2. A description of the topology based approach for building hierarchies is given in Sect. 3. In Sect. 4 we briefly describe the bounding volumes that we investigate. For the k-DOPs we detail our construction, which allows a parametric construction for any even k. Empirical results for complex test scenes arising in the context of hair modeling are the content of Sect. 5. We finish with a short conclusion in Sect. 6. 2. Related Work Collision detection among deformable objects is an active research area, cf. [TKH∗ 05]. Unfortunately, the article of Teschner et al. [TKH∗ 05] omits some important recent developments, e.g. the work of Guibas et al. [GNRZ02] on collision detection in one-dimensional deformable structures. There Guibas et al. proposed a new class of hierarchy for one dimensional structures, the so called wrapped spherical hierarchy, which exploits the topological proximity of the primitives constituting the underlying geometry. Lotan et al. [LSHL02] used a topology based approach for collision detection in Monte Carlo simulations of large protein molecules. In particular, they prove a sub-quadratic upper bound for the interference detection with the topology based hierarchy when the protein chain meets certain requirements. Brown et al. [BLM03] adopted the topology based hierarchy for collision detection in knot tying simulation in ropes or sutures. Sobottka et al. discussed the adoption of this approach to densely packed fiber assemblies [SVW05]. However, they restrict their comparison to the wrapped spherical hierarchy and the layered ABB hierarchy. In the context of hair modeling the choice of the collision detection method depends on whether the underlying model is implicit or explicit. Explicit models, in which hair is simulated on a per fiber or per cluster basis, have been used by Hadap and Thalmann [HMT01], Anjyo et al. [iAUK92], Plante et al. [PCP01, PCP02], Chang et al. [CJY02], Ward et al. [WLL∗ 03], and Bando et al. [BCN03]. In such models inter-fiber collisions are either neglected or detected with
voxel grids or octrees. Ward et al. [WLL∗ 03] store swept sphere volumes into a grid. In contrast, implicit models simulate feature points of the underlying hair volume. The actual hair style is generated by subsequent interpolation. The number of primitives used in these simulations are one or two orders of magnitudes smaller than in our test cases and in almost all cases times for collision detection are not explicitly given, so direct comparisons are not possible.
3. The Topology Based Approach For our tests we consider three different classes of hierarchies: the canonical form of the bounding volume hierarchy which we will refer to as (1) spatially adapted hierarchy and the topology based hierarchy which we will refer to as chain aligned hierarchy because the bounding volumes are aligned with the run of the filaments of our assemblies. As we shall see later in this section the chain aligned hierarchy class can be further divided into the (2) wrapped hierarchy and the (3) layered hierarchy. All three classes can be instantiated with different types of bounding volumes. In particular, we focus on ABBs, OBBs, k-DOPs and spheres. The wrapped hierarchy is, however, subject to restrictions which we will discuss later. There are other interesting bounding volume types like quantized orientation slabs (QuOSPO’s) [He99], shells [SKM98, KGL∗ 98], pie slices (tetrahedrons) [BCG∗ 96], cylinders [Ber04], zonotopes (Minkowski sum of line segments) [GNZ03], etc., which deserve closer attention but which we will omit here for brevity. The adoption of bounding volume hierarchies built on the topological structure of the underlying geometry has some major advantages over the traditional approach where spatial proximity is encoded. First, topological proximity implies that two objects are also in spatial proximity whereas the opposite is not true. Second, in dynamic deformable scenes the spatial proximity of the objects or the object features varies over time whereas the topological structure cannot change (except when objects are dismembered which is habitually not the case). In order to reduce the update costs one could attempt to maintain the structure of a spatially adapted hierarchy over several time steps. However, since in a long thin structure even small local changes can cause large global desubmitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation
Figure 2: Wrapped (left) and layered (right) hierarchy of a given chain.
formations such lazy update schemes can corrupt the hierarchy and necessitate a quadratic number of collision tests. Moreover, it was proven [GNRZ02, LSHL02] for a constrictive chain that collision detection has a sub-quadratic upper bound of O(n4/3 ) in R3 if the corresponding bounding volume hierarchy is based on the topology of the chain. Thereby, it makes no difference whether the hierarchy is wrapped or layered [Ber04]. A similar proof was given by Halperin and Overmars [HO94] for ball sequences subject to certain restrictions which are characteristic for protein molecules. In particular, they proved that self collision can be detected in O(n) time. For our tests the hierarchies are constructed on the fiber assemblies or hair styles. A fiber or filament is a one dimensional structure with certain length and diameter (although one can give different definitions we will use both terms synonymously). It is represented by a sequence of small capped cylinders to which will refer as segments. The diameter of a fiber is a function of its arc length. Although it is very small compared to its length (slender structure) it is crucially used for collision detection. 3.1. Hierarchy Construction In this section we detail the construction process of the three hierarchy classes. Chain aligned hierarchy: In case of the chain aligned hierarchy we build a balanced binary tree TB on the order of the segments of the underlying filament assembly. Each node of the tree owns a cage which encloses continuous parts of the underlying assembly, i.e., its segments are in topological order. The cage can either be computed from the cages of the two child nodes or from the respective sub-chain stored at the leaves of a sub-tree rooted at that node (cf. Fig. 2). According to Guibas et al. [GNRZ02] the former class of hierarchy is called layered hierarchy the latter one is called wrapped hierarchy. The cages at the leaf nodes correspond to the minimum enclosing volume of the associated segment. The hierarchy is constructed in a two step process: first submitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
3
we build an ‘empty’ balanced binary tree (without computing the bounding volumes). This is possible because the number of leaf nodes is known in advance (it corresponds to the total number of segments in the assembly). The tree is at least one-balanced and when the total number of segments is a power of two the tree is perfectly balanced. In the second step the update procedure is called which calculates the respective cages at each node. The update procedure is explained in Sec. 3.3. Unfortunately, human scalp hair consists of 80 000 up to 130 000 filaments. To circumvent constructing a single tree for each filament of the assembly and comparing the trees by pairs during the collision detection process we define the assembly S as ordered sequence S = {S1 , ..., Si }, 1 ≤ i ≤ m of fibers Si (each consisting of ni segments) such that the segments of S are ‘end point connected’. That is, Si,ni is the predecessor of Si+1,ni+1 , Si+1,1 of Si+2,1 and so forth. We then build a single hierarchy T (S) on this sequence. According to Lotan et al. [LSHL02] we refer to the corresponding tree as chain aligned hierarchy. Alternatively, we use a threading scheme wherein segments with the same ordinal number are grouped together. This is only possible if all segments have the same length. Spatially adapted hierarchy: For the comparisons we also build a spatially adapted version for each bounding volume type. It is generated in a top-down process wherein we perform a spatial subdivision of the set of segments into smaller subsets until each set contains only one segment. The main problem of the subdivision process is to find a proper splitting plain as well as an appropriate splitting point which yields a balanced binary tree. Therefore, each bounding box of a subset is split in the middle of the longest axis. This may take O(n2 ) time in the worst case, i.e., when the n primitives are poorly distributed (e.g., lay on each other) whereas for a homogeneous distribution it takes O(n log n) time. If this median split strategy fails the second longest and then the third longest axis is taken. There may exist certain segment configurations where this simple strategy fails, e.g., when segments are parallel. We then repeat the three tests with the boxes being split at the projection of the subsets barycenter onto the current axis. This strategy can only fail if two segments have a common center which is numerically impossible.
3.2. Collision Detection The process of collision detection is typically divided into broad phase and narrow phase. In the broad phase we try to exclude objects from the collision detection process which are a long way away from each other. This is achieved by sort and prune strategies. We pass on the broad phase because all filaments of our assemblies are in more or less proximity and so there is no noticeable benefit. In the narrow phase the actual intersection tests are performed. Given the hierarchy TB our goal is to find all colliding pairs of segments of our assembly. Traditionally, the hierarchies TB1 and TB2
4
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation
of two rigid bodies are checked for collisions by performing a simultaneous top-down traversal, a depth first search. A common split heuristic is to split nodes according to the the size of their cages. To check for self collision the traversal is performed in an analogous manner such that the right and the left subtree of each node are recursively compared starting with the children of the root. When two leaves are to be compared we directly test the primitives for intersection which are capped cylinders in our case.
3.3. Maintenance of the Hierarchy The maintenance of the hierarchy is an important part of the collision detection process when we consider deformable objects. For rigid objects which are subject to rigid body transform a once built hierarchy can be updated by applying the same transformation to each bounding volume. When we embark on costly update strategies like space subdivision one could be in favor to maintain the hierarchy over several time steps. Unfortunately, this can corrupt the hierarchy and result in near worst case collision detection times. Recomputing all cages can be expensive and is unnecessary in most cases. In particular, Guibas et al. [GNRZ02] proposed an sophisticated update scheme for the wrapped spherical hierarchy which they call cascade verification. It uses a combinatorial description of the cages wherein each sphere is described by at most four basis spheres. The validity of the basis is recursively checked for each node. The worst case complexity is O(n log n) but closer to linear in practice. This scheme applies to other bounding volumes types as well if they can be described by a set of basis volumes. However, we have implemented the cascade verification only for the spherical hierarchy. For wrapped OBBs the full top-down update is performed. In case of the layered hierarchies we pursue a bottom-up approach wherein the hierarchy is traversed in bottom-up direction. At each node we compute the bounding volume of its two child cages. As we will see in the results section this approach turns out to be fastest possible. At the leaves the cages are recomputed from the underlying filament structure. The cascade verification applies to the layered hierarchy as well but due to its increased storage costs and its worse complexity it is not profitable. The spatially adapted hierarchy is updated by the full spatial subdivision of the underlying segment set.
4. Bounding Volumes In this section we briefly discuss the instances of the three hierarchy classes along with the different bounding volume types. We restrict ourselves to the four most popular types: ABBs, k-DOPs, OBBs, and spheres. For our tests we constructed the wrapped and the layered hierarchy as well as their spatially adapted counterpart (cf. Sec. 3.1).
4.1. Axis Aligned Bounding Boxes Although, ABBs are bad approximations for needle like objects we would like to include them into our test program. ABBs are frequently used in physical based simulation because of their simplicity [BCG∗ 96, vdB97, LAM01, BFA02]. Known to be slower than OBB trees van den Bergen [vdB97] has examined the run-time behavior of top-down constructed spatially adapted ABB-hierarchies for deformable models and significantly reduced the performance differences. This is achieved by an improved bottom-up update scheme in which each ABB is resized to fit the corresponding triangles of the underlying mesh. Refitting the tree is up to ten times faster than rebuilding it. The drawback is that refitting based on the positions of the primitives can generate a higher degree of overlapping as in the case of a complete rebuild. This may corrupt the hierarchy over several time steps. Note that for ABBs the wrapped hierarchy corresponds to the layered hierarchy (cf. Sec. 4.2.2). In principle, the same observation made by van den Bergen [vdB97] has led to their fast bottom-up update scheme which is equivalent to ours with the minor difference that we obstinately follow the topology of the chain. 4.2. Discrete Orientable Polytopes While ABBs and spheres provide bad fitting bounding volumes for the segments of a filament the use of the more interesting k-DOPs leads to tighter fitting volumes and thus to faster collision detection. A DOP is a convex polytope which is defined by the intersection of half spaces. Each half space is defined by its normal and a scalar and constitutes the supporting hyperplane for one facet of the polytope. The concept of orientation slaps, i.e., polytopes with pairwise collinear but antipodal normals was first introduced by Kay and Kajiya [KK89] for rendering purposes. It has been adopted by Klosowski et al. [KHM∗ 98] for collision detection between rigid bodies. In their work they focus on the ‘standard DOPs’ with k/2 fixed orientations and k = {6, 14, 18, 26}. In contrast to existing approaches which restrict themselves to the standard values for k we are interested in the question if there exists an optimal k for collision detection in fiber assemblies. Following the conventional definitions for these DOPs the normals are restricted to the set {−1, 0, 1}. The problem that arises when considering a varying number of normals is how one can find a proper set of directions. This problem is closely related to Grassmanian packing problems which we will discuss in the next section. 4.2.1. Parameterized DOPs Finding a set of proper directions is closely related to the problem of equally distributing points on a sphere subject to the constraint that every two points must be antipodal. submitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation
One obvious approach to solve this problem would be to use a physics based simulation that minimizes the distance between N points lying on a sphere. The constraints are then enforced by introducing repelling forces. A similar problem has been addressed by He [He99] in conjunction with the orientation space quantization problem in QuOSPO† trees. That is, finding a set of normals that minimizes the intersection probability of the bounding polytopes of two given hierarchies defined in local frames right after the tumbling process‡ . This probability is hard to compute because it depends on the geometry of the models as well as their location. This can be circumvented by introducing a suitable similarity measure defined by the angles between the sets of normals. The solution to the quantization problem is a set of n uniformly distributed points on the unit sphere. Evenly distributing points on a sphere is not an easy task [Rus01]. He [He99] used sphere tesselation by subdivision of an octahedron and subsequent projection of the triangle centers to the spheres surface. However, this method does not satisfy our condition that every two points must be antipodal. Furthermore, the number of points obtained by this subdivision scheme is predetermined by 8 · 4n , where n is the subdivison depth. We would like to generate an arbitrary number of antipodal points such that the rays they define take the maximum possible distance to each other. A similar question has been posed by Conway et al. [CHS96] in a more formal way: How should N of n-dimensional subspaces of the m-dimensional Euclidian space be arranged so that each takes the maximum possible distance to all other subspaces. Mathematically this problem can be formulated using Grassmanian spaces. The Grassmannian space G(m, n) is the set of all n-dimensional subspaces of the real Euclidian mdimensional space Rm . It forms a compact Riemannian manifold of dimension n(m − n). Specifically, we are interested in the Grassmanian space G(3, 1), i.e., the set of all lines in the three dimensional Euclidian space. According to Conway et al. [CHS96] the optimal packing is defined in terms of the minimizing chordal distance. Let P, Q ∈ G(m, n) be n-planes. Furthermore, let θi ∈ [0, π/2], i ∈ [1, . . . , n] be the principal angles between the two planes which can be defined as follows: cos θi = max max uv = ui vi , u∈P v∈Q
with i = 1, . . . , n. The vectors ui and vi are called principal vectors corresponding to the pair P and Q. Furthermore, we have uu = vv = 1, uu j = 0, vv j = 0, (1 ≤ j ≤ i − 1).
† Quantized Orientation Slabs with Primary Orientation ‡ In the tumbling process two sets of normals defining the polytopes of two given hierarchies are mapped to each other which normally leads to much larger bounding volumes. submitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
5
Then the chordal distance is given by: !1 n
dc (P, Q) =
∑ sin2 θi
2
.
i=1
In contrast to other popular distance measures the square of the chordal distance is differentiable everywhere. This leads to the following definition of the packing problem: Given N n-dimensional subspaces of R3 to be packed find a set of planes P1 , . . . , PN ∈ G(m, n) with the largest possible chordal distance mini6= j dc (Pi , Pj ) between any two planes. This problem is well defined since G(m, n) is compact. This problem was restated by Conway et al. [CHS96] as an optimization problem. They generated presumably optimal packings for a wide range of (m, n) using a pattern optimizer. A large database can be found under [Slo05] which provides a basis for our DOP tests. The main advantage of this optimization based approach is that quality metrics like the angle between the subspaces can be used directly as an optimization criterion whereas in case of a physics based simulation the distance constraint is enforced indirectly using repelling forces, cf. [MBT∗ 03]. 4.2.2. Wrapping DOPs As stated in Sec. 3 the wrapped hierarchy is subject to certain restrictions. In this context, one can make the observation that for DOPs the wrapped hierarchy corresponds to the layered hierarchy. This is easy to see: Let S = {S1 , S2 , . . . , Sn } a sequence of segments and Si, j ⊆ S with 1 ≤ i < j ≤ n an arbitrary subsequence of S. Then, if the minimum enclosing volume is an discrete ori entable polytopethe MEV Si, j is equal to MEV Si, j = MEV(MEV Si,k , MEV Sk+1, j ) where Si,k and Sk+1, j are arbitrary subsequences of Si, j with i ≤ k ≤ j. In particular, this observation includes the ABB as a special case and applies to capped cylinders as well (segments with extent). 4.2.3. Splitting Planes and Segment Embedding For the spatially adapted DOP hierarchy the question of finding a proper splitting plane arises again. This problem was broadly discussed by Klosowski et al. [KHM∗ 98]. In their work they experimented with different splitting strategies. However, we decided not to use one of their approaches but in an analogous manner to the ABBs and OBBs we choose the splitting axes from the set of k/2 directions that define the k-DOP. Therefore, we sort the axes with respect to the DOPs extension in the corresponding direction. This requires the sorting of k/2 real values which can be done in O(k log k). Consequently, the splitting point lies on half the distance between the two planes confining the slab in one direction. Thus, the coordinates of the split point are given by 1/2 · ni (max i + min i ) with 0 ≤ i < k/2.
6
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation
To embed a single segment (small capped cylinder) into an arbitrary DOP we need a distance function which describes how close an arbitrary plane can be moved before it touches the cylinder. Let C the capped cylinder with the end points p1 and p2 and let de (P,C) the euclidian distance between any half space plane P that touches the cylinder and the origin. The minimum distance of an arbitrary plane to the cylinder axis a = p2 − p1 is r. So, each plane with distance r that is not in parallel with the cylinder axis shares one boundary point pb with the pole caps which is given by pb = p1|2 + rn where n is the normal of the plane. The question, which point to choose depends on the sign of the directional cosine of the cylinder axis and the half space normals ni : > 0, p2 = 0, p1 ∨ p2 ni a < 0, p1 . From the boundary point we obtain the distance of the corresponding plane to the origin as dei = pb ni . 4.3. Oriented Bounding Boxes Oriented bounding boxes have been widely adopted for collision detection [BCG∗ 96, GLM96, LKM∗ 00] because they normally provide very good approximations to the geometry of the underlying model. They were first introduced by Barequet et al. [BCG∗ 96] as an instance of the more general BOXTREES (bottom-up constructed binary trees whose leaves wrap the primitives of an underlying triangle mesh). In contrast, Gottschalk et al. [GLM96] construct the hierarchy in a top-down manner. However, the main drawback of OBB hierarchies still are the collision detection times which are usually an order of magnitude larger than for conventional ABB hierarchies although the fast separating axis test (SAT) is used. In contrast to orientation slaps (DOPs) OBBs can be wrapped. 4.3.1. Bottom-Up Construction Since the construction of an exact OBB takes O(n3 ) time, the main orientations of an approximate version are typically derived from a principal component analysis (PCA) of the underlying vertices. This yields rather arbitrary boxes in most cases. Lahanas et al. [LKM∗ 00] propose a method based on Powell’s quadratically convergent optimization. The goal is to find a set of angles (θ1 , θ1 , θ3 ) that minimize the the volume V (θ1 , θ1 , θ3 ) of the OBB by rotating the points of the geometry around a fixed set of axes. A set of directions can also obtained from the minimum enclosing ellipsoid. Here, we use the run of the fibers to efficiently construct the OBBs on the first and the second layer of the hierarchy. To build the OBB hierarchy in a bottom-up fashion we
Figure 3: On the first and the second level of the chain aligned hierarchy the local coordinate system of the OBB is obtained from the underlying segments.
start at the lowest level by embedding the cylinders into OBBs. On the second layer we join the segments of the underlying assemblies by pairs following the run of the filaments. The orientation {ei } of the presumably smallest box is computed for every two adjacent segments (s1 = {pi , pi+1 }, s2 = {pi+1 , pi+2 }) with i = {0, 2, 4, 6, ...}, i < n (cf. Fig. 3). They span a plane having a normal vector parallel to the vector product of the two segment directions ((pi − pi+1 ) × (pi+2 − pi+1 )) wich provides e2 . Using Freeman and Shapira’s theorem the minimum enclosing rectangle of a polygon is flush with one of its edges [FS75]. As a heuristic we always take the vector from pi+2 to the first point pi as the flushing edge instead of testing all three edges which provides e3 . Direction e1 is obtained as cross product e1 = e3 ×e2 and is equal to the direction from point pi+1 perpendicular to e3 . The extends of the box are computed from the triangle spanned by the two segments enlarged by the radius of the corresponding filament. As we can see from the above definition this schemes is applied to all segment pairs starting with even vertex numbers. In case of an odd vertex number the remaining terminal segment is packed into a box together with the terminal segment of the next fiber of the global array where next means the next ordinal number. This is treated as special case: The problem of computing a passably fitting box for two segments is solved by performing a PCA on the base of the corresponding four points. This may not always lead to an optimal solution. Furthermore, in case of degeneration due to parallel segments the box is directly computed from the segments direction, the direction orthogonal to both segments and the normal of the plane spanned by three points of the segments. The third level cages of the hierarchy as well as all cages on the levels above are obtained by performing a PCA on the basis of the eight corner points of the two boxes of the child nodes. That is, the three principal components are taken as box orientation. The extents are obtained as the maximum projective distance from the eight points onto the principal axes. To simplify the computation process we require the filaments to have the same radius.
4.4. Spheres Sphere trees are popular in collision detection because of their simplicity [Qui94, PG95, JP04]. Spheres are, however, submitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation
7
Figure 4: Times for maintenance / update [sec] (left), times to detect all collision [sec] (center) and times to detect first collision only [msec] (right) for different models obtained with different hierarchy types.
bad approximations for most geometries especially when needle like objects like segments are to be encapsulated. We instantiated three classes of spherical hierarchies: the layered, the wrapped and the spatially adapted hierarchy. The construction process for the two top-down versions (wrapped chain aligned and spatially adapted) implicates the problem of computing the minimum enclosing sphere (MES) for a given set of points. This problem has been subject to extensive studies in computational geometry. There exist algorithms which solve this problem in linear time [Meg82, Wel91]. We use an implementation of the latter algorithm despite its large oscillations in computation times caused by randomization. Note, that the implementation is restricted to spheres of equal size. So, we choose the fiber radius to be constant as well as the length of the segments. 5. Results We tested fiber assemblies of varying complexity with the different types of hierarchies. A test environment has been implemented in C++. Measurements were carried out on a Intel Pentium IV, 2.4 GHz with 2 GB of RAM. The assemblies represent typical hair styles, hair strands, and random assemblies. Our test cases are shown in Fig. 1. In the following and in the graphs we use the following abbreviations for the hierarchies: layered ABB hierarchy (AL), spatially adapted ABB hierarchy (AS), layered DOP hierarchy (DL), spatially adapted DOP hierarchy (DS), layered sphere hierarchy (SL), wrapped sphere hierarchy (SW), spatially adapted sphere hierarchy (SS), layered OBB hierarchy (OL), wrapped OBB hierarchy (OW), spatially adapted OBB hierarchy (OS).
most of them fit into a memory of a standard PC. Due to increased memory requirements the spherical hierarchy as well as the OBB hierarchy have problems to handle some of the large models. Moreover, they cannot manage the intermediate models with passable effort, so we interrupted the process of construction or collision detection after a given limit was exceeded. Chain-aligned vs. spatially adapted hierarchies. As we can see in Fig. 4 (left) the update times for the spatially adapted hierarchies (which include the construction of the tree) are much higher than for the chain aligned hierarchies. These costs are mainly caused by the spatial subdivision process. However, with respect to collision detection the spatially adapted hierarchies are faster than the chain aligned hierarchies in most cases, cf. Fig. 4 (center). The exception is the cloth scenario. Using DOPs we achieved slightly better times with the DL than with the DS. In the case of the chain aligned hierarchies most time is spent in cage overlapping tests. The path in the tree to decide whether a collision occurs is much longer than for spatially adapted hierarchies. The spatial subdivision scheme leads to well separated bounding volumes at relatively high costs whereas the bottom-up construction process along the end point connected filaments causes much more overlapping of the boxes. The resulting cages are not nearly as well separated as in the spatially adapted case. But this worse separation is achieved at lowest possible costs.
For all test cases times for construction, update or maintenance as well as for collision detection were measured. Furthermore, we measured the times to find the first collision (averaged over 1 000 trials).
Different times for collision detection are thus mainly due to different numbers of cage intersection tests that are performed, cf. Fig. 5 (left, center). Whereas the number of tests might differ by a factor of up to ten the number of primitives tested are almost identical. The number of cages which actually overlap are also higher for the chain aligned hierarchies.
Note that the models used herein are large. Nevertheless
So also in the queries of finding the first occurring col-
submitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
8
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation
lision the spatially adapted hierarchies perform better, cf. Fig. 4 (right). For one collision detection cycle both update and collision detection must be taken into account. For the hair strand shown in Fig. 1 the spatially adapted hierarchies are superior to the chain aligned hierarchies, cf. Fig. 5 (left). For the more complex scenario of a whole human head model the update of the spatially adapted hierarchies becomes so costly that the chain aligned hierarchies performs much better despite of the fact that much more cages are tested for overlapping. Furthermore, we observe that the lead of the chain aligned hierarchies over the spatially adapted hierarchies becomes smaller for small models. Note that we have experimented with a second kind of update scheme (cf. Sec. 3.1) for the AL but it performs bad in all cases (up to ten times slower) because it causes too much overlapping on the lowest hierarchy levels. Another interesting observation we made with the OBB hierarchies in general is that an upstream collision check based on SAT is always beneficial although a simple cylinder intersection test needs less arithmetic operations and the volume ratio between the tight fitting OBB and the cylinder is 10/π.
Figure 6: Results of the increasing DOP tests for varying k for model Tress A.
Cage volumes. Fig. 5 (right) shows the evolution of the average cage volume across the hierarchy levels for different hierarchy types obtained with model Tress A. It turns out that layering leads to slightly larger volumes than wrapping or as is the case for the spatially adapted hierarchy. In particular, layering OBBs is very problematic as the cage volumes explode with decreasing hierarchy level. The root cage volume of the OBB hierarchy is five orders of magnitudes larger than its pendent in the layered spherical hierarchy. Increasing k for DOPs. In this test we increased the values for k from 6 to 200. The set of normals was obtained as is described in Sect. 4.2. The results for the model Tress A summarized in Fig. 6 show the following: Although the number of cages tested, the number of cage intersections, and the number of primitives tested decreases when k increases, the minimum for the collision detection times is in the interior of the test interval [6, 200]. This minimum was identified to be k = 20. Note that the update time for the hierarchy monotonically increases with k but is much smaller than the collision detection time. However, if we carefully inspect Fig. 7 which depicts the results of the increasing k-DOP test ([6, 60]) for different models one can easily see that the minimum strongly depends on the geometry of the model. In most cases no clear minimum exists. Its more or less smoothed over a wide range of values. E.g., for model Soup the collision detection times are still decreasing at k = 60. We would like to emphasize that none of the generated normal sets includes normals which coincide with the global
Figure 7: The results of the increasing DOP tests with the DOP hierarchy for varying k show, that the minimum strongly depends on the geometry of the model. In most cases it is not possible to clearly identify the minimum. Model Tress C corresponds to model Tress B with doubled number of filaments.
directions, i.e., having two components set to zero. Thus, the update times for the automatically generated 6-DOP are not as good as for the hand optimized one (the ABB), because it implies a lot of useless zero multiplications which can expeditiously add up to tens of millions per update cycle. submitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation
9
Figure 5: Times for update and collision detection (left) for model Tress B and the respective number of cage tests, cage intersections, and primitive tests (center) obtained with different hierarchy types. Right: Evolution of the average cage volume across the hierarchy levels of different hierarchy types (model Tress A).
6. Conclusion We have found that in the context of self collision detection for fiber based hair modeling carefully designed topology based hierarchies of ABBs or k-DOPs show the best performance, when considering the times for collision detection as well as for updates, which is the most relevant scenario. Our parametric construction of k-DOPs allowed us to run empirical tests for varying k. These tests do not only give us optimal values for k for the currently used sequential implementation but also show that in potential future hardwareassisted collision detection methods even bigger values of k can be optimal. Whereas for the currently used sequential implementation the performances of ABBs and k-DOPS are quite similar, the obvious potential for parallelization in kDOPs in the number of k makes a topology based hierarchy of k-DOPs the most promising candidate in this direction. Although our work has been motivated by human hair modeling and our major examples are taken from this area, we presume that our work is relevant for other areas, in which collision detection or proximity queries of densely packed fiber assemblies plays a role, such as in various forms of molecular simulations. Our investigations, covering topology based hierarchies and spatially adapted hierarchies with respect to all of the most popular bounding volumes and being applied to large collections of densely packed fibers is complementing the asymptotic analysis and less systematic investigations for much smaller example classes in the cited literature [GNRZ02, LSHL02]. References [BCG∗ 96] BAREQUET G., C HAZELLE B., G UIBAS L. J., M ITCHELL J. S. B., TAL A.: BOXTREE: A hierarchical representation for surfaces in 3D. Computer Graphics Forum 15, 3 (1996), 387–396. [BCN03]
BANDO Y., C HEN B.-Y., N ISHITA T.: Animating hair
submitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)
with loosely connected particles. Computer Graphics Forum 22, 3 (2003), 411–411. Eurographics 2003. [Ber04]
B EREG S.: Cylindrical hierarchy for deforming necklaces. Int. J. Comput. Geom. Appl. 14, 1–2 (2004), 3– 18.
[BFA02]
B RIDSON R., F EDKIW R., A NDERSON J.: Robust treatment of collisions, contact and friction for cloth animation. ACM Transactions on Graphics (TOG) 21, 3 (2002), 594–603. SIGGRAPH 2002.
[BLM03]
B ROWN J., L ATOMBE J.-C., M ONTGOMERY K.: Real-time knot tying simulation. The Visual Computer 20, 2 (2003), 165–179.
[CHS96]
C ONWAY J. H., H ARDIN R. H., S LOANE N. J. A.: Packing lines, planes, etc.: Packings in Grassmannian space. Experimental Mathematics 5 (1996), 139–159.
[CJY02]
C HANG J. T., J IN J., Y U Y.: A practical model for hair mutual interactions. In ACM SIGGRAPH Symposium on Computer Animation (San Antonio, 2002), pp. 73– 80.
[Eri05]
E RICSON C.: Real-Time Collision Detection. Elsevier, 2005.
[FGL03]
F UHRMANN A., G ROSS C., L UCKAS V.: Interactive animation of cloth including self collision detection. In Journal of WSCG (2003), vol. 11.
[FS75]
F REEMAN H., S HAPIRA R.: Determining the minimum-area encasing rectangle for an arbitrary closed curve. Communications of the ACM 18, 7 (1975), 409–413.
[GLM96]
G OTTSCHALK S., L IN M. C., M ANOCHA D.: OBBTree: a hierarchical structure for rapid interference detection. In Proceedings of the 23rd annual conference on Computer graphics and interactive techniques (1996), ACM Press, pp. 171–180.
[GNRZ02] G UIBAS L., N GUYEN A., RUSSEL D., Z HANG L.:
10
G. Sobottka & A. Weber / Efficient Bounding Volume Hierarchies for Hair Simulation Collision detection for deforming necklaces. In Proceedings of the eighteenth annual symposium on Computational geometry (2002), ACM Press, pp. 33–42.
deformable objects with tetrahedra. In Proc. International Meshing Roundtable (2003). [Meg82]
G UIBAS L. J., N GUYEN A., Z HANG L.: Zonotopes as bounding volumes. In Proceedings of the fourteenth annual ACM-SIAM symposium on Discrete algorithms (2003), pp. 803–812.
M EGIDDO N.: Linear-time algorithms for linear programming in R3 and related problems. In Proc. 23rd Annual IEEE Sympos. Found. Comput. Sci. (1982), pp. 329–338.
[PCP01]
[He99]
H E T.: Fast collision detection using QuOSPO trees. In Proc. of the Symposium on Interacitve 3D Graphics (1999), pp. 55–62.
P LANTE E., C ANI M.-P., P OULIN P.: A layered wisp model for simulating interactions inside long hair. In Computer Animation and Simulation (Sept. 2001).
[PCP02]
[HMT01]
H ADAP S., M AGNENAT-T HALMANN N.: Modeling dynamic hair as a continuum. Computer Graphics Forum 20, 3 (2001).
P LANTE E., C ANI M.-P., P OULIN P.: Capturing the complexity of hair motion. Graphical Models 64, 1 (Jan. 2002), 40–58.
[PG95]
[HO94]
H ALPERIN D., OVERMARS M. H.: Spheres, molecules, and hidden surface removal. In Symposium on Computational Geometry (1994), pp. 113–122.
PALMER I. J., G RIMSDALE R. L.: Collision detection for animation using sphere-trees. In Computer Graphics Forum (1995), vol. 14, pp. 105–116.
[Qui94]
Q UINLAN S.: Efficient distance computation between non-convex objects. In IEEE Int. Conference on Robotics and Automation (1994), pp. 3324–3329.
[Rus01]
RUSIN D.: Frequently-asked questions about spheres, 2001. http://www.math.niu.edu/ rusin/knownmath/index/spheres.html.
[SKM98]
S. K RISHNAN A. PATTEKAR M. L., M ANOCHA D.: Spherical shell: A higher order bounding volume for fast proximity queries. In Proceedings of the Workshop on the Algorithmic Foundations of Robotics WAFR’98 (1998).
[Slo05]
S LOANE N. J. A.: Neil J. A. Sloane: Home Page, 2005. http://www.research.att.com/ njas/index.html.
[SVW05]
S OBOTTKA G., VARNIK E., W EBER A.: Collision detection in densely packed fiber assemblies with application to hair modeling. In Conference on Imaging Science, Systems and Technology: Computer Graphics, Las Vegas, 2005 (2005), pp. 244–250.
[GNZ03]
[iAUK92]
[JP04]
ICHI A NJYO K., U SAMI Y., K URIHARA T.: A simple method for extracting the natural beauty of hair. In Proceedings of the 19th annual conference on Computer graphics and interactive techniques (1992), ACM Press, pp. 111–120. SIGGRAPH 92.
JAMES D. L., PAI D. K.: BD-Tree: Output-sensitive collision detection for reduced deformable models. ACM Transactions on Graphics 23, 3 (2004), 393–398. SIGGRAPH 2004.
[KGL∗ 98] K RISHNAN S., G OPI M., L IN M., M ANOCHA D., PATTEKAR A.: Rapid and accurate contact determination between spline models using shelltrees. In Proceedings of Eurographics’98 (1998), pp. 803–812. [KHM∗ 98]
K LOSOWSKI J. T., H ELD M., M ITCHELL J. S. B., S OWIZRAL H., Z IKAN K.: Efficient collision detection using bounding volume hierarchies of k-DOPs. In IEEE Transactions on Visualization and Computer Graphics (Mar. 1998), vol. 4.
[KK89]
K AJIYA J. T., K AY T. L.: Rendering fur with three dimensional textures. In Proceedings of the 16th annual conference on Computer graphics and interactive techniques (1989), ACM Press, pp. 271–280.
[LAM01]
L ARSSON T., A KENINE -M ÖLLER T.: Collision detection for continuously deforming bodies. In Proceedinsg of Eurographics, short presentations (2001), pp. 325–333.
[LKM∗ 00] L AHANAS M., K EMMERER T., M ILICKOVIC N., K AROUZAKIS K., BALTAS D., Z AMBOGLOU N.: Optimized bounding boxes for three-dimensional treatment planning in brachytherapy. Medical Physics 27, 10 (2000), 2333–2342. [LSHL02] L OTAN I., S CHWARZER F., H ALPERIN D., L ATOMBE J.-C.: Efficient maintenance and self-collision testing for kinematic chains. In Proceedings of the eighteenth annual symposium on Computational geometry (2002), ACM Press, pp. 43–52. [MBT∗ 03] M OLINO N., B RIDSON R., T ERAN J., , F EDKIW R.: A crystalline, red green strategy for meshing highly
[TKH∗ 05] T ESCHNER M., K IMMERLE S., H EIDELBERGER B., Z ACHMANN G., R AGHUPATHI L., F UHRMANN A., C ANI M.-P., FAURE F., M AGNETAT-T HALMANN N., S TRASSER W., VOLINO P.: Collision detection for deformable objects. Computer Graphics forum 24, 1 (2005), 61–81. [vdB97]
VAN DEN B ERGEN G.: Efficient collision detection of complex deformable models using AABB trees. Journal of Graphics Tools 2, 4 (1997), 1–14.
[VMT04]
VOLINO P., M AGNENAT-T HALMANN N.: Animating complex hairstyles in real-time. In Proc. of the ACM Symposium on Virtual Reality Software and Technology, Hong-Kong, November, 2004 (2004).
[Wel91]
W ELZL E.: Smallest enclosing disks (balls and ellipsoids). In New Results and New Trends in Computer Science, Maurer H., (Ed.), vol. 555 of Lecture Notes in Computer Science. Springer-Verlag, Aug. 1991, pp. 359–370.
[WLL∗ 03] WARD K., L IN M. C., L EE J., F ISHER S., M ACRI D.: Modeling hair using level-of-detail representations. In Proc. of Computer Animation and Social Agents (2003). submitted to Workshop On Virtual Reality Interaction and Physical Simulation (2005)