Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terrain collider using Rapier's heightfield #5

Open
zeerooth opened this issue Jun 24, 2023 · 3 comments
Open

Terrain collider using Rapier's heightfield #5

zeerooth opened this issue Jun 24, 2023 · 3 comments

Comments

@zeerooth
Copy link

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.

@kurtkuehnert
Copy link
Owner

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.

@zeerooth
Copy link
Author

zeerooth commented Jul 2, 2023

@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?

@jmatsushita
Copy link

Would love to see this too! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants