mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
feat: third-person camera now checks solid entities
This commit is contained in:
parent
15bbf55e29
commit
fc57e98a96
3 changed files with 29 additions and 9 deletions
|
|
@ -162,7 +162,11 @@ void Entities::loadEntity(const dv::value& map, Entity entity) {
|
|||
}
|
||||
|
||||
std::optional<Entities::RaycastResult> Entities::rayCast(
|
||||
glm::vec3 start, glm::vec3 dir, float maxDistance, entityid_t ignore
|
||||
glm::vec3 start,
|
||||
glm::vec3 dir,
|
||||
float maxDistance,
|
||||
entityid_t ignore,
|
||||
bool solidOnly
|
||||
) {
|
||||
Ray ray(start, dir);
|
||||
auto view = registry->view<EntityId, Transform, Rigidbody>();
|
||||
|
|
@ -171,7 +175,7 @@ std::optional<Entities::RaycastResult> Entities::rayCast(
|
|||
glm::ivec3 foundNormal;
|
||||
|
||||
for (auto [entity, eid, transform, body] : view.each()) {
|
||||
if (eid.uid == ignore || !body.enabled) {
|
||||
if (eid.uid == ignore || !body.enabled || (solidOnly && !eid.def.solid)) {
|
||||
continue;
|
||||
}
|
||||
auto& hitbox = body.hitbox;
|
||||
|
|
|
|||
|
|
@ -88,12 +88,14 @@ public:
|
|||
/// @param dir Ray direction normalized vector
|
||||
/// @param maxDistance Max ray length
|
||||
/// @param ignore Ignored entity ID
|
||||
/// @param solidOnly If true, only entities with solid hitboxes will be checked
|
||||
/// @return An optional structure containing entity, normal and distance
|
||||
std::optional<RaycastResult> rayCast(
|
||||
glm::vec3 start,
|
||||
glm::vec3 dir,
|
||||
float maxDistance,
|
||||
entityid_t ignore = -1
|
||||
entityid_t ignore = -1,
|
||||
bool solidOnly = false
|
||||
);
|
||||
|
||||
void loadEntities(dv::value map);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue