box2d-rust 1.3.0

Pure Rust port of the Box2D v3 2D physics engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
// World queries from physics_world.c: overlap tests, ray casts, shape casts,
// and the mover (character controller) queries.
//
// C passes function pointers plus a void* context; the Rust port passes
// closures, matching the dynamic-tree callback style used across the crate.
// The tree traversal callbacks (TreeQueryCallback, RayCastCallback, ...) are
// inlined as closures because their only job in C is to unpack the context
// struct.
//
// Queries take &mut World like C takes a non-const world: an active
// recording session captures every query with its hits (the C trampolines
// become a tee inside the callback). The traversal itself only reads, via a
// scoped immutable reborrow.
//
// SPDX-FileCopyrightText: 2023 Erin Catto
// SPDX-License-Identifier: MIT

use super::World;
use crate::aabb::offset_aabb;
use crate::body::get_body_transform_quick;
use crate::collision::PlaneResult;
use crate::collision::{Capsule, CastOutput, RayCastInput, ShapeCastInput};
use crate::constants::linear_slop;
use crate::distance::{shape_distance, DistanceInput, ShapeProxy, SimplexCache};
use crate::dynamic_tree::{BoxCastInput, TreeStats};
use crate::id::ShapeId;
use crate::math_functions::{
    is_normalized, is_valid_aabb, is_valid_position, is_valid_vec2, make_aabb, offset_pos, sub_pos,
    to_relative_transform, to_vec2, Aabb, Pos, Vec2,
};
use crate::recording::{
    rec_w_aabb, rec_w_bool, rec_w_capsule, rec_w_f32, rec_w_planeresult, rec_w_position,
    rec_w_queryfilter, rec_w_rayresult, rec_w_shapeid, rec_w_shapeproxy, rec_w_vec2,
    record_query_result, QueryRecorder, OP_QUERY_CAST_MOVER, OP_QUERY_CAST_RAY,
    OP_QUERY_CAST_RAY_CLOSEST, OP_QUERY_CAST_SHAPE, OP_QUERY_COLLIDE_MOVER, OP_QUERY_OVERLAP_AABB,
    OP_QUERY_OVERLAP_SHAPE,
};
use crate::shape::{
    collide_mover, make_shape_distance_proxy, ray_cast_shape, shape_cast_shape,
    should_query_collide, Shape,
};
use crate::types::{QueryFilter, BODY_TYPE_COUNT};

/// Make a user-facing shape id for a shape. Queries hand these to callbacks.
fn query_shape_id(world: &World, shape: &Shape) -> ShapeId {
    ShapeId {
        index1: shape.id + 1,
        world0: world.world_id,
        generation: shape.generation,
    }
}

/// Overlap test for all shapes that potentially overlap the provided AABB.
/// The callback receives each overlapping shape id and returns false to
/// terminate the query. (b2World_OverlapAABB + static TreeQueryCallback)
pub fn world_overlap_aabb(
    world: &mut World,
    origin: Pos,
    aabb: Aabb,
    filter: QueryFilter,
    mut fcn: impl FnMut(ShapeId) -> bool,
) -> TreeStats {
    let mut tree_stats = TreeStats::default();

    debug_assert!(!world.locked);
    if world.locked {
        return tree_stats;
    }

    debug_assert!(is_valid_position(origin));
    debug_assert!(is_valid_aabb(aabb));

    let mut q = QueryRecorder::begin(world, |buf| {
        rec_w_position(buf, origin);
        rec_w_aabb(buf, aabb);
        rec_w_queryfilter(buf, filter);
    });

    {
        let world: &World = world;

        // Lift to a world float box with outward rounding so the conservative
        // tree test never misses
        let world_box = offset_aabb(aabb, origin);

        for i in 0..BODY_TYPE_COUNT {
            let tree_result =
                world.broad_phase.trees[i].query(world_box, filter.mask_bits, |_, user_data| {
                    // (static TreeQueryCallback)
                    let shape_id = user_data as i32;
                    let shape = &world.shapes[shape_id as usize];

                    if !should_query_collide(shape.filter, filter) {
                        return true;
                    }

                    let id = ShapeId {
                        index1: shape_id + 1,
                        world0: world.world_id,
                        generation: shape.generation,
                    };
                    let ret = fcn(id);
                    if q.active() {
                        // (b2RecOverlapTrampoline)
                        rec_w_shapeid(&mut q.buf, id);
                        rec_w_bool(&mut q.buf, ret);
                        q.hits += 1;
                    }
                    ret
                });

            tree_stats.node_visits += tree_result.node_visits;
            tree_stats.leaf_visits += tree_result.leaf_visits;
        }
    }

    q.commit(world, OP_QUERY_OVERLAP_AABB, Some(tree_stats));
    tree_stats
}

