style: IterationCount to IterationPerStep
This commit is contained in:
parent
0257911018
commit
ab0e868d52
|
@ -8,7 +8,7 @@ public interface IPhysicsEngine2D
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of iterations the <see cref="IPhysicsEngine2D"/> performs per step.
|
/// The number of iterations the <see cref="IPhysicsEngine2D"/> performs per step.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int IterationCount { get; set; }
|
int IterationPerStep { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Advances the physics simulation by the specified time.
|
/// Advances the physics simulation by the specified time.
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class PhysicsEngine2D : IPhysicsEngine2D
|
||||||
private readonly ICollisionDetector2D collisionDetector = null!;
|
private readonly ICollisionDetector2D collisionDetector = null!;
|
||||||
private readonly ICollisionResolver2D collisionResolver = null!;
|
private readonly ICollisionResolver2D collisionResolver = null!;
|
||||||
|
|
||||||
public int IterationCount { get => _iterationCount; set => _iterationCount = value < 1 ? 1 : value; }
|
public int IterationPerStep { get => _iterationCount; set => _iterationCount = value < 1 ? 1 : value; }
|
||||||
|
|
||||||
public void AddRigidBody(IRigidBody2D rigidBody)
|
public void AddRigidBody(IRigidBody2D rigidBody)
|
||||||
{
|
{
|
||||||
|
@ -39,9 +39,9 @@ public class PhysicsEngine2D : IPhysicsEngine2D
|
||||||
|
|
||||||
public void Step(float deltaTime)
|
public void Step(float deltaTime)
|
||||||
{
|
{
|
||||||
float intervalDeltaTime = deltaTime / IterationCount;
|
float intervalDeltaTime = deltaTime / IterationPerStep;
|
||||||
|
|
||||||
for (int iterationIndex = 0; iterationIndex < IterationCount; iterationIndex++)
|
for (int iterationIndex = 0; iterationIndex < IterationPerStep; iterationIndex++)
|
||||||
{
|
{
|
||||||
// Can Parallel
|
// Can Parallel
|
||||||
for (int i = 0; i < rigidBodies.Count; i++)
|
for (int i = 0; i < rigidBodies.Count; i++)
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class PhysicsEngine2DCacher : IPhysicsEngine2D, IAssignableGameManager
|
||||||
public Action<IAssignableGameManager>? OnGameManagerAssigned { get; set; } = null;
|
public Action<IAssignableGameManager>? OnGameManagerAssigned { get; set; } = null;
|
||||||
|
|
||||||
|
|
||||||
private int _iterationCount = 1;
|
private int _iterationPerStep = 1;
|
||||||
|
|
||||||
protected readonly ICollisionDetector2D collisionDetector = null!;
|
protected readonly ICollisionDetector2D collisionDetector = null!;
|
||||||
protected readonly ICollisionResolver2D collisionResolver = null!;
|
protected readonly ICollisionResolver2D collisionResolver = null!;
|
||||||
|
@ -21,14 +21,14 @@ public class PhysicsEngine2DCacher : IPhysicsEngine2D, IAssignableGameManager
|
||||||
protected BehaviourCacher<ICollider2D> colliderCacher = new();
|
protected BehaviourCacher<ICollider2D> colliderCacher = new();
|
||||||
|
|
||||||
|
|
||||||
public int IterationCount { get => _iterationCount; set => _iterationCount = value < 1 ? 1 : value; }
|
public int IterationPerStep { get => _iterationPerStep; set => _iterationPerStep = value < 1 ? 1 : value; }
|
||||||
public IGameManager GameManager { get; private set; } = null!;
|
public IGameManager GameManager { get; private set; } = null!;
|
||||||
|
|
||||||
public void Step(float deltaTime)
|
public void Step(float deltaTime)
|
||||||
{
|
{
|
||||||
float intervalDeltaTime = deltaTime / IterationCount;
|
float intervalDeltaTime = deltaTime / IterationPerStep;
|
||||||
|
|
||||||
for (int iterationIndex = 0; iterationIndex < IterationCount; iterationIndex++)
|
for (int iterationIndex = 0; iterationIndex < IterationPerStep; iterationIndex++)
|
||||||
{
|
{
|
||||||
// Can Parallel
|
// Can Parallel
|
||||||
foreach (var rigidBody in rigidBodyCacher)
|
foreach (var rigidBody in rigidBodyCacher)
|
||||||
|
|
Loading…
Reference in New Issue