QuadTreeCollisionDetection class
Collision detection modification to support a Quad Tree broadphase.
Do not use standard items list for components. Instead adds all components into QuadTreeBroadphase class.
- Inheritance
-
- Object
- CollisionDetection<
ShapeHitbox, QuadTreeBroadphase> - StandardCollisionDetection<
QuadTreeBroadphase> - QuadTreeCollisionDetection
Constructors
- QuadTreeCollisionDetection({required Rect mapDimensions, required ExternalBroadphaseCheck onComponentTypeCheck, required ExternalMinDistanceCheck minimumDistanceCheck, int maxObjects = 25, int maxDepth = 10})
Properties
- broadphase → QuadTreeBroadphase
-
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 -
override
-
addAll(
Iterable< ShapeHitbox> items) → void -
override
-
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.inherited -
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.
inherited
-
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.inherited -
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.
inherited
-
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.inherited -
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< ? out}) → List<ShapeHitbox> >RaycastResult< ShapeHitbox> > -
Casts rays uniformly between
startAngle
tostartAngle
+sweepAngle
from the givenorigin
and returns all hitboxes and intersection points the rays hit.numberOfRays
is the number of rays that should be casted.inherited -
raytrace(
Ray2 ray, {int maxDepth = 10, bool hitboxFilter(ShapeHitbox candidate)?, List< ShapeHitbox> ? ignoreHitboxes, List<RaycastResult< ? out}) → Iterable<ShapeHitbox> >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.inherited -
remove(
ShapeHitbox item) → void -
Removes the
item
from the collision detection, if you just want to temporarily inactivate it you can setcollisionType = CollisionType.inactive;
instead.override -
removeAll(
Iterable< ShapeHitbox> items) → void -
Removes all
items
from the collision detection, see remove.override -
run(
) → void -
Run collision detection for the current state of items.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited