Module technology.sola.engine
Class SpatialHashMapCollisionDetectionBroadPhase
java.lang.Object
technology.sola.engine.physics.system.collision.SpatialHashMapCollisionDetectionBroadPhase
- All Implemented Interfaces:
CollisionDetectionBroadPhase
@NullMarked
public class SpatialHashMapCollisionDetectionBroadPhase
extends Object
implements CollisionDetectionBroadPhase
SpatialHashMapCollisionDetectionBroadPhase is a
CollisionDetectionBroadPhase
implementation utilizing a
SpatialHashMap
internally.-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance that allows the internal spatial hash map to determine a good cell size based on the entities.SpatialHashMapCollisionDetectionBroadPhase
(@Nullable Integer spatialHashMapCellSize) Creates an instance with fixed cell size for the internal spatial hash map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
populate
(Collection<technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent>> views) Populates the underlying data structure from the list of collidable entities.Collection<technology.sola.ecs.view.View2Entry<ColliderComponent,
TransformComponent>> query
(technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent> searchEntry) Searches for collidable entities that are near the search entity.void
renderDebug
(Renderer renderer, Matrix3D cameraScaleTransform, Matrix3D cameraTranslationTransform) Renders debug information about this broad phase algorithm.
-
Constructor Details
-
SpatialHashMapCollisionDetectionBroadPhase
public SpatialHashMapCollisionDetectionBroadPhase()Creates an instance that allows the internal spatial hash map to determine a good cell size based on the entities. -
SpatialHashMapCollisionDetectionBroadPhase
Creates an instance with fixed cell size for the internal spatial hash map.- Parameters:
spatialHashMapCellSize
- the cell size for the spatial hash map
-
-
Method Details
-
populate
public void populate(Collection<technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent>> views) Description copied from interface:CollisionDetectionBroadPhase
Populates the underlying data structure from the list of collidable entities.- Specified by:
populate
in interfaceCollisionDetectionBroadPhase
- Parameters:
views
- the list of collidable entities
-
query
public Collection<technology.sola.ecs.view.View2Entry<ColliderComponent,TransformComponent>> query(technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent> searchEntry) Description copied from interface:CollisionDetectionBroadPhase
Searches for collidable entities that are near the search entity.- Specified by:
query
in interfaceCollisionDetectionBroadPhase
- Parameters:
searchEntry
- the entity to search for possible collisions for- Returns:
- the list of nearby collidable entities
-
renderDebug
public void renderDebug(Renderer renderer, Matrix3D cameraScaleTransform, Matrix3D cameraTranslationTransform) Description copied from interface:CollisionDetectionBroadPhase
Renders debug information about this broad phase algorithm.- Specified by:
renderDebug
in interfaceCollisionDetectionBroadPhase
- Parameters:
renderer
- theRenderer
cameraScaleTransform
- the camera's scale transform matrixcameraTranslationTransform
- the camera's translation transform matrix
-