Class SpatialHashMap

java.lang.Object
technology.sola.engine.physics.utils.SpatialHashMap

@NullMarked public class SpatialHashMap extends Object
The SpatialHashMap class is a spatial hashmap implementation that maps Entity into a bucket with other entities based on its 2D coordinate. This helps reduce the number of collision checks that are needed during broad phase collision detection.
  • Constructor Details

  • Method Details

    • getCellSize

      public int getCellSize()
      Returns:
      the current cell size of this spatial hashmap
    • getNearbyViewEntries

      public List<technology.sola.ecs.view.View2Entry<ColliderComponent,TransformComponent>> getNearbyViewEntries(technology.sola.ecs.view.View2Entry<ColliderComponent,TransformComponent> viewEntry)
      Returns a list of ViewEntry containing an Entity that is in the same bucket as the entity to check.
      Parameters:
      viewEntry - the view entry containing the entity to check
      Returns:
      list of nearby entities
    • getBucketIds

      public Set<SpatialHashMap.BucketId> getBucketIds()
      Returns:
      the set of current SpatialHashMap.BucketIds