PhysicsEngines

From OpenSimulator

Revision as of 19:53, 16 November 2007 by Adjohn (Talk | contribs)

Jump to: navigation, search

There are several physics engines available for use in OpenSim. Currently, they are "basicphysics", "OpenDynamicsEngine", "RealPhysX" & "BulletX" (modified version). The plugin "basicphysics" is the default and can be seen in the OpenSim.ini file.

  • When starting OpenSim in either Windows or Linux, one can add -physics=OpenDynamicsEngine to run the OpenDynamicsEngine (ODE) instead of basicphysics, or change the corresponding parameter in OpenSim.ini.
  • When starting OpenSim in Windows, one can add -physics=RealPhysX if one has the appropriate DLL's which are not shipped with OpenSim due to license constraints.
  • When starting OpenSim in either Windows or Linux, one can add -physics=modified_BulletX to run a modified version of the BulletX Physics Engine aka Modified BulletX. See the next information about details and progress.

To conclude, basicphysics & OpenDynamicsEngine both are appropriate for Linux and in addition, RealPhysX is appropriate as an option for Windows if the supporting DLL's are available. Modified BulletX should be fine for Windows and Linux (not the original BulletX).

As of 10/9/07, ODE has received the bulk of testing. It supports basic collision with box-shaped primitives as well as box prims with box-shaped hollows. Bullet supports box-shaped prims and appears stable; there has been little testing yet, and it is known to have issues with friction (you skate around on non-level surfaces). Physx has not been updated in quite a while.

Contents

Compiling ODE from source (Linux)

