refactor: StepRigidbody Method Improved
This commit is contained in:
parent
64205353e5
commit
697e7c35b9
|
@ -37,8 +37,6 @@ public class PhysicsEngine2D : IPhysicsEngine2D
|
||||||
rigidBodies.Remove(rigidBody);
|
rigidBodies.Remove(rigidBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Line> lines = new List<Line>(32);
|
|
||||||
|
|
||||||
public void Step(float deltaTime)
|
public void Step(float deltaTime)
|
||||||
{
|
{
|
||||||
float intervalDeltaTime = deltaTime / IterationCount;
|
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;
|
rigidBody.Transform.Position += rigidBody.Velocity * intervalDeltaTime;
|
||||||
nextPosition += rigidBody.Velocity * intervalDeltaTime;
|
rigidBody.Transform.Rotation += rigidBody.AngularVelocity * intervalDeltaTime;
|
||||||
|
|
||||||
rigidBody.Transform.Position = nextPosition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBehaviourAdded(IBehaviourController controller, IBehaviour behaviour)
|
private void OnBehaviourAdded(IBehaviourController controller, IBehaviour behaviour)
|
||||||
|
|
Loading…
Reference in New Issue