Package ecs
Class PolygonCollider
java.lang.Object
ecs.Component
ecs.PolygonCollider
- All Implemented Interfaces:
Comparable<Component>,Collider
A polygon collider for a
GameObject.
Collision detection uses GJK in MathUtils.gjksmCollision(PrimitiveShape, PrimitiveShape).
Must not be mixed with other colliders.- Since:
- 06.12.2021
- Author:
- Juyas
-
Nested Class Summary
Nested classes/interfaces inherited from class ecs.Component
Component.ComponentOrder -
Field Summary
Fields inherited from class ecs.Component
gameObject -
Constructor Summary
ConstructorsConstructorDescriptionPolygonCollider(PrimitiveShape shape) PolygonCollider(PrimitiveShape shape, boolean passive) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCollideWith(Collider other) Determines whether a collider could potentially intersect with another collider ONLY by their collision layers.detectCollision(Collider collider) Determines whether a collider intersects with another collider IGNORING the collision layers.getShape()The shape of the collider.booleanhasMask(int layer) Determines whether a collision mask for a specified layer is enabled.booleanisOnLayer(int layer) Determines whether the collider exists in a specified layer.layer(int... layers) Sets multiple layers at once for handy usage.shortlayers()A short containing all enabled layers encoded as bit mask.shortmask()A short containing all enabled masks encoded as bit mask.mask(int... masks) Sets multiple masks at once for handy usage.booleanpassive()Defines the behaviour of this collider.voidsetLayer(int layer, boolean active) Change the colliders presence in a specified layer.voidsetMask(int layer, boolean active) Changes the collision mask entry for a specified layer.voidsetShape(PrimitiveShape shape) Overwrite the shape of the collider.voidstart()Called once on Component initialization.voidupdate(float dt) Called once per frame for each Component
-
Constructor Details
-
PolygonCollider
-
PolygonCollider
-
-
Method Details
-
layer
Sets multiple layers at once for handy usage.- Parameters:
layers- all layers that should be set.- Returns:
- the collider itself, to chain the call.
-
mask
Sets multiple masks at once for handy usage.- Parameters:
masks- all layers that should be set.- Returns:
- the collider itself, to chain the call.
-
setShape
Overwrite the shape of the collider. Use with caution.- Parameters:
shape- the new shape.
-
start
public void start()Description copied from class:ComponentCalled once on Component initialization. -
getShape
Description copied from interface:ColliderThe shape of the collider. -
detectCollision
Description copied from interface:ColliderDetermines whether a collider intersects with another collider IGNORING the collision layers.- Specified by:
detectCollisionin interfaceCollider- Parameters:
collider- the other collider- Returns:
- an object containing the result of collision detection
-
canCollideWith
Description copied from interface:ColliderDetermines whether a collider could potentially intersect with another collider ONLY by their collision layers. This method can be considered part of the broad phase of collision detection.- Specified by:
canCollideWithin interfaceCollider- Parameters:
other- the other collider- Returns:
- true if and only if both objects could potentially collide
-
layers
public short layers()Description copied from interface:ColliderA short containing all enabled layers encoded as bit mask. Should be usable to compare different masks with each other to check for intersection. -
mask
public short mask()Description copied from interface:ColliderA short containing all enabled masks encoded as bit mask. Should be usable to compare different masks with each other to check for intersection. -
hasMask
public boolean hasMask(int layer) Description copied from interface:ColliderDetermines whether a collision mask for a specified layer is enabled. -
isOnLayer
public boolean isOnLayer(int layer) Description copied from interface:ColliderDetermines whether the collider exists in a specified layer. -
setLayer
public void setLayer(int layer, boolean active) Description copied from interface:ColliderChange the colliders presence in a specified layer. Making a collider present in a specified layer will it enable to collide with all collider including the specified layer in their collision mask. -
setMask
public void setMask(int layer, boolean active) Description copied from interface:ColliderChanges the collision mask entry for a specified layer. Enabling the mask for layer n will allow this collider to collide with any other collider set in the target layer n vise versa. -
passive
public boolean passive()Description copied from interface:ColliderDefines the behaviour of this collider. A passive collider will never get checked against others colliders, however any collider might get checked against it. -
update
public void update(float dt) Description copied from class:ComponentCalled once per frame for each Component
-