Jump to content

Single convex hull physics weights (long and technical).


Drongle McMahon
 Share

You are about to reply to a thread that has been inactive for 3319 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

WARNING - Read only if you like detailed technical nit picking, or of you really do need to know how to calculate convex hull phsyics weights.

Note. While this reports the current situation as far as I have been able to discern it, the physics weight calcultions may change. I will update this if I become aware of such a change. While test have been done with meshes a lot more complex than the example shown, there is no guarantee that the results can be extrapolated to very complex models.

Preamble:
This was prepared as a jira, but, now that others cannot see jiras, I would like to solicit opinions before deciding whether to submit it to the new system. It is a description of an inconsistency between the physics weight calculations described in the wiki and tha actual physics weights for mesh using a single convex hull as the physcs shape. This leads to what appears to me to be unexpected behaviour. This post is rather intense and technical and it is not enormously important. So you should not bother to read it unless you have a particular interest in how physics weights are calculated. Part of the information was submitted in a jira in the old system, but further  investigation has made the situation more clear. That is the other motivation for putting this here, as I can no longer add to that jira. This may be regarded as a clarifying addendum to that jira.

Expected behaviour:
There are three common cases where a single convex hull provides the physics shape of a mesh prim; the default convex hull for the whole mesh (used for shape type "Convex Hull"), a single hull produced from a suitably specified physics mesh by decomposition (Analyze) but without simplification, and a single hull produced by applying "Simplify" to a decomposed shape consisting of multiple hulls. More often, the initial decomposition will produce multiple hulls. There are three properties that I would expect to pertain to physics weights of all these physics shapes based on convex hulls:

(1) I expect the contribution of an identical hull to physics weight to be the same whether it is the only hull in the shape or whether it is one component of a multi-hull shape.

(2) I expect two sets of objects that present identical sets of hulls to the physics engine to have the same combined physics weights.

(3) I expect a more complex shape consisting of multiple hulls to have a physics weight higher than, or at least equal to that of a simpler single hull occupying the identical space.

I would welcome suggestions for why these expectations might not be reasonable. It turns out that all three of them are not generally satisfied. This has been found for a variety of shapes, but I will illustrate it here with just one especially simple set of examples.

Physics weights in the wiki:
The wiki contains a description of a formula that is supposedly used for calculating physics weights. It consists of three parts, which are additive in the case of a linkset that contains models with different physics shape types. The first part (0.1I) is for meshes with physics shapes made up of linked prims with undistorted shapes that can be represented as havok primitives. For shapes consisting only of convex hulls, I = 0, and so there is no weight from this part. The second (0.2H+0.04(V-4H); V = vertex count, H = hull count) is for shapes made up of convex hulls. The third part (0.1T(1/100Vp), but now substituted with a different calculation that is not completely described) is for triangle-based shapes.

It is trivially demonstrated that the third part is not used for decomposed shapes consisting of multiple convex hulls, by examining the inworld physics weight for any such mesh. The hull and vertex counts (V and H) are shown in the uploader after pressing "Analyze". The inworld physics weight for any of these meshes, when set to physics shape type "Prim", exactly matches the scond term of the equation. This shows that the third term does not contribute to the physics weight. Furthermore, the third term varies with size while the convex hull weights do not.

So in discussing the physics weights of meshes with all physics shapes consisting of multiple convex hulls, we only need to consider the second term. Conveniently this can be simplified as 0.2H + 0.04(V - 4H) = 0.2H + 0.04V - 0.16H = 0.04(H + V).

Weights inconsistent with the wiki:
However, investigation with many shapes revealed that this formula does not always predict the physics weight when the physics shape is a single convex hull. Instead, those weights are exactly predicted by a new expression, 0.04(H + 2E - 2V), where H and V have the same meanings as above (H always being 1) and E is the number of edges in the mesh representing the physics shape after removing internal coplanar vertices and edges from flat faces (i.e. conversion of all flat surfaces to ngons). This was discovered empirically, and, like the multiple-hull expression from the wiki, is exact. Once again, this appears to rule out a contribution from the third term, and once again, the weight does not vary with size while the third term does.

