Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/Box2D.NET.Samples/Graphics/Draws.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void DrawSolidPolygon(Draw draw, in B2Transform transform, ReadOnl
AddPolygon(ref draw.polygons, transform, vertices, vertexCount, radius, color);
}

public static void DrawTransform(Draw draw, B2Transform transform, float scale)
public static void DrawTransform(Draw draw, in B2Transform transform, float scale)
{
B2Vec2 p1 = transform.p;

Expand Down Expand Up @@ -103,9 +103,9 @@ public static void DrawCircle(Draw draw, B2Vec2 center, float radius, B2HexColor
AddCircle(ref draw.hollowCircles, center, radius, color);
}

public static void DrawSolidCircle(Draw draw, B2Transform transform, float radius, B2HexColor color)
public static void DrawSolidCircle(Draw draw, in B2Transform transform, float radius, B2HexColor color)
{
AddSolidCircle(ref draw.circles, ref transform, radius, color);
AddSolidCircle(ref draw.circles, transform, radius, color);
}

public static void DrawSolidCapsule(Draw draw, B2Vec2 p1, B2Vec2 p2, float radius, B2HexColor color)
Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET.Samples/Graphics/SolidCircles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static void DestroySolidCircles(GL gl, ref SolidCircleRender render)
}
}

public static void AddSolidCircle(ref SolidCircleRender render, ref B2Transform transform, float radius, B2HexColor color)
public static void AddSolidCircle(ref SolidCircleRender render, in B2Transform transform, float radius, B2HexColor color)
{
RGBA8 rgba = RGBA8.MakeRGBA8(color, 1.0f);
render.circles.Add(new SolidCircleData(transform, radius, rgba));
Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET.Samples/Primitives/CapsuleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct CapsuleData
public float length;
public RGBA8 rgba;

public CapsuleData(B2Transform transform, float radius, float length, RGBA8 rgba)
public CapsuleData(in B2Transform transform, float radius, float length, RGBA8 rgba)
{
this.transform = transform;
this.radius = radius;
Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET.Samples/Primitives/SolidCircleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct SolidCircleData
public float radius;
public RGBA8 rgba;

public SolidCircleData(B2Transform transform, float radius, RGBA8 rgba)
public SolidCircleData(in B2Transform transform, float radius, RGBA8 rgba)
{
this.transform = transform;
this.radius = radius;
Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET.Samples/Samples/Collisions/ShapeCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private B2ShapeProxy MakeProxy(ShapeType type, float radius)
return proxy;
}

private void DrawShape(ShapeType type, B2Transform transform, float radius, B2HexColor color)
private void DrawShape(ShapeType type, in B2Transform transform, float radius, B2HexColor color)
{
switch (type)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Box2D.NET.Samples/Samples/Collisions/ShapeDistance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ B2ShapeProxy MakeProxy(ShapeType type, float radius)
return proxy;
}

void DrawShape(ShapeType type, ref B2Transform transform, float radius, B2HexColor color)
void DrawShape(ShapeType type, in B2Transform transform, float radius, B2HexColor color)
{
switch (type)
{
Expand Down Expand Up @@ -389,8 +389,8 @@ public override void Draw()
base.Draw();

var empty = b2Transform_identity;
DrawShape(m_typeA, ref empty, m_radiusA, B2HexColor.b2_colorCyan);
DrawShape(m_typeB, ref m_transform, m_radiusB, B2HexColor.b2_colorBisque);
DrawShape(m_typeA, empty, m_radiusA, B2HexColor.b2_colorCyan);
DrawShape(m_typeB, m_transform, m_radiusB, B2HexColor.b2_colorBisque);

if (m_drawSimplex)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Box2D.NET.Samples/Samples/Issues/ShapeCastChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private bool ShapeCastSingle(ref PhysicsHitQueryResult2D outResult, B2Vec2 start
start,
b2MakeRot(rotation)
);
B2ShapeProxy transformedShape = TransformShapeProxy(ref transform, ref shape);
B2ShapeProxy transformedShape = TransformShapeProxy(transform, ref shape);

B2Vec2 translation = new B2Vec2(end.X - start.X, end.Y - start.Y);
B2QueryFilter filter = new B2QueryFilter(0x1, 0x1);
Expand Down Expand Up @@ -252,7 +252,7 @@ private static float b2CastResult_Closest(in B2ShapeId shapeId, B2Vec2 point, B2
return fraction;
}

private static B2ShapeProxy TransformShapeProxy(ref B2Transform t, ref B2ShapeProxy proxy)
private static B2ShapeProxy TransformShapeProxy(in B2Transform t, ref B2ShapeProxy proxy)
{
B2ShapeProxy ret = new B2ShapeProxy();
ret.count = proxy.count;
Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET/B2DistanceJoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ internal static void b2SolveDistanceJoint(B2JointSim @base, B2StepContext contex
}
#endif

internal static void b2DrawDistanceJoint(B2DebugDraw draw, B2JointSim @base, B2Transform transformA, B2Transform transformB)
internal static void b2DrawDistanceJoint(B2DebugDraw draw, B2JointSim @base, in B2Transform transformA, in B2Transform transformB)
{
B2_ASSERT(@base.type == B2JointType.b2_distanceJoint);

Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET/B2Geometries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public static B2AABB b2ComputePolygonAABB(in B2Polygon shape, in B2Transform xf)
}

/// Compute the bounding box of a transformed line segment
public static B2AABB b2ComputeSegmentAABB(in B2Segment shape, B2Transform xf)
public static B2AABB b2ComputeSegmentAABB(in B2Segment shape, in B2Transform xf)
{
B2Vec2 v1 = b2TransformPoint(xf, shape.point1);
B2Vec2 v2 = b2TransformPoint(xf, shape.point2);
Expand Down
4 changes: 2 additions & 2 deletions src/Box2D.NET/B2Joints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ public static B2WorldId b2Joint_GetWorld(B2JointId jointId)
}

/// Set the local frame on bodyA
public static void b2Joint_SetLocalFrameA(B2JointId jointId, B2Transform localFrame)
public static void b2Joint_SetLocalFrameA(B2JointId jointId, in B2Transform localFrame)
{
B2_ASSERT(b2IsValidTransform(localFrame));

Expand All @@ -810,7 +810,7 @@ public static B2Transform b2Joint_GetLocalFrameA(B2JointId jointId)
}

/// Set the local frame on bodyB
public static void b2Joint_SetLocalFrameB(B2JointId jointId, B2Transform localFrame)
public static void b2Joint_SetLocalFrameB(B2JointId jointId, in B2Transform localFrame)
{
B2_ASSERT(b2IsValidTransform(localFrame));

Expand Down
24 changes: 12 additions & 12 deletions src/Box2D.NET/B2Manifolds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static B2Polygon b2MakeCapsule(B2Vec2 p1, B2Vec2 p2, float radius)
// localAnchorB = qBc * (point - pB)
// anchorB = point - pB = qA * localAnchorA + pA - pB
// = anchorA + (pA - pB)
public static B2Manifold b2CollideCircles(ref B2Circle circleA, B2Transform xfA, ref B2Circle circleB, B2Transform xfB)
public static B2Manifold b2CollideCircles(ref B2Circle circleA, in B2Transform xfA, ref B2Circle circleB, in B2Transform xfB)
{
B2Manifold manifold = new B2Manifold();

Expand Down Expand Up @@ -80,7 +80,7 @@ public static B2Manifold b2CollideCircles(ref B2Circle circleA, B2Transform xfA,

/// Compute the contact manifold between a capsule and circle
/// Compute the collision manifold between a capsule and circle
public static B2Manifold b2CollideCapsuleAndCircle(in B2Capsule capsuleA, B2Transform xfA, ref B2Circle circleB, B2Transform xfB)
public static B2Manifold b2CollideCapsuleAndCircle(in B2Capsule capsuleA, in B2Transform xfA, ref B2Circle circleB, in B2Transform xfB)
{
B2Manifold manifold = new B2Manifold();

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

/// Compute the contact manifold between a polygon and a circle
public static B2Manifold b2CollidePolygonAndCircle(ref B2Polygon polygonA, B2Transform xfA, ref B2Circle circleB, B2Transform xfB)
public static B2Manifold b2CollidePolygonAndCircle(ref B2Polygon polygonA, in B2Transform xfA, ref B2Circle circleB, in B2Transform xfB)
{
B2Manifold manifold = new B2Manifold();
float speculativeDistance = B2_SPECULATIVE_DISTANCE;
Expand Down Expand Up @@ -266,7 +266,7 @@ public static B2Manifold b2CollidePolygonAndCircle(ref B2Polygon polygonA, B2Tra
/// Compute the contact manifold between a capsule and circle
// Follows Ericson 5.1.9 Closest Points of Two Line Segments
// Adds some logic to support clipping to get two contact points
public static B2Manifold b2CollideCapsules(in B2Capsule capsuleA, B2Transform xfA, in B2Capsule capsuleB, B2Transform xfB)
public static B2Manifold b2CollideCapsules(in B2Capsule capsuleA, in B2Transform xfA, in B2Capsule capsuleB, in B2Transform xfB)
{
B2Vec2 origin = capsuleA.center1;

Expand Down Expand Up @@ -537,14 +537,14 @@ public static B2Manifold b2CollideCapsules(in B2Capsule capsuleA, B2Transform xf
}

/// Compute the contact manifold between an segment and a capsule
public static B2Manifold b2CollideSegmentAndCapsule(ref B2Segment segmentA, B2Transform xfA, in B2Capsule capsuleB, B2Transform xfB)
public static B2Manifold b2CollideSegmentAndCapsule(ref B2Segment segmentA, in B2Transform xfA, in B2Capsule capsuleB, in B2Transform xfB)
{
B2Capsule capsuleA = new B2Capsule(segmentA.point1, segmentA.point2, 0.0f);
return b2CollideCapsules(capsuleA, xfA, capsuleB, xfB);
}

/// Compute the contact manifold between a polygon and capsule
public static B2Manifold b2CollidePolygonAndCapsule(ref B2Polygon polygonA, B2Transform xfA, in B2Capsule capsuleB, B2Transform xfB)
public static B2Manifold b2CollidePolygonAndCapsule(ref 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);
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, B2Transform xfA, ref B2Polygon polygonB, B2Transform xfB)
public static B2Manifold b2CollidePolygons(ref B2Polygon polygonA, in B2Transform xfA, ref B2Polygon polygonB, in B2Transform xfB)
{
B2Vec2 origin = polygonA.vertices[0];
float linearSlop = B2_LINEAR_SLOP;
Expand Down Expand Up @@ -1088,21 +1088,21 @@ public static B2Manifold b2CollidePolygons(ref B2Polygon polygonA, B2Transform x
}

/// Compute the contact manifold between an segment and a circle
public static B2Manifold b2CollideSegmentAndCircle(ref B2Segment segmentA, B2Transform xfA, ref B2Circle circleB, B2Transform xfB)
public static B2Manifold b2CollideSegmentAndCircle(ref B2Segment segmentA, in B2Transform xfA, ref B2Circle circleB, in B2Transform xfB)
{
B2Capsule capsuleA = new B2Capsule(segmentA.point1, segmentA.point2, 0.0f);
return b2CollideCapsuleAndCircle(capsuleA, xfA, ref circleB, xfB);
}

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

/// Compute the contact manifold between a chain segment and a circle
public static B2Manifold b2CollideChainSegmentAndCircle(ref B2ChainSegment segmentA, B2Transform xfA, ref B2Circle circleB, B2Transform xfB)
public static B2Manifold b2CollideChainSegmentAndCircle(ref B2ChainSegment segmentA, in B2Transform xfA, ref B2Circle circleB, in B2Transform xfB)
{
B2Manifold manifold = new B2Manifold();

Expand Down Expand Up @@ -1190,7 +1190,7 @@ public static B2Manifold b2CollideChainSegmentAndCircle(ref B2ChainSegment segme
}

/// Compute the contact manifold between a chain segment and a capsule
public static B2Manifold b2CollideChainSegmentAndCapsule(ref B2ChainSegment segmentA, B2Transform xfA, in B2Capsule capsuleB, B2Transform xfB, ref B2SimplexCache cache)
public static B2Manifold b2CollideChainSegmentAndCapsule(ref 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(ref segmentA, xfA, ref polyB, xfB, ref cache);
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(ref B2ChainSegment segmentA, B2Transform xfA, ref B2Polygon polygonB,
public static B2Manifold b2CollideChainSegmentAndPolygon(ref B2ChainSegment segmentA, in B2Transform xfA, ref B2Polygon polygonB,
B2Transform xfB, ref B2SimplexCache cache)
{
B2Manifold manifold = new B2Manifold();
Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET/B2PrismaticJoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ internal static void b2SolvePrismaticJoint(B2JointSim @base, B2StepContext conte
}
#endif

internal static void b2DrawPrismaticJoint(B2DebugDraw draw, B2JointSim @base, B2Transform transformA, B2Transform transformB, float drawScale)
internal static void b2DrawPrismaticJoint(B2DebugDraw draw, B2JointSim @base, in B2Transform transformA, in B2Transform transformB, float drawScale)
{
B2_ASSERT(@base.type == B2JointType.b2_prismaticJoint);

Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET/B2RevoluteJoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ internal static void b2SolveRevoluteJoint(B2JointSim @base, B2StepContext contex
}
#endif

internal static void b2DrawRevoluteJoint(B2DebugDraw draw, B2JointSim @base, B2Transform transformA, B2Transform transformB, float drawScale)
internal static void b2DrawRevoluteJoint(B2DebugDraw draw, B2JointSim @base, in B2Transform transformA, in B2Transform transformB, float drawScale)
{
B2_ASSERT(@base.type == B2JointType.b2_revoluteJoint);

Expand Down
10 changes: 5 additions & 5 deletions src/Box2D.NET/B2Shapes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ internal static B2ChainShape b2GetChainShape(B2World world, B2ChainId chainId)
return chain;
}

internal static void b2UpdateShapeAABBs(B2Shape shape, B2Transform transform, B2BodyType proxyType)
internal static void b2UpdateShapeAABBs(B2Shape shape, in B2Transform transform, B2BodyType proxyType)
{
// Compute a bounding box with a speculative margin
float speculativeDistance = B2_SPECULATIVE_DISTANCE;
Expand Down Expand Up @@ -836,7 +836,7 @@ internal static B2ShapeExtent b2ComputeShapeExtent(B2Shape shape, B2Vec2 localCe
return extent;
}

internal static B2CastOutput b2RayCastShape(in B2RayCastInput input, B2Shape shape, B2Transform transform)
internal static B2CastOutput b2RayCastShape(in B2RayCastInput input, B2Shape shape, in B2Transform transform)
{
B2RayCastInput localInput = input;
localInput.origin = b2InvTransformPoint(transform, input.origin);
Expand Down Expand Up @@ -869,7 +869,7 @@ internal static B2CastOutput b2RayCastShape(in B2RayCastInput input, B2Shape sha
return output;
}

internal static B2CastOutput b2ShapeCastShape(in B2ShapeCastInput input, B2Shape shape, B2Transform transform)
internal static B2CastOutput b2ShapeCastShape(in B2ShapeCastInput input, B2Shape shape, in B2Transform transform)
{
B2CastOutput output = new B2CastOutput();

Expand Down Expand Up @@ -933,7 +933,7 @@ internal static B2CastOutput b2ShapeCastShape(in B2ShapeCastInput input, B2Shape
return output;
}

internal static B2PlaneResult b2CollideMover(in B2Capsule mover, B2Shape shape, B2Transform transform)
internal static B2PlaneResult b2CollideMover(in B2Capsule mover, B2Shape shape, in B2Transform transform)
{
B2Capsule localMover = new B2Capsule();
localMover.center1 = b2InvTransformPoint(transform, mover.center1);
Expand Down Expand Up @@ -972,7 +972,7 @@ internal static B2PlaneResult b2CollideMover(in B2Capsule mover, B2Shape shape,
}


public static void b2CreateShapeProxy(B2Shape shape, B2BroadPhase bp, B2BodyType type, B2Transform transform, bool forcePairCreation)
public static void b2CreateShapeProxy(B2Shape shape, B2BroadPhase bp, B2BodyType type, in B2Transform transform, bool forcePairCreation)
{
B2_ASSERT(shape.proxyKey == B2_NULL_INDEX);

Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET/B2WeldJoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ internal static void b2DumpWeldJoint()
}
#endif

internal static void b2DrawWeldJoint(B2DebugDraw draw, B2JointSim @base, B2Transform transformA, B2Transform transformB, float drawScale)
internal static void b2DrawWeldJoint(B2DebugDraw draw, B2JointSim @base, in B2Transform transformA, in B2Transform transformB, float drawScale)
{
B2_ASSERT(@base.type == B2JointType.b2_weldJoint);

Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET/B2WheelJoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ void b2WheelJoint_Dump()
}
#endif

internal static void b2DrawWheelJoint(B2DebugDraw draw, B2JointSim @base, B2Transform transformA, B2Transform transformB, float drawScale)
internal static void b2DrawWheelJoint(B2DebugDraw draw, B2JointSim @base, in B2Transform transformA, in B2Transform transformB, float drawScale)
{
B2_ASSERT(@base.type == B2JointType.b2_wheelJoint);

Expand Down
Loading