diff --git a/src/Box2D.NET.Samples/Graphics/Draws.cs b/src/Box2D.NET.Samples/Graphics/Draws.cs index 7d1983da..d53c6367 100644 --- a/src/Box2D.NET.Samples/Graphics/Draws.cs +++ b/src/Box2D.NET.Samples/Graphics/Draws.cs @@ -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; @@ -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) diff --git a/src/Box2D.NET.Samples/Graphics/SolidCircles.cs b/src/Box2D.NET.Samples/Graphics/SolidCircles.cs index 89025616..fb2f536f 100644 --- a/src/Box2D.NET.Samples/Graphics/SolidCircles.cs +++ b/src/Box2D.NET.Samples/Graphics/SolidCircles.cs @@ -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)); diff --git a/src/Box2D.NET.Samples/Primitives/CapsuleData.cs b/src/Box2D.NET.Samples/Primitives/CapsuleData.cs index a54a9c62..53d43e4f 100644 --- a/src/Box2D.NET.Samples/Primitives/CapsuleData.cs +++ b/src/Box2D.NET.Samples/Primitives/CapsuleData.cs @@ -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; diff --git a/src/Box2D.NET.Samples/Primitives/SolidCircleData.cs b/src/Box2D.NET.Samples/Primitives/SolidCircleData.cs index f17d64e5..b05dcf6e 100644 --- a/src/Box2D.NET.Samples/Primitives/SolidCircleData.cs +++ b/src/Box2D.NET.Samples/Primitives/SolidCircleData.cs @@ -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; diff --git a/src/Box2D.NET.Samples/Samples/Collisions/ShapeCast.cs b/src/Box2D.NET.Samples/Samples/Collisions/ShapeCast.cs index 0c910bef..379cc1b3 100644 --- a/src/Box2D.NET.Samples/Samples/Collisions/ShapeCast.cs +++ b/src/Box2D.NET.Samples/Samples/Collisions/ShapeCast.cs @@ -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) { diff --git a/src/Box2D.NET.Samples/Samples/Collisions/ShapeDistance.cs b/src/Box2D.NET.Samples/Samples/Collisions/ShapeDistance.cs index feb9ccc7..c80e0df8 100644 --- a/src/Box2D.NET.Samples/Samples/Collisions/ShapeDistance.cs +++ b/src/Box2D.NET.Samples/Samples/Collisions/ShapeDistance.cs @@ -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) { @@ -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) { diff --git a/src/Box2D.NET.Samples/Samples/Issues/ShapeCastChain.cs b/src/Box2D.NET.Samples/Samples/Issues/ShapeCastChain.cs index 7ab5151d..0d6d8996 100644 --- a/src/Box2D.NET.Samples/Samples/Issues/ShapeCastChain.cs +++ b/src/Box2D.NET.Samples/Samples/Issues/ShapeCastChain.cs @@ -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); @@ -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; diff --git a/src/Box2D.NET/B2DistanceJoints.cs b/src/Box2D.NET/B2DistanceJoints.cs index f40c0620..157efd4c 100644 --- a/src/Box2D.NET/B2DistanceJoints.cs +++ b/src/Box2D.NET/B2DistanceJoints.cs @@ -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); diff --git a/src/Box2D.NET/B2Geometries.cs b/src/Box2D.NET/B2Geometries.cs index 2a710710..4b903324 100644 --- a/src/Box2D.NET/B2Geometries.cs +++ b/src/Box2D.NET/B2Geometries.cs @@ -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); diff --git a/src/Box2D.NET/B2Joints.cs b/src/Box2D.NET/B2Joints.cs index 709f9b58..699e0369 100644 --- a/src/Box2D.NET/B2Joints.cs +++ b/src/Box2D.NET/B2Joints.cs @@ -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)); @@ -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)); diff --git a/src/Box2D.NET/B2Manifolds.cs b/src/Box2D.NET/B2Manifolds.cs index 15687d66..9c83aba4 100644 --- a/src/Box2D.NET/B2Manifolds.cs +++ b/src/Box2D.NET/B2Manifolds.cs @@ -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(); @@ -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(); @@ -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; @@ -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; @@ -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); @@ -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; @@ -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(); @@ -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); @@ -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(); diff --git a/src/Box2D.NET/B2PrismaticJoints.cs b/src/Box2D.NET/B2PrismaticJoints.cs index 7f589938..5a82f7cc 100644 --- a/src/Box2D.NET/B2PrismaticJoints.cs +++ b/src/Box2D.NET/B2PrismaticJoints.cs @@ -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); diff --git a/src/Box2D.NET/B2RevoluteJoints.cs b/src/Box2D.NET/B2RevoluteJoints.cs index 392fb377..1a35d1e9 100644 --- a/src/Box2D.NET/B2RevoluteJoints.cs +++ b/src/Box2D.NET/B2RevoluteJoints.cs @@ -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); diff --git a/src/Box2D.NET/B2Shapes.cs b/src/Box2D.NET/B2Shapes.cs index bbb6aac4..6a136935 100644 --- a/src/Box2D.NET/B2Shapes.cs +++ b/src/Box2D.NET/B2Shapes.cs @@ -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; @@ -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); @@ -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(); @@ -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); @@ -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); diff --git a/src/Box2D.NET/B2WeldJoints.cs b/src/Box2D.NET/B2WeldJoints.cs index 600ebcf0..735bfba2 100644 --- a/src/Box2D.NET/B2WeldJoints.cs +++ b/src/Box2D.NET/B2WeldJoints.cs @@ -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); diff --git a/src/Box2D.NET/B2WheelJoints.cs b/src/Box2D.NET/B2WheelJoints.cs index 2664dfe0..fe5d176d 100644 --- a/src/Box2D.NET/B2WheelJoints.cs +++ b/src/Box2D.NET/B2WheelJoints.cs @@ -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);