For a number of simple cases where every vertex has exactly three protruding edges, E = 3V/2, so that 0.04(H + 2E - 2V) = 0.04 (H + 3V - 2V) = 0.04(H + V), and both expressions yield the same value. These cases include the tetrahedron, the cube, the regular dodecahedron and all polygonal prisms. However, in other equally common cases, such as the octahedron, the icosahedron and most convex meshes with curved faces composed of flat quads, the numbers are quite different. These cases lead to the anomalous situation where the weight attributed to the identical convex hull is different depending on whether it is the only hull or whether it is accompanied by others. The new formula predicts the physics weight correctly in all three of the common cases where single-hull shapes are encountered (above).

Reproduction (example):
The example presented here uses a set of simple models containing identical regular octahedra that together illustrate divergence from all three of the expected behaviours described above. Each model was uploaded using the same geometry for all four LOD slots and for the physics shape. The physics shapes are all decomposed (Analyzed) without simplifying. (In the case of octo4, solid decomposition has to be used to obtain the expected two hulls). The number of hulls and vertices in the physics shapes are taken from the upload floater after "Analyze" and all agree with the numbers expected for the mesh geometries. The phsyics weights were measured by using ten (single octahedron models, 1&4) or five (double octahedron models, 2&3) replicates, selecting all of them and using "More Info" to see the physics weights (at least twice, to avoid the occasional effects of delayed updates). These multiples were used to overcome the limited precision of that display. So the observed weights below are all those of ten octahedra. The measured weights for "Convex hull" physics shape type all matched those shown in the upload dialog, as expected.

Octo1 is a single regular octahedron: V = 6, H = 1, E = 12.  
Predicted wiki: ph.wt = 0.28; new: ph.wt = 0.52.
Observed for ten copies: Prim = 5.2, CH = 5.2.
New prediction correct for both (both have a single hull).

Octo2 is two detached octahedra in one mesh: V = 12, H = 2, E = 24.
Predicted wiki: ph.wt = 0.56; new ph.wt = 1.04
Observed for five (10 octahedra): Prim = 2.8, CH = 4.2*.
Wiki prediction is correct for Prim (2 hulls), new for CH (one hull).

*the expected convex hull has V = 10, H = 1, E = 16; wiki => 0.44; new => 0.84 (picture below).

Octo3 is the same as Octo2, but each octahedron is a separate mesh, producing a linkset.
Predicted wiki: ph.wt = 0.56; new ph.wt = 1.04
Observed for five (10 octahedra): Prim = 5.2, CH = 5.2.
New prediction is correct for both (both have a single hull per mesh/prim).

Octo4 is the same octahedron divided into two square pyramids, but still in one mesh. It fills exactly the same space as the octahedron (picture below).
V = 10, H = 2, E = 16. Predicted wiki: ph.wt = 0.48; new ph.wt = 0.56
Observed for ten: Prim = 4.8, CH = 5.2**.
Wiki prediction is correct for Prim (2 hulls), new for CH (one hull).

**The convex hull is just the original octahedron, so predictions are as for octo1.

Summary of observed behaviour:

Replicated to a total of ten octahedra, with shape type Prim, the first three models present exactly the same shapes to the physics engine, but the weights vary by a factor of almost two. This contradicts expectation (2).

The physics weight is changed either by combining two single-hull meshes to yield a double-hull mesh (Octo1 vs Octo2), or by splitting a multi-hull mesh into a linkset of single-hull meshes (Octo 3 vs Octo2). Thus the same hull does not always have the same weight, because it depends whether it exists alone or together with another hull. This contradits expectation (1).

Octo4 has a more complex phsyics shape than Octo1, with more hulls and vertices, but the phsyics weight of Octo4 (as Prim type), 0.48, is less than that of Octo1, 0.52. This contradicts expectation (3).

Footnotes:
Links to collada files with the four Octo models will be added when I have found somewhere to put them.

Equivalent results were found with icosahedron models and a dumbell model. The anomalous weight with a single hull was found in many other models that were less fully examined.

This picture shows: on the left, the construction of the octahedron from two rectangular pyramids in Octo4; on the right, the arrangement of octahedra in Octo2 or Octo3, with the convex hull of Octo2 added and highlighted.

rephyscalcs_forum.png

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3319 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...