Thursday 3 September 2020

Second Life Mesh Physics 101

 

(Originally posted on the official Second Life forum)

Physics in a virtual world has two purposes, it defines where avatars (and objects set to be physical) can and can't move and it provides surfaces for "ray tracing" (a feature that defines which spots you can rez on and is also used for pathfinding and a few other things).

Physics engines work with two very different kinds of physical objects, surfaces and hulls. (There's a third one too, height fields but it's only used for the system ground so it isn't relevant here). HAVOK, the physics engine used by Second Life, operates with five different hulls and two different surfaces but only the two surfaces and one of the hulls are available for meshes.

When we analyze the physics, the uploader will try to convert the physics mesh we feed it into one or more hulls, if we don't analyze, it will use the input as it is and treat it as a surface. The physics engine, including the uploader's analyze function, is not LL's own, HAVOK is an Irish software copmany currently owned by Microsoft. This means there's not much LL can do about it, they have to use it as it is.

Both surface and hull physics have their pros and cons:


Hulls

A hull can be compared to ban lines in that they defines an "exclusion zone" you are not allowed to be inside.

The pros are:

  • They are always totally solid, if you are inside it, you will always be pushed out.
  • The physics weight is constant. If the hulls are all simple cubes, each of them will always add 0.360 to the physics weight. More complex hull shapes may add a bit more but it's still constant.

The cons:

  • The physics engine won't allow two hulls to touch each other, it will always leave a little bit of space between them. The uploader tries to compensate for this by shrinking the physics shape slightly but this is not a precise science so you will always hover a little bit above a mesh surface made with hulls.
  • There is no way to reduce the physics weight below the 0.360 per hull limit and the hull shapes are always farly simple. If an objects needs a complex physics shape, it'll have to be made from a lot of hulls.
  • Since a hull isn't defined by its surface and ray tracing is all based on surfaces, it can sometimes cause problems with rezzing and for pathfinding characters.

Surfaces

As I said, we have two different kinds of them:

Triangle

A single triangle has a constant physics weight of 0.200, making it the lightest of the shapes available for mesh (three of the special hulls we can't use are even lighter). It doesn't give us any useable physics of course but can still be handy for objects that can be phantom anyway.

Triangle list

Triangle list is just another name for a mesh, a surface made from several triangles streched between vertices. It is said to be heavier on the server than hull physics but that is a truth with modifcations. We often need multiple hulls or a very complex single hull to get a good physics model and in those cases triangle lists are usually considerably lighter.

One peculiar quirk HAVOK has, is that it doesn't handle triangle lists with small or very long and narrow triangles very well, the bigger the triangles are, the better. If the object size is smaller than 0.5 m on any axis, HAVOK simply gives up and handles it as a single convex hull and depending on other factros, you can get very high physics weight long before you reach that limit.

Pros:

  • Allows for very precise physics shapes
  • No ray tracing issues

Cons:

  • May cause inflated physics weight for very thin objects
  • Does not work at all with objects smaller than the 0.5 m limit
  • Is single sided so you may be able to penetrate it (with a little bit of difficulty) if you walk into it from the back side
  • If you move very fast, you may end up penetrating the surface before the physics engine has time to react. This is not a problem with normal avatar walking/running/flying speeds (unless there is a server glitch) but if you drop onto the surface from a high altitude or crash into it in a fast moving vehicle you can sometimes go right through it.

Four special points worth mentioning

For a physics model is made from a single 12 tri cube it doesn't seem to matter whether it's analyzed or not. The physics weight is always 0.360 and it doesn't seem to suffer from any of the quirks neither of the hull or surface physics. This may be because it corresponds exactly with the object's bounding box.

The bounding box is a cube surrounding the entire object. The physics engine can't keep track of the relations between every single object and avatar in a region of course so it uses the bounding boxes as a preliminary check to see if two objects are so enough to each other it'll have to do a more precise calculation.

For those who wonder, the "convex hull" option in the edit window uses HAVOK's analyzer to generate a single hull for the entire object. The physics weight depends on how complex that hull is but usually it's lower than the more detailed "prim physics".

Practically all parcels in Second Life are configured with no pushing. This means worn items are always phantom so there is no point in using elaborate physics models for clothes, hair, jewelry etc. Just upload with a single triangle as physics.

Monday 30 March 2020

Brick walls


Brick walls

Brick sizes

Brick sizes vary depending on location and age of course but not nearly as much as we may think. The measurements here are for modern standard Norwegian bricks but they're not far off for other styles and nations:

RL 133% 150% 200%
Whole bricks per meter horizontally 5 3.75 3.33 2.5
Layers per meter vertically 14-15 10-11 9-10 7-7.5

Cement bricks

Cement bricks are generally about twice the size of redbricks:

RL 133% 150% 200%
Whole bricks per meter horizontally 2.5 1.9 1.6 1.25
Layers per meter vertically 5 3.75 3.3 2.5


Bonds

The bond is the pattern of the bricks in a wall. Let's establish some terminology first:
  • Stretcher: The regular brick with its long side facing outwards
  • Header: A brick with its short side facing outwards
  • Soldier: A brick standing vertically
  • Joint: Well, obviously - the horizontal or vertical mortar filled space between the bricks
  • Single thickness wall: A wall as thick as the header side of a brick
  • Double thickness wall: A wall as thick as the stretcher side of a brick
If we want a solid brick wall, we want it double thickness and without consecutive aligned vertical joints (don't worry, it'll all come clear when you look at the pictures). For simpler walls that don't have to carry much load, there are other options too.

Solid brick wall patterns

There are lots of different bonds used for solid, double thickness walls. Here are the most common - and two slightly unusual - ones:

 Common bond


Every sixth layer is made from headers, the rest from staggered stretchers.

English bond


Alternating stretcher and header layers. This is regarded as the strongest of the regular bonds.

Flemish bond


Each layer made from alternating stretchers and headers.

Garden bond


A pattern of two stretchers and one header in each layer.

Flemish/Common mix


I'm not sure if this has a special name, usually I've seen it referred to as "common bond". It's similar to the regualr common bond but with every sixth layer made in the Flemish alternating stretcher and header style rather than from ehaders only.

"Scandinavian garden bond"


Another bond I don't know a name for. I've onyl seen it twice, once in Norway and once in Denmark, so I decided to call it "Scandinavian garden". It's the same as the regular garden bond with two stretchers and one header in each layer but the layers are shifted relatively to each other (seemingly at random) so the headers aren't aligned vertially with each other.

Not so solid bonds

Stretcher bond (aka Running bond)


Stretchers only, each layer shifted a quarter, third or (usually) half brick width to avoid aligned vertical joints. This is what you'll usually see on a single thickness wall but it's not really recommended for load breaign double thickness ones.

Stack bond


Stretchers stacked nicely on top of each other. Sometimes used as decorative coverage on walls and embankments made from other materials but it is a very weak wall and you don't want to use it on its own.

Soldier crown


A layer of soldiers added to the wall, usually at the very top where it doesn't affect the structural strength very much. The illustration shows it on top of a stretcher bond wall but it can be added to any bond.