amerkoleci / JoltPhysicsSharp

JoltPhysics C# bindings
MIT License
238 stars 34 forks source link

BroadPhaseQuery/NarrowPhaseQuery #66

Closed bjornbytes closed 6 months ago

bjornbytes commented 6 months ago

This exposes BroadPhaseQuery and more of the NarrowPhaseQuery methods.

I didn't like the existing collector objects because they required excessive heap allocation and didn't allow the application to control early exit behavior. I converted them to C callback functions, and internally the bindings create a C++ collector class that calls the C callback for every hit. This gives the application more control over how it handles the hits -- it could append to a list, track the closest hit, do custom filtering, immediately cancel the raycast on the first hit, etc.

bjornbytes commented 6 months ago

Oops, the ToJolt methods for the filters are returning references to stack memory, I'll need to rethink those.

bjornbytes commented 6 months ago

Ok this should be good to go, I'm using the new raycast/shapecast callbacks in LÖVR successfully now. If you have a better idea for those _padding members, go for it, it was just to silence a warning about padding >_<.

amerkoleci commented 6 months ago

Thanks!