java.lang.Object
technology.sola.engine.physics.utils.CollisionUtils
The CollisionUtils class is a collection of various methods that help in collision detection and resolution.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable MinimumTranslationVector
calculateAABBVsAABB
(Rectangle rectangleA, Rectangle rectangleB) Calculates aMinimumTranslationVector
for a collision between two axis alignedRectangle
s.static @Nullable MinimumTranslationVector
calculateAABBVsCircle
(Rectangle rectangle, Circle circle) static @Nullable MinimumTranslationVector
calculateCircleVsCircle
(Circle circleA, Circle circleB) Calculates aMinimumTranslationVector
for a collision between twoCircle
s.static @Nullable CollisionManifold
calculateCollisionManifold
(technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent> viewEntryA, technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent> viewEntryB) Calculates aCollisionManifold
for twoEntity
that collided.
-
Method Details
-
calculateCollisionManifold
public static @Nullable CollisionManifold calculateCollisionManifold(technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent> viewEntryA, technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent> viewEntryB) Calculates aCollisionManifold
for twoEntity
that collided.- Parameters:
viewEntryA
- the first Entity in aView2Entry
ofColliderComponent
andTransformComponent
viewEntryB
- the second Entity in aView2Entry
ofColliderComponent
andTransformComponent
- Returns:
- the resulting
CollisionManifold
-
calculateAABBVsCircle
public static @Nullable MinimumTranslationVector calculateAABBVsCircle(Rectangle rectangle, Circle circle) - Parameters:
rectangle
- the rectanglecircle
- the circle- Returns:
- the
MinimumTranslationVector
if there is a collision or else null
-
calculateAABBVsAABB
public static @Nullable MinimumTranslationVector calculateAABBVsAABB(Rectangle rectangleA, Rectangle rectangleB) Calculates aMinimumTranslationVector
for a collision between two axis alignedRectangle
s.
Note: This should not be used until penetration bug is fixed. Penetration and normal are incorrect when AABB are inside each other- Parameters:
rectangleA
- the first rectanglerectangleB
- the second rectangle- Returns:
- the
MinimumTranslationVector
if there is a collision or else null
-
calculateCircleVsCircle
public static @Nullable MinimumTranslationVector calculateCircleVsCircle(Circle circleA, Circle circleB) Calculates aMinimumTranslationVector
for a collision between twoCircle
s.- Parameters:
circleA
- the first circlecircleB
- the second circle- Returns:
- the
MinimumTranslationVector
if there is a collision or else null
-