FreshRSS

Zobrazení pro čtení

Jsou dostupné nové články, klikněte pro obnovení stránky.

Setting a meshcollider's sharedmesh to a mesh which has been generated directly on the GPU gives "Failed extracting collision mesh"

I've been attempting to modify this example project https://github.com/keijiro/ComputeMarchingCubes

I'm trying to repurpose it to build terrain. After the Update() method in Assets/NoiseField/NoiseFieldVisualizer.cs I want to set a MeshCollider's sharedMesh to use the mesh that's been generated.

All I've done is add a line after the mesh is set:

GetComponent<MeshCollider>().sharedMesh = GetComponent<MeshFilter>().sharedMesh;

Currently I get an error:

Failed extracting collision mesh because vertex at index 2817 contains a non-finite value (0.000000, -nan, 1.000000). Mesh asset path "" Mesh name ""

When I iterate over sharedMesh.vertices and log them to console, I get either (0, 0, 0) or (-431602100.00, -431602100.00, -431602100.00) for each vertex value. Presumably because the values haven't been sent back to the CPU?

I have mesh cleaning enabled for the MeshCollider.

Is it possible to generate a mesh collider with a GPU-only mesh? Preferably without transferring the points back to the CPU.

❌