kurtkuehnert / bevy_terrain

A terrain rendering plugin for the bevy game engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terrain collider using Rapier's heightfield

zeerooth opened this issue · comments

Hello,

I really like this project, but one of the important things that appear to be missing for potential games and simulations is colliders on the terrain. Rapier contains a collider type that seems to be ideal for this purpose, I'm talking about heightfield colliders. Are there possibly any plans to include this? I tried to make a prototype with these myself, but this project is pretty big and honestly I have no idea where to even begin. Can you provide me with some guidance? Most importantly I need to find a step in the whole preprocessing/rendering pipeline where the images are processed and already available in the form of 2d height matrix, spawning a collider at this point should be trivial.

Hi Zeerooth,
thank you very much for your interest in this plugin. I have been really busy with university for the last couple of weeks and will remain so for the next month as well.

The overlapping data tiles are the problem with extracting the collision mesh from the preprocessed terrain data.
I believe that it would be pretty difficult to maintain an excerpt of the terrain mesh around the viewer.

Ideally, we could just sample the height value at any XZ coordinate on the CPU just like we do it in the shaders.
Most of this stuff is already set up, but the interface is not nice. I do not think that this would work with rapier though.

Alternatively, we could create mesh segments from the source height data, that we manage separately.

@kurtkuehnert

Thanks for the reply, I managed to conjure a rough prototype of the heightfield collider inside bevy_terrain, without offloading the collider for now (see the PR), but the issue is with scaling and the gaps between colliders.

Overlapping data tiles that you mentioned wouldn't be much of a problem, but after debugging the code for a bit I'm pretty certain that the tile that we get from NodeAtlas's height attachments don't contain the border data between the individual lod 0 nodes and I don't know if that's by design or maybe a bug. The documentation states that it should be included so I'm confused why they don't seem to match at all. Could you share some of your insight into this please?

Would love to see this too! 👍