Improved Physics Queries #12201
Replies: 2 comments
-
Another method I miss from physics queries is one that returns shape rest info from multiple contacts.
Adding a sweep test to PhysicsDirectSpaceState3D would result in a shape cast that is more accurate and performant than the current binary search. There is currently no proposal for this yet. I might try tackling this.
Changing the return types of the current queries would be a breaking change, my guess is that (sadly) this may only happen in the far future (Godot 5). |
Beta Was this translation helpful? Give feedback.
-
Nice. I'm not sure what it takes for a PR to be accepted, but hopefully this one goes through soon. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I know there are a few different discussions/issues which touch on this, but feel like they're all sort of part of the same problem, and hasn't really been addressed fully yet.
So for really basic functionality, or using the built in nodes, querying the world is simple enough, but if you need to manually do anything more advanced than that, it becomes a lot harder/cumbersome to use.
I'm also comparing this to Unity which has a lot more functionality, and what it does have is much simpler to use.
As I see it there are four major problems it at the moment:
1. Missing really basic common functionality.
ray_cast
, andclosest_point
- methods for individual colliders.ray_cast_all
,motion_cast_all
,overlap_all
- for space states.compute_penetration
- calculates the distance and direction two colliders are overlapping.2. Existing functions are way more complex and unintuitive than they should be.
Primarily this is referring to
cast_motion
andget_rest_info
.There's no reason for it being this complex - there should really be a single
sweep_shape
which returns the distance and collision results in a single call.This also overlaps with point 1. -
XXX_all
variants of the raycast and overlap methods would be a lot less clunky (and possibly more performant) than looping and updating theexclude
property.3. Return values.
I know there are some issues about adding struct support to gdscript, though I don't know if or when this would be implemented.
But basically dictionaries are just awkward to use, and some sort of
HitResult
object with appropriate properties would be much more convenient.4. Inaccurate
motion_cast
.As far as I can tell the current method is just an approximation that steps the shape through the scene at some fixed resolution until an overlap is found.
I don't know how complex/possible it would be for arbitrary collision shapes, but for basic geometric shapes such as circles/spheres etc. surely this could be done mathematically, which would be 100% accurate, and possibly more performant.
Beta Was this translation helpful? Give feedback.
All reactions