/// Overlap test for all shapes that overlap the provided shape proxy. The
/// callback returns false to terminate the query.
/// (b2World_OverlapShape + static TreeOverlapCallback)
pub fn world_overlap_shape(
    world: &mut World,
    origin: Pos,
    proxy: &ShapeProxy,
    filter: QueryFilter,
    mut fcn: impl FnMut(ShapeId) -> bool,
) -> TreeStats {
    let mut tree_stats = TreeStats::default();

    debug_assert!(!world.locked);
    if world.locked {
        return tree_stats;
    }

    debug_assert!(is_valid_position(origin));

    let mut q = QueryRecorder::begin(world, |buf| {
        rec_w_position(buf, origin);
        rec_w_shapeproxy(buf, proxy);
        rec_w_queryfilter(buf, filter);
    });

    {
        let world: &World = world;

        // Relative box lifted to world float with outward rounding,
        // conservative for the tree
        let aabb = offset_aabb(
            make_aabb(&proxy.points[..proxy.count as usize], proxy.radius),
            origin,
        );

        for i in 0..BODY_TYPE_COUNT {
            let tree_result =
                world.broad_phase.trees[i].query(aabb, filter.mask_bits, |_, user_data| {
                    // (static TreeOverlapCallback)
                    let shape_id = user_data as i32;
                    let shape = &world.shapes[shape_id as usize];

                    if !should_query_collide(shape.filter, filter) {
                        return true;
                    }

                    // Re-center on the query origin so the distance test
                    // stays in float precision far from the world origin
                    let body = &world.bodies[shape.body_id as usize];
                    let transform =
                        to_relative_transform(get_body_transform_quick(world, body), origin);

                    let input = DistanceInput {
                        proxy_a: *proxy,
                        proxy_b: make_shape_distance_proxy(shape),
                        transform,
                        use_radii: true,
                    };

                    let mut cache = SimplexCache::default();
                    let output = shape_distance(&input, &mut cache, None);

                    let tolerance = 0.1 * linear_slop();
                    if output.distance > tolerance {
                        return true;
                    }

                    let id = query_shape_id(world, shape);
                    let ret = fcn(id);
                    if q.active() {
                        rec_w_shapeid(&mut q.buf, id);
                        rec_w_bool(&mut q.buf, ret);
                        q.hits += 1;
                    }
                    ret
                });

            tree_stats.node_visits += tree_result.node_visits;
            tree_stats.leaf_visits += tree_result.leaf_visits;
        }
    }

    q.commit(world, OP_QUERY_OVERLAP_SHAPE, Some(tree_stats));
    tree_stats
}

/// The shared per-tree ray cast loop. CastRay records around it; the closest
/// variant runs it directly and records a self-contained result instead,
/// matching C where the two entry points duplicate this loop.
fn cast_ray_impl(
    world: &World,
    origin: Pos,
    translation: Vec2,
    filter: QueryFilter,
    mut fcn: impl FnMut(ShapeId, Pos, Vec2, f32) -> f32,
) -> TreeStats {
    let mut tree_stats = TreeStats::default();

    // Tree traversal sees the origin truncated to float, displacing the ray
    // by up to one coordinate ULP, a graze sized miss tolerance at extreme
    // range. Per-shape casts re-difference against the full precision origin.
    let mut input = RayCastInput {
        origin: to_vec2(origin),
        translation,
        max_fraction: 1.0,
    };

    let mut fraction = 1.0f32;

    for i in 0..BODY_TYPE_COUNT {
        let tree_result = world.broad_phase.trees[i].ray_cast(
            &input,
            filter.mask_bits,
            |tree_input, _, user_data| {
                // (static RayCastCallback)
                let shape_id = user_data as i32;
                let shape = &world.shapes[shape_id as usize];

                if !should_query_collide(shape.filter, filter) {
                    return tree_input.max_fraction;
                }

                let body = &world.bodies[shape.body_id as usize];
                let xf = get_body_transform_quick(world, body);

                // Re-center on the body so the per-shape cast stays in float
                // precision far from the origin. The tree traversal already
                // used the truncated origin in input. Here we re-difference in
                // full precision against the body position.
                let base = xf.p;
                let transform = to_relative_transform(xf, base);
                let mut local_input = *tree_input;
                local_input.origin = sub_pos(origin, base);
                let output: CastOutput = ray_cast_shape(&local_input, shape, transform);

                if output.hit {
                    let id = query_shape_id(world, shape);
                    let point = offset_pos(base, output.point);
                    let user_fraction = fcn(id, point, output.normal, output.fraction);

                    // The user may return -1 to skip this shape
                    if (0.0..=1.0).contains(&user_fraction) {
                        fraction = user_fraction;
                    }

                    return user_fraction;
                }

                tree_input.max_fraction
            },
        );
        tree_stats.node_visits += tree_result.node_visits;
        tree_stats.leaf_visits += tree_result.leaf_visits;

        if fraction == 0.0 {
            break;
        }

        input.max_fraction = fraction;
    }

    tree_stats
}

