From 17084154a290729425b0a68c69f4cc120caa6419 Mon Sep 17 00:00:00 2001
From: Evan Hemsley <2342303+ehemsley@users.noreply.github.com>
Date: Sun, 5 Jan 2020 13:35:49 -0800
Subject: [PATCH] change multishape test transform behavior
---
Bonk/NarrowPhase/NarrowPhase.cs | 14 +++++++-------
Test/NarrowPhaseTest.cs | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Bonk/NarrowPhase/NarrowPhase.cs b/Bonk/NarrowPhase/NarrowPhase.cs
index 676a6e8..fe69be5 100644
--- a/Bonk/NarrowPhase/NarrowPhase.cs
+++ b/Bonk/NarrowPhase/NarrowPhase.cs
@@ -70,9 +70,9 @@ namespace MoonTools.Core.Bonk
///
public static bool TestCollision(MultiShape multiShape, Transform2D multiShapeTransform, IShape2D shape, Transform2D shapeTransform)
{
- foreach (var (otherShape, otherTransform) in multiShape.ShapeTransformPairs)
+ foreach (var (otherShape, otherTransform) in multiShape.TransformedShapeTransforms(multiShapeTransform))
{
- if (TestCollision(shape, shapeTransform, otherShape, multiShapeTransform.Compose(otherTransform))) { return true; }
+ if (TestCollision(shape, shapeTransform, otherShape, otherTransform)) { return true; }
}
return false;
}
@@ -88,9 +88,9 @@ namespace MoonTools.Core.Bonk
///
public static bool TestCollision(IShape2D shape, Transform2D shapeTransform, MultiShape multiShape, Transform2D multiShapeTransform)
{
- foreach (var (otherShape, otherTransform) in multiShape.ShapeTransformPairs)
+ foreach (var (otherShape, otherTransform) in multiShape.TransformedShapeTransforms(multiShapeTransform))
{
- if (TestCollision(shape, shapeTransform, otherShape, multiShapeTransform.Compose(otherTransform))) { return true; }
+ if (TestCollision(shape, shapeTransform, otherShape, otherTransform)) { return true; }
}
return false;
}
@@ -106,11 +106,11 @@ namespace MoonTools.Core.Bonk
///
public static bool TestCollision(MultiShape multiShapeA, Transform2D transformA, MultiShape multiShapeB, Transform2D transformB)
{
- foreach (var (shapeA, shapeTransformA) in multiShapeA.ShapeTransformPairs)
+ foreach (var (shapeA, shapeTransformA) in multiShapeA.TransformedShapeTransforms(transformA))
{
- foreach (var (shapeB, shapeTransformB) in multiShapeB.ShapeTransformPairs)
+ foreach (var (shapeB, shapeTransformB) in multiShapeB.TransformedShapeTransforms(transformB))
{
- if (TestCollision(shapeA, transformA.Compose(shapeTransformA), shapeB, transformB.Compose(shapeTransformB))) { return true; }
+ if (TestCollision(shapeA, shapeTransformA, shapeB, shapeTransformB)) { return true; }
}
}
return false;
diff --git a/Test/NarrowPhaseTest.cs b/Test/NarrowPhaseTest.cs
index 3cc1d1d..c648490 100644
--- a/Test/NarrowPhaseTest.cs
+++ b/Test/NarrowPhaseTest.cs
@@ -418,7 +418,7 @@ namespace Tests
var transformA = new Transform2D(new Position2D(0, 0));
var rectangleB = new Rectangle(2, 2);
- var transformB = new Transform2D(new Vector2(1, 0));
+ var transformB = new Transform2D(new Vector2(1, 0), 0, new Vector2(-1, 1));
NarrowPhase.TestRectangleOverlap(rectangleA, transformA, rectangleB, transformB).Should().BeTrue();
}