Mesh/Mesh physics


This article explains the physics behavior of imported mesh objects and, to a lesser extent, triangle-based prims under new accounting

Mesh Assets: Physics Shapes and Decompositions

A valid mesh asset will contain:

  1. A single convex hull with no more than 256 vertices
    • All assets will contain a single convex hull with no more than 256 verts that will be used:
      • If the physics shape type is set to "Convex Hull"
      • If there is no decomposition and the prim is in motion of any kind
  2. (Optional) An additional convex decomposition containing up to 256 vertices per hull and up to 256 hulls
  3. (Optional) A mesh designated specifically for use in the physics engine

Mesh Asset Header Identifiers

Decomposition Data Block Members

Physics Representation for Rezzed Prims

Error creating thumbnail: convert-im6.q16: delegate failed `'rsvg-convert' -o '%o' '%i @ error/delegate.c/InvokeDelegate/1966. convert-im6.q16: unable to open file `/tmp/magick-z5EkIeBj5Iu67FhxZ7dfwHW53KZ0mLQ5': No such file or directory @ error/constitute.c/ReadImage/619. convert-im6.q16: no images defined `PNG:/tmp/transform_e10625b0faaa.png' @ error/convert.c/ConvertImageCommand/3229.

Exceptions:

  1. A non-physical prim which is moving (e.g., via llSetVelocity or being grabbed) is treated as dynamic until all motion has ceased for several frames

Notes:

  1. Meshes should initially rez with shape type "Convex Hull" as the physics resource cost (see below) for detailed physics meshes may be very high and depends on the prim's scale
  2. A mesh object uploaded without an explicit physics shape or decomposition cannot be changed to shape type prim and will always be represented as a single convex hull bounding the mesh.
  3. At any time prior to release to Agni, we may choose to require a physics mesh be provided
  4. No linkset or prim with a pure physics resource cost exceeding 32.0 may be set physical

Physics Resource Cost

There will be a new physics-based resource cost (PRC) computation. It will be used directly in determining whether objects can be made physical and will be a factor in determining total prim resource cost for a parcel or region.

Opt-In

A prim or linkset will have a physics resource cost (PRC) computed if and only if it contains:

OR

Formula

Notes:

The third term in the above equation (the one governing triangle mesh cost) is no longer correct. The actual math is now substantially more complex but the result is easier to understand.

Triangle Mesh Overview Briefly, the cost of a physics triangle mesh now depends on two things: (1) The number of triangles and (2) The "average width" of those triangles at the mesh's current scale. The width of a triangle is defined as the width (smaller side) of the tightest rectangle you can draw around the triangle. The average is computed "harmonically" (1/avg = 1/a + 1/b + ... ), which was done to favor weight smaller triangles more heavily. This average is then clamped to be between 0.001m and 20m (right now) and then used in the simple formula:

C = MAX( constant * num_triangles / triangle_width, minimum_mesh_cost )

The value of "constant" has been selected so that for a flat mesh with 0.5m wide triangles, each triangle costs 0.1 units with a minimum total mesh cost of 0.5 units. However, these values are subject to change.

Please note that the computed triangle_width is only an APPROXIMATION of the exact triangle width in most cases.


IMPORTANT: For triangle-based shapes, the cost grows inversely with the scale of the prim! More specifically, it varies linearly with triangle density. This is important as triangle density has a huge impact on physics performance. Also note that for large meshes, the density multiplier may be less than unity, resulting in a discounting effect.

The resulting number may not be an integer. A prim with physics shape type "none" does not contribute to the pure PRC!

NEW An additional factor has been added to this computation. If a linkset is made physical, it will incur an additional penalty that will depend on its scale. The formula is:

penalized_cost = base_physics_cost * ( 1 + 0.04 * A )

where A is the the mean face area of the linkset's axis aligned bounding box (defined by its overall scale). Here's an example to make it clear

Another quick example:

Note that the penalized cost does NOT affect whether the object can be made physical in the first place. Rest assured that if your linkset has a physics weight of <32.0 prim equivalents when NOT physical you will still be able to set it physical. Of course, if doing so results in the cost going up, something on your parcel may be returned to you if you are over your resource quota.

Simulator resource cost (SRC)

Simulator resource cost (SRC) reflects the cost of "managing" a linkset or prim. For example, this includes things like sending out updates about the object's state to relevant viewers.

SRC = simulation_factor * active_cost * ( num_objects + (linkset_factor/num_objects) )

What this means is that to minimize SRC, you should:

  1. Group your prims into as few linksets as possible
  2. Minimize the number of linksets you need to script or make physical
  3. Minimize the number of unlinked or small linksets
  4. If an object is physical or scripted, keep its linkset as small as possible (but don't create multiple scripted unlinked prims instead!)

Region resource cost (RRC)

Regions and parcel limits for prims/linksets will use the region resource cost which is the greater of the SRC and the bandwidth resource cost (also known as streaming resource cost, described elsewhere).