/// Cast a ray into the world to collect shapes in the path of the ray. The
/// callback receives `(shape_id, point, normal, fraction)` and controls the
/// continuation like C's b2CastResultFcn: return -1 to ignore the hit, 0 to
/// terminate, a fraction to clip the ray, or 1 to continue without clipping.
/// (b2World_CastRay + static RayCastCallback)
pub fn world_cast_ray(
    world: &mut World,
    origin: Pos,
    translation: Vec2,
    filter: QueryFilter,
    mut fcn: impl FnMut(ShapeId, Pos, Vec2, f32) -> f32,
) -> TreeStats {
    debug_assert!(!world.locked);
    if world.locked {
        return TreeStats::default();
    }

    debug_assert!(is_valid_position(origin));
    debug_assert!(is_valid_vec2(translation));

    let mut q = QueryRecorder::begin(world, |buf| {
        rec_w_position(buf, origin);
        rec_w_vec2(buf, translation);
        rec_w_queryfilter(buf, filter);
    });

    let tree_stats = cast_ray_impl(
        world,
        origin,
        translation,
        filter,
        |id, point, normal, fraction| {
            let ret = fcn(id, point, normal, fraction);
            if q.active() {
                // (b2RecCastTrampoline)
                rec_w_shapeid(&mut q.buf, id);
                rec_w_position(&mut q.buf, point);
                rec_w_vec2(&mut q.buf, normal);
                rec_w_f32(&mut q.buf, fraction);
                rec_w_f32(&mut q.buf, ret);
                q.hits += 1;
            }
            ret
        },
    );

    q.commit(world, OP_QUERY_CAST_RAY, Some(tree_stats));
    tree_stats
}

/// Cast a ray into the world to collect the closest hit. This is a
/// convenience function. Ignores initial overlap.
/// (b2World_CastRayClosest + static b2RayCastClosestFcn)
pub fn world_cast_ray_closest(
    world: &mut World,
    origin: Pos,
    translation: Vec2,
    filter: QueryFilter,
) -> crate::types::RayResult {
    let mut result = crate::types::RayResult::default();

    debug_assert!(!world.locked);
    if world.locked {
        return result;
    }

    debug_assert!(is_valid_position(origin));
    debug_assert!(is_valid_vec2(translation));

    // C runs its own loop with b2RayCastClosestFcn and records one
    // self-contained result, never per-hit tails.
    let stats = cast_ray_impl(
        world,
        origin,
        translation,
        filter,
        |id, point, normal, fraction| {
            // Ignore initial overlap
            if fraction == 0.0 {
                return -1.0;
            }

            result.shape_id = id;
            result.point = point;
            result.normal = normal;
            result.fraction = fraction;
            result.hit = true;
            fraction
        },
    );

    result.node_visits = stats.node_visits;
    result.leaf_visits = stats.leaf_visits;

    record_query_result(
        world,
        OP_QUERY_CAST_RAY_CLOSEST,
        |buf| {
            rec_w_position(buf, origin);
            rec_w_vec2(buf, translation);
            rec_w_queryfilter(buf, filter);
        },
        |buf| rec_w_rayresult(buf, &result),
    );

    result
}

