mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
fix Entities.hasBlockingInside
This commit is contained in:
parent
93565d19ad
commit
5874abff98
2 changed files with 7 additions and 3 deletions
|
|
@ -405,9 +405,9 @@ void Entities::render(Assets* assets, ModelBatch& batch, const Frustum& frustum,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entities::hasBlockingInside(AABB aabb) {
|
bool Entities::hasBlockingInside(AABB aabb) {
|
||||||
auto view = registry.view<EntityId, Transform>();
|
auto view = registry.view<EntityId, Transform, Rigidbody>();
|
||||||
for (auto [entity, eid, transform] : view.each()) {
|
for (auto [entity, eid, transform, body] : view.each()) {
|
||||||
if (eid.def.blocking && aabb.contains(transform.pos)) {
|
if (eid.def.blocking && aabb.intersect(body.hitbox.getAABB())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ struct Hitbox {
|
||||||
bool crouching = false;
|
bool crouching = false;
|
||||||
|
|
||||||
Hitbox(BodyType type, glm::vec3 position, glm::vec3 halfsize);
|
Hitbox(BodyType type, glm::vec3 position, glm::vec3 halfsize);
|
||||||
|
|
||||||
|
AABB getAABB() const {
|
||||||
|
return AABB(position-halfsize, position+halfsize);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PHYSICS_HITBOX_HPP_
|
#endif // PHYSICS_HITBOX_HPP_
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue