fix blocks placing when crouching
This commit is contained in:
parent
6442a3476f
commit
8617784084
@ -18,7 +18,6 @@ entity:despawn()
|
|||||||
|
|
||||||
-- Возращает имя скелета сущности
|
-- Возращает имя скелета сущности
|
||||||
entity:get_skeleton() -> str
|
entity:get_skeleton() -> str
|
||||||
|
|
||||||
-- Заменяет скелет сущности
|
-- Заменяет скелет сущности
|
||||||
entity:set_skeleton(name: str)
|
entity:set_skeleton(name: str)
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ entity:get_uid() -> int
|
|||||||
|
|
||||||
-- Возвращает компонент по имени
|
-- Возвращает компонент по имени
|
||||||
entity:get_component(name: str) -> компонент или nil
|
entity:get_component(name: str) -> компонент или nil
|
||||||
|
|
||||||
-- Проверяет наличие компонента по имени
|
-- Проверяет наличие компонента по имени
|
||||||
entity:has_component(name: str) -> bool
|
entity:has_component(name: str) -> bool
|
||||||
```
|
```
|
||||||
|
|||||||
@ -100,6 +100,17 @@ struct AABB {
|
|||||||
b.z >= aabb.a.z
|
b.z >= aabb.a.z
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool intersect(const AABB& aabb, float margin) {
|
||||||
|
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 &&
|
||||||
|
a.z <= aabb.b.z+margin &&
|
||||||
|
b.z >= aabb.a.z-margin
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MATHS_AABB_HPP_
|
#endif // MATHS_AABB_HPP_
|
||||||
|
|||||||
@ -407,7 +407,7 @@ 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, Rigidbody>();
|
auto view = registry.view<EntityId, Rigidbody>();
|
||||||
for (auto [entity, eid, body] : view.each()) {
|
for (auto [entity, eid, body] : view.each()) {
|
||||||
if (eid.def.blocking && aabb.intersect(body.hitbox.getAABB())) {
|
if (eid.def.blocking && aabb.intersect(body.hitbox.getAABB(), -0.05f)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,6 +88,7 @@ static std::tuple<size_t, std::unique_ptr<Bone>> read_node(
|
|||||||
std::string model;
|
std::string model;
|
||||||
root->str("name", name);
|
root->str("name", name);
|
||||||
root->str("model", model);
|
root->str("model", model);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Bone>> bones;
|
std::vector<std::unique_ptr<Bone>> bones;
|
||||||
size_t count = 1;
|
size_t count = 1;
|
||||||
if (auto nodesList = root->list("nodes")) {
|
if (auto nodesList = root->list("nodes")) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user