add entities raycast

This commit is contained in:
MihailRis
2024-07-14 10:50:06 +03:00
parent 638a0d9850
commit c17f3fec54
8 changed files with 90 additions and 15 deletions
+16
View File
@@ -160,6 +160,12 @@ class Entities {
void preparePhysics();
public:
struct RaycastResult {
entityid_t entity;
glm::ivec3 normal;
float distance;
};
Entities(Level* level);
void clean();
@@ -184,6 +190,16 @@ public:
return std::nullopt;
}
/// @brief Entities raycast. No blocks check included, use combined with
/// Chunks.rayCast
/// @param start Ray start
/// @param dir Ray direction normalized vector
/// @param maxDistance Max ray length
/// @param ignore Ignored entity ID
/// @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);
void loadEntities(dynamic::Map_sptr map);
void loadEntity(const dynamic::Map_sptr& map);
void loadEntity(const dynamic::Map_sptr& map, Entity entity);