Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What is "Bake Scaled Mesh Physx Collision Data"?

Discussion in 'Editor & General Support' started by bibbinator, Oct 29, 2010.

  1. bibbinator

    bibbinator

    Joined:
    Nov 20, 2009
    Posts:
    507
    Hi,
    Does anybody know what causes the "Bake Scaled Mesh Physx Collision Data" function to be called or where it's called from?
    Thanks!
     

    Attached Files:

  2. Vicenti

    Vicenti

    Joined:
    Feb 10, 2010
    Posts:
    664
    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.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    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. ;) It does involve a mesh collider though:

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

    --Eric
     
  4. Nima

    Nima

    Joined:
    May 2, 2011
    Posts:
    75
    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?
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    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)
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    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
     
    piliponful likes this.
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    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.
     
  8. Nima

    Nima

    Joined:
    May 2, 2011
    Posts:
    75
    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...
     
  9. Nima

    Nima

    Joined:
    May 2, 2011
    Posts:
    75
    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.
     
    Last edited: Jun 14, 2011
  10. piliponful

    piliponful

    Joined:
    Dec 6, 2016
    Posts:
    1
    Thank you very much. That was execly my problem!
     
  11. Xepherys

    Xepherys

    Joined:
    Sep 9, 2012
    Posts:
    204
    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?