Game Development Reference
In-Depth Information
int getNeighbors( int vertex, int
ee = vertices[vertex].edge;
neighborList[0] = vertex;
neighborList[1] = edges[ee].vertex;
e = edges[ee].prev; e = edges[e].neighbor;
while (e != ee) {
neighborList[n] = edges[e].vertex;
e = edges[e].prev; e = edges[e].neighbor;
return n;
Of course, we have to deal with the case where one of these references does
not exist—for example, if the triangle has no neighboring triangle. Those refer-
ences can be set to
1, and the implementation has to handle them with some
14.3.1 Viscous Damping
The neighborhood information can be used to construct more sophisticated forces.
In a viscous material, two particles in the vicinity of each other feel a pairwise in-
fluence if they have a nonzero relative velocity. We use this fact to formulate
another form of damping. A vertex should experience resistance when its ve-
locity differs from its neighbors. We sum over all our neighbors and add up the
velocity differences between the vertices. In the end, we divide by the amount of
f neigh
v j
v i ,
nbr( i )
j∈ nbr( i )
or in pseudocode,
for each vertex v in v i.neighbors {
sumVel += v.vel;
averageVel = sumVel / v i.numNeighbors;
neighborForce = (averageVel v i.vel) / timeStep;
This damping model combined with a bit of global damping should be enough to
keep the system stable.
Search Nedrilad ::

Custom Search