Skip to content

Commit b8b81f0

Browse files
authored
Merge pull request #139 from jcyuan/missing-filter
added the missing one before didn't add.
2 parents 239efa6 + ca26826 commit b8b81f0

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

rapier-compat/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"description": "Build scripts for compatibility package with inlined webassembly as base64.",
44
"private": true,
55
"scripts": {
6-
"build-rust-2d": "cd ../rapier2d; wasm-pack build --target web",
7-
"build-rust-3d": "cd ../rapier3d; wasm-pack build --target web",
6+
"build-rust-2d": "cd ../rapier2d && wasm-pack build --target web",
7+
"build-rust-3d": "cd ../rapier3d && wasm-pack build --target web",
88
"build-rust": "npm run build-rust-2d && npm run build-rust-3d",
99
"build-genjs": "sh ./gen_src.sh",
1010
"build-js": "rollup --config rollup.config.js",

src.ts/pipeline/query_pipeline.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,17 @@ export class QueryPipeline {
263263
colliders: ColliderSet,
264264
point: Vector,
265265
groups: InteractionGroups,
266+
filter?: (collider: ColliderHandle) => boolean,
266267
): PointColliderProjection | null {
267268
let rawPoint = VectorOps.intoRaw(point);
268269
let result = PointColliderProjection.fromRaw(
269270
colliders,
270-
this.raw.projectPointAndGetFeature(colliders.raw, rawPoint, groups),
271+
this.raw.projectPointAndGetFeature(
272+
colliders.raw,
273+
rawPoint,
274+
groups,
275+
filter,
276+
),
271277
);
272278

273279
rawPoint.free();

src.ts/pipeline/world.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,13 @@ export class World {
669669
public projectPointAndGetFeature(
670670
point: Vector,
671671
groups: InteractionGroups,
672+
filter?: (collider: Collider) => boolean,
672673
): PointColliderProjection | null {
673674
return this.queryPipeline.projectPointAndGetFeature(
674675
this.colliders,
675676
point,
676677
groups,
678+
castClosure(this.colliders, filter),
677679
);
678680
}
679681

src/pipeline/query_pipeline.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,19 @@ impl RawQueryPipeline {
180180
colliders: &RawColliderSet,
181181
point: &RawVector,
182182
groups: u32,
183+
filter: &js_sys::Function,
183184
) -> Option<RawPointColliderProjection> {
185+
let rfilter = wrap_filter(filter);
186+
let rfilter = rfilter
187+
.as_ref()
188+
.map(|f| f as &dyn Fn(ColliderHandle) -> bool);
189+
184190
self.0
185191
.project_point_and_get_feature(
186192
&colliders.0,
187193
&point.0.into(),
188194
crate::geometry::unpack_interaction_groups(groups),
189-
None,
195+
rfilter,
190196
)
191197
.map(|(handle, proj, feature)| RawPointColliderProjection {
192198
handle,

0 commit comments

Comments
 (0)