Skip to content

Commit 8f77c65

Browse files
committed
Fix SlideJoint issue when updating body_type #250
1 parent 538b7fa commit 8f77c65

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

Chipmunk2D

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ the Pymunk webpage for some examples.
1919
2007 - 2024, Victor Blomqvist - vb@viblo.se, MIT License
2020

2121
This release is based on the latest Pymunk release (6.8.1),
22-
using Chipmunk2D 7 rev 7a29dcfa49931f26632f3019582f289ba811a2b9.
22+
using Chipmunk2D 7 rev dfc2fb8ca023ce6376fa2cf4a7f91c92ee08a970.
2323

2424

2525
Installation

pymunk/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@
3636

3737
chipmunk_version = "%s-%s" % (
3838
ffi.string(cp.cpVersionString).decode("utf-8"),
39-
"7a29dcfa49931f26632f3019582f289ba811a2b9",
39+
"dfc2fb8ca023ce6376fa2cf4a7f91c92ee08a970",
4040
)

pymunk/tests/test_body.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,27 @@ def test_shapes(self) -> None:
271271
self.assertTrue(s1 not in s.static_body.shapes)
272272

273273
def test_body_type_update(self) -> None:
274+
274275
s = p.Space()
275276
b1 = p.Body(body_type=p.Body.STATIC)
276277
b1.position = 3, 4
277278
b2 = p.Body(body_type=p.Body.STATIC)
278-
c = p.PinJoint(b1, b2, (0, 0), (1, 1))
279-
s.add(b1, b2, c)
279+
280+
# Test with each type of joint
281+
joints = [
282+
p.DampedRotarySpring(b1, b2, 0, 10, 0.1),
283+
p.DampedSpring(b1, b2, (0, 0), (1, 1), 1, 0.1, 0.1),
284+
p.GearJoint(b1, b2, 1, 2),
285+
p.GrooveJoint(b1, b2, (0, 0), (1, 2), (0, 0)),
286+
p.PinJoint(b1, b2, (0, 0), (1, 1)),
287+
p.PivotJoint(b1, b2, (0, 0), (0, 0)),
288+
p.RatchetJoint(b1, b2, 0.1, 0.2),
289+
p.RotaryLimitJoint(b1, b2, 0, 1),
290+
p.SimpleMotor(b1, b2, 1),
291+
p.SlideJoint(b1, b2, (0, 0), (0, 0), 0, 10),
292+
]
293+
294+
s.add(b1, b2, *joints)
280295
s.step(1)
281296

282297
b1.body_type = p.Body.DYNAMIC
@@ -290,9 +305,9 @@ def test_body_type_update(self) -> None:
290305
s.step(1)
291306

292307
self.assertEqual(b1.position, (3, 4))
293-
self.assertAlmostEqual(b1.velocity.x, 0)
294-
self.assertAlmostEqual(b1.velocity.y, 0)
295-
self.assertAlmostEqual(b1.angular_velocity, 0)
308+
self.assertAlmostEqual(b1.velocity.x, -2.994608977)
309+
self.assertAlmostEqual(b1.velocity.y, -3.992811970)
310+
self.assertAlmostEqual(b1.angular_velocity, 1)
296311

297312
def test_pickle(self) -> None:
298313
b = p.Body(1, 2)

0 commit comments

Comments
 (0)