#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESH_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESH_H #include "areatype.hpp" #include "bounds.hpp" #include #include #include #include #include #include namespace DetourNavigator { class Mesh { public: Mesh(std::vector&& indices, std::vector&& vertices, std::vector&& areaTypes); const std::vector& getIndices() const noexcept { return mIndices; } const std::vector& getVertices() const noexcept { return mVertices; } const std::vector& getAreaTypes() const noexcept { return mAreaTypes; } std::size_t getVerticesCount() const noexcept { return mVertices.size() / 3; } std::size_t getTrianglesCount() const noexcept { return mAreaTypes.size(); } private: std::vector mIndices; std::vector mVertices; std::vector mAreaTypes; friend inline bool operator<(const Mesh& lhs, const Mesh& rhs) noexcept { return std::tie(lhs.mIndices, lhs.mVertices, lhs.mAreaTypes) < std::tie(rhs.mIndices, rhs.mVertices, rhs.mAreaTypes); } friend inline std::size_t getSize(const Mesh& value) noexcept { return value.mIndices.size() * sizeof(int) + value.mVertices.size() * sizeof(float) + value.mAreaTypes.size() * sizeof(AreaType); } }; struct Water { int mCellSize; btTransform mTransform; }; class RecastMesh { public: RecastMesh(std::size_t generation, std::size_t revision, Mesh mesh, std::vector water); std::size_t getGeneration() const { return mGeneration; } std::size_t getRevision() const { return mRevision; } const Mesh& getMesh() const noexcept { return mMesh; } const std::vector& getWater() const { return mWater; } const Bounds& getBounds() const { return mBounds; } private: std::size_t mGeneration; std::size_t mRevision; Mesh mMesh; std::vector mWater; Bounds mBounds; friend inline bool operator <(const RecastMesh& lhs, const RecastMesh& rhs) noexcept { return std::tie(lhs.mMesh, lhs.mWater) < std::tie(rhs.mMesh, rhs.mWater); } friend inline std::size_t getSize(const RecastMesh& value) noexcept { return getSize(value.mMesh) + value.mWater.size() * sizeof(Water); } }; inline bool operator<(const Water& lhs, const Water& rhs) noexcept { return std::tie(lhs.mCellSize, lhs.mTransform) < std::tie(rhs.mCellSize, rhs.mTransform); } } #endif