Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src.ts/pipeline/query_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
InteractionGroups, PointColliderProjection,
Ray,
RayColliderIntersection,
RayColliderToi, Shape, ShapeColliderTOI, ShapeTOI
RayColliderToi, Shape, ShapeColliderTOI
} from "../geometry";
import { IslandManager, RigidBodySet } from "../dynamics";
import { Rotation, RotationOps, Vector, VectorOps } from "../math";
Expand Down Expand Up @@ -51,13 +51,15 @@ export class QueryPipeline {
* origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
* whereas `false` implies that all shapes are hollow for this ray-cast.
* @param groups - Used to filter the colliders that can or cannot be hit by the ray.
* @param filter - The callback to filter out which collider will be hit.
*/
public castRay(
colliders: ColliderSet,
ray: Ray,
maxToi: number,
solid: boolean,
groups: InteractionGroups
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): RayColliderToi | null {
let rawOrig = VectorOps.intoRaw(ray.origin);
let rawDir = VectorOps.intoRaw(ray.dir);
Expand All @@ -68,6 +70,7 @@ export class QueryPipeline {
maxToi,
solid,
groups,
filter
));

rawOrig.free();
Expand Down Expand Up @@ -95,7 +98,8 @@ export class QueryPipeline {
ray: Ray,
maxToi: number,
solid: boolean,
groups: InteractionGroups
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): RayColliderIntersection | null {
let rawOrig = VectorOps.intoRaw(ray.origin);
let rawDir = VectorOps.intoRaw(ray.dir);
Expand All @@ -106,6 +110,7 @@ export class QueryPipeline {
maxToi,
solid,
groups,
filter
));

rawOrig.free();
Expand Down Expand Up @@ -136,6 +141,7 @@ export class QueryPipeline {
solid: boolean,
groups: InteractionGroups,
callback: (intersect: RayColliderIntersection) => boolean,
filter?: (collider: ColliderHandle) => boolean
) {
let rawOrig = VectorOps.intoRaw(ray.origin);
let rawDir = VectorOps.intoRaw(ray.dir);
Expand All @@ -151,6 +157,7 @@ export class QueryPipeline {
solid,
groups,
rawCallback,
filter
);

rawOrig.free();
Expand All @@ -173,6 +180,7 @@ export class QueryPipeline {
shapeRot: Rotation,
shape: Shape,
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): ColliderHandle | null {
let rawPos = VectorOps.intoRaw(shapePos);
let rawRot = RotationOps.intoRaw(shapeRot);
Expand All @@ -183,6 +191,7 @@ export class QueryPipeline {
rawRot,
rawShape,
groups,
filter
);

rawPos.free();
Expand Down Expand Up @@ -210,13 +219,15 @@ export class QueryPipeline {
point: Vector,
solid: boolean,
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): PointColliderProjection | null {
let rawPoint = VectorOps.intoRaw(point);
let result = PointColliderProjection.fromRaw(this.raw.projectPoint(
colliders.raw,
rawPoint,
solid,
groups,
filter
));

rawPoint.free();
Expand All @@ -239,6 +250,7 @@ export class QueryPipeline {
point: Vector,
groups: InteractionGroups,
callback: (handle: ColliderHandle) => boolean,
filter?: (collider: ColliderHandle) => boolean
) {
let rawPoint = VectorOps.intoRaw(point);

Expand All @@ -247,6 +259,7 @@ export class QueryPipeline {
rawPoint,
groups,
callback,
filter
);

rawPoint.free();
Expand Down Expand Up @@ -275,6 +288,7 @@ export class QueryPipeline {
shape: Shape,
maxToi: number,
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): ShapeColliderTOI | null {
let rawPos = VectorOps.intoRaw(shapePos);
let rawRot = RotationOps.intoRaw(shapeRot);
Expand All @@ -289,6 +303,7 @@ export class QueryPipeline {
rawShape,
maxToi,
groups,
filter
));

rawPos.free();
Expand Down Expand Up @@ -317,6 +332,7 @@ export class QueryPipeline {
shape: Shape,
groups: InteractionGroups,
callback: (handle: ColliderHandle) => boolean,
filter?: (collider: ColliderHandle) => boolean
) {
let rawPos = VectorOps.intoRaw(shapePos);
let rawRot = RotationOps.intoRaw(shapeRot);
Expand All @@ -329,6 +345,7 @@ export class QueryPipeline {
rawShape,
groups,
callback,
filter
);

rawPos.free();
Expand Down
34 changes: 21 additions & 13 deletions src.ts/pipeline/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
NarrowPhase, PointColliderProjection,
Ray,
RayColliderIntersection,
RayColliderToi, Shape, ShapeColliderTOI, ShapeTOI, TempContactManifold
RayColliderToi, Shape, ShapeColliderTOI, TempContactManifold
} from "../geometry";
import {
CCDSolver,
Expand Down Expand Up @@ -507,14 +507,16 @@ export class World {
* origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
* whereas `false` implies that all shapes are hollow for this ray-cast.
* @param groups - Used to filter the colliders that can or cannot be hit by the ray.
* @param filter - The callback to filter out which collider will be hit.
*/
public castRay(
ray: Ray,
maxToi: number,
solid: boolean,
groups: InteractionGroups
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): RayColliderToi | null {
return this.queryPipeline.castRay(this.colliders, ray, maxToi, solid, groups);
return this.queryPipeline.castRay(this.colliders, ray, maxToi, solid, groups, filter);
}

/**
Expand All @@ -533,9 +535,10 @@ export class World {
ray: Ray,
maxToi: number,
solid: boolean,
groups: InteractionGroups
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): RayColliderIntersection | null {
return this.queryPipeline.castRayAndGetNormal(this.colliders, ray, maxToi, solid, groups);
return this.queryPipeline.castRayAndGetNormal(this.colliders, ray, maxToi, solid, groups, filter);
}


Expand All @@ -558,8 +561,9 @@ export class World {
solid: boolean,
groups: InteractionGroups,
callback: (intersect: RayColliderIntersection) => boolean,
filter?: (collider: ColliderHandle) => boolean
) {
this.queryPipeline.intersectionsWithRay(this.colliders, ray, maxToi, solid, groups, callback)
this.queryPipeline.intersectionsWithRay(this.colliders, ray, maxToi, solid, groups, callback, filter)
}

/**
Expand All @@ -576,8 +580,9 @@ export class World {
shapeRot: Rotation,
shape: Shape,
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): ColliderHandle | null {
return this.queryPipeline.intersectionWithShape(this.colliders, shapePos, shapeRot, shape, groups);
return this.queryPipeline.intersectionWithShape(this.colliders, shapePos, shapeRot, shape, groups, filter);
}

/**
Expand All @@ -596,8 +601,9 @@ export class World {
point: Vector,
solid: boolean,
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): PointColliderProjection | null {
return this.queryPipeline.projectPoint(this.colliders, point, solid, groups);
return this.queryPipeline.projectPoint(this.colliders, point, solid, groups, filter);
}

/**
Expand All @@ -613,8 +619,9 @@ export class World {
point: Vector,
groups: InteractionGroups,
callback: (handle: ColliderHandle) => boolean,
filter?: (collider: ColliderHandle) => boolean
) {
this.queryPipeline.intersectionsWithPoint(this.colliders, point, groups, callback);
this.queryPipeline.intersectionsWithPoint(this.colliders, point, groups, callback, filter);
}

/**
Expand All @@ -638,8 +645,9 @@ export class World {
shape: Shape,
maxToi: number,
groups: InteractionGroups,
filter?: (collider: ColliderHandle) => boolean
): ShapeColliderTOI | null {
return this.queryPipeline.castShape(this.colliders, shapePos, shapeRot, shapeVel, shape, maxToi, groups);
return this.queryPipeline.castShape(this.colliders, shapePos, shapeRot, shapeVel, shape, maxToi, groups, filter);
}

/**
Expand All @@ -658,8 +666,9 @@ export class World {
shape: Shape,
groups: InteractionGroups,
callback: (handle: ColliderHandle) => boolean,
filter?: (collider: ColliderHandle) => boolean
) {
this.queryPipeline.intersectionsWithShape(this.colliders, shapePos, shapeRot, shape, groups, callback);
this.queryPipeline.intersectionsWithShape(this.colliders, shapePos, shapeRot, shape, groups, callback, filter);
}

/**
Expand All @@ -673,7 +682,7 @@ export class World {
public collidersWithAabbIntersectingAabb(
aabbCenter: Vector,
aabbHalfExtents: Vector,
callback: (handle: ColliderHandle) => boolean,
callback: (handle: ColliderHandle) => boolean
) {
this.queryPipeline.collidersWithAabbIntersectingAabb(aabbCenter, aabbHalfExtents, callback);
}
Expand Down Expand Up @@ -717,5 +726,4 @@ export class World {
public intersectionPair(collider1: ColliderHandle, collider2: ColliderHandle): boolean {
return this.narrowPhase.intersectionPair(collider1, collider2);
}

}
Loading