stride icon indicating copy to clipboard operation
stride copied to clipboard

[Feature Request] Add `impulse` information to `Stride.Physics.ContactPoint`

Open Oberon-Zheng opened this issue 4 months ago • 0 comments

As Stride API indicated, Stride.Physics.ContactPoint gets collision information in simulation via an internal method LatestContactPointsFor(), in which ContactPoint obtains the contact data in a buffer and returned with Bullet Native API (to be elaborative, it's from btManifoldPoint/ManifoldPoint in BulletSharp). https://github.com/stride3d/stride/blob/4c46fdcc4da0021514fbaaea3d432095d164b9b6/sources/engine/Stride.Physics/Simulation.cs#L493-L506

Since it's found that Stride ContactPoint provides limited contact info about collider, normalvec, distance and point pos. But other game engines can also provide the impulse of contact (e.g., in Unity, we can get this via ContactPoint.impulse field, in Godot we can find this via get_contact_impulse of PhysicsServer), which is missing in Stride API but actually supported in BulletSharp.ManifoldPoint (point.m_appliedImpulse). https://github.com/stride3d/stride/blob/4c46fdcc4da0021514fbaaea3d432095d164b9b6/sources/engine/Stride.Physics/ContactPoint.cs#L11-L39

AFAIAC, sometimes this impulse information is useful for physics interaction manipulation, so it's probably necessary reasonable to provide this in ContactPoint since the underlying Bullet body is literally not accessible directly as internal member of RigidbodyComponent.

Oberon-Zheng avatar Oct 18 '24 00:10 Oberon-Zheng