diff --git a/engine/Definitions/common/Physics/IPhysicsBody.def b/engine/Definitions/common/Physics/IPhysicsBody.def index 6a087a22..0363b96b 100644 --- a/engine/Definitions/common/Physics/IPhysicsBody.def +++ b/engine/Definitions/common/Physics/IPhysicsBody.def @@ -125,4 +125,6 @@ native class IPhysicsBody as NativeEngine.IPhysicsBody void SetTrigger( bool trigger ); void ResetProxy(); + + void SetBullet( bool bEnabled ); } diff --git a/engine/Sandbox.Engine/Scene/Components/Collider/Rigidbody.cs b/engine/Sandbox.Engine/Scene/Components/Collider/Rigidbody.cs index 795c3c04..46455b4a 100644 --- a/engine/Sandbox.Engine/Scene/Components/Collider/Rigidbody.cs +++ b/engine/Sandbox.Engine/Scene/Components/Collider/Rigidbody.cs @@ -296,6 +296,24 @@ sealed public partial class Rigidbody : Component, Component.ExecuteInEditor, IG } } + /// + /// Enable enhanced continuous collision detection (CCD) for this body. + /// When enabled, the body performs CCD against dynamic bodies + /// (but not against other bodies with enhanced CCD enabled). + /// This is useful for fast-moving objects like bullets or rockets + /// that need reliable collision detection. + /// + [Advanced, Property] + public bool EnhancedCcd + { + get; + set + { + if ( field == value ) return; + if ( _body.IsValid() ) _body.EnhancedCcd = value; + } + } + /// /// Resets the inertia tensor and its rotation to the values automatically calculated from the attached colliders. /// This removes any custom overrides set via or . @@ -391,6 +409,8 @@ sealed public partial class Rigidbody : Component, Component.ExecuteInEditor, IG _body.Velocity = _lastVelocity; _body.AngularVelocity = _lastAngularVelocity; + _body.EnhancedCcd = EnhancedCcd; + // Make sure we clear these so we don't reapply them again later _lastVelocity = default; _lastAngularVelocity = default; diff --git a/engine/Sandbox.Engine/Systems/Physics/PhysicsBody.cs b/engine/Sandbox.Engine/Systems/Physics/PhysicsBody.cs index f8b9d986..a2f88202 100644 --- a/engine/Sandbox.Engine/Systems/Physics/PhysicsBody.cs +++ b/engine/Sandbox.Engine/Systems/Physics/PhysicsBody.cs @@ -1233,4 +1233,16 @@ public sealed partial class PhysicsBody : IHandle { native.ResetProxy(); } + + /// + /// Enable enhanced continuous collision detection (CCD) for this body. + /// When enabled, the body performs CCD against dynamic bodies + /// (but not against other bodies with enhanced CCD enabled). + /// This is useful for fast-moving objects like bullets or rockets + /// that need reliable collision detection. + /// + public bool EnhancedCcd + { + set => native.SetBullet( value ); + } }