/// Cast a shape through the world. Similar to a cast ray except that a shape
/// is cast instead of a point. The callback contract matches
/// [`world_cast_ray`]. (b2World_CastShape + static ShapeCastCallback)
pub fn world_cast_shape(
    world: &mut World,
    origin: Pos,
    proxy: &ShapeProxy,
    translation: Vec2,
    filter: QueryFilter,
    mut fcn: impl FnMut(ShapeId, Pos, Vec2, f32) -> f32,
) -> TreeStats {
    let mut tree_stats = TreeStats::default();

    debug_assert!(!world.locked);
    if world.locked {
        return tree_stats;
    }

    debug_assert!(is_valid_position(origin));
    debug_assert!(is_valid_vec2(translation));

    let mut q = QueryRecorder::begin(world, |buf| {
        rec_w_position(buf, origin);
        rec_w_shapeproxy(buf, proxy);
        rec_w_vec2(buf, translation);
        rec_w_queryfilter(buf, filter);
    });

    {
        let world: &World = world;

        // Origin relative input carried on the context in C
        // (WorldShapeCastContext)
        let cast_input = ShapeCastInput {
            proxy: *proxy,
            translation,
            max_fraction: 1.0,
            can_encroach: false,
        };

        let mut fraction = 1.0f32;

        // Bound the proxy in origin relative space then lift to a
        // conservative world float box. The tree node boxes use the same
        // directed rounding, so the swept box never clips a shape far from
        // the origin. Per shape casts re-difference at full precision against
        // the carried origin.
        let local_box = make_aabb(&proxy.points[..proxy.count as usize], proxy.radius);
        let box_ = offset_aabb(local_box, origin);
        let mut tree_input = BoxCastInput {
            box_,
            translation,
            max_fraction: 1.0,
        };

        for i in 0..BODY_TYPE_COUNT {
            let tree_result = world.broad_phase.trees[i].box_cast(
                &tree_input,
                filter.mask_bits,
                |box_input, _, user_data| {
                    // (static ShapeCastCallback)
                    let shape_id = user_data as i32;
                    let shape = &world.shapes[shape_id as usize];

                    if !should_query_collide(shape.filter, filter) {
                        return box_input.max_fraction;
                    }

                    // Rebuild from the origin relative input, taking only the
                    // advancing fraction from the tree. The tree input is
                    // world float and would lose the cast far from the origin.
                    let mut local_input = cast_input;
                    local_input.max_fraction = box_input.max_fraction;

                    let body = &world.bodies[shape.body_id as usize];
                    let transform = get_body_transform_quick(world, body);
                    let local_transform = to_relative_transform(transform, origin);

                    let output = shape_cast_shape(&local_input, shape, local_transform);

                    if output.hit {
                        let id = query_shape_id(world, shape);
                        let point = offset_pos(origin, output.point);
                        let user_fraction = fcn(id, point, output.normal, output.fraction);
                        if q.active() {
                            rec_w_shapeid(&mut q.buf, id);
                            rec_w_position(&mut q.buf, point);
                            rec_w_vec2(&mut q.buf, output.normal);
                            rec_w_f32(&mut q.buf, output.fraction);
                            rec_w_f32(&mut q.buf, user_fraction);
                            q.hits += 1;
                        }

                        // The user may return -1 to skip this shape
                        if (0.0..=1.0).contains(&user_fraction) {
                            fraction = user_fraction;
                        }

                        return user_fraction;
                    }

                    box_input.max_fraction
                },
            );
            tree_stats.node_visits += tree_result.node_visits;
            tree_stats.leaf_visits += tree_result.leaf_visits;

            if fraction == 0.0 {
                break;
            }

            tree_input.max_fraction = fraction;
        }
    }

    q.commit(world, OP_QUERY_CAST_SHAPE, Some(tree_stats));
    tree_stats
}

