mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
optimize collisions calculations (remove the stupid)
This commit is contained in:
parent
49aa7cdfba
commit
b0d231c927
9 changed files with 134 additions and 103 deletions
|
|
@ -38,6 +38,14 @@ struct AABB {
|
|||
return AABB(a + pos, b + pos);
|
||||
}
|
||||
|
||||
AABB operator+(const glm::vec3& offset) const {
|
||||
return translated(offset);
|
||||
}
|
||||
|
||||
AABB operator-(const glm::vec3& offset) const {
|
||||
return translated(-offset);
|
||||
}
|
||||
|
||||
/// @brief Multiply AABB size from center
|
||||
inline void scale(const glm::vec3 mul) {
|
||||
glm::vec3 center = (a + b) * 0.5f;
|
||||
|
|
@ -91,14 +99,14 @@ struct AABB {
|
|||
addPoint(matrix * glm::vec4(pb.x, pa.y, pb.z, 1.0f));
|
||||
}
|
||||
|
||||
inline bool intersect(const AABB& aabb) {
|
||||
inline bool intersects(const AABB& aabb) const {
|
||||
return (
|
||||
a.x <= aabb.b.x && b.x >= aabb.a.x && a.y <= aabb.b.y &&
|
||||
b.y >= aabb.a.y && a.z <= aabb.b.z && b.z >= aabb.a.z
|
||||
);
|
||||
}
|
||||
|
||||
inline bool intersect(const AABB& aabb, float margin) {
|
||||
inline bool intersects(const AABB& aabb, float margin) const {
|
||||
return (
|
||||
a.x <= aabb.b.x + margin && b.x >= aabb.a.x - margin &&
|
||||
a.y <= aabb.b.y + margin && b.y >= aabb.a.y - margin &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue