position based dynamics
position based dynamics
An object model does not only consist of a set of where k0= 1 (1 k)1/s and s is the iteration
particles but also a set of internal constraints such count of a constraint solver. Instead of directly
Position Based Dynamics 3
multiplying Dxi by k, k0 makes k independent of angle between T1 and T2. The gradient ∇xC(x1,
the solver and more predictable. . . . , x4) shows as follows:
x2 n1 þ ðn2 x2 Þd
Stretching Constraint ∇x4 Cðx1 , . . . , x4 Þ ¼
jx2 x4 j
For each edge of a triangle mesh, a stretching
constraint is built to control the movement of x2 n2 þ ðn1 x2 Þd
∇x3 Cðx1 , . . . , x4 Þ ¼
both its vertices, x1 and x2. This constraint can jx2 x3 j
be represented as a distance constraint function
C(x1, x2) = |x1 x2| d, where the scalar x3 n2 þ ðn1 x3 Þd
∇x2 Cðx1 , . . . , x4 Þ ¼
value d is the initial distance between x1 and x2. jx2 x3 j
Such as Fig. 1, both vertices are projected to x4 n1 þ ðn2 x4 Þd
the direction of gradient vector ∇xC(x1, x2), i.e.,
jx2 x4 j
∇x1 Cðx1 , x2 Þ ¼ n , and ∇x2 Cðx1 , x2 Þ ¼ n ,
with n = (x1 x2)/jx1 x2j. Thus, we can get ∇x1 Cðx1 , . . . , x4 Þ ¼ ∇x2 Cðx1 , . . . , x4 Þ
the final displacements as follows:
∇x3 Cðx1 , . . . , x4 Þ∇x4 Cðx1 , . . . , x4 Þ
w1 Cðx1 , x2 Þ
Dx1 ¼ ∙ where d = n1 ∙ n2. Then the final correction Dxi is
P
2 2
wj ∇xj Cðx1 , x2 Þ as follows:
j¼1
pffiffiffiffiffiffiffiffiffiffiffiffiffi
w 1 ðj x1 x 2 j d Þ x1 x 2 wi 1 d2 Cðx1 , . . . , x4 Þ
n¼ ∙ Dxi ¼ 4 ∙∇ Cðx1 , . . . , x4 Þ
w1 þ w2 j x1 x2 j P 2 xi
wj ∇xj Cðx1 , . . . , x4 Þ
j¼1
w2 Cðx1 , x2 Þ
Dx2 ¼ þ ∙
P
2 2
wj ∇xj Cðx1 , x2 Þ Volume Constraint
j¼1
For each closed triangle mesh, a volume con-
w 2 ðj x1 x 2 j d Þ x1 x 2 straint is built to maintain its volume and pressure.
n¼þ ∙
w1 þ w2 j x1 x2 j This constraint function refers to all N particles of
the mesh.
!
l
X
Bending Constraint C ðx 1 , . . . , x N Þ ¼ xti1 xti2 ∙xti3
For each pair of adjacent triangles T1(x1, x2, x3) i¼1
and T2(x1, x4, x2) such as Fig. 2, we generate a kpressure V 0
bending constraint with constraint function:
Here l is the amount of all triangles. xti1 , xti2 , and
Cðx1 , x2 , x3 , x4 Þ ¼ cos 1 ðn1 ∙n2 Þ j0 xti3 represent the three particles of triangle
i respectively. kpressure is a pressure factor and used particle potentially overlaps with any triangles by
to simulate overpressure status, and V0 is the checking the same hash index.
original volume of the closed mesh. Furthermore, As for the collision detection between deform-
we can derive the gradient vector xi Cðx1 , . . . , xN Þ : able objects and rigid bodies, bounding volume
hierarchy (BVH) (Gottschalk et al. 1996) is built
X
∇xi Cðx1 , . . . , xN Þ ¼ xt j xt j and maintained to speed up the process of culling
2 3
j:t j1 ¼i
nonoverlapping parts of the objects. BVH is a tree
X data structure, and constructed by recursively
þ xt j xt j dividing objects into subsets of geometric primi-
3 1
j:t j2 ¼i tives. In the meantime, these primitives are
X enclosed into simple bounding volumes, like
þ xt j xt j spheres, AABB, OBB, or k-DOP and stored into
1 2
j:t j3 ¼i the corresponding tree nodes. By doing the tree
traversal recursively and performing simple over-
where j : t j1 ¼ i, j : t j2 ¼ i, and j : t j3 ¼ i are the lapping tests among bounding volumes, it does
triangle indices containing xi in first, second, and not only simplify the collision computations but
third place, respectively. also reduces the number of collision pairs.
Once a vertex-triangle pair has been detected,
continuous collision handling (Müller et al. 2007)
Collision Constraints is then used to check if the vertex has penetrated
into the triangle. We shoot a ray (xi ! xi0) for
Unlike internal constraints (Minter) which are gen- vertex i to perform a ray-triangle intersection
erated once before simulation, collision con- test. If this ray hits the triangle, we compute the
straints (Mcoll) are detected and generated at each hit point xhit and the triangle’s surface normal nhit
time step before entering the constraint solver at this position and judge whether the inequality
loop. In other words, the number of collision constraint function is satisfied:
constraints varies and depends on actual colliding
particles. A collision constraint C(xv, xt1, xt2, xt3) Cðxv , xt1 , xt2 , xt3 Þ ¼ ðxv xhit Þ nhit h > 0:
is generated and inserted into the system if the
vertex (xv) hits or penetrates into another triangle Here h is a collision margin or surface thick-
(xt1 , xt2 , xt3). Also, due the collision constraint is ness value. When the above constraint is solved,
an inequality constraint, it will not be performed we can compute the correction Dxv = h (xv
if the collision does not satisfy the condition of xhit) ∙ nhit. If the ray hits the front side of the
C(x1, . . . , xN) < 0. There are both continuous triangle, nhit is computed as follows:
collision and static collision handling methods
ðxt2 xt1 Þ ðxt3 xt1 Þ
used to solve different collision cases (Müller nhit ¼
et al. 2007). jðxt2 xt1 Þ ðxt3 xt1 Þj
In order to efficiently detect potential collision
and self-collision pairs of deformable objects, a In contrast, if the ray hits the back side of the
spatial hashing table (Teschner et al. 2003) is triangle, then we get
built. It can early exclude most of collision pairs
which are not colliding with each other. Firstly, ðxt3 xt1 Þ ðxt2 xt1 Þ
nhit ¼
the predicted positions of particles and AABBs of jðxt3 xt1 Þ ðxt2 xt1 Þj
triangles are discretized to 3D cell indices with
respect to a predefined grid cell size. Then, these When a ray is completely inside a closed
cell indices are further mapped into 1D hash object, continuous collision handling does not
index. Lastly, we are able to quickly detect if a work at this case. At this moment, we apply static
Position Based Dynamics 5
collision handling (Müller et al. 2007) to compute constant density. It allows similar incompressibility
the surface point xs, which is closest to xv, and the and convergence to modern smoothed particle
surface normal ns at this position. Lastly, we can hydrodynamic (SPH) solvers (Monaghan 1992).
have a modified correction Dxv: Macklin et al. (2014) modeled gases, liquids,
deformable solids, rigid bodies, and cloth as
Dxv ¼ h ðxv xs Þ∙ particle-based models connected by constraints.
ðxt3 xt1 Þ ðxt2 xt1 Þ Also, they treat contact and collisions in a unified
ns ¼ h ðxv xs Þ∙ manner so as to support two-way interactions with
jðxt3 xt1 Þ ðxt2 xt1 Þj
one another.
For the collision handling between deformable
objects and rigid bodies, if we need two-way
interactions, a correction Dxv is applied to a Cross-References
deformable vertex. Also, an impulse miDxv /Dt is
simultaneously applied to the rigid body at the hit ▶ Collision Detection
point. ▶ Deformable Models
▶ Explicit Methods
▶ Fluid Simulation
The Future ▶ Implicit Methods