There are a couple of pitfalls in your code that can cause problems.
There is no nullptr check for:
- MeshAssetMaterial
- MeshAsset
If this fails it’s a cascade of problems as LocalMeshLength will return 0
As you should know you should never divide by 0. It’s a problem waiting to happen.
Still looking further into the code to check what else can be problematic, will update with an edit.