Physics Issue when trying to animate custom models

Hi all :blush:

I figured I’d chime in, since I’m the developer who worked most on physics animations recently in Keyshot.

First off: which version of Keyshot is this in? We made stability improvements in 2023.1 that resolved many issues just like this one. If you are already using 2023.1 or later, carry on :slight_smile:

Unfortunately, I do not have a ready-made solution to resolve such issues in all cases. Most likely this is due to a poor convex decomposition made by Keyshot (see below for an explanation), although there could be other factors, like the scale in your scene, but most of the scale issues were solved in 2023.1.

In any case, I would be happy to investigate your meshes, to see if there are some workarounds, or better yet, some areas of improvements in Keyshot, such that we could make it better in future versions. @luke.orford If you are able, could you share the bip file with the hearts that shows the issue? For example, via a WeTransfer link that you send in DM to me. Alternatively, I can share a private OneDrive folder for you to upload, if the files are sensitive.

I can also shed some light on the inner workings of physics simulations in Keyshot. That could help you all figure out strategies to avoid issues, hopefully.

The most important concept to understand is convex decomposition. All dynamic objects in the scene (the ones you “check” in the physics tool) will undergo a convex decomposition: that is, split the mesh into smaller meshes that are all convex. That is because the physics simulation engine we use, called PhysX, requires complex meshes to be convex in order to simulate them.
That process is in itself very much not error-proof. I will spare you the details, but the gist of it is that the quality of the convex decomposition can vary a lot. It all depends on the input mesh, and its shape: the convex decomposition algorithm has its weaknesses, so if you are unlucky, the mesh you are using ends up having a poor convex decomposition.
Unfortunately, there is no way currently in Keyshot to visualize the convex decomposition. At least if as users, we were able to see the result of the convex decomposition process, we would be able to understand where the simulation issues come from (when they do come from the convex decomposition), and through trial-and-error on the input mesh, hopefully work around the issues in the convex decomposition algorithm.
We are very much aware of this, and have already discussed the introduction of a tool to visualize convex decompositions. The reason it’s not in Keyshot right now is as always: lack of time. We are prioritizing work on other features at the time being.
All this means that in current versions of Keyshot, your main strategy when facing such issues should be to modify the input mesh in various manners. Simplifying the mesh is a good option, because it transforms it while keeping its shape, and also removing some artifacts that the convex decomposition algorithm has trouble with.

For objects that are static, i.e. not checked in the tool, we just send them as-is to the physics simulation. So there will not be any problems related to convex decomposition - although there can be other types of problems, for example with “open” meshes (i.e. mere surfaces, like planes), the normals need to be in the “right” direction, otherwise the collisions won’t be happening correctly (the collisions happen correctly when an object comes from the direction of the normals into the static object).

There are currently no circumstances in which we use bounding boxes in the physics simulation. We either use the input meshes as is, or a convex decomposition of them.

The other frequent source of issues comes from the simulation itself. The physics simulation employs many different algorithms, which I’m not going to detail here, but what’s important is that these algorithms also have limitations. As much as possible, we try to transform the scene under the hood, such that what we send to the simulation engine is “nice” (i.e. has the fewest issues possible). The improvements we have made in 2023.1 were mainly in that area. That is why after 2023.1, scaling issues should be very rare.
That is why you may come across surprising scenarios sometimes, for example when you add an new object in a scene that works fine, suddenly the scene doesn’t simulate well anymore, even though the new object doesn’t even touch the others.
A useful strategy for issues that originate from the simulation is to play with the simulation settings: gravity, friction, bounciness, simulation quality. Here’s a summarized breakdown of their effect.

  • Gravity: as Oscar pointed out, lower gravity will usually mean fewer issues. However that of course means the resulting animation will be longer - but you can then easily speed it up in Keyshot (you don’t have to do it in post!), by reducing the size of the animation folder containing the animation(s). Also the simulation will look different, so the result might not be what you expect when scaled back to the duration and speed you envisioned.
  • Friction: I have not yet seen a meaningful effect on stability for this parameter. That does not mean it could not have one though :wink:
  • Bounciness: Like gravity, a high bounciness means that objects will more easily jump around, so try reducing that value.
  • Simulation quality: That’s an easy one. Just crank it up to the max when you get issues, and see if that has an effect. Usually it does have a positive effect.

And that concludes my technical dive into the physics simulation in Keyshot :smile: Hopefully that understanding will help making the most out of that feature.

If there are any further questions, I’d be glad to answer them :blush:

Cheers,
Florian

5 Likes

Thanks Florian for your extended comment and explanation of the more inner working!

Just a small question, is it true that it’s currently running on CPU or is that only the convex decomposition? I looked for a bit at the NVidia developer pages and from what I read the latest versions of PhysX should be pretty fast on current generations of GPUs.

1 Like

that’s a great read for people to understand what is going on. I’m bookmarking this for future reference!

2 Likes

My pleasure :blush:

It is true, the physics simulation is only making use of the CPU as of today. Again, the reason for the lack of GPU support is a lack of time to implement it.

1 Like

Hello Florian!
Thanks for this detailed explination! Its very helpful in explaining the situation. I can send you the files later, currently trying to figure this all out in what little free time I have, so as soon as i get i chance i will see what i can do based on all your recomendations.

Thanks again! Everyone in this post has been super useful in helping me out!

2 Likes