Extremely Precise Mesh Terrain Collisions

taadaaa

4 Likes

Cool. Is it achieved by using a bunch of MeshParts with precise angles or by another method?

Nope. Take the original mesh part, split all faces, slightly downscale all of those faces, and layer on top of the original mesh (with the original mesh having CanCollide off).

2 Likes

For games with big maps using this method, wouldn’t it be quite performance intensive?

1 Like

I like this, maybe you could do a version where each mesh part is one chunk! Roblox’s StreamingEnabled is specifically 64x64 chunks, it should help make things performant!

1 Like

Nope. In a tweet I made, I gave a walkthrough of this method and gave a brief explanation of how it improves performance. I made the whole terrain chunk about 4k triangles, less than most weapon models in first-person shooter games.

2 Likes

But weapon models in first-person shooter games don’t have 4k triangle precise convex decomposition hitboxes…

Though I guess this is the only way to have accurate hitboxes in Roblox.

Here is a wireframe of a single terrain voxel.

image

If you have a 4k triangle map and 4k triangle hitbox, you will have far greater performance compared to Roblox-built terrain.

1 Like

Your terrain hitbox has each triangle split, that combined with precise convex decomposition collision creates a 4k triangle hitbox.

Here are the hitboxes for some terrain without split triangles

image
Default | PreciseConvexDecomposition


Box | Hull


(mesh)

As you can see these are optimized at the cost of less accurate collisions.

Roblox-built terrain (hopefully) has a special version optimized for terrain. But even if it doesn’t it’s still much faster, though not as ‘extremely precise’, as your hitbox.

So I wouldn’t use it too much…


I wonder how PreciseConvexDecomposition would ‘decompose’ your special split hitbox. Could you post a picture of it like above? I used the Mesh Optimization Tools plugin, but you can enable it manually by going to File > Studio Settings… > Studio > Visualization > Show Decomposition Geometry

1 Like

Terrain w/o/ hitbox if it was precise convex decomposition:

Hitbox precise convex decomposition:

4 Likes

So you’re pretty much meshing out every triangle individually, and then giving each one precise convex decomposition collision, is that right? That’s pretty cool because you basically have perfect collision for every single voxel!!?

1 Like

Not quite, but almost! Instead of each triangle being calculated, it’s every face. The face averages out the triangle data!

2 Likes

Ohhhhhh dang so you’re removing the jagged qualities of the triangles!