Skip to content

Commit feb985d

Browse files
committed
refactor: b2CreateChain API to use 'in' parameter
- Changed `b2CreateChain` signature to accept `B2ChainDef` as `in` parameter instead of `ref`. - Updated internal implementation to use `ref readonly` for accessing `materials` and `points` from the definition, ensuring efficiency and safety. - Updated all call sites in Samples and Benchmarks to remove the `ref` keyword.
1 parent 97d13a6 commit feb985d

18 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/Box2D.NET.Samples/Samples/Characters/Mover.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public Mover(SampleContext context) : base(context)
142142
chainDef.count = count;
143143
chainDef.isLoop = true;
144144

145-
b2CreateChain(groundId1, ref chainDef);
145+
b2CreateChain(groundId1, chainDef);
146146
}
147147

148148
B2BodyId groundId2;
@@ -172,7 +172,7 @@ public Mover(SampleContext context) : base(context)
172172
chainDef.count = count;
173173
chainDef.isLoop = true;
174174

175-
b2CreateChain(groundId2, ref chainDef);
175+
b2CreateChain(groundId2, chainDef);
176176
}
177177

178178
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ void Create(int index)
229229
chainDef.points = points;
230230
chainDef.count = 4;
231231
chainDef.isLoop = true;
232-
b2CreateChain(m_bodyIds[m_bodyIndex], ref chainDef);
232+
b2CreateChain(m_bodyIds[m_bodyIndex], chainDef);
233233
}
234234

235235
m_bodyIndex = (m_bodyIndex + 1) % e_maxCount;

src/Box2D.NET.Samples/Samples/Continuous/ChainDrop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public ChainDrop(SampleContext context) : base(context)
4848
chainDef.count = 4;
4949
chainDef.isLoop = true;
5050

51-
b2CreateChain(groundId, ref chainDef);
51+
b2CreateChain(groundId, chainDef);
5252

5353
m_bodyId = b2_nullBodyId;
5454
m_yOffset = -0.1f;

src/Box2D.NET.Samples/Samples/Continuous/ChainSlide.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public ChainSlide(SampleContext context) : base(context)
6666
chainDef.count = count;
6767
chainDef.isLoop = true;
6868

69-
b2CreateChain(groundId, ref chainDef);
69+
b2CreateChain(groundId, chainDef);
7070
}
7171

7272
{

src/Box2D.NET.Samples/Samples/Continuous/GhostBumps.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void CreateScene()
113113
chainDef.materials = new[] { material };
114114
chainDef.materialCount = 1;
115115

116-
b2CreateChain(m_groundId, ref chainDef);
116+
b2CreateChain(m_groundId, chainDef);
117117
}
118118
else
119119
{

src/Box2D.NET.Samples/Samples/Continuous/Pinball.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public Pinball(SampleContext context) : base(context)
5757
chainDef.points = vs;
5858
chainDef.count = 5;
5959
chainDef.isLoop = true;
60-
b2CreateChain(groundId, ref chainDef);
60+
b2CreateChain(groundId, chainDef);
6161
}
6262

6363
// Flippers

src/Box2D.NET.Samples/Samples/Events/ContactEvent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public ContactEvent(SampleContext context) : base(context)
6161
chainDef.points = points;
6262
chainDef.isLoop = true;
6363

64-
b2CreateChain(groundId, ref chainDef);
64+
b2CreateChain(groundId, chainDef);
6565
}
6666

6767
// Player

src/Box2D.NET.Samples/Samples/Events/FootSensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public FootSensor(SampleContext context) : base(context)
6767
chainDef.isLoop = false;
6868
chainDef.enableSensorEvents = true;
6969

70-
b2CreateChain(groundId, ref chainDef);
70+
b2CreateChain(groundId, chainDef);
7171
}
7272

7373
{

src/Box2D.NET.Samples/Samples/Events/PersistentContact.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public PersistentContact(SampleContext context) : base(context)
5151
chainDef.count = 22;
5252
chainDef.isLoop = true;
5353

54-
b2CreateChain(groundId, ref chainDef);
54+
b2CreateChain(groundId, chainDef);
5555
}
5656

5757
{

src/Box2D.NET.Samples/Samples/Events/SensorFunnel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public SensorFunnel(SampleContext context) : base(context)
114114
chainDef.isLoop = true;
115115
chainDef.materials = [material];
116116
chainDef.materialCount = 1;
117-
b2CreateChain(groundId, ref chainDef);
117+
b2CreateChain(groundId, chainDef);
118118

119119
float sign = 1.0f;
120120
float y = 14.0f;

0 commit comments

Comments
 (0)