#ifndef SHARED_MOVEMENT_HH_ #define SHARED_MOVEMENT_HH_ #include "shared/math.hh" #include "shared/player.hh" #include "shared/shared.hh" #include "shared/world.hh" #include #include #include #include namespace shared { namespace movement { struct aabb { glm::vec3 min; glm::vec3 max; }; bool intersect_aabbs(const aabb& a, const aabb& b) noexcept; struct line { glm::vec3 origin; glm::vec3 dir; }; struct ray_aabb_ret { glm::vec3 position; float time; glm::vec3 normal; }; std::optional intersect_ray_aabb(const line& line, const aabb& aabb) noexcept; struct moving_aabb { struct aabb aabb; glm::vec3 velocity; }; struct moving_aabb_ret { float time; glm::vec3 normal; }; std::optional intersect_moving_aabbs(const moving_aabb& a, const moving_aabb& b) noexcept; // A block with a bit more info. struct blockinfo { shared::world::block block; struct aabb aabb; shared::math::coords chunk_pos; glm::ivec3 pos; }; // /WE/ should use this function to generate our blockdatas. constexpr int move_width = static_cast(1.0f + 2 * shared::player::HALFWIDTH + 1.0f); constexpr int move_height = static_cast(1.0f + shared::player::HEIGHT); // Walking a player is fairly complicated, and requires a std::vector of // blockdata that represents all the blocks near a player. // TODO provide an additional deltatime arugment to enable prediction. void move(shared::player& player, const std::vector& blockinfos, const float deltatime) noexcept; } // namespace movement } // namespace shared #endif