methusalah / SplineMesh

A Unity plugin to create curved content in real-time with bézier curves
https://twitter.com/dumas181
MIT License
1.05k stars 104 forks source link

Spline Mesh Tiling repeats onto itself after hitting vertex limit #51

Open Lasercar opened 3 years ago

Lasercar commented 3 years ago

When a repeating spline mesh tiling is extended to a long distance, it breaks and repeats onto itself. I've checked and no one else has reported this. I'm using Unity 2020.3.14f1.

SplineMesh Bug SplineMesh Bug2

methusalah commented 3 years ago

I think this happens when the generated mesh get more than 65535 vertices. Can you check that and report back?

Lasercar commented 3 years ago

Yep, the MeshBlender mesh has more than 65535 vertices.

MeshBender Mesh
methusalah commented 3 years ago

In general, creating such a big mesh is bad design. In your example, the rail road will be drawn entirely each frame, even if only 1% of it is in the camera field. I would suggest creating a script that will only build the track out of a certain number of curve or a certain distance, to prevent reaching the mesh vertex limit and enable frustrum culling.

As for going past the limit, I think it is possible to ask Unity to manage meshes with more vertices but I never tried it. It should also be possible to change the MeshBender code to create a new mesh when the limit is reached, but this will require some code refactor, and you would need to manage the normal smoothing where the two mesh connect.

Lasercar commented 3 years ago

Ok. Not sure where to start for all of that though.