asdasda
This commit is contained in:
parent
a05fb3ba33
commit
8a2e15e6f0
|
@ -14,6 +14,11 @@ public class Collider2DAABBBehaviour(Vector2 lowerBound, Vector2 upperBound) : B
|
||||||
public Vector2 LowerBound { get; } = lowerBound;
|
public Vector2 LowerBound { get; } = lowerBound;
|
||||||
public Vector2 UpperBound { get; } = upperBound;
|
public Vector2 UpperBound { get; } = upperBound;
|
||||||
|
|
||||||
|
|
||||||
|
private Vector2 worldLowerBound = lowerBound;
|
||||||
|
private Vector2 worldUpperBound = upperBound;
|
||||||
|
|
||||||
|
|
||||||
private IRigidBody2D? _rigidBody2D = null;
|
private IRigidBody2D? _rigidBody2D = null;
|
||||||
|
|
||||||
public IRigidBody2D? RigidBody2D
|
public IRigidBody2D? RigidBody2D
|
||||||
|
@ -35,8 +40,8 @@ public class Collider2DAABBBehaviour(Vector2 lowerBound, Vector2 upperBound) : B
|
||||||
|
|
||||||
public bool CheckCollision(Vector2 point, ICollider2D otherCollider)
|
public bool CheckCollision(Vector2 point, ICollider2D otherCollider)
|
||||||
{
|
{
|
||||||
if (point.X >= LowerBound.X + Transform.Position.X && point.X <= UpperBound.X + Transform.Position.X &&
|
if (point.X >= worldLowerBound.X && point.X <= worldUpperBound.X &&
|
||||||
point.Y >= LowerBound.Y + Transform.Position.Y && point.Y <= UpperBound.Y + Transform.Position.Y)
|
point.Y >= worldLowerBound.Y && point.Y <= worldUpperBound.Y)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -44,6 +49,7 @@ public class Collider2DAABBBehaviour(Vector2 lowerBound, Vector2 upperBound) : B
|
||||||
|
|
||||||
public void Recalculate()
|
public void Recalculate()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
worldLowerBound = LowerBound + Transform.Position;
|
||||||
|
worldUpperBound = UpperBound + Transform.Position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class PhysicsEngine2D : IPhysicsEngine2D
|
||||||
{
|
{
|
||||||
float intervalDeltaTime = deltaTime / IterationCount;
|
float intervalDeltaTime = deltaTime / IterationCount;
|
||||||
|
|
||||||
for (int i = 0; i < IterationCount; i++)
|
for (int iterationIndex = 0; iterationIndex < IterationCount; iterationIndex++)
|
||||||
{
|
{
|
||||||
foreach (var rigidBody in rigidBodies)
|
foreach (var rigidBody in rigidBodies)
|
||||||
StepRigidBody(rigidBody, intervalDeltaTime);
|
StepRigidBody(rigidBody, intervalDeltaTime);
|
||||||
|
@ -54,6 +54,15 @@ public class PhysicsEngine2D : IPhysicsEngine2D
|
||||||
foreach (var collider in colliders)
|
foreach (var collider in colliders)
|
||||||
collider.Recalculate();
|
collider.Recalculate();
|
||||||
|
|
||||||
|
for (int ix = colliders.Count - 1; ix >= 0; ix--)
|
||||||
|
{
|
||||||
|
ICollider2D colliderX = colliders[ix];
|
||||||
|
for (int iy = colliders.Count - 1; iy >= ix + 1; iy--)
|
||||||
|
{
|
||||||
|
ICollider2D colliderY = colliders[iy];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue