X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FWorld.hpp;h=767f527a9034b97f352c66eda80f42d3f6569c0b;hb=1bc2f230105ad6e1ee8d999ddc079cd85d244bf9;hp=c24ccf327f4a21a848a5f6db1dc4616be3aea192;hpb=8639a90bcbcd045c57cd489f02a25e0df4236deb;p=blank.git diff --git a/src/world/World.hpp b/src/world/World.hpp index c24ccf3..767f527 100644 --- a/src/world/World.hpp +++ b/src/world/World.hpp @@ -45,28 +45,31 @@ public: /// check if this ray hits a block /// depth in the collision is the distance between the ray's /// origin and the intersection point - /// M is the global transform for given reference chunk + /// reference is the chunk offset of the ray in world space bool Intersection( const Ray &, - const glm::mat4 &M, - const Chunk::Pos &reference, + const ExactLocation::Coarse &reference, WorldCollision &); /// check if this ray hits an entity /// intersections with the reference are not tested - /// M is the global transform for the chunk of given reference entity + /// the ray is assumed to be in world space offset by entity's chunk coords bool Intersection( const Ray &, - const glm::mat4 &M, const Entity &reference, EntityCollision &); /// check if given entity intersects with the world -// bool Intersection(const Entity &e, std::vector &col) { -// return Intersection(e, e.GetState(), col); -// } bool Intersection(const Entity &e, const EntityState &, std::vector &); + /// check if given box (M * AABB) intersects with the world + /// M is assumed to be calculated in reference to given chunk coords + bool Intersection( + const AABB &box, + const glm::mat4 &M, + const glm::ivec3 &reference, + std::vector &); + const BlockTypeRegistry &BlockTypes() noexcept { return block_type; } ChunkStore &Chunks() noexcept { return chunks; } @@ -85,14 +88,18 @@ public: /// returs an existing entity if ID is already taken Entity &ForceAddEntity(std::uint32_t id); + std::list &Players() noexcept { return players; } const std::list &Players() const noexcept { return players; } std::list &Entities() noexcept { return entities; } const std::list &Entities() const noexcept { return entities; } + // dt in ms void Update(int dt); + // dt in s void Update(Entity &, float dt); void Render(Viewport &); + void RenderDebug(Viewport &); private: using EntityHandle = std::list::iterator; @@ -121,6 +128,14 @@ private: const EntityState & ); + /// calculate light direction and intensity at entity's location + void GetLight( + const Entity &entity, + glm::vec3 &direction, + glm::vec3 &color, + glm::vec3 &ambient + ); + private: Config config;