If you want to compile the OpenDynamicsEngine (ODE) by yourself, get the latest OpenSim libraries source code (Ver. 0.9 as of Oct '07) from the SVN: http://opensimulator.org/svn/opensim-libs Switch to the ode directory and compile it as follows:

./configure --enable-shared
make -k

(I used to suggest --with-trimesh=gimpact, but no longer. As of ODE 0.9, Opcode is the preferred and best-supported collision library)

This should create a libode.a and lidode.so file in the src/ode subdirectory. Copy these two files to the opensim bin directory (after having backed up the original files there). [er, I don't think the .a file is necessary to put in bin!]

Compiling ODE from source (Windows)

the standard distribution from ode.org has a build directory, in which you will find subdirs for several Microsoft compilers.

The standard .sln files (at least for VS2005) compile ode.dll such that it depends on at least two Microsoft runtime dll's. This can cause failure and confusion, so do the following: Right-click on ode in Solution Explorer, and select properties. under Configuration Properties/General, change "Use of MFC" to read "Use MFC in a Static Library"

then compile as usual.

ODE Plugin in OpenSim

Currently, the ODE Plugin suports collisions Av2Av, Av2Prim and Prim2Prim. Avies and (active)physical prim movement supported.

The currently collision behavior is:

  • For avies, a capsule of .5m of radius and a length of .9m and 50Kg of mass
  • For prims, like a Box with a mass of a Box of = 0.5Kg/l = 0.5Kg/dm3 = 500Kg/m3.

To-do list (next changes)

  • Tune all collisions
  • Introduce Prim Shape Type to have more than the box shape using the Meshmerizer tri-mesh generator
  • Fix bugs
  • Implement grab and throw

Known bugs

  • Ground Collisions: Certain ground terrain causes avatar to bounce into the air without warning
  • Mis-aligned Terrain: The visible terrain is slightly mis-aligned against the heightmap. This causes the avatar to appear as if it's standing on empty space while slightly off of a hill and causes the avatar to appear as if it's knees are bent or feet in the terrain on the other side.
  • Making avatar taller causes knee bending.

BulletX Plugin in OpenSim: Modified BulletX

BulletX Plugin in OpenSim runs the modified version of BulletX. The original version of BulletX runs under and has code-dependencies with MS.XNA. The orginal BulletX can be found at XNADev.ru. The modified version removes all code dependencies with MS.XNA. On the other hand, it needs another library to work. This library is based on Mono.Xna and it's called MonoCompactMaths. The modified BulletX and the MonoXnaCompactMaths can be found on the svn of OpenSim. Because its code independency of MS.XNA, the modified BulletX should can be run under either MS.Net or Mono and, therefore, either Windows or Linux (obviously you can combine Windows + Mono)

Currently, BulletX Plugin suports collisions Av2Av, Av2Prim and Prim2Prim. Prims and avies movement supported. By the way, collisions needs tunning. The currently collision's behavoir are:

  • For avies, like and sphere of 1m of radious and 50Kg of mass
  • For prims, like a Box of the prim-size and a mass that it depends of its sizes. The mass it's the mass of Box of water with density = 1Kg/l = 1Kg/dm3 = 1000Kg/m3 (Be water my friend! :D).

To-do list (next changes)

  • Tune collision
  • Introduce Prim Shape Type to have more than the box shape.
  • More than 1 region in a Sim and then more than 1 sim (grid)
  • Fix bugs

Known bugs

  • Icy bug: an avatar acts like it is on ice and tends to drift off the edge of the sim after a while
  • Crash on BulletX. You will find the next message in console sometimes: Overflow in AABB, object removed from simulation If you can reproduce this, please email bugs@continuousphysics.com Please include above information, your Platform, version of OS. Thanks.
  • Rotation doesn't seem to work

POS Plugin in OpenSim

POS is Physics Of Simplicity. It is BasicPhysics with collisions.

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.

The currently collision behavior is:

  • Currently, POS has the same behavior as BasicPhysics

To-do list (next changes)

  • TODO

Known bugs

  • TODO

Physics Testing Videos

ODE

  • 360 Prims (Sim Crashes) [11/08/2007 rev.2308]
 QuickTime > http://www.nebadonizumi.com/vid/opensim/opensim_ODE_physics_test_01.mov
 Stage6 > http://stage6.divx.com/user/3dlibre/video/1847652/
 YouTube > http://www.youtube.com/watch?v=Y0olsWlTc0A
  • 180 Prims (Sim Does Not Crash) [11/08/2007 rev.2308]
 QuickTime > http://www.nebadonizumi.com/vid/opensim/opensim_ODE_physics_test_02.mov
 Stage6 > http://stage6.divx.com/user/3dlibre/video/1847715/
 YouTube > http://www.youtube.com/watch?v=9lR_2H7VODU
  • 90 Prims (Sim Does Not Crash) [11/08/2007 rev.2308]
 Quicktime > http://www.nebadonizumi.com/vid/opensim/opensim_ODE_physics_test_03.mov
 Stage6 > http://stage6.divx.com/user/3dlibre/video/1847731/
 YouTube > http://www.youtube.com/watch?v=t9ulYO8I26Q

BulletX

  • 360 Prims (Sim Crashes) [11/08/2007 rev.2308]
 QuickTime > http://www.nebadonizumi.com/vid/opensim/opensim_BulletX_physics_test_01.mov
 Stage6 > http://stage6.divx.com/user/3dlibre/video/1847745/
  • 180 Prims (Sim Crashes) [11/08/2007 rev.2308]
 QuickTime > http://www.nebadonizumi.com/vid/opensim/opensim_BulletX_physics_test_02.mov
  • 90 Prims (Sim Crashes) [11/08/2007 rev.2308]
 QuickTime > http://www.nebadonizumi.com/vid/opensim/opensim_BulletX_physics_test_03.mov

Second Life Havok 1

  • 360 Prims [11/08/2007]
 http://www.nebadonizumi.com/vid/opensim/SecondLife_physics_test_01.mov

Second Life Havok 4

  • 360 Prims [11/08/2007]
 http://www.nebadonizumi.com/vid/opensim/SecondLifeBetaHavok_physics_test_01.mov
  • 1000 Prims [11/09/2007]
 http://www.nebadonizumi.com/vid/opensim/SecondLifeBetaHavok_physics_test_02.mov
  • 1000 Prims [11/09/2007]
 http://www.nebadonizumi.com/vid/opensim/SecondLifeBetaHavok_physics_test_03.mov
Personal tools
General
About This Wiki