/// Cast a capsule mover through the world. This is a special shape cast that
/// handles sliding along other shapes while reducing clipping. Returns the
/// fraction of the translation that can be performed without a hit.
/// (b2World_CastMover + static MoverCastCallback)
pub fn world_cast_mover(
    world: &mut World,
    origin: Pos,
    mover: &Capsule,
    translation: Vec2,
    filter: QueryFilter,
) -> f32 {
    debug_assert!(is_valid_position(origin));
    debug_assert!(is_valid_vec2(translation));
    debug_assert!(mover.radius > 2.0 * linear_slop());

    debug_assert!(!world.locked);
    if world.locked {
        return 1.0;
    }

    let mut fraction = 1.0f32;

    {
        let world: &World = world;

        // Origin relative input carried on the context in C
        // (WorldMoverCastContext)
        let mut cast_input = ShapeCastInput::default();
        cast_input.proxy.points[0] = mover.center1;
        cast_input.proxy.points[1] = mover.center2;
        cast_input.proxy.count = 2;
        cast_input.proxy.radius = mover.radius;
        cast_input.translation = translation;
        cast_input.max_fraction = 1.0;
        cast_input.can_encroach = true;

        // Bound the capsule in origin relative space then lift to a
        // conservative world float box
        let centers = [mover.center1, mover.center2];
        let box_ = offset_aabb(make_aabb(&centers, mover.radius), origin);
        let mut tree_input = BoxCastInput {
            box_,
            translation,
            max_fraction: 1.0,
        };

        for i in 0..BODY_TYPE_COUNT {
            world.broad_phase.trees[i].box_cast(
                &tree_input,
                filter.mask_bits,
                |box_input, _, user_data| {
                    // (static MoverCastCallback)
                    let shape_id = user_data as i32;
                    let shape = &world.shapes[shape_id as usize];

                    if !should_query_collide(shape.filter, filter) {
                        return fraction;
                    }

                    // Rebuild from the origin relative input, taking only the
                    // advancing fraction from the tree
                    let mut local_input = cast_input;
                    local_input.max_fraction = box_input.max_fraction;

                    let body = &world.bodies[shape.body_id as usize];
                    let transform =
                        to_relative_transform(get_body_transform_quick(world, body), origin);

                    let output = shape_cast_shape(&local_input, shape, transform);
                    if output.fraction == 0.0 {
                        // Ignore overlapping shapes
                        return fraction;
                    }

                    fraction = output.fraction;
                    output.fraction
                },
            );

            if fraction == 0.0 {
                break;
            }

            tree_input.max_fraction = fraction;
        }
    }

    record_query_result(
        world,
        OP_QUERY_CAST_MOVER,
        |buf| {
            rec_w_position(buf, origin);
            rec_w_capsule(buf, *mover);
            rec_w_vec2(buf, translation);
            rec_w_queryfilter(buf, filter);
        },
        |buf| rec_w_f32(buf, fraction),
    );

    fraction
}

/// Collide a capsule mover with the world, gathering collision planes that
/// can be fed to `solve_planes`. Useful for character controllers. The
/// callback returns false to terminate the query.
/// (b2World_CollideMover + static TreeCollideCallback)
pub fn world_collide_mover(
    world: &mut World,
    origin: Pos,
    mover: &Capsule,
    filter: QueryFilter,
    mut fcn: impl FnMut(ShapeId, &PlaneResult) -> bool,
) {
    debug_assert!(!world.locked);
    if world.locked {
        return;
    }

    debug_assert!(is_valid_position(origin));

    let mut q = QueryRecorder::begin(world, |buf| {
        rec_w_position(buf, origin);
        rec_w_capsule(buf, *mover);
        rec_w_queryfilter(buf, filter);
    });

    {
        let world: &World = world;

        let r = Vec2 {
            x: mover.radius,
            y: mover.radius,
        };

        // Relative box lifted to world float with outward rounding,
        // conservative for the tree
        let rel_box = Aabb {
            lower_bound: crate::math_functions::sub(
                crate::math_functions::min(mover.center1, mover.center2),
                r,
            ),
            upper_bound: crate::math_functions::add(
                crate::math_functions::max(mover.center1, mover.center2),
                r,
            ),
        };
        let aabb = offset_aabb(rel_box, origin);

        for i in 0..BODY_TYPE_COUNT {
            world.broad_phase.trees[i].query(aabb, filter.mask_bits, |_, user_data| {
                // (static TreeCollideCallback)
                let shape_id = user_data as i32;
                let shape = &world.shapes[shape_id as usize];

                if !should_query_collide(shape.filter, filter) {
                    return true;
                }

                // Re-center on the query origin, the mover and the resulting
                // planes are origin relative
                let body = &world.bodies[shape.body_id as usize];
                let transform =
                    to_relative_transform(get_body_transform_quick(world, body), origin);

                let result = collide_mover(mover, shape, transform);

                // todo handle deep overlap
                if result.hit && is_normalized(result.plane.normal) {
                    let id = query_shape_id(world, shape);
                    let ret = fcn(id, &result);
                    if q.active() {
                        // (b2RecPlaneTrampoline)
                        rec_w_shapeid(&mut q.buf, id);
                        rec_w_planeresult(&mut q.buf, &result);
                        rec_w_bool(&mut q.buf, ret);
                        q.hits += 1;
                    }
                    return ret;
                }

                true
            });
        }
    }

    // CollideMover has no TREESTATS tail (returns void)
    q.commit(world, OP_QUERY_COLLIDE_MOVER, None);
}