Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Box2D.NET.Samples/Samples/Collisions/Manifold.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2025 Erin Catto
// SPDX-FileCopyrightText: 2025 Erin Catto
// SPDX-FileCopyrightText: 2025 Ikpil Choi(ikpil@naver.com)
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -305,7 +305,7 @@ public override void Step()
B2Transform transform1 = new B2Transform(offset, b2Rot_identity);
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);

B2Manifold m = b2CollidePolygonAndCircle(ref box, transform1, circle, transform2);
B2Manifold m = b2CollidePolygonAndCircle(in box, transform1, circle, transform2);

DrawSolidPolygon(m_draw, transform1, box.vertices.AsSpan(), box.count, m_round, color1);
DrawSolidCircle(m_draw, new B2Transform(circle.center, transform2.q), circle.radius, color2);
Expand Down Expand Up @@ -346,7 +346,7 @@ public override void Step()
B2Transform transform1 = new B2Transform(offset, b2Rot_identity);
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);

B2Manifold m = b2CollidePolygonAndCapsule(ref box, transform1, capsule, transform2);
B2Manifold m = b2CollidePolygonAndCapsule(in box, transform1, capsule, transform2);

DrawSolidPolygon(m_draw, transform1, box.vertices.AsSpan(), box.count, box.radius, color1);

Expand Down Expand Up @@ -394,7 +394,7 @@ public override void Step()
B2Transform transform1 = new B2Transform(offset, b2Rot_identity);
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);

B2Manifold m = b2CollidePolygons(ref box1, transform1, ref box, transform2);
B2Manifold m = b2CollidePolygons(in box1, transform1, in box, transform2);

DrawSolidPolygon(m_draw, transform1, box1.vertices.AsSpan(), box1.count, box1.radius, color1);
DrawSolidPolygon(m_draw, transform2, box.vertices.AsSpan(), box.count, box.radius, color2);
Expand All @@ -413,7 +413,7 @@ public override void Step()
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);
// b2Transform transform2 = {b2Add({0.0f, -0.1f}, offset), {0.0f, 1.0f}};

B2Manifold m = b2CollidePolygons(ref box1, transform1, ref box, transform2);
B2Manifold m = b2CollidePolygons(in box1, transform1, in box, transform2);

DrawSolidPolygon(m_draw, transform1, box1.vertices.AsSpan(), box1.count, box1.radius, color1);
DrawSolidPolygon(m_draw, transform2, box.vertices.AsSpan(), box.count, box.radius, color2);
Expand All @@ -433,7 +433,7 @@ public override void Step()
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);
// b2Transform transform2 = {b2Add({0.0f, -0.1f}, offset), {0.0f, 1.0f}};

B2Manifold m = b2CollidePolygons(ref box, transform1, ref rox, transform2);
B2Manifold m = b2CollidePolygons(in box, transform1, in rox, transform2);

DrawSolidPolygon(m_draw, transform1, box.vertices.AsSpan(), box.count, box.radius, color1);
DrawSolidPolygon(m_draw, transform2, rox.vertices.AsSpan(), rox.count, rox.radius, color2);
Expand All @@ -453,7 +453,7 @@ public override void Step()
// b2Transform transform1 = {{6.48024225f, 2.07872653f}, {-0.938356698f, 0.345668465f}};
// b2Transform transform2 = {{5.52862263f, 2.51146317f}, {-0.859374702f, -0.511346340f}};

B2Manifold m = b2CollidePolygons(ref rox, transform1, ref rox, transform2);
B2Manifold m = b2CollidePolygons(in rox, transform1, in rox, transform2);

DrawSolidPolygon(m_draw, transform1, rox.vertices.AsSpan(), rox.count, rox.radius, color1);
DrawSolidPolygon(m_draw, transform2, rox.vertices.AsSpan(), rox.count, rox.radius, color2);
Expand All @@ -473,7 +473,7 @@ public override void Step()
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);
// b2Transform transform2 = {b2Add({-1.44583416f, 0.397352695f}, offset), m_transform.q};

B2Manifold m = b2CollideSegmentAndPolygon(segment, transform1, ref rox, transform2);
B2Manifold m = b2CollideSegmentAndPolygon(segment, transform1, in rox, transform2);

