fix: collider2Ds not updating collider after new assignment

This commit is contained in:
2025-04-08 23:18:33 +03:00
parent 2535a1d6ec
commit 26a80452bc
3 changed files with 25 additions and 6 deletions

View File

@@ -6,11 +6,20 @@ namespace Syntriax.Engine.Physics2D;
public class Collider2DShapeBehaviour : Collider2DBehaviourBase, IShapeCollider2D
{
public Shape2D ShapeWorld { get => _shapeWorld; protected set => _shapeWorld = value; }
public Shape2D ShapeLocal { get; set; } = Shape2D.Square;
public Shape2D ShapeLocal
{
get => _shapeLocal;
set
{
_shapeLocal = value;
NeedsRecalculation = true;
}
}
private Shape2D _shapeWorld = Shape2D.Square.CreateCopy();
private Shape2D _shapeWorld = Shape2D.Square;
private Shape2D _shapeLocal = Shape2D.Square;
public override void CalculateCollider() => Transform.TransformShape(ShapeLocal, ref _shapeWorld);
public override void CalculateCollider() => ShapeLocal.Transform(Transform, ref _shapeWorld);
public Collider2DShapeBehaviour() { }
public Collider2DShapeBehaviour(Shape2D shape)