Skip to content

Commit b4a0690

Browse files
committed
Minor fixes to docs of new features
1 parent 6471d3d commit b4a0690

File tree

5 files changed

+53
-26
lines changed

5 files changed

+53
-26
lines changed

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 - 2025, Victor Blomqvist - [email protected], MIT License
2020

2121
This release is based on the latest Pymunk release (7.0.0),
22-
using Munk2D 1.0 rev 9c3026aded65c439d64d1cb4fa537544fa8a3989.
22+
using Munk2D 1.0 rev fc7ecea12aad22df30f89f7cfc0b6aa271f864ee.
2323

2424

2525
Installation

pymunk/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
"moment_for_poly",
5555
"moment_for_segment",
5656
"moment_for_box",
57+
"area_for_circle",
58+
"area_for_segment",
59+
"area_for_poly",
60+
"empty_callback",
5761
"SegmentQueryInfo",
5862
"ContactPoint",
5963
"ContactPointSet",

pymunk/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
cp = _chipmunk_cffi.lib
3333
ffi = _chipmunk_cffi.ffi
3434

35-
version = "7.0.0"
35+
version = "1.0.0"
3636

3737
chipmunk_version = "%s-%s" % (
3838
ffi.string(cp.cpVersionString).decode("utf-8"),
39-
"9c3026aded65c439d64d1cb4fa537544fa8a3989",
39+
"fc7ecea12aad22df30f89f7cfc0b6aa271f864ee",
4040
)

pymunk/arbiter.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@ def __init__(self, _arbiter: ffi.CData, space: "Space") -> None:
4343
def process_collision(self) -> bool:
4444
"""Decides if the collision should be processed or rejected.
4545
46-
Set this during a begin() or pre_solve() callback to override
47-
the default (True) value.
48-
49-
Set this to true to process the collision normally or
50-
false to cause pymunk to ignore the collision entirely. If you set it to
51-
false from a `begin` callback, the `pre_solve` and `post_solve` callbacks will never be run,
52-
but you will still recieve a separate event when the shapes stop
53-
overlapping.
46+
Set this during a `begin()` or `pre_solve()` callback to override
47+
the default (`True`) value.
48+
49+
Set this to `true` to process the collision normally or
50+
`false` to cause Pymunk to ignore the collision entirely. Note that
51+
while `post_solve` might be skipped if this is `false`, `separate`
52+
will always be called when the shapes stop overlapping.
53+
54+
.. note::
55+
No collision will be processed for a sensor Shape, or a Shape
56+
attached to a STATIC or KINEMATIC Body.
5457
5558
"""
5659
return lib.cpArbiterGetProcessCollision(self._arbiter)

pymunk/space.py

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -596,28 +596,48 @@ def on_collision(
596596
separate: Optional[_CollisionCallback] = None,
597597
data: Any = None,
598598
) -> None:
599-
"""Set callbacks that will be called during the 4 phases of collision handling.
600-
601-
Use None to indicate any collision_type.
602-
603-
Fill the desired collision callback functions, for details see the
604-
:py:class:`CollisionHandler` object.
599+
"""Set callbacks that will be called during the 4 phases of collision
600+
handling.
605601
606602
Whenever shapes with collision types (:py:attr:`Shape.collision_type`)
607-
a and b collide, this handler will be used to process the collision
608-
events. If no handler is set, the default is to process collision as
603+
a and b collide, the callback will be used to process the collision
604+
events. If no callback is set, the default is to process collision
609605
normally.
610606
611-
If multiple handlers match the collision, the order will be that the
612-
most specific handler is called first.
607+
Its possible to pass in None for one or both of the collision types.
608+
None matches any collision type on a Shape.
613609
614-
Note that if a handler already exist for the a,b pair, that existing
615-
handler will be returned.
610+
If you call this multiple times with the same combination of
611+
collision_type_a and collision_type_b, then the last call will
612+
overwrite the earlier.
613+
614+
If multiple callbacks match the collision, the order will be that the
615+
most specific handler is called first.
616616
617-
:param int collision_type_a: Collision type a
618-
:param int collision_type_b: Collision type b
617+
Callback phases:
618+
619+
- **begin**: Two shapes just started touching for the first time
620+
this step.
621+
- **pre_solve**: Two shapes are touching during this step, before
622+
collision resolution. You may override collision values using
623+
Arbiter.friction, Arbiter.elasticity or Arbiter.surfaceVelocity
624+
to provide custom friction, elasticity, or surface velocity
625+
values. See Arbiter for more info.
626+
- **post_solve**: Two shapes are touching and their collision response
627+
has been processed. You can retrieve the collision impulse or
628+
kinetic energy at this time if you want to use it to calculate
629+
sound volumes or damage amounts. See Arbiter for more info.
630+
- **separate**: Two shapes have just stopped touching for the
631+
first time this step. To ensure that begin()/separate() are
632+
always called in balanced pairs, it will also be called when
633+
removing a shape while its in contact with something or when
634+
de-allocating the space.
635+
636+
From each callback you can set process_collision on the Arbiter,
637+
which decides if the collision should be processed or not.
638+
639+
data will be passed in to the callback function unchanged.
619640
620-
:rtype: :py:class:`CollisionHandler`
621641
"""
622642
# key = min(collision_type_a, collision_type_b), max(
623643
# collision_type_a, collision_type_b

0 commit comments

Comments
 (0)