B2Vec2 p1 = b2TransformPoint(transform1, segment.point1);
B2Vec2 p2 = b2TransformPoint(transform1, segment.point2);
Expand All @@ -494,7 +494,7 @@ public override void Step()
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);
// b2Transform transform2 = {b2Add({0.0f, -0.1f}, offset), {0.0f, 1.0f}};

B2Manifold m = b2CollidePolygons(ref wox, transform1, ref wox, transform2);
B2Manifold m = b2CollidePolygons(in wox, transform1, in wox, transform2);

DrawSolidPolygon(m_draw, transform1, wox.vertices.AsSpan(), wox.count, wox.radius, color1);
DrawSolidPolygon(m_draw, transform1, wox.vertices.AsSpan(), wox.count, 0.0f, color1);
Expand All @@ -521,7 +521,7 @@ public override void Step()
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);
// b2Transform transform2 = {b2Add({0.0f, -0.1f}, offset), {0.0f, 1.0f}};

B2Manifold m = b2CollidePolygons(ref w1, transform1, ref w2, transform2);
B2Manifold m = b2CollidePolygons(in w1, transform1, in w2, transform2);

DrawSolidPolygon(m_draw, transform1, w1.vertices.AsSpan(), w1.count, w1.radius, color1);
DrawSolidPolygon(m_draw, transform1, w1.vertices.AsSpan(), w1.count, 0.0f, color1);
Expand All @@ -546,7 +546,7 @@ public override void Step()
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);
// b2Transform transform2 = {b2Add({0.0f, -0.1f}, offset), {0.0f, 1.0f}};

B2Manifold m = b2CollidePolygons(ref box, transform1, ref tri, transform2);
B2Manifold m = b2CollidePolygons(in box, transform1, in tri, transform2);

DrawSolidPolygon(m_draw, transform1, box.vertices.AsSpan(), box.count, 0.0f, color1);
DrawSolidPolygon(m_draw, transform2, tri.vertices.AsSpan(), tri.count, 0.0f, color2);
Expand Down Expand Up @@ -611,8 +611,8 @@ public override void Step()
B2Transform transform1 = new B2Transform(offset, b2Rot_identity);
B2Transform transform2 = new B2Transform(b2Add(m_transform.p, offset), m_transform.q);

B2Manifold m1 = b2CollideChainSegmentAndPolygon(segment1, transform1, ref rox, transform2, ref m_smgroxCache1);
B2Manifold m2 = b2CollideChainSegmentAndPolygon(segment2, transform1, ref rox, transform2, ref m_smgroxCache2);
B2Manifold m1 = b2CollideChainSegmentAndPolygon(segment1, transform1, in rox, transform2, ref m_smgroxCache1);
B2Manifold m2 = b2CollideChainSegmentAndPolygon(segment2, transform1, in rox, transform2, ref m_smgroxCache2);

