mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 21:45:33 +00:00
Move Water struct out of RecastMesh class
This commit is contained in:
parent
d60edb36aa
commit
a1549321d7
8 changed files with 31 additions and 31 deletions
|
@ -83,7 +83,7 @@ namespace
|
|||
std::uniform_real_distribution<btScalar> distribution(0.0, 1.0);
|
||||
std::generate_n(out, count, [&] {
|
||||
const btVector3 shift(distribution(random), distribution(random), distribution(random));
|
||||
return RecastMesh::Water {1, btTransform(btMatrix3x3::getIdentity(), shift)};
|
||||
return Water {1, btTransform(btMatrix3x3::getIdentity(), shift)};
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace
|
|||
const std::size_t generation = std::uniform_int_distribution<std::size_t>(0, 100)(random);
|
||||
const std::size_t revision = std::uniform_int_distribution<std::size_t>(0, 10000)(random);
|
||||
Mesh mesh = generateMesh(triangles, random);
|
||||
std::vector<RecastMesh::Water> water;
|
||||
std::vector<Water> water;
|
||||
generateWater(std::back_inserter(water), 2, random);
|
||||
RecastMesh recastMesh(generation, revision, std::move(mesh), std::move(water));
|
||||
return Key {agentHalfExtents, tilePosition, std::move(recastMesh)};
|
||||
|
|
|
@ -143,12 +143,12 @@ namespace
|
|||
const std::size_t mGeneration = 0;
|
||||
const std::size_t mRevision = 0;
|
||||
const Mesh mMesh {makeMesh()};
|
||||
const std::vector<RecastMesh::Water> mWater {};
|
||||
const std::vector<Water> mWater {};
|
||||
const RecastMesh mRecastMesh {mGeneration, mRevision, mMesh, mWater};
|
||||
std::unique_ptr<PreparedNavMeshData> mPreparedNavMeshData {makePeparedNavMeshData(3)};
|
||||
|
||||
const std::size_t mRecastMeshSize = sizeof(mRecastMesh) + getSize(mRecastMesh);
|
||||
const std::size_t mRecastMeshWithWaterSize = mRecastMeshSize + sizeof(RecastMesh::Water);
|
||||
const std::size_t mRecastMeshWithWaterSize = mRecastMeshSize + sizeof(Water);
|
||||
const std::size_t mPreparedNavMeshDataSize = sizeof(*mPreparedNavMeshData) + getSize(*mPreparedNavMeshData);
|
||||
};
|
||||
|
||||
|
@ -231,7 +231,7 @@ namespace
|
|||
{
|
||||
const std::size_t maxSize = 1;
|
||||
NavMeshTilesCache cache(maxSize);
|
||||
const std::vector<RecastMesh::Water> water {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> water {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh unexistentRecastMesh {mGeneration, mRevision, mMesh, water};
|
||||
|
||||
cache.set(mAgentHalfExtents, mTilePosition, mRecastMesh, std::move(mPreparedNavMeshData));
|
||||
|
@ -243,7 +243,7 @@ namespace
|
|||
const std::size_t maxSize = mRecastMeshWithWaterSize + mPreparedNavMeshDataSize;
|
||||
NavMeshTilesCache cache(maxSize);
|
||||
|
||||
const std::vector<RecastMesh::Water> water {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> water {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, water};
|
||||
auto anotherPreparedNavMeshData = makePeparedNavMeshData(3);
|
||||
const auto copy = clone(*anotherPreparedNavMeshData);
|
||||
|
@ -261,7 +261,7 @@ namespace
|
|||
const std::size_t maxSize = mRecastMeshWithWaterSize + mPreparedNavMeshDataSize;
|
||||
NavMeshTilesCache cache(maxSize);
|
||||
|
||||
const std::vector<RecastMesh::Water> water {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> water {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, water};
|
||||
auto anotherPreparedNavMeshData = makePeparedNavMeshData(3);
|
||||
|
||||
|
@ -277,11 +277,11 @@ namespace
|
|||
NavMeshTilesCache cache(maxSize);
|
||||
const auto copy = clone(*mPreparedNavMeshData);
|
||||
|
||||
const std::vector<RecastMesh::Water> leastRecentlySetWater {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> leastRecentlySetWater {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh leastRecentlySetRecastMesh {mGeneration, mRevision, mMesh, leastRecentlySetWater};
|
||||
auto leastRecentlySetData = makePeparedNavMeshData(3);
|
||||
|
||||
const std::vector<RecastMesh::Water> mostRecentlySetWater {1, RecastMesh::Water {2, btTransform::getIdentity()}};
|
||||
const std::vector<Water> mostRecentlySetWater {1, Water {2, btTransform::getIdentity()}};
|
||||
const RecastMesh mostRecentlySetRecastMesh {mGeneration, mRevision, mMesh, mostRecentlySetWater};
|
||||
auto mostRecentlySetData = makePeparedNavMeshData(3);
|
||||
|
||||
|
@ -303,12 +303,12 @@ namespace
|
|||
const std::size_t maxSize = 2 * (mRecastMeshWithWaterSize + mPreparedNavMeshDataSize);
|
||||
NavMeshTilesCache cache(maxSize);
|
||||
|
||||
const std::vector<RecastMesh::Water> leastRecentlyUsedWater {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> leastRecentlyUsedWater {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh leastRecentlyUsedRecastMesh {mGeneration, mRevision, mMesh, leastRecentlyUsedWater};
|
||||
auto leastRecentlyUsedData = makePeparedNavMeshData(3);
|
||||
const auto leastRecentlyUsedCopy = clone(*leastRecentlyUsedData);
|
||||
|
||||
const std::vector<RecastMesh::Water> mostRecentlyUsedWater {1, RecastMesh::Water {2, btTransform::getIdentity()}};
|
||||
const std::vector<Water> mostRecentlyUsedWater {1, Water {2, btTransform::getIdentity()}};
|
||||
const RecastMesh mostRecentlyUsedRecastMesh {mGeneration, mRevision, mMesh, mostRecentlyUsedWater};
|
||||
auto mostRecentlyUsedData = makePeparedNavMeshData(3);
|
||||
const auto mostRecentlyUsedCopy = clone(*mostRecentlyUsedData);
|
||||
|
@ -342,7 +342,7 @@ namespace
|
|||
const std::size_t maxSize = 2 * (mRecastMeshWithWaterSize + mPreparedNavMeshDataSize);
|
||||
NavMeshTilesCache cache(maxSize);
|
||||
|
||||
const std::vector<RecastMesh::Water> water {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> water {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh tooLargeRecastMesh {mGeneration, mRevision, mMesh, water};
|
||||
auto tooLargeData = makePeparedNavMeshData(10);
|
||||
|
||||
|
@ -356,11 +356,11 @@ namespace
|
|||
const std::size_t maxSize = 2 * (mRecastMeshWithWaterSize + mPreparedNavMeshDataSize);
|
||||
NavMeshTilesCache cache(maxSize);
|
||||
|
||||
const std::vector<RecastMesh::Water> anotherWater {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> anotherWater {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, anotherWater};
|
||||
auto anotherData = makePeparedNavMeshData(3);
|
||||
|
||||
const std::vector<RecastMesh::Water> tooLargeWater {1, RecastMesh::Water {2, btTransform::getIdentity()}};
|
||||
const std::vector<Water> tooLargeWater {1, Water {2, btTransform::getIdentity()}};
|
||||
const RecastMesh tooLargeRecastMesh {mGeneration, mRevision, mMesh, tooLargeWater};
|
||||
auto tooLargeData = makePeparedNavMeshData(10);
|
||||
|
||||
|
@ -380,7 +380,7 @@ namespace
|
|||
const std::size_t maxSize = mRecastMeshWithWaterSize + mPreparedNavMeshDataSize;
|
||||
NavMeshTilesCache cache(maxSize);
|
||||
|
||||
const std::vector<RecastMesh::Water> water {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> water {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, water};
|
||||
auto anotherData = makePeparedNavMeshData(3);
|
||||
|
||||
|
@ -399,7 +399,7 @@ namespace
|
|||
const std::size_t maxSize = mRecastMeshWithWaterSize + mPreparedNavMeshDataSize;
|
||||
NavMeshTilesCache cache(maxSize);
|
||||
|
||||
const std::vector<RecastMesh::Water> water {1, RecastMesh::Water {1, btTransform::getIdentity()}};
|
||||
const std::vector<Water> water {1, Water {1, btTransform::getIdentity()}};
|
||||
const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, water};
|
||||
auto anotherData = makePeparedNavMeshData(3);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
static inline bool operator ==(const RecastMesh::Water& lhs, const RecastMesh::Water& rhs)
|
||||
static inline bool operator ==(const Water& lhs, const Water& rhs)
|
||||
{
|
||||
return lhs.mCellSize == rhs.mCellSize && lhs.mTransform == rhs.mTransform;
|
||||
}
|
||||
|
@ -404,8 +404,8 @@ namespace
|
|||
RecastMeshBuilder builder(mBounds);
|
||||
builder.addWater(1000, btTransform(btMatrix3x3::getIdentity(), btVector3(100, 200, 300)));
|
||||
const auto recastMesh = std::move(builder).create(mGeneration, mRevision);
|
||||
EXPECT_EQ(recastMesh->getWater(), std::vector<RecastMesh::Water>({
|
||||
RecastMesh::Water {1000, btTransform(btMatrix3x3::getIdentity(), btVector3(100, 200, 300))}
|
||||
EXPECT_EQ(recastMesh->getWater(), std::vector<Water>({
|
||||
Water {1000, btTransform(btMatrix3x3::getIdentity(), btVector3(100, 200, 300))}
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace
|
|||
osg::Vec3f mMax;
|
||||
};
|
||||
|
||||
WaterBounds getWaterBounds(const RecastMesh::Water& water, const Settings& settings,
|
||||
WaterBounds getWaterBounds(const Water& water, const Settings& settings,
|
||||
const osg::Vec3f& agentHalfExtents)
|
||||
{
|
||||
if (water.mCellSize == std::numeric_limits<int>::max())
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace DetourNavigator
|
|||
struct RecastMeshData
|
||||
{
|
||||
Mesh mMesh;
|
||||
std::vector<RecastMesh::Water> mWater;
|
||||
std::vector<Water> mWater;
|
||||
};
|
||||
|
||||
inline bool operator <(const RecastMeshData& lhs, const RecastMeshData& rhs)
|
||||
|
|
|
@ -45,15 +45,15 @@ namespace DetourNavigator
|
|||
}
|
||||
};
|
||||
|
||||
struct Water
|
||||
{
|
||||
int mCellSize;
|
||||
btTransform mTransform;
|
||||
};
|
||||
|
||||
class RecastMesh
|
||||
{
|
||||
public:
|
||||
struct Water
|
||||
{
|
||||
int mCellSize;
|
||||
btTransform mTransform;
|
||||
};
|
||||
|
||||
RecastMesh(std::size_t generation, std::size_t revision, Mesh mesh, std::vector<Water> water);
|
||||
|
||||
std::size_t getGeneration() const
|
||||
|
@ -92,11 +92,11 @@ namespace DetourNavigator
|
|||
|
||||
friend inline std::size_t getSize(const RecastMesh& value) noexcept
|
||||
{
|
||||
return getSize(value.mMesh) + value.mWater.size() * sizeof(RecastMesh::Water);
|
||||
return getSize(value.mMesh) + value.mWater.size() * sizeof(Water);
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator<(const RecastMesh::Water& lhs, const RecastMesh::Water& rhs) noexcept
|
||||
inline bool operator<(const Water& lhs, const Water& rhs) noexcept
|
||||
{
|
||||
return std::tie(lhs.mCellSize, lhs.mTransform) < std::tie(rhs.mCellSize, rhs.mTransform);
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace DetourNavigator
|
|||
|
||||
void RecastMeshBuilder::addWater(const int cellSize, const btTransform& transform)
|
||||
{
|
||||
mWater.push_back(RecastMesh::Water {cellSize, transform});
|
||||
mWater.push_back(Water {cellSize, transform});
|
||||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> RecastMeshBuilder::create(std::size_t generation, std::size_t revision) &&
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace DetourNavigator
|
|||
private:
|
||||
const TileBounds mBounds;
|
||||
std::vector<RecastMeshTriangle> mTriangles;
|
||||
std::vector<RecastMesh::Water> mWater;
|
||||
std::vector<Water> mWater;
|
||||
|
||||
void addObject(const btConcaveShape& shape, const btTransform& transform, btTriangleCallback&& callback);
|
||||
|
||||
|
|
Loading…
Reference in a new issue