What is "Bake Scaled Mesh Physx Collision Data"?

Hi,
Does anybody know what causes the “Bake Scaled Mesh Physx Collision Data” function to be called or where it’s called from?
Thanks!

I have no experience with this myself but it looks like you have a mesh collider attached to an animated mesh, resulting in an animated mesh collider. Physx has to bake the collision data to make it efficient, but that has to be done every time the mesh changes.

That’s not possible since the skinned mesh data isn’t readable back from the graphics card. Also it would be really slow even if it were possible, not just sorta slow. :wink: It does involve a mesh collider though:

You have an object with a mesh collider scaled at something other than <1, 1, 1>.

–Eric

I am seeing a similar problem (of CPU usage going over 50% on Mesh.Bake Scaled Mesh PhysX CollisionData).
However, it only seems to happen when I try to deactivate a game object through GameObject.SetActiveRecursively(false) or GameObject.active = false;

Also, is there a quick way to check for mesh colliders scaled at something other than <1,1,1> in a scene?

Is it static? moving a static marked collision mesh would cause physx to recalculate it every single frame (which should only be a precalculate step)

also ensure to not move around mesh collider objects that aren’t convex marked, as such mesh collider objects are not meant to move at all, the whole collision tree for object and world in that sector need to be updated all the time which is extremely cpu intense

1 Like

Yeah if you do want to do that kind of stuff I think you might need to a) ensure it is NOT marked as static and b) ensure it is kinematic.

I am still confused as to why it only happens when I try to deactivate a game object. If I comment out the line that deactivates the game objects, then this problem goes away…

I think I found the problem, It’s not just deactivating the game object with the mesh collider that causes the CPU usage spike, but deactivating then reactivating it causes the collider to re recalculated, hence causing the spike in CPU usage.

Thank you very much. That was execly my problem!

What about mesh colliders on skinned meshes that animate during movement? I have a skinned mesh, not static, convex, but man when they spawn in they eat resources like crazy for a minute. Is there a way to bake the associated geometry somehow?