#ifndef SHARED_MOVEMENT_MOVEMENT_HH_ #define SHARED_MOVEMENT_MOVEMENT_HH_ #include "shared/entity/animate.hh" #include "shared/entity/moveable.hh" #include "shared/math/math.hh" #include "shared/movement/struct.hh" #include "shared/shared.hh" #include "shared/world/chunk.hh" #include #include #include #define GLM_ENABLE_EXPERIMENTAL #include #include namespace shared { namespace movement { // Returns a local pos relative to the base chunk pos, which can be negative, // or over 16.0f. glm::vec3 make_relative(const shared::math::coords& base_chunk_pos, const glm::vec3& other_local_pos, const shared::math::coords& other_chunk_pos) noexcept; void normalise_position(glm::vec3& local_pos, shared::math::coords& chunk_pos) noexcept; 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; // We need more information about the block during movement code. struct block { shared::world::block block; struct aabb aabb; shared::math::coords chunk_pos; glm::ivec3 pos; }; using blocks = std::vector; // Returns a vec2 describing how wide and tall the array of blocks should be (to // ensure you never fall through anything at variable tickrates). glm::ivec2 get_move_xy(const std::uint32_t& tickrate, const moveable& moveable) noexcept; [[nodiscard]] shared::animate move(const shared::moveable& moveable, const blocks& blocks, const std::uint32_t& tickrate) noexcept; } // namespace movement } // namespace shared #endif