[FEATURE] collisions!!!!!!!!!!! YAY

This commit is contained in:
Menno
2021-05-28 15:45:46 +02:00
parent 28400fb320
commit e8b3e1b482
9 changed files with 166 additions and 38 deletions

View File

@@ -7,11 +7,7 @@ namespace entities
: Entity(model, position, rotation, scale),
bounding_box(bounding_box)
{
const glm::vec3& center = bounding_box.center_pos;
const glm::vec3& size = bounding_box.size;
min_xyz = glm::vec3(center.x - size.x, center.y - size.y, center.z - size.z);
max_xyz = glm::vec3(center.x + size.x, center.y + size.y, center.z + size.z);
MoveCollisionBox();
}
void CollisionEntity::OnCollide(const collision::Collision& collision)
@@ -35,4 +31,14 @@ namespace entities
(min_xyz.y <= e.max_xyz.y && max_xyz.y >= e.min_xyz.y) &&
(min_xyz.z <= e.max_xyz.z && max_xyz.z >= e.min_xyz.z);
}
void CollisionEntity::MoveCollisionBox()
{
bounding_box.center_pos = position;
const glm::vec3 size = bounding_box.size;
min_xyz = bounding_box.center_pos;
max_xyz = glm::vec3(min_xyz.x + size.x, min_xyz.y + size.y, min_xyz.z + size.z);
}
}