Physics in OpenSim

[2011-10-04 There is now a new version of Bullet physics that works but remains under testing: see notes below.]

Recently, my private grid (running OpenSim 0.7.0.2-post-fixes) has been having some major problems with the standard physics engine ODE (the Open Dynamics Engine) throwing exceptions due to segment faults when running on Mono 2.6.7. This happened after Mono was upgraded when I incautiously decided to upgrade Ubuntu 10.04 to 10.10 without first checking whether the bundled new Mono version would interfere with OpenSim. It’s not easy to downgrade since various bundled parts of Ubuntu 10.10 rely on this version of Mono. Currently, I’m not quite sure if I have managed to solve it and, if so, how, but the problems are currently levelling off have now inexplicably disappeared again. It largely happens with hollow or cut-path prims, usually large ones over 10m, and is was entirely reproducible. I tried using ulimit -s 262144 but I’m wondering if this was set in the same child shell as the GNU Screen session in which OpenSim runs, as it seemed to have little effect until I did it manually. The crashes have temporarily abated, but I am no closer to finding out whether it is anything to do with ulimit and the stack size.

It did focus my mind on the ODE physics engine, however. Readers may know that Second Life ™ uses the free binary distribution of Havok 4, noting that the proprietary source code however is not freely available as open source. It can’t be distributed for commercial purposes (likely to be a problem for some commercial grids based on OpenSim) and the OpenSim developers can’t modify it for use with OpenSim without access to the source code. There are several other physics engines packaged with OpenSim. These are: Basic Physics, BulletDotNET BulletX, ODE, Modifed BulletX, POS, RealPhysX. [2011-10-04] only ODE and BulletSPlugin are now functional. Since at one point I could barely keep an avatar moving near my build for a few seconds at a time without crashing the region server, I decided to try these out. The initial results were not at all encouraging:

Basic Physics – this works fine but, as it sounds, is basic: in fact, so much so that it does not support collisions. Flight is jerky and all prims are phantom, so buildings or any prim structures are basically pointless. It may have some use for debugging, although the jerky flight made it awkward to use for building.

BulletDotNET – as my grid runs Linux, it wasn’t possible to test this, as it only runs on Windows and .NET rather than Linux and Mono. [defunct]

BulletX – it has long been recommended that Modified BulletX is used to replace this under OpenSim, so I did not test it directly and don’t know if it is still directly supported as a separate option. [defunct]

ODE – largely fine, minus proper vehicle physics and one or two minor glitches. But if my experience and that of several others is typical, use caution for the time being if you intend to upgrade to Mono 2.6.7 in the near future, which appears to the most likely source of the recent spate of crashes. [2011-10-04] Note that Mono 2.6.x and 2.10.x but NOT 2.8.x work with the OpenSim 0.7.2 Release Candidate according to the release notes, but I suggest that you do not use above 2.4.3 with OpenSim 0.7.1.x versions. According to this Mantis issue, the crash problems should have been sorted out, so please comment here or re-open the issue there if you experience problems similar to those I described.

Modifed BulletX – disappointing, this is no longer functional in OpenSim. Although it is possible to start a simulator using this physics engine, it appears to process every prim in every region before it is possible to connect, which takes a long time. At the end of this process, the avatar is unable to move from around 100m in flight without being bounced slowly back into that position, and other movement is likewise impossible. It’s thus difficult for the average user to test whether physics works for other objects and collisions. [defunct]

POS – billed as Basic Physics with collisions, at least it is possible to start a simulator and connect to it, although avatar movement does not work at all, unlike in Basic Physics. It appears to be obsolete. It was not possible to test it any further; in any case, it never supported much functionality in the first place. [defunct]

RealPhysX – while this may be a useful physics engine too, it is no longer functional with OpenSim, which simply crashes on start up. [defunct]

[2011-10-04] BulletSPlugin was added in June by Robert Adams, as noted at the top of this post.

So, whether or not the more advanced physics engines listed above (e.g. BulletDotNET, BulletX, Modified BulletX, RealPhysX) are better or worse than ODE is currently impossible to tell inside OpenSim running on Linux, and I’ll leave it to others running Windows to discuss BulletDotNET.

However, I did discover that there are various other physics engines available for gaming applications, of which ODE is only one. The problem is that it would require a new physics API to be written for OpenSim in C#, since none of these are currently supported. Although OpenSim is technically modular enough to allow this, it has never yet been done. There are a number of other physics engines available, as I gleaned from this discussion, from which this is the relevant excerpt:

