Component to store mesh collider data to solve collision in a PhysicWorld.
More...
#include <Component.hpp>
|
void | updateCollider (const std::vector< glm::vec3 > &coords, const glm::mat4 &model) |
| This method updates the collider cornders coords by iterating over all mesh vertices. It will find the minimum and the maximum corner in World Space Coordinates, the corresponding vertex coords are the new bottom left and top right corners.
|
void | updateCollider (const glm::vec3 &position, const glm::vec3 &size) |
| This method update a non Optimized Bounding Box by summing the given size with the given position. This kind of update is generally used for colliders where doesn't matter the precision of collision detection.
|
bool | isColliding (const ColliderComponent &other) const |
| Checks if the given collider is overlapping with the current one.
|
| ColliderComponent ()=default |
| Instances a basic Component.
|
| ColliderComponent (const glm::vec3 &position, const glm::vec3 &size) |
| Instances a non Optimized Bounding Box collider.
|
|
ColliderType | type = COLLIDER_CUBE |
| collider type
|
glm::vec3 | position {} |
| collider center position
|
glm::vec3 | normal {} |
| collider normal vector (in case is a plane)
|
glm::vec3 | size {} |
glm::vec3 | botLeft {} |
| bottom left corner coords
|
glm::vec3 | topRight {} |
| top right corner coords
|
bool | isStatic = false |
| define if the mesh is simulated in the PhsyicWorld or not
|
Component to store mesh collider data to solve collision in a PhysicWorld.
- Note
- It is also possible to use a default system of collision detection integrated with ECS systems, it uses a simple AABB detection.
- See also
- systems::collision::getCollisions()
◆ ColliderComponent()
ColliderComponent::ColliderComponent |
( |
const glm::vec3 & | position, |
|
|
const glm::vec3 & | size ) |
|
inline |
Instances a non Optimized Bounding Box collider.
- Parameters
-
position | collider center position |
size | collider size (center-right) |
◆ isColliding()
Checks if the given collider is overlapping with the current one.
- Parameters
-
other | collider of the other mesh |
- Returns
- true if other and this colliders are overlapping
◆ updateCollider() [1/2]
void ColliderComponent::updateCollider |
( |
const glm::vec3 & | position, |
|
|
const glm::vec3 & | size ) |
|
inline |
This method update a non Optimized Bounding Box by summing the given size with the given position. This kind of update is generally used for colliders where doesn't matter the precision of collision detection.
- Parameters
-
position | collider center position |
size | collider size |
- See also
- ColliderComponent::size
◆ updateCollider() [2/2]
void ColliderComponent::updateCollider |
( |
const std::vector< glm::vec3 > & | coords, |
|
|
const glm::mat4 & | model ) |
|
inline |
This method updates the collider cornders coords by iterating over all mesh vertices. It will find the minimum and the maximum corner in World Space Coordinates, the corresponding vertex coords are the new bottom left and top right corners.
- Note
- This is also called in this project: Optimized Bounding Box. This means that the collider "perfectly" contains the mesh in the most efficient single square.
◆ size
glm::vec3 ColliderComponent::size {} |
collider size
- Note
- It need to follow the projection: in case the projection is ortho the size should be different from perspective projection.
The documentation for this class was generated from the following file: