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 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 <>
>> (experimental)
>> – Bullet <>
>> – Dynamechs<>
>> (deprecated)
>> – Havok <>
>> (experimental)
>> – IBDS <>
>> (experimental)
>> – JigLib <>
>> – Meqon <>
>> (deprecated)
>> – Newton <>
>> – ODE <>
>> – OpenTissue <>
>> – PhysX (a.k.a Novodex, Ageia PhysX, nVidia PhysX)<>
>> – Simple Physics Engine<>
>> – Tokamak <>
>> – 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.

The slow death of Viewer 1.x, the half-life of the hypergrid, and other stories

Despite the popularity of third-party viewers such as Phoenix (formerly Emerald) and the disastrous design and usability problems of Linden Viewer 2.0, it has now become clear that Viewer 1.x is dying a slow death. The final release of the Phoenix viewer is out, to be replaced by a new Firestorm viewer based on the 2.0 codebase, and there are similar plans for Imprudence to be replaced by the new Kokua viewer (whose name, I’m afraid, does not strike me as nearly as memorable – what’s wrong with Phoenix 2.0 and Imprudence 2.0 for names, rather than changing them just when they start to get well-known?)

This is, of course, a demonstration that the world of OpenSim grids, so dependent on the Linden codebase, is still very much semi-detached from development in SL, and interoperability will always remain a core issue.

One reason for this is mesh, coming soon (but we’re still not sure when) to a simulator near you. Look out, OpenSim and ModRex! Despite the latter’s support for mesh being far older than the Linden effort, ported back from RealXtend‘s version of the OpenSim codebase to a region module for OpenSim, it has never caught on. Although OpenSim developers seem to be working on mesh, it’s no longer clear if ModRex is the main plank of this effort. It still only works in standalone mode, not in grid mode. The pace of development on ModRex seems still to be incredibly slow, after an initial burst of activity, and it’s blog and web presence remains embryonic and dated.

The 1.x codebase can support some newer backported features such as Display Names (which is not likely to be complex code) but it will be increasingly difficult, and most likely impossible, to continue developing viewers that work for both OpenSim and SL without embracing the viewer 2.0 codebase. Incidentally, Display Names will not work on OpenSim, but apparently will on Aurora based-grids (see below). Hopefully, however, the terrible viewer  design will be completely ignored. Even the developer of Kirsten’s viewer, which rather slavishly avoids any affront to Linden Lab by providing direct support for OpenSim (which is a simple matter of using the open source grid manager code from the Hippo viewer), has been critical of the Viewer 2.0 design. I should say, in Kirsten’s defence, that it is not completely impossible to use the present version of the viewer with OpenSim.

Meanwhile, new forks of the OpenSim server codebase are appearing, notably Aurora, which provides a great deal of core functionality that users have been crying out for. The new Kokua Viewer (a separate project loosely associated with Aurora, previously known as Imprudence) will support some of these extra features. At present, things like profiles, groups, search and web interfaces have to be hacked together once per upgrade, and database changes leave all of these side projects struggling to keep up with the OpenSim codebase.

OpenSim developers, after their huge success with Hypergrid, have managed to undo their own work by fracturing the community into no less than three mutually incompatible and often unreliable versions of what is the most fundamental part of the open metaverse. At present, Hypergrid is barely working at all, and it is a major victory to teleport off one’s own servers. Yesterday I finally managed to reach OSGrid (though it’s misconfigured locally, so that one cannot leave) using a test grid running Aurora, although I cannot do so with any revision of OpenSim 0.7.1-dev on which it is based. Admittedly the latter is development code, but many grids are already running it, including OSGrid. People were astonished to see someone arrive from the outside: one said it had been a year since they had known it to be working! Obviously, some of the unreliability is down to local server configurations, which is an operational problem. But why keep breaking Hypergrid with every new release? Why does it have to be so hard? This is no way to help grow the open source metaverse.

It seems that the OpenSim developers do not seem to see the hypergrid as a priority even though it is what makes people compare OpenSim grids to the Web and its rich competitor SL to the once-mighty AOL. At present, documentation and communication about OpenSim remain amateur and patchy. Of course, the developers make the blinkered ideological claim that they are NOT a competitor to SL, but such claims are often made by those who are manifestly failing to capitalise on their obvious strategic advantages. However talented the OpenSim developers are, they are terrible salesmen. And they are convincing nobody. Their user base certainly is competing with SL, even if they personally, as developers, are not. Remember, the user is queen – or even king!

Get it together again! All this fine work needs a bit more coordination, no?