keenanwoodall / Deform

A fully-featured deformer system for Unity that lets you stack effects to animate models in real-time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update the MeshCollider

IwakuraRein opened this issue · comments

commented

Hi. I noticed that Deformable.RecalculateMeshCollider() simply replaced the MeshCollider.sharedMesh and let Unity rebuild the collider.

I am curious if Unity can expose mesh collider's vertices so we can explicitly edit them with job system, simlarly as how we edit the mesh?

To my knowledge, the only way to update a mesh collider's mesh is to set the sharedMesh property. I would be interested in a way to manually update the internal mesh collider data since reassigning the mesh is expensive, but it does not appear to be possible at this time :(

You should not modify mesh geometry that is used for colliders because the physics engine has to rebuild an internal mesh collision acceleration structure every time you change the mesh. This causes a substantial performance overhead. For meshes that need to collide and change at runtime, it is often better to approximate the mesh shape with primitive colliders like capsules, spheres and boxes.