Game Development Reference
In-Depth Information
How it works...
When deforming the terrain, we collect all the points we want to modify and the new
heights in lists; then, we collectively update the terrain based on them. There is an ad-
justHeight method to update a single point as well, but it is assumed that it's faster us-
ing a list.
Locking the terrain means faster rendering. Whether to lock the terrain or not depends on
the implementation. If it is a terrain that is changed with every frame, it probably doesn't
need to be locked. On the other hand, if it changes only occasionally, it should probably be
locked.
The formula that is used to calculate the change in height is deltaHeight = force * (1 - dis-
tance / radius) . This means that the change in height will be highest when it is closest to
the center; it will then fall off linearly as the distance increases and we get closer to the
edge of the radius. A variation worth exploring is to use the root with deltaHeight = force *
FastMath.sqrt(1 - distance / radius) instead. This will provide a rounder shape to the ter-
rain.
Search WWH ::




Custom Search