diff --git a/src/Box2D.NET.Samples/Samples/Collisions/TimeOfImpact.cs b/src/Box2D.NET.Samples/Samples/Collisions/TimeOfImpact.cs index 344fac6..8d9f0bd 100644 --- a/src/Box2D.NET.Samples/Samples/Collisions/TimeOfImpact.cs +++ b/src/Box2D.NET.Samples/Samples/Collisions/TimeOfImpact.cs @@ -66,7 +66,7 @@ public override void Step() _input.sweepB = _sweepB; _input.maxFraction = 1.0f; - _output = b2TimeOfImpact(ref _input); + _output = b2TimeOfImpact(_input); } public override void Draw() diff --git a/src/Box2D.NET/B2Distances.cs b/src/Box2D.NET/B2Distances.cs index dbc1a88..a1c3a25 100644 --- a/src/Box2D.NET/B2Distances.cs +++ b/src/Box2D.NET/B2Distances.cs @@ -967,7 +967,7 @@ b2CastOutput b2ShapeCastMerged( const b2ShapeCastPairInput* input, b2ShapeCastDa } #endif - public static B2SeparationFunction b2MakeSeparationFunction(ref B2SimplexCache cache, ref B2ShapeProxy proxyA, ref B2Sweep sweepA, ref B2ShapeProxy proxyB, ref B2Sweep sweepB, float t1) + public static B2SeparationFunction b2MakeSeparationFunction(ref B2SimplexCache cache, in B2ShapeProxy proxyA, in B2Sweep sweepA, in B2ShapeProxy proxyB, in B2Sweep sweepB, float t1) { B2SeparationFunction f = new B2SeparationFunction(); @@ -1170,7 +1170,7 @@ static float b2EvaluateSeparation(B2SeparationFunction f, int indexA, int indexB /// again. // CCD via the local separating axis method. This seeks progression // by computing the largest time at which separation is maintained. - public static B2TOIOutput b2TimeOfImpact(ref B2TOIInput input) + public static B2TOIOutput b2TimeOfImpact(in B2TOIInput input) { #if B2_SNOOP_TOI_COUNTERS ulong ticks = b2GetTicks(); @@ -1181,8 +1181,8 @@ public static B2TOIOutput b2TimeOfImpact(ref B2TOIInput input) output.state = B2TOIState.b2_toiStateUnknown; output.fraction = input.maxFraction; - B2Sweep sweepA = input.sweepA; - B2Sweep sweepB = input.sweepB; + ref readonly B2Sweep sweepA = ref input.sweepA; + ref readonly B2Sweep sweepB = ref input.sweepB; B2_ASSERT(b2IsNormalizedRot(sweepA.q1) && b2IsNormalizedRot(sweepA.q2)); B2_ASSERT(b2IsNormalizedRot(sweepB.q1) && b2IsNormalizedRot(sweepB.q2)); @@ -1190,8 +1190,8 @@ public static B2TOIOutput b2TimeOfImpact(ref B2TOIInput input) // c1 can be at the origin yet the points are far away // B2Vec2 origin = b2Add(sweepA.c1, input.proxyA.points[0]); - ref B2ShapeProxy proxyA = ref input.proxyA; - ref B2ShapeProxy proxyB = ref input.proxyB; + ref readonly B2ShapeProxy proxyA = ref input.proxyA; + ref readonly B2ShapeProxy proxyB = ref input.proxyB; float tMax = input.maxFraction; @@ -1273,7 +1273,7 @@ public static B2TOIOutput b2TimeOfImpact(ref B2TOIInput input) } // Initialize the separating axis. - B2SeparationFunction fcn = b2MakeSeparationFunction(ref cache, ref proxyA, ref sweepA, ref proxyB, ref sweepB, t1); + B2SeparationFunction fcn = b2MakeSeparationFunction(ref cache, proxyA, sweepA, proxyB, sweepB, t1); #if FALSE // Dump the curve seen by the root finder { diff --git a/src/Box2D.NET/B2Solvers.cs b/src/Box2D.NET/B2Solvers.cs index 63e4247..1756c4b 100644 --- a/src/Box2D.NET/B2Solvers.cs +++ b/src/Box2D.NET/B2Solvers.cs @@ -434,7 +434,7 @@ internal static bool b2ContinuousQueryCallback(int proxyId, ulong userData, ref input.sweepB = continuousContext.sweep; input.maxFraction = continuousContext.fraction; - B2TOIOutput output = b2TimeOfImpact(ref input); + B2TOIOutput output = b2TimeOfImpact(input); if (isSensor) { // Only accept a sensor hit that is sooner than the current solid hit. @@ -469,7 +469,7 @@ internal static bool b2ContinuousQueryCallback(int proxyId, ulong userData, ref B2ShapeExtent extent = b2ComputeShapeExtent(fastShape, centroid); float radius = B2_CORE_FRACTION * extent.minExtent; input.proxyB = b2MakeProxy(centroid, 1, radius); - output = b2TimeOfImpact(ref input); + output = b2TimeOfImpact(input); if (0.0f < output.fraction && output.fraction < continuousContext.fraction) { hitFraction = output.fraction; diff --git a/test/Box2D.NET.Test/B2DistanceTest.cs b/test/Box2D.NET.Test/B2DistanceTest.cs index cc8c796..82bd12e 100644 --- a/test/Box2D.NET.Test/B2DistanceTest.cs +++ b/test/Box2D.NET.Test/B2DistanceTest.cs @@ -113,7 +113,7 @@ public void TimeOfImpactTest() input.sweepB = new B2Sweep(b2Vec2_zero, b2Vec2_zero, new B2Vec2(-2.0f, 0.0f), b2Rot_identity, b2Rot_identity); input.maxFraction = 1.0f; - B2TOIOutput output = b2TimeOfImpact(ref input); + B2TOIOutput output = b2TimeOfImpact(input); Assert.That(output.state, Is.EqualTo(B2TOIState.b2_toiStateHit)); Assert.That(output.fraction - 0.5f, Is.LessThan(0.005f));