Skip to content

Commit 87ec303

Browse files
committed
[upstream] Cast initial overlap (box2d #933)
final
1 parent 8e7a0fa commit 87ec303

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,10 @@ void DrawManifold(ref B2Manifold manifold)
256256
}
257257
}
258258

259-
public override void Step()
259+
public override void Draw(Settings settings)
260260
{
261+
base.Draw(settings);
262+
261263
B2HexColor color1 = B2HexColor.b2_colorYellow;
262264
B2HexColor color2 = B2HexColor.b2_colorMagenta;
263265

src/Box2D.NET.Samples/Samples/Joints/RevoluteJoint.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class RevoluteJoint : Sample
2727
private float m_hertz;
2828
private float m_dampingRatio;
2929
private float m_targetDegrees;
30-
private float m_targetAngle;
3130
private bool m_enableSpring;
3231
private bool m_enableMotor;
3332
private bool m_enableLimit;
@@ -62,7 +61,7 @@ public RevoluteJoint(SampleContext context) : base(context)
6261
m_enableMotor = false;
6362
m_hertz = 2.0f;
6463
m_dampingRatio = 0.5f;
65-
m_targetAngle = 45.0f;
64+
m_targetDegrees = 45.0f;
6665
m_motorSpeed = 1.0f;
6766
m_motorTorque = 1000.0f;
6867

@@ -198,12 +197,12 @@ public override void UpdateGui()
198197
b2RevoluteJoint_SetSpringDampingRatio(m_jointId1, m_dampingRatio);
199198
b2Joint_WakeBodies(m_jointId1);
200199
}
201-
202-
203-
if ( ImGui.SliderFloat( "Degrees", ref m_targetDegrees, -180.0f, 180.0f, "%.0f" ) )
200+
201+
202+
if (ImGui.SliderFloat("Degrees", ref m_targetDegrees, -180.0f, 180.0f, "%.0f"))
204203
{
205-
b2RevoluteJoint_SetTargetAngle( m_jointId1, B2_PI * m_targetDegrees / 180.0f );
206-
b2Joint_WakeBodies( m_jointId1 );
204+
b2RevoluteJoint_SetTargetAngle(m_jointId1, B2_PI * m_targetDegrees / 180.0f);
205+
b2Joint_WakeBodies(m_jointId1);
207206
}
208207
}
209208

@@ -213,17 +212,16 @@ public override void UpdateGui()
213212
public override void Draw(Settings settings)
214213
{
215214
base.Draw(settings);
216-
215+
217216
float angle1 = b2RevoluteJoint_GetAngle(m_jointId1);
218217
DrawTextLine($"Angle (Deg) 1 = {angle1:F1}");
219-
218+
220219

221220
float torque1 = b2RevoluteJoint_GetMotorTorque(m_jointId1);
222221
DrawTextLine($"Motor Torque 1 = {torque1:F1}");
223-
222+
224223

225224
float torque2 = b2RevoluteJoint_GetMotorTorque(m_jointId2);
226225
DrawTextLine($"Motor Torque 2 = {torque2:F1}");
227-
228226
}
229227
}

src/Box2D.NET.Shared/Human.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public void Clear()
2525

2626
scale = 0.0f;
2727
isSpawned = false;
28+
frictionTorque = 0.0f;
29+
originalScale = 0.0f;
2830
}
2931
}
3032
}

src/Box2D.NET/B2Distances.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ public static B2CastOutput b2ShapeCast(ref B2ShapeCastPairInput input)
734734
if (denominator >= 0.0f)
735735
{
736736
// Miss
737-
output.fraction = 1.0f;
738737
return output;
739738
}
740739

src/Box2D.NET/B2Shapes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace Box2D.NET
2424
{
2525
public static class B2Shapes
2626
{
27+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2728
public static float b2GetShapeRadius(B2Shape shape)
2829
{
2930
switch (shape.type)

test/Box2D.NET.Test/B2MathTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public void MathTest()
2929
Assert.That(r.s - s, Is.LessThan(0.002f));
3030

3131
float xn = b2UnwindAngle(angle);
32-
3332
Assert.That(-B2_PI <= xn && xn <= B2_PI, Is.True);
3433

3534
float a = b2Atan2(s, c);

0 commit comments

Comments
 (0)