[Opensim-dev] Physics Of Simplicity

dan miller danbmil99 at yahoo.com
Fri Nov 16 21:33:26 UTC 2007


so late last night (US west coast time) a lively discussion ensued on
#opensim regarding the idea of a simple collision-capable physics engine. 
The new engine was aptly named POS (Physics Of Simplicity?), though
alternate meanings for the TLA could be construed.  The name is probably a
result of the apparently high state of inebriation of several of the
participants in the discussion.

It looks like chi11ken did the honors of actually checking in the engine,
which is so far just a copy of basicphysics.  The reason for an alternate
plugin is simply so we can fool around with this without breaking basic
physics, which we surely would do if we didn't have an alternate engine. 
This seems preferable to trying to add flags & whatnot to maintain the
present functionality of basic.

I wanted to outline here for posterity some of the discussion regarding a
simple box/sphere-based collider.  Hopefully my early afternoon sobriety
will make for a clear and concise description.

The basic idea is that all prims are rectilinear solids, and all avatars are
spheres.  (we may introduce a tweak later which would make the avatar an
elongated ellipse, but the sphere case is easier to understand and
implement, so we'll start with that.)

Taking the simplest case, imagine a prim with dimensions (a, b, c), and
oriented so that its edges are parallel to the x, y, and z coordinates.  Its
center is at location (x0, y0, z0).

The avatar will be a sphere with radius r.  We wish to place the avatar at
location, (x1, y1, z1).  Our question is, does this move put the avatar in a
place where it overlaps (penetrates) the prim?  (Obviously in the real world
we need to do this test against every prim in the scene).

In this simplified case, the math is pretty easy.  For each axis, we do a
range check.  The algorithm looks like this:

if( abs(x1-x0) >= (a/2+r) ) return false
if( abs(y1-y0) >= (b/2+r) ) return false
if( abs(z1-z0) >= (c/2+r) ) return false
return true

Something this simple would be good enough to test out some ideas and walk
on level prims.  To get rotation into the picture, all we have to do is
recalculate the avatar's position according to the local rotational frame of
the prim.  I'm not sure of the exact calls, but you would get a rotational
matrix representing the prim's present orientation, invert it, and multply
the vector (x1, y1, z1) by that inverted matrix (or maybe you can do it with
quaternions).  Now you can do the same check as above, and get the correct
results in the prim's rotational frame of reference.

Next step will be avatar movement.


-danx0r




More information about the Opensim-dev mailing list