Module technology.sola.engine
Class QuadTreeCollisionDetectionBroadPhase
java.lang.Object
technology.sola.engine.physics.system.collision.QuadTreeCollisionDetectionBroadPhase
- All Implemented Interfaces:
CollisionDetectionBroadPhase
@NullMarked
public class QuadTreeCollisionDetectionBroadPhase
extends Object
implements CollisionDetectionBroadPhase
QuadTreeCollisionDetectionBroadPhase is a
CollisionDetectionBroadPhase implementation using a
QuadTreeNode internally.-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance with bounds being auto calculated based on entries in the world, maxDepth set to 5, and maxEntitiesPerNode set to 8.QuadTreeCollisionDetectionBroadPhase(@Nullable Rectangle screenBounds) Creates an instance with desired fixed bounds, maxDepth set to 5, and maxEntitiesPerNode set to 8.QuadTreeCollisionDetectionBroadPhase(@Nullable Rectangle screenBounds, int maxDepth, int maxEntitiesPerNode) Creates an instance with desired fixed bounds, maxDepth, and maxEntitiesPerNode. -
Method Summary
Modifier and TypeMethodDescriptionvoidpopulate(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.voidrenderDebug(Renderer renderer, Matrix3D cameraScaleTransform, Matrix3D cameraTranslationTransform) Renders debug information about this broad phase algorithm.
-
Constructor Details
-
QuadTreeCollisionDetectionBroadPhase
public QuadTreeCollisionDetectionBroadPhase()Creates an instance with bounds being auto calculated based on entries in the world, maxDepth set to 5, and maxEntitiesPerNode set to 8. -
QuadTreeCollisionDetectionBroadPhase
Creates an instance with desired fixed bounds, maxDepth set to 5, and maxEntitiesPerNode set to 8.- Parameters:
screenBounds- the bounds of the quad tree
-
QuadTreeCollisionDetectionBroadPhase
public QuadTreeCollisionDetectionBroadPhase(@Nullable Rectangle screenBounds, int maxDepth, int maxEntitiesPerNode) Creates an instance with desired fixed bounds, maxDepth, and maxEntitiesPerNode.- Parameters:
screenBounds- the bounds of the quad treemaxDepth- the maximum depth of the quad treemaxEntitiesPerNode- the max number of entities per node
-
-
Method Details
-
populate
public void populate(Collection<technology.sola.ecs.view.View2Entry<ColliderComponent, TransformComponent>> views) Description copied from interface:CollisionDetectionBroadPhasePopulates the underlying data structure from the list of collidable entities.- Specified by:
populatein 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:CollisionDetectionBroadPhaseSearches for collidable entities that are near the search entity.- Specified by:
queryin 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:CollisionDetectionBroadPhaseRenders debug information about this broad phase algorithm.- Specified by:
renderDebugin interfaceCollisionDetectionBroadPhase- Parameters:
renderer- theRenderercameraScaleTransform- the camera's scale transform matrixcameraTranslationTransform- the camera's translation transform matrix
-