 |
Home > Second Life News > Developer Journal
There has been talk in Second Life and rumors in the forums about the impending
migration to "Havok 2." Some of you may be wondering what this means and how it
will affect the Second Life experience. This issue of the Developer's Journal will
try to answer these questions and shed some light on where Second Life will be going
in future releases.
.gif) |
 |
 |
 |
Havok 2
October 23, 2003
By Andrew Meadows
What is Havok?
Havok is an excellent off-the-shelf physics engine for making games. Second
Life currently uses version 1 of Havok to perform the physics simulation of
its objects. Although the next version of Havok was released earlier this year,
we have been unable to use it in Second Life because it was missing a few crucial
features particular to our implementation. The next release of Havok 2 will include
the final features we need and we will be working soon to migrate to the new codebase.
What is a physics engine?
The "physics engine" of an application is the portion of the software that computes
the motion and collisions of all the objects in the world. Each object has static
properties, such as its shape and mass, as well as dynamic parameters such as position
and velocity. These properties and parameters are used as input to the physics engine,
which then computes how the dynamic properties change over a small increment of time
(about 1/50th of a second). After the new parameters are computed, they are fed back into
the engine and propagated forward another cycle again, and so on.
There are several distinct stages of the Havok computation cycle: action, collision
detection, and integration. The "action" stage is where objects are accelerated forward
by scripts, joints, or other constraints-in other words, their new velocities are computed.
The "collision detection" stage determines which objects are colliding and how and then
modifies their velocities accordingly. Finally, the integration step actually moves objects
to their new positions.
The collision detection stage has subparts of its own: the "broadphase" and the "narrowphase"
collision passes. The broadphase is the step where the engine determines which objects
are colliding or are about to collide. The result of the broadphase step is a list of pairs
of colliding objects, each of which is processed by the "narrowphase" collision algorithms,
which compute exactly how objects are colliding and the consequential forces of rebound and friction.
What has changed in Havok 2?
The most important change in Havok 2 is in the speed and accuracy of its "broadphase"
collision detection algorithms. It's much faster! Depending on the configuration of the
content that is being simulated, we can expect to find Havok 2 anywhere from two to ten times
faster than its predecessor, and most of this will be gained in either the time it takes to
complete the broadphase step, or from the reduced number of almost-but-not-quite colliding
pairs passed down to the narrowphase step.
Another noteworthy change is the speed of an "asynchronous collision detection" query.
Think of it as asking the physics engine the question: "What are all of the objects that
are colliding with this one?" Such a question might be asked outside of the main propagation
loop when computing where to place the view camera, how to make an avatar sit down, or when
placing a new object in the world. In Havok 1, queries of this sort could take as long as
a full broadphase step to answer-making them too expensive (in CPU resources) to use very
often. However, they will be much faster in Havok 2, and, in most cases, should take only
a small fraction of the time required for a full broadphase step.
There are a multitude of other improvements and feature-adds to Havok 2 that are
beneficial, although most of these benefits affect the developers using the Havok
application programming interface (API) rather than the users of the final game or application.
Some of them are: a built-in system for resolving inter-penetrations, more stable (and
slightly faster) constraint solvers for hinges and other joints, a simplified interface
for making multi-primitive objects, and more ways to override default behavior with special code.
How will Havok 2 improve Second Life?
Here's a list of improvements that should be possible when we start using Havok 2:
- No more "deep-thinks." A deep-think is caused by a collision configuration
that is so complicated that the physics engine will take anywhere from one second to
twelve hours to compute the result. This is a "feature" of ambitious physics engines
that try to handle concave objects (such as a hollow cut torus). Concave-concave
collision simulation is an active topic of computer science research that does not yet
have any easy answers. While Havok 2 has state of the art collision detection, it
still has the deep-think problem. On the other hand, since Second Life has a limited
set of primitive shapes and since Havok 2 has a much easier API for combining primitives
to make more complicated shapes, we expect to be able to remove the deep-think problem
by changing how concave primitives are built.
- Smaller "collision tolerance." You know that annoying 0.1 meter gap between
stacked primitives? Although Havok 2 still has this "collision tolerance," it can be made
much smaller without slowing the physics engine down. In addition, our solution to the
aforementioned improvement will make it possible to further reduce this visible defect.
- Less "lag." It is well known that a pile of hollow cut torii (or even a sufficiently
large pile of boxes) will slow the physics engine down enough to visibly affect the
response of the servers and cause a variety of lag. Since Havok 2 will be much faster, it
will be able to handle larger piles before its performance degrades.
Finally, there are a few outcomes that will depend on how well Havok 2 performs. Although
bandwidth and server-client communication computation also affect the overhead of
a larger object count, we may be able to increase the maximum object limit per
simulator since Havok 2 should be much faster. Elimination of deep-thinks may enable
new primitive shapes, such as the "spiral" which was removed back in mid-beta for
performance reasons. Using new features in Havok 2 for character control, we may be
able to improve and smooth the movement of avatars.
As you can see, Havok 2 opens up new possibilities and promises to enhance the Second
Life experience. We're eager to begin working on it, and it will be an important part
of the improvements for future releases of Second Life.
|
 |
 |
 |
 |
Note to editors: Second Life™ and Linden Lab™ are trademarks or registered
trademarks of Linden Research, Inc.
|
 |
.gif) |
 |
 |
 |
About the Author
Andrew Meadows is a member of the Linden Lab team building the software
and technology that makes Second Life possible. He has worked on many of
the features that use the Havok 1 physics engine, and will be helping with
the upgrade to the Havok 2 codebase. Before joining Linden Lab he studied
plasma physics and built instruments for ionospheric rocket payloads.
|
 |
 |
 |
 |
|
 |