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

Support Request: MeshCollider or NativeBoundingVolumeTree #23

Open
tony-topper opened this issue Nov 3, 2022 · 3 comments
Open

Support Request: MeshCollider or NativeBoundingVolumeTree #23

tony-topper opened this issue Nov 3, 2022 · 3 comments

Comments

@tony-topper
Copy link

Trying to get some insight on which route I want to take on something.

image

You see the set of bounding boxes I've created here. Debating between just creating a mesh with triangles and using a Mesh Collider or using your AABB bounding boxes in the NativeBoundingVolumeTree to determine collisions.

Do you have any insight on what the performance differences would be here? Unity says this is how the Mesh Collider works: https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Geometry.html

I am trying to calculate when things, mostly the player, are behind tree branches.

@andywiecko
Copy link
Owner

Hi @tony-topper, thanks for the feedback!

I think it depends on your setup. I need more information regarding the collisions (targets) and the objects (dynamics/static). BurstCollections already has implemented an efficient tree vs tree and AABB vs tree query.

I am trying to calculate when things, mostly the player, are behind tree branches.

I assume that these objects can be represented with triangle mesh, so using tree vs tree as a broad-phase could be a natural thing to do. To solve the narrow-phase you have a few options: (a) checking if point is in triangle (b) triangle-triangle intersection check (c) edge-edge intersection check (d) ...

I have some collision algorithms in PBD2D package. All predicted collisions are generated from tree vs tree collisions. It works pretty well on targets with many triangles.

After our discussion on a different thread, I guess that you are using the Unity.Jobs pipeline. I think that using using MeshCollider would be slower than writing a burst job with NativeBoundingVolumeTree. So this could be an advantage to NativeBoundingVolumeTree.

I hope this helps!

Best,
Andrzej

@tony-topper
Copy link
Author

Thanks so much for the reply @andywiecko. This is very helpful. At the moment I am a solo dev, so it's nice to get someone else's perspective.

I think going the Unity.Jobs route will make sense. Now I need to find the quickest way to build an array of items in the bounding tree. Many thanks.

@andywiecko
Copy link
Owner

I'm glad that I could help. I really appreciate your feedback. Your contributions to my projects make them better.

Now I need to find the quickest way to build an array of items in the bounding tree. Many thanks.

In my PBD2D I have an abstract system for updating tree volumes for different objects (triangles, points, edges, etc.). It uses the IConvertableToAABB interface. You can check my readonly struct Triangle : IConvertableToAABB implementation.

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

2 participants