Add a new method to PhysicsDirectSpaceState
for getting shape rest info from multiple contacts
#11609
Labels
PhysicsDirectSpaceState
for getting shape rest info from multiple contacts
#11609
Describe the project you are working on
I'm working on a 3D kinematic/virtual character body implementation. These types of bodies are simulated using collision checks outside of the dynamic physics simulation, hence the name virtual.
Describe the problem or limitation you are having in your project
I often just need to get the intersections of the shape at a given position, no motion involved (ex.: What is the character currently touching?). While
PhysicsServer3D.body_test_motion
can be used for moving the shape and getting the full shape rest info at the unsafe fraction, it can not be used for a stationary collision check, because the the shape is moved away from collisions in the recovery phase, so it's very inaccurate, and also is a huge overhead because it involves a large number of collision checks.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Ideally,
PhysicsDirectSpaceState.get_rest_info
should just be able to give out the complete rest information, but I understand that it would break compatibility, so I propose a new method instead. Adding this new method will allow getting all contact infos of a shape's intersections in a given space. The method should be available in both 3D and 2D.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I already started implementing it in this PR: godotengine/godot/pull/101676.
The method functions like
PhysicsDirectSpaceState.get_rest_info
, but allows for multiple results.The method's second parameter allows for limiting the number of results.
It returns an array of dictionaries, the dictionaries contain the same data as the one returned by
PhysicsDirectSpaceState.get_rest_info
.A code snippet from my test project:
If this enhancement will not be used often, can it be worked around with a few lines of script?
This is a core functionality of a 3D and 2D physics engine, no workaround possible.
Is there a reason why this should be core and not an add-on in the asset library?
This is a core functionality of a 3D and 2D physics engine.
The text was updated successfully, but these errors were encountered: