mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
Rigidbody isbullet (#3649)
This commit is contained in:
@@ -125,4 +125,6 @@ native class IPhysicsBody as NativeEngine.IPhysicsBody
|
||||
void SetTrigger( bool trigger );
|
||||
|
||||
void ResetProxy();
|
||||
|
||||
void SetBullet( bool bEnabled );
|
||||
}
|
||||
|
||||
@@ -296,6 +296,24 @@ sealed public partial class Rigidbody : Component, Component.ExecuteInEditor, IG
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[Advanced, Property]
|
||||
public bool EnhancedCcd
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
if ( field == value ) return;
|
||||
if ( _body.IsValid() ) _body.EnhancedCcd = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the inertia tensor and its rotation to the values automatically calculated from the attached colliders.
|
||||
/// This removes any custom overrides set via <see cref="InertiaTensor"/> or <see cref="InertiaTensorRotation"/>.
|
||||
@@ -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;
|
||||
|
||||
@@ -1233,4 +1233,16 @@ public sealed partial class PhysicsBody : IHandle
|
||||
{
|
||||
native.ResetProxy();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public bool EnhancedCcd
|
||||
{
|
||||
set => native.SetBullet( value );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user