StandardCollisionDetection<B extends Broadphase<ShapeHitbox>> class

The default implementation of CollisionDetection. Checks whether any ShapeHitboxs in items collide with each other and calls their callback methods accordingly.

By default the Sweep broadphase is used, this can be configured by passing in another Broadphase to the constructor.

Inheritance
Implementers

Constructors

StandardCollisionDetection({B? broadphase})

Properties

broadphase → B
finalinherited
collisionsCompletedNotifier CollisionDetectionCompletionNotifier
finalinherited
hashCode int
The hash code for this object.
no setterinherited
items List<ShapeHitbox>
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(ShapeHitbox item) → void
inherited
addAll(Iterable<ShapeHitbox> items) → void
inherited
handleCollision(Set<Vector2> intersectionPoints, ShapeHitbox hitboxA, ShapeHitbox hitboxB) → void
Calls the two colliding hitboxes every tick when they are colliding. They are called with the intersectionPoints and instances of each other, so that they can determine what hitbox (and what ShapeHitbox.hitboxParent that they have collided with.
override
handleCollisionEnd(ShapeHitbox hitboxA, ShapeHitbox hitboxB) → void
Calls the two colliding hitboxes once when two hitboxes have stopped colliding. They are called with instances of each other, so that they can determine what hitbox (and what ShapeHitbox.hitboxParent that they have stopped colliding with.
override
handleCollisionStart(Set<Vector2> intersectionPoints, ShapeHitbox hitboxA, ShapeHitbox hitboxB) → void
Calls the two colliding hitboxes when they first starts to collide. They are called with the intersectionPoints and instances of each other, so that they can determine what hitbox (and what ShapeHitbox.hitboxParent that they have collided with.
override
intersections(ShapeHitbox hitboxA, ShapeHitbox hitboxB) Set<Vector2>
Check what the intersection points of two collidables are, returns an empty list if there are no intersections.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
raycast(Ray2 ray, {double? maxDistance, bool hitboxFilter(ShapeHitbox candidate)?, List<ShapeHitbox>? ignoreHitboxes, RaycastResult<ShapeHitbox>? out}) RaycastResult<ShapeHitbox>?
Returns the first hitbox that the given ray hits and the associated intersection information; or null if the ray doesn't hit any hitbox.
override
raycastAll(Vector2 origin, {required int numberOfRays, double startAngle = 0, double sweepAngle = tau, double? maxDistance, List<Ray2>? rays, bool hitboxFilter(ShapeHitbox candidate)?, List<ShapeHitbox>? ignoreHitboxes, List<RaycastResult<ShapeHitbox>>? out}) List<RaycastResult<ShapeHitbox>>
Casts rays uniformly between startAngle to startAngle+sweepAngle from the given origin and returns all hitboxes and intersection points the rays hit. numberOfRays is the number of rays that should be casted.
override
raytrace(Ray2 ray, {int maxDepth = 10, bool hitboxFilter(ShapeHitbox candidate)?, List<ShapeHitbox>? ignoreHitboxes, List<RaycastResult<ShapeHitbox>>? out}) Iterable<RaycastResult<ShapeHitbox>>
Follows the ray and its reflections until maxDepth is reached and then returns all hitboxes, intersection points, normals and reflection rays (bundled in a list of RaycastResults) from where the ray hits.
override
remove(ShapeHitbox item) → void
Removes the item from the collision detection, if you just want to temporarily inactivate it you can set collisionType = CollisionType.inactive; instead.
inherited
removeAll(Iterable<ShapeHitbox> items) → void
Removes all items from the collision detection, see remove.
inherited
run() → void
Run collision detection for the current state of items.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited