Dynamic rigid body with complex compound shape

Dynamic rigid body with complex compound shape

Hi!

I'm using rigid bodies with complex compound shape (hundreds of box shapes alligned to uniform grid).

What best compound shape for this case?
I've tried hkpBvCompressedMeshShape, but it's quite slow in narrow phase (~20ms)

hkpMoppBvTreeShape is faster in narrow phase (~5-10ms), but when object is moving in empty space (no other objects at all), it's quite slow (~5-10ms). Why is Mopp slow when it's just moving?

hkpStaticCompoundShape should not be used at all for dynamic bodies, and indeed, it's very slow in narrow phase (peaks to ~50ms).

Thank you for any help.

Additionally, what's good shape for dynamic rigid bodies with collision mesh ~1000K triangles?
I've already read user guide topic Creating Physics Objects and other topics about Mopp and compressed mesh shape.

7 帖子 / 0 全新

Hi Ondrej,

Could you tell us a bit more about your use case for these shapes, specifically why you need such complex shapes to be dynamic bodies? Could you use a simpler shape that approximates this shape?

In regards to the "dynamic rigid bodies with collision mesh ~1000K triangles": are talking about rigid bodies that are colliding with a single mesh that has 1000K triangles or rigid bodies that have 1000K triangles each?

Amy

Amy Developer Support Engineer Havok www.havok.com

Hi Amy,

I've been able to improve performance a bit, when moving hkpMoppBvTreeShape constructed from 315 boxes on release, it takes 0.2ms compared to 0.02ms when doing nothing, that quite acceptable.

It's large space ship / mothership, players should be able to construct it in-game from various parts, including interiors. They should be able to walk inside and land with smaller ships. It's size is few hundred meteres. Collision geometry is already aproximated by cubes. Before hkpMoppBvTreeShape is created, cubes are merged into larger rectangular clusters, so 2600 cubes are represented by 315 boxes.

Two mothership should be able to collide (later we'll add destruction). We've considered keyframed objects, but at some point we want at least partially elastic collisions.

Meshes with ~1000K triangles...alternative shape for motherships, because hkpMoppBvTreeShape was slow when moving. We can consider there will be 2 (max. 3) colliding mothership, no more.

Why is hkpMoppBvTreeShape "slow" (0.2ms) when moving in empty space (hkpBvCompressedMeshShape is not)?
Do you have any recommendation regarding our situation? (I don't think we can simplify mothership collision shape more)

Thank you,
any help is highly appreciated.

Ondrej

Hi Ondrej,

"Do you have any recommendation regarding our situation? (I don't think we can simplify mothership collision shape more)"
* Have you tried to simplify the mothership into groups of convex hulls rather than approximating it with cubes? If you can approximate the ship with fewer hulls than boxes this may be a better solution than the boxes (and depending on the shape of your ship they might more closely approximate the shape of the ship).
* Have you considered a StaticCompoundShape? You can't change the shape of the object once it's made but you can disable/enable child shapes as you like (perhaps to disable and replace destructable parts with their broken pieces?) and if players construct the ship in a seperate menu the shape could be reconstructed between menus. The StaticCompoundShapeKeyDisablingDemo shows creating and disabling parts of a StaticCompoundShape.

"Why is hkpMoppBvTreeShape "slow" (0.2ms)"
According to our physics team:
The hkpBvCompressedMeshShape is a much more recent addition with a built-in bounding volume tree so the BV tree and shape are together when the hkpBvCompressedMeshShape is queried (i.e use the BV tree to know which region you are in, and then forward the call to the corresponding child shape). Where as a hkpMoppBvTreeShape has a BV tree in it and it's shape possibly in another location in memory, so when it is queried it's going to take longer to fetch the child shape from memory.

Amy Developer Support Engineer Havok www.havok.com

Hi Amy,

thank you for answers, we'll try both options. Is it wise to use StaticCompoundShape for dynamic rigid body? (Documentation says it's not)

Hi Amy,

thank you, we'll try both suggestions. Is it wise to use StaticCompoundShape for dynamic rigid body? I'm asking, because documentation says: This shape should not be used for dynamic bodies.

Hi Ondrej,

The manual's warning is a bit harsh here. Event if the Static Compound Shape was primarily designed for landscapes, you can actually have dynamic bodies with Static Compound Shapes. There could be some issues on PS3, though, but in the general case it will work.

Val

Val - Havok Software Engineer - Physics