Mesh/Mesh physics
Mesh Physics Design Document
Purpose: To specify 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:
- A single convex hull with no more than 256 vertices
- (Optional) An additional convex decomposition containing up to 256 vertices per hull and up to 256 hulls
- (Optional) A mesh designated specifically for use in the physics engine
- All assets will contain a single 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
Mesh Asset Header Identifiers
- "physics_shape" - optional, reference to mesh to be used in place of visible mesh for collisions
- "decomposition" - required, reference to one or more convex hulls of no more than 256 vertices each to be used in place of physical mesh
Decomposition Data Block Members
- "Min"/"Max" - required, LLVector3, floating point domain to decode binary U16 data to
- "HullList" - optional, binary U8, list of point counts of hulls stored in "Position". '0' is special cased to indicate 256 points.
- "Position" - optional, binary U16, list of positions of points in hulls that make up the multi-hull decomposition of this mesh
- "Hull" - required, binary U16, list of positions in a single convex hull of no more than 256 verts that wraps entire physical mesh
- "Hull" is generated automatically at upload time by feeding the physics shape, mid lod, or high lod into LLConvexDecomposition:
- Stage 1: Mode set to "Preview"
- Stage 2: Simplify mode set to "Retain%", retain percentage set to zero.
- "Hull" is generated automatically at upload time by feeding the physics shape, mid lod, or high lod into LLConvexDecomposition:
Physics Representation for Rezzed Prims
Exceptions:
- A non-physical prim which is moving (e.g., via llSetVelocity) is treated as dynamic until all motion has ceased for several frames
Notes:
- 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
- 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.
- At any time prior to release to Agni, we may choose to require a physics mesh be provided
- 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 at least one of the following is true:
- It contains a mesh asset
- It contains a prim with a physics shape type other than "Prim"
Formula
- PRC
- Notes:
- 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.
- This formula is subject to change during beta--particularly the coefficients.
- The resulting number may not be an integer
- A prim with physics shape type "none" does not contribute to the pure PRC!
- Simulator Resource Cost (SRC)
Overall cost to the simulator for a linkset or prim is reflected in the Simulator Resource Cost (SRC). SRC accounts for two additional factors: the constant overhead of handling individual prims and rounding. The SRC is computed as follows:
- Determine the tentative PRC as the sum of the PRCs of all prims in a linkset, rounded to the nearest whole number.
- Determine the minimum SRC as one half of the number of prims in the linkset, rounding to the nearest whole number. If this number is less than 1, it is rounded to 1.
- The SRC is the greater of 1 and 2.
If a linkset does not meet the criteria above for having a PRC, its SRC = PRC = num prims in linkset (just as it always has been).
- 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 in the wiki).