Skip to content

Commit

Permalink
fix: very minor prop. grid presentation changes for bepu (#2556)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eideren authored Dec 14, 2024
1 parent 9f56722 commit 25e65f4
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public sealed class BepuSimulation : IDisposable
private const string CategoryTime = "Time";
private const string CategoryConstraints = "Constraints";
private const string CategoryForces = "Forces";
private const string MaskCategory = "Collisions";
private const string MaskCategory = "Collision Matrix";

private TimeSpan _fixedTimeStep = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / 60);
private readonly Dictionary<Type, Elider> _simulationUpdateComponents = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,40 @@ public bool Gravity
}
}

public InterpolationMode InterpolationMode
{
get => _interpolationMode;
set
{
if (_interpolationMode == InterpolationMode.None && value != InterpolationMode.None)
Simulation?.RegisterInterpolated(this);
if (_interpolationMode != InterpolationMode.None && value == InterpolationMode.None)
Simulation?.UnregisterInterpolated(this);
_interpolationMode = value;
}
}

/// <summary>
/// Shortcut to <see cref="ContinuousDetection"/>.<see cref="ContinuousDetection.Mode"/>
/// </summary>
public ContinuousDetectionMode ContinuousDetectionMode
{
get => _continuous.Mode;
set
{
if (_continuous.Mode == value)
return;

_continuous = value switch
{
ContinuousDetectionMode.Discrete => ContinuousDetection.Discrete,
ContinuousDetectionMode.Passive => ContinuousDetection.Passive,
ContinuousDetectionMode.Continuous => ContinuousDetection.Continuous(),
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null)
};
}
}

public float SleepThreshold
{
get => _sleepThreshold;
Expand Down Expand Up @@ -111,40 +145,6 @@ public byte MinimumTimestepCountUnderThreshold
}
}

public InterpolationMode InterpolationMode
{
get => _interpolationMode;
set
{
if (_interpolationMode == InterpolationMode.None && value != InterpolationMode.None)
Simulation?.RegisterInterpolated(this);
if (_interpolationMode != InterpolationMode.None && value == InterpolationMode.None)
Simulation?.UnregisterInterpolated(this);
_interpolationMode = value;
}
}

/// <summary>
/// Shortcut to <see cref="ContinuousDetection"/>.<see cref="ContinuousDetection.Mode"/>
/// </summary>
public ContinuousDetectionMode ContinuousDetectionMode
{
get => _continuous.Mode;
set
{
if (_continuous.Mode == value)
return;

_continuous = value switch
{
ContinuousDetectionMode.Discrete => ContinuousDetection.Discrete,
ContinuousDetectionMode.Passive => ContinuousDetection.Passive,
ContinuousDetectionMode.Continuous => ContinuousDetection.Continuous(),
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null)
};
}
}

[DataMemberIgnore]
public bool Awake
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public abstract class CollidableComponent : EntityComponent
/// <remarks>
/// Changing this value will reset some of the internal physics state of this body
/// </remarks>
[MemberRequired, Display(Expand = ExpandRule.Always)]
[Display(Expand = ExpandRule.Always)]
public required ICollider Collider
{
get
Expand All @@ -80,41 +80,6 @@ public required ICollider Collider
}
}

/// <summary>
/// Provides the ability to collect and mutate contact data when this object collides with other objects.
/// </summary>
public IContactEventHandler? ContactEventHandler
{
get
{
return _trigger;
}
set
{
if (IsContactHandlerRegistered())
UnregisterContactHandler();

_trigger = value;
RegisterContactHandler();
TryUpdateMaterialProperties();
}
}

[DefaultValueIsSceneBased]
public ISimulationSelector SimulationSelector
{
get
{
return _simulationSelector;
}
set
{
_simulationSelector = value;
if (Processor is not null)
ReAttach(_simulationSelector.Pick(Processor.BepuConfiguration, Entity));
}
}

public float SpringFrequency
{
get
Expand Down Expand Up @@ -189,6 +154,41 @@ public CollisionGroup CollisionGroup
}
}

[DefaultValueIsSceneBased]
public ISimulationSelector SimulationSelector
{
get
{
return _simulationSelector;
}
set
{
_simulationSelector = value;
if (Processor is not null)
ReAttach(_simulationSelector.Pick(Processor.BepuConfiguration, Entity));
}
}

/// <summary>
/// Provides the ability to collect and mutate contact data when this object collides with other objects.
/// </summary>
public IContactEventHandler? ContactEventHandler
{
get
{
return _trigger;
}
set
{
if (IsContactHandlerRegistered())
UnregisterContactHandler();

_trigger = value;
RegisterContactHandler();
TryUpdateMaterialProperties();
}
}

/// <summary>
/// The center of mass of this object
/// </summary>
Expand Down

0 comments on commit 25e65f4

Please sign in to comment.