Skip to content

Commit 509f322

Browse files
committed
Merge branch 'master' of github.com:viblo/pymunk
2 parents 9dabe76 + 8bcc643 commit 509f322

File tree

5 files changed

+106
-36
lines changed

5 files changed

+106
-36
lines changed

.github/workflows/wheels.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
os: [ubuntu-20.04, windows-2019, macos-11]
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
with:
1616
submodules: true
1717

@@ -21,7 +21,7 @@ jobs:
2121
python3 -c "import pathlib,glob;pathlib.Path('GITHUB_ENV').write_text('SDIST_PATH' + glob.glob('dist/*.tar.gz')[0])"
2222
2323
- name: Build wheels
24-
uses: pypa/[email protected].2
24+
uses: pypa/[email protected].5
2525
env:
2626
CIBW_BUILD:
2727
"cp37-* cp38-* cp39-* cp310-* cp311-* cp312-* pp39-* pp310-*"
@@ -32,40 +32,42 @@ jobs:
3232
package-dir: "$SDIST_PATH"
3333

3434
- name: Upload wheel artifacts
35-
uses: actions/upload-artifact@v3
35+
uses: actions/upload-artifact@v4
3636
if: ${{ github.ref == 'refs/heads/master'}}
3737
with:
38+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
3839
path: ./wheelhouse/*.whl
3940
retention-days: 7
4041

4142
- name: Upload sdist artifact
42-
uses: actions/upload-artifact@v3
43+
uses: actions/upload-artifact@v4
4344
if:
4445
${{ github.ref == 'refs/heads/master' && matrix.os == 'windows-2019'}}
4546
with:
47+
name: sdist-${{ matrix.os }}-${{ strategy.job-index }}
4648
path: ./dist/*.tar.gz
4749
retention-days: 7
4850

4951
build_wasm:
5052
name: Build wheels for wasm / emscripten
5153
runs-on: ubuntu-22.04
5254
steps:
53-
- uses: actions/checkout@v3
55+
- uses: actions/checkout@v4
5456
with:
5557
submodules: true
56-
- uses: actions/setup-python@v4
58+
- uses: actions/setup-python@v5
5759
with:
5860
python-version: "3.11.2"
5961
- run: |
6062
pip install pyodide-build>=0.23.3
6163
echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
62-
- uses: mymindstorm/setup-emsdk@v12
64+
- uses: mymindstorm/setup-emsdk@v14
6365
with:
6466
version: ${{ env.EMSCRIPTEN_VERSION }}
6567
- run: pyodide build
6668
env:
6769
PYMUNK_BUILD_SLIM: 1
68-
- uses: actions/upload-artifact@v3
70+
- uses: actions/upload-artifact@v4
6971
if: ${{ github.ref == 'refs/heads/master' }}
7072
with:
7173
path: ./dist/*.whl

TODO.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,17 @@ v6.x
3939
v7+ (all potentially breaking changes)
4040
---
4141
- Think about split between pymunk.util and pymunk modules
42+
43+
44+
Chipmunk improvements
45+
---------------------
4246
- Investigate the SPOOK solver, which could be much more stable than what is currently used. (but probably very difficult to switch to). https://github.com/viblo/pymunk/issues/216
4347
- Investigate "Affine Body Dynamics Fast, Stable & Intersection-free Simulation of Stiff Materials"
44-
48+
- optimize step function:
49+
- streamline build - benchmark
50+
- https://www.microsoft.com/en-us/research/wp-content/uploads/2016/12/ccds.pdf
51+
- collision detection:
52+
- r-tree https://www.sebastiansylvan.com/post/r-trees--adapting-out-of-core-techniques-to-modern-memory-architectures/
4553

4654
Typing a existing project - learnings
4755
-------------------------------------

docs/src/showcase.rst

+25-1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,30 @@ Pymunk has been used or referenced in a number of scientific papers.
260260

261261
List of papers which has used or mentioned Pymunk:
262262

263+
# Pan, Hainan, Bailiang Chen, Kaihong Huang, Junkai Ren, Chuang Cheng, Huimin Lu, and Hui Zhang.
264+
"Flipper Control Method for Tracked Robot Based on Deep Reinforcement Learning."
265+
Journal of System Simulation 36, no. 2 (2024): 405.
266+
267+
# Liu, Ziang, Genggeng Zhou, Jeff He, Tobia Marcucci, Li Fei-Fei, Jiajun Wu, and Yunzhu Li.
268+
"Model-Based Control with Sparse Neural Dynamics."
269+
arXiv preprint arXiv:2312.12791 (2023).
270+
271+
# Yuan, Jianya, Mengxue Han, Hongjian Wang, Bo Zhong, Wei Gao, and Dan Yu.
272+
"AUV Collision Avoidance Planning Method Based on Deep Deterministic Policy Gradient."
273+
Journal of Marine Science and Engineering 11, no. 12 (2023): 2258.
274+
275+
# Renna, Luca.
276+
"Deep Reinforcement Learning for 2D Physics-Based Object Manipulation in Clutter."
277+
arXiv preprint arXiv:2312.04570 (2023).
278+
279+
# Sosa, Felix, Samuel J. Gershman, and Tomer D. Ullman.
280+
"Blending simulation and abstraction for physical reasoning."
281+
(2023).
282+
283+
#. Li, Shiqian, Kewen Wu, Chi Zhang, and Yixin Zhu.
284+
"I-PHYRE: Interactive Physical Reasoning."
285+
arXiv preprint arXiv:2312.03009 (2023).
286+
263287
#. Almar Oliva, Eduard.
264288
"Disseny i construcció d'un robot autònom per jugar al billar."
265289
Master's thesis, Universitat Politècnica de Catalunya, 2023.
@@ -587,7 +611,7 @@ List of papers which has used or mentioned Pymunk:
587611
"Dynamic Robot Path Planning Among Crowds in Emergency Situations."
588612

589613

590-
List last updated 2023-10-11. If something is missing or wrong, please contact
614+
List last updated 2023-12-25. If something is missing or wrong, please contact
591615
me!
592616

593617
.. (list made using "Chicago" style citation)

pymunk/tests/test_batch.py

+38
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,41 @@ def check_arb_data(arb: pymunk.Arbiter) -> None:
147147
b1.each_arbiter(check_arb_data)
148148
b2.each_arbiter(check_arb_data)
149149
b3.each_arbiter(check_arb_data)
150+
151+
def test_get_arbiter_sensor(self):
152+
s = pymunk.Space()
153+
154+
b1 = pymunk.Body(1, 1)
155+
s1 = pymunk.Circle(b1, 40)
156+
s.add(b1, s1)
157+
158+
b2 = pymunk.Body(1, 1)
159+
b2.position = 1,0
160+
s2 = pymunk.Poly.create_box(b2)
161+
s2.sensor = True
162+
s.add(b2, s2)
163+
164+
s.step(0.1)
165+
166+
data = pymunk.batch.Buffer()
167+
pymunk.batch.get_space_arbiters(
168+
s,
169+
pymunk.batch.ArbiterFields.BODY_A_ID
170+
| pymunk.batch.ArbiterFields.BODY_B_ID
171+
| pymunk.batch.ArbiterFields.CONTACT_COUNT
172+
| pymunk.batch.ArbiterFields.DISTANCE_1
173+
| pymunk.batch.ArbiterFields.DISTANCE_2
174+
| pymunk.batch.ArbiterFields.POINT_A_1
175+
| pymunk.batch.ArbiterFields.POINT_A_2
176+
| pymunk.batch.ArbiterFields.POINT_B_1
177+
| pymunk.batch.ArbiterFields.POINT_B_2,
178+
data,
179+
)
180+
181+
182+
self.assertEqual(list(memoryview(data.int_buf()).cast("P")), [b1.id, b2.id, 0])
183+
184+
self.assertEqual(
185+
list(memoryview(data.float_buf()).cast("d")),
186+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
187+
)

pymunk_cffi/extensions.c

+24-26
Original file line numberDiff line numberDiff line change
@@ -63,29 +63,6 @@ struct pmBatchedData
6363
pmBatchableBodyFields fields;
6464
};
6565

66-
// cpVectArray *
67-
// cpVectArrayNew(int size)
68-
// {
69-
// cpVectArray *arr = (cpVectArray *)cpcalloc(1, sizeof(cpVectArray));
70-
71-
// arr->num = 0;
72-
// arr->max = (size ? size : 4);
73-
// arr->arr = (cpVect *)cpcalloc(arr->max, sizeof(cpVect));
74-
75-
// return arr;
76-
// }
77-
78-
// void cpVectArrayFree(cpVectArray *arr)
79-
// {
80-
// if (arr)
81-
// {
82-
// cpfree(arr->arr);
83-
// arr->arr = NULL;
84-
85-
// cpfree(arr);
86-
// }
87-
// }
88-
8966
pmFloatArray *
9067
pmFloatArrayNew(int size)
9168
{
@@ -234,15 +211,36 @@ void pmSpaceArbiterIteratorFuncBatched(cpArbiter *arbiter, void *data)
234211
}
235212
if (d->fields & POINT_A_1)
236213
{
237-
pmFloatArrayPushVect(d->floatArray, cpArbiterGetPointA(arbiter, 0));
214+
if (cpArbiterGetCount(arbiter) > 0)
215+
{
216+
pmFloatArrayPushVect(d->floatArray, cpArbiterGetPointA(arbiter, 0));
217+
}
218+
else
219+
{
220+
pmFloatArrayPushVect(d->floatArray, cpv(0, 0));
221+
}
238222
}
239223
if (d->fields & POINT_B_1)
240224
{
241-
pmFloatArrayPushVect(d->floatArray, cpArbiterGetPointB(arbiter, 0));
225+
if (cpArbiterGetCount(arbiter) > 0)
226+
{
227+
pmFloatArrayPushVect(d->floatArray, cpArbiterGetPointB(arbiter, 0));
228+
}
229+
else
230+
{
231+
pmFloatArrayPushVect(d->floatArray, cpv(0, 0));
232+
}
242233
}
243234
if (d->fields & DISTANCE_1)
244235
{
245-
pmFloatArrayPush(d->floatArray, cpArbiterGetDepth(arbiter, 0));
236+
if (cpArbiterGetCount(arbiter) > 0)
237+
{
238+
pmFloatArrayPush(d->floatArray, cpArbiterGetDepth(arbiter, 0));
239+
}
240+
else
241+
{
242+
pmFloatArrayPush(d->floatArray, 0);
243+
}
246244
}
247245
if (d->fields & POINT_A_2)
248246
{

0 commit comments

Comments
 (0)