AmbientRun / Ambient

The multiplayer game engine
https://ambient.run
Apache License 2.0
3.78k stars 122 forks source link

Physics API improvements #213

Open philpax opened 1 year ago

philpax commented 1 year ago

As requested by @SK83RJOSH and with other suggestions by me. I'm publicly sketching these out before I implement them:

Something else to keep in mind that whatever we expose should be portable to other physics engines, too. We may support other physics engines to enable certain applications / deployments.

Feel free to suggest other features of interest that you would like exposed. I'd like to ensure that they all have a consistent interface, which is why I'm not going to nail any of these down until I have a good idea of what should be implemented.

SK83RJOSH commented 1 year ago

For collision filtering, we're going to need to make some refactors to the physics set up in the ECS:

If we do the first half of this list, we can clean up a number of things, which will make things like mass() a lot easier to implement / more fine grained. It will also mean we have a good basis to do raycast filters in the future.

Some suggestions for refactoring raycasts:

With these changes, we can significantly reduce the complexity of things like:

philpax commented 1 year ago

All that sounds good to me. @FredrikNoren ?

FredrikNoren commented 1 year ago

Yup sounds great!

droqen commented 1 year ago

Physics collisions: I'd like to request customizable individual collision behaviours. My use case is a plane_collider that I'm using to detect where on the water's surface the player has clicked, but I don't want this to collide with anything else, at all.

It's purely for this one raycast, so toggling everything to not collide with it would be pretty annoying.

Most commonly I see collision layers. Godot has "layer" and "mask" as separate bitwise flags, so I can say my entity is a layer 2&3&4 entity and hits layer 1&2 entities. I don't exactly get why it works that way, but it has always worked well for every use case that I've encountered.

image