refactor: StepRigidbody Method Improved

This commit is contained in:
Syntriax 2024-01-23 12:20:43 +03:00
parent 64205353e5
commit 697e7c35b9
1 changed files with 3 additions and 7 deletions

View File

@ -37,8 +37,6 @@ public class PhysicsEngine2D : IPhysicsEngine2D
rigidBodies.Remove(rigidBody);
}
private List<Line> lines = new List<Line>(32);
public void Step(float deltaTime)
{
float intervalDeltaTime = deltaTime / IterationCount;
@ -53,12 +51,10 @@ public class PhysicsEngine2D : IPhysicsEngine2D
}
}
private void StepRigidBody(IRigidBody2D rigidBody, float intervalDeltaTime)
private static void StepRigidBody(IRigidBody2D rigidBody, float intervalDeltaTime)
{
Vector2D nextPosition = rigidBody.Transform.Position;
nextPosition += rigidBody.Velocity * intervalDeltaTime;
rigidBody.Transform.Position = nextPosition;
rigidBody.Transform.Position += rigidBody.Velocity * intervalDeltaTime;
rigidBody.Transform.Rotation += rigidBody.AngularVelocity * intervalDeltaTime;
}
private void OnBehaviourAdded(IBehaviourController controller, IBehaviour behaviour)