{
B2Vec2 g2 = b2TransformPoint(transform1, segment1.ghost2);
Expand Down
4 changes: 2 additions & 2 deletions src/Box2D.NET.Samples/Samples/Collisions/SmoothManifold.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2025 Erin Catto
// SPDX-FileCopyrightText: 2025 Erin Catto
// SPDX-FileCopyrightText: 2025 Ikpil Choi(ikpil@naver.com)
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -300,7 +300,7 @@ public override void Draw()
{
ref readonly B2ChainSegment segment = ref m_segments[i];
B2SimplexCache cache = new B2SimplexCache();
B2Manifold m = b2CollideChainSegmentAndPolygon(segment, transform1, ref rox, transform2, ref cache);
B2Manifold m = b2CollideChainSegmentAndPolygon(segment, transform1, in rox, transform2, ref cache);
DrawManifold(m);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Box2D.NET/B2Contacts.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Erin Catto
// SPDX-FileCopyrightText: 2023 Erin Catto
// SPDX-FileCopyrightText: 2025 Ikpil Choi(ikpil@naver.com)
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -63,19 +63,19 @@ internal static B2Manifold b2CapsuleManifold(B2Shape shapeA, in B2Transform xfA,
internal static B2Manifold b2PolygonAndCircleManifold(B2Shape shapeA, in B2Transform xfA, B2Shape shapeB, in B2Transform xfB, ref B2SimplexCache cache)
{
B2_UNUSED(cache);
return b2CollidePolygonAndCircle(ref shapeA.us.polygon, xfA, shapeB.us.circle, xfB);
return b2CollidePolygonAndCircle(in shapeA.us.polygon, xfA, shapeB.us.circle, xfB);
}

internal static B2Manifold b2PolygonAndCapsuleManifold(B2Shape shapeA, in B2Transform xfA, B2Shape shapeB, in B2Transform xfB, ref B2SimplexCache cache)
{
B2_UNUSED(cache);
return b2CollidePolygonAndCapsule(ref shapeA.us.polygon, xfA, shapeB.us.capsule, xfB);
return b2CollidePolygonAndCapsule(in shapeA.us.polygon, xfA, shapeB.us.capsule, xfB);
}

internal static B2Manifold b2PolygonManifold(B2Shape shapeA, in B2Transform xfA, B2Shape shapeB, in B2Transform xfB, ref B2SimplexCache cache)
{
B2_UNUSED(cache);
return b2CollidePolygons(ref shapeA.us.polygon, xfA, ref shapeB.us.polygon, xfB);
return b2CollidePolygons(in shapeA.us.polygon, xfA, in shapeB.us.polygon, xfB);
}

internal static B2Manifold b2SegmentAndCircleManifold(B2Shape shapeA, in B2Transform xfA, B2Shape shapeB, in B2Transform xfB, ref B2SimplexCache cache)
Expand All @@ -93,7 +93,7 @@ internal static B2Manifold b2SegmentAndCapsuleManifold(B2Shape shapeA, in B2Tran
internal static B2Manifold b2SegmentAndPolygonManifold(B2Shape shapeA, in B2Transform xfA, B2Shape shapeB, in B2Transform xfB, ref B2SimplexCache cache)
{
B2_UNUSED(cache);
return b2CollideSegmentAndPolygon(shapeA.us.segment, xfA, ref shapeB.us.polygon, xfB);
return b2CollideSegmentAndPolygon(shapeA.us.segment, xfA, in shapeB.us.polygon, xfB);
}

internal static B2Manifold b2ChainSegmentAndCircleManifold(B2Shape shapeA, in B2Transform xfA, B2Shape shapeB, in B2Transform xfB, ref B2SimplexCache cache)
Expand All @@ -109,7 +109,7 @@ internal static B2Manifold b2ChainSegmentAndCapsuleManifold(B2Shape shapeA, in B

internal static B2Manifold b2ChainSegmentAndPolygonManifold(B2Shape shapeA, in B2Transform xfA, B2Shape shapeB, in B2Transform xfB, ref B2SimplexCache cache)
{
return b2CollideChainSegmentAndPolygon(shapeA.us.chainSegment, xfA, ref shapeB.us.polygon, xfB, ref cache);
return b2CollideChainSegmentAndPolygon(shapeA.us.chainSegment, xfA, in shapeB.us.polygon, xfB, ref cache);
}

internal static void b2AddType(b2ManifoldFcn fcn, B2ShapeType type1, B2ShapeType type2)
Expand Down
18 changes: 9 additions & 9 deletions src/Box2D.NET/B2Manifolds.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Erin Catto
// SPDX-FileCopyrightText: 2023 Erin Catto
// SPDX-FileCopyrightText: 2025 Ikpil Choi(ikpil@naver.com)
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -145,7 +145,7 @@ public static B2Manifold b2CollideCapsuleAndCircle(in B2Capsule capsuleA, in B2T
}

/// Compute the contact manifold between a polygon and a circle
public static B2Manifold b2CollidePolygonAndCircle(ref B2Polygon polygonA, in B2Transform xfA, in B2Circle circleB, in B2Transform xfB)
public static B2Manifold b2CollidePolygonAndCircle(in B2Polygon polygonA, in B2Transform xfA, in B2Circle circleB, in B2Transform xfB)
{
B2Manifold manifold = new B2Manifold();
float speculativeDistance = B2_SPECULATIVE_DISTANCE;
Expand Down Expand Up @@ -544,10 +544,10 @@ public static B2Manifold b2CollideSegmentAndCapsule(in B2Segment segmentA, in B2
}

/// Compute the contact manifold between a polygon and capsule
public static B2Manifold b2CollidePolygonAndCapsule(ref B2Polygon polygonA, in B2Transform xfA, in B2Capsule capsuleB, in B2Transform xfB)
public static B2Manifold b2CollidePolygonAndCapsule(in B2Polygon polygonA, in B2Transform xfA, in B2Capsule capsuleB, in B2Transform xfB)
{
B2Polygon polyB = b2MakeCapsule(capsuleB.center1, capsuleB.center2, capsuleB.radius);
return b2CollidePolygons(ref polygonA, xfA, ref polyB, xfB);
return b2CollidePolygons(in polygonA, xfA, in polyB, xfB);
}

// Polygon clipper used to compute contact points when there are potentially two contact points.
Expand Down Expand Up @@ -742,7 +742,7 @@ internal static float b2FindMaxSeparation(ref int edgeIndex, ref B2Polygon poly1
// else
// clip edges
// end
public static B2Manifold b2CollidePolygons(ref B2Polygon polygonA, in B2Transform xfA, ref B2Polygon polygonB, in B2Transform xfB)
public static B2Manifold b2CollidePolygons(in B2Polygon polygonA, in B2Transform xfA, in B2Polygon polygonB, in B2Transform xfB)
{
B2Vec2 origin = polygonA.vertices[0];
float linearSlop = B2_LINEAR_SLOP;
Expand Down Expand Up @@ -1095,10 +1095,10 @@ public static B2Manifold b2CollideSegmentAndCircle(in B2Segment segmentA, in B2T
}

/// Compute the contact manifold between an segment and a polygon
public static B2Manifold b2CollideSegmentAndPolygon(in B2Segment segmentA, in B2Transform xfA, ref B2Polygon polygonB, in B2Transform xfB)
public static B2Manifold b2CollideSegmentAndPolygon(in B2Segment segmentA, in B2Transform xfA, in B2Polygon polygonB, in B2Transform xfB)
{
B2Polygon polygonA = b2MakeCapsule(segmentA.point1, segmentA.point2, 0.0f);
return b2CollidePolygons(ref polygonA, xfA, ref polygonB, xfB);
return b2CollidePolygons(in polygonA, xfA, in polygonB, xfB);
}

/// Compute the contact manifold between a chain segment and a circle
Expand Down Expand Up @@ -1193,7 +1193,7 @@ public static B2Manifold b2CollideChainSegmentAndCircle(in B2ChainSegment segmen
public static B2Manifold b2CollideChainSegmentAndCapsule(in B2ChainSegment segmentA, in B2Transform xfA, in B2Capsule capsuleB, in B2Transform xfB, ref B2SimplexCache cache)
{
B2Polygon polyB = b2MakeCapsule(capsuleB.center1, capsuleB.center2, capsuleB.radius);
return b2CollideChainSegmentAndPolygon(segmentA, xfA, ref polyB, xfB, ref cache);
return b2CollideChainSegmentAndPolygon(segmentA, xfA, in polyB, xfB, ref cache);
}

internal static B2Manifold b2ClipSegments(B2Vec2 a1, B2Vec2 a2, B2Vec2 b1, B2Vec2 b2, B2Vec2 normal, float ra, float rb, ushort id1, ushort id2)
Expand Down Expand Up @@ -1311,7 +1311,7 @@ internal static B2NormalType b2ClassifyNormal(B2ChainSegmentParams param, B2Vec2
}

/// Compute the contact manifold between a chain segment and a rounded polygon
public static B2Manifold b2CollideChainSegmentAndPolygon(in B2ChainSegment segmentA, in B2Transform xfA, ref B2Polygon polygonB,
public static B2Manifold b2CollideChainSegmentAndPolygon(in B2ChainSegment segmentA, in B2Transform xfA, in B2Polygon polygonB,
B2Transform xfB, ref B2SimplexCache cache)
{
B2Manifold manifold = new B2Manifold();
Expand Down
Loading