Skip to content

Commit d5fad3e

Browse files
committed
refactor: b2GetSweepTransform(ref B2Sweep sweep, -> b2GetSweepTransform(in B2Sweep sweep
1 parent e83b8c0 commit d5fad3e

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/Box2D.NET.Samples/Samples/Collisions/TimeOfImpact.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public override void Draw()
8181
B2Vec2[] vertices = new B2Vec2[B2_MAX_POLYGON_VERTICES];
8282

8383
// Draw A
84-
B2Transform transformA = b2GetSweepTransform(ref _sweepA, 0.0f);
84+
B2Transform transformA = b2GetSweepTransform(_sweepA, 0.0f);
8585
for (int i = 0; i < m_countA; ++i)
8686
{
8787
vertices[i] = b2TransformPoint(transformA, m_verticesA[i]);
@@ -90,7 +90,7 @@ public override void Draw()
9090
DrawPolygon(m_draw, vertices, m_countA, B2HexColor.b2_colorGray);
9191

9292
// Draw B at t = 0
93-
B2Transform transformB = b2GetSweepTransform(ref _sweepB, 0.0f);
93+
B2Transform transformB = b2GetSweepTransform(_sweepB, 0.0f);
9494
for (int i = 0; i < m_countB; ++i)
9595
{
9696
vertices[i] = b2TransformPoint(transformB, m_verticesB[i]);
@@ -100,7 +100,7 @@ public override void Draw()
100100
// m_context.g_draw.DrawPolygon( vertices, m_countB, b2HexColor.b2_colorGreen );
101101

102102
// Draw B at t = hit_time
103-
transformB = b2GetSweepTransform(ref _sweepB, _output.fraction);
103+
transformB = b2GetSweepTransform(_sweepB, _output.fraction);
104104
for (int i = 0; i < m_countB; ++i)
105105
{
106106
vertices[i] = b2TransformPoint(transformB, m_verticesB[i]);
@@ -109,7 +109,7 @@ public override void Draw()
109109
DrawPolygon(m_draw, vertices, m_countB, B2HexColor.b2_colorOrange);
110110

111111
// Draw B at t = 1
112-
transformB = b2GetSweepTransform(ref _sweepB, 1.0f);
112+
transformB = b2GetSweepTransform(_sweepB, 1.0f);
113113
for (int i = 0; i < m_countB; ++i)
114114
{
115115
vertices[i] = b2TransformPoint(transformB, m_verticesB[i]);
@@ -123,8 +123,8 @@ public override void Draw()
123123
B2DistanceInput distanceInput = new B2DistanceInput();
124124
distanceInput.proxyA = _input.proxyA;
125125
distanceInput.proxyB = _input.proxyB;
126-
distanceInput.transformA = b2GetSweepTransform(ref _sweepA, _output.fraction);
127-
distanceInput.transformB = b2GetSweepTransform(ref _sweepB, _output.fraction);
126+
distanceInput.transformA = b2GetSweepTransform(_sweepA, _output.fraction);
127+
distanceInput.transformB = b2GetSweepTransform(_sweepB, _output.fraction);
128128
distanceInput.useRadii = false;
129129
B2SimplexCache cache = new B2SimplexCache();
130130
B2DistanceOutput distanceOutput = b2ShapeDistance(ref distanceInput, ref cache, null, 0);

src/Box2D.NET/B2Distances.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static class B2Distances
2525
#endif
2626

2727
/// Evaluate the transform sweep at a specific time.
28-
public static B2Transform b2GetSweepTransform(ref B2Sweep sweep, float time)
28+
public static B2Transform b2GetSweepTransform(in B2Sweep sweep, float time)
2929
{
3030
// https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/
3131
B2Transform xf;
@@ -139,7 +139,7 @@ public static B2ShapeProxy b2MakeProxy(ReadOnlySpan<B2Vec2> points, int count, f
139139
}
140140

141141
/// Make a proxy with a transform. This is a deep copy of the points.
142-
public static B2ShapeProxy b2MakeOffsetProxy(ReadOnlySpan<B2Vec2> points, int count, float radius, B2Vec2 position, B2Rot rotation)
142+
public static B2ShapeProxy b2MakeOffsetProxy(ReadOnlySpan<B2Vec2> points, int count, float radius, B2Vec2 position, in B2Rot rotation)
143143
{
144144
count = b2MinInt(count, B2_MAX_POLYGON_VERTICES);
145145
B2Transform transform = new B2Transform(position, rotation);
@@ -980,8 +980,8 @@ public static B2SeparationFunction b2MakeSeparationFunction(ref B2SimplexCache c
980980
f.sweepA = sweepA;
981981
f.sweepB = sweepB;
982982

983-
B2Transform xfA = b2GetSweepTransform(ref sweepA, t1);
984-
B2Transform xfB = b2GetSweepTransform(ref sweepB, t1);
983+
B2Transform xfA = b2GetSweepTransform(sweepA, t1);
984+
B2Transform xfB = b2GetSweepTransform(sweepB, t1);
985985

986986
if (count == 1)
987987
{
@@ -1049,8 +1049,8 @@ public static B2SeparationFunction b2MakeSeparationFunction(ref B2SimplexCache c
10491049

10501050
internal static float b2FindMinSeparation(ref B2SeparationFunction f, ref int indexA, ref int indexB, float t)
10511051
{
1052-
B2Transform xfA = b2GetSweepTransform(ref f.sweepA, t);
1053-
B2Transform xfB = b2GetSweepTransform(ref f.sweepB, t);
1052+
B2Transform xfA = b2GetSweepTransform(f.sweepA, t);
1053+
B2Transform xfB = b2GetSweepTransform(f.sweepB, t);
10541054

10551055
switch (f.type)
10561056
{
@@ -1117,8 +1117,8 @@ internal static float b2FindMinSeparation(ref B2SeparationFunction f, ref int in
11171117
//
11181118
static float b2EvaluateSeparation(B2SeparationFunction f, int indexA, int indexB, float t)
11191119
{
1120-
B2Transform xfA = b2GetSweepTransform(ref f.sweepA, t);
1121-
B2Transform xfB = b2GetSweepTransform(ref f.sweepB, t);
1120+
B2Transform xfA = b2GetSweepTransform(f.sweepA, t);
1121+
B2Transform xfB = b2GetSweepTransform(f.sweepB, t);
11221122

11231123
switch (f.type)
11241124
{
@@ -1215,8 +1215,8 @@ public static B2TOIOutput b2TimeOfImpact(ref B2TOIInput input)
12151215
// This loop terminates when an axis is repeated (no progress is made).
12161216
for (;;)
12171217
{
1218-
B2Transform xfA = b2GetSweepTransform(ref sweepA, t1);
1219-
B2Transform xfB = b2GetSweepTransform(ref sweepB, t1);
1218+
B2Transform xfA = b2GetSweepTransform(sweepA, t1);
1219+
B2Transform xfB = b2GetSweepTransform(sweepB, t1);
12201220

12211221
// Get the distance between shapes. We can also use the results
12221222
// to get a separating axis.

0 commit comments

Comments
 (0)