Box2D <http://www.adrianboeing.com/pal/engines.html#box2d>
>> (experimental)
>> – Bullet <http://www.adrianboeing.com/pal/engines.html#bullet>
>> – Dynamechs<http://www.adrianboeing.com/pal/engines.html#dynamechs>
>> (deprecated)
>> – Havok <http://www.adrianboeing.com/pal/engines.html#havok>
>> (experimental)
>> – IBDS <http://www.adrianboeing.com/pal/engines.html#ibds>
>> (experimental)
>> – JigLib <http://www.adrianboeing.com/pal/engines.html#jig>
>> – Meqon <http://www.adrianboeing.com/pal/engines.html#meqon>
>> (deprecated)
>> – Newton <http://www.adrianboeing.com/pal/engines.html#newton>
>> – ODE <http://www.adrianboeing.com/pal/engines.html#ode>
>> – OpenTissue <http://www.adrianboeing.com/pal/engines.html#ot>
>> – PhysX (a.k.a Novodex, Ageia PhysX, nVidia PhysX)<http://www.adrianboeing.com/pal/engines.html#novodex>
>> – Simple Physics Engine<http://www.adrianboeing.com/pal/engines.html#spe>
>>
>> – Tokamak <http://www.adrianboeing.com/pal/engines.html#tokamak>
>> – TrueAxis <http://www.adrianboeing.com/pal/engines.html#trueaxis>

I’m not entirely sure for how many of these the source code is available as fully open source software, or whether there are commercial restrictions on some of them, so I’ll leave it to the reader to follow up on this point. There are instructions for using Newton physics with OpenSim dating from 2008, and these may still work although I have not tested them. This is an open source N-body gravity physics engine for astrophysics that is not aimed primarily at gaming physics and collisions and is apparently NOT the same as Newton Game Dynamics, a freely available proprietary, closed source physics engine for gaming. Obviously, OpenSim and SL employ gaming physics.

The really interesting possibility for physics is the Physics Abstraction Layer (PAL), which OpenSim developers such as Adam Frisby and Teravus Ovares have been keeping an eye on for some years. If suitable developers could be found and the logistical issues overcome, it would enable more or less any advanced physics engine to be used with OpenSim. I wonder if any developer types with more knowledge than me would like to comment on the feasibility of this? It does seem that ODE physics development for OpenSim hasn’t moved on much lately, so perhaps it is not a current priority?

The new Aurora distribution of OpenSim is working on a modified version of ODE that apparently includes vehicle and underwater physics. I did notice that, when testing this (in early alpha, to be fair), once or twice I ended up propelled upwards and left standing on a vertical block of air about 20 feet tall. But no doubt such glitches will be ironed out: it is impressive that they are taking on the fearsome work of improving the physics engine, which I doubt is work for the faint-hearted. [2011-10-04] It seems from their web site that many improvements have been made to Aurora, including ODE fixes and enabling HyperGrid.

Since physics is so basic to the experience of 3D worlds, surely it should be more of a priority in order to improve the user experience? At the same time, I know it is a difficult area of technical development. I hope to see advances in this area, given occasional glitches, and my recent bad experiences with ODE crashes. To some users, though not me in particular, vehicle physics in particular is an important missing area of functionality. At present, it seems that we have little alternative to continuing to use ODE with OpenSim for the foreseeable future. [2011-10-04] Although in testing, BulletSPlugin apparently now works, and is said to outperform ODE in some respects. I have not tried it out myself, however.

Advertisements
Leave a comment

2 Comments

  1. fantastic explanations (especially for someone like me) and i now understand a bit more than before

    i did have a question, in trying out the different engines, did it take a lot of time to reconfigure? seems a labour intensive thing to implement each one

    Reply
    • Hi, sorry – I’ve not been keeping up with this blog too well lately. I ought to have replied ages ago, which is really bad of me.

      Actually it only takes changing one line in OpenSim.ini, see more details here (though don’t bother reading all the way down because there is a lot of detail for developers that won’t particularly help and isn’t very clearly laid out). At least, for the physics engines supplied by default with OpenSim, of which there are quite a number. It’s a shame that so few actually work, although ODE is usually good. It has been modified by the Aurora project, but I haven’t installed the up-to-date version, and the old one had some new glitches. I noticed that I occasionally ended up walking in the air, for instance, but this was some months ago.

      This is why I haven’t tried the other ones that I list lower down, because they aren’t supplied and various dll files need to be downloaded and often compiled, if these are in fact compatible with OpenSim at all. Like you I suspect, I’m not that keen on using partially working physics engines. The main thing that I tried to do in this post was give people the heads-up so they don’t end up trying old things that no longer work.

      Apparently there is now a new ODE library with 0.7.1-dev (see this mantis issue), so it’s been suggested to be by Justin Casey-Clark that the problem that inspired me to write this post is solved. I’ve been out of OpenSim for a little while but will post when I get a chance to test it on my own box.

      Thanks for your comment, and sorry once again for the delay in my response 🙂

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: