mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 18:39:43 +00:00
Merge branch 'navigator_cleanup' into 'master'
Some cleanup in the detournavigator code See merge request OpenMW/openmw!1371
This commit is contained in:
commit
9b7ff526ef
4 changed files with 9 additions and 13 deletions
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
class dtNavMesh;
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace
|
|||
}
|
||||
|
||||
bool rasterizeTriangles(rcContext& context, const Rectangle& rectangle, const rcConfig& config,
|
||||
const unsigned char* areas, std::size_t areasSize, rcHeightfield& solid)
|
||||
AreaType areaType, rcHeightfield& solid)
|
||||
{
|
||||
const osg::Vec2f tileBoundsMin(
|
||||
std::clamp(rectangle.mBounds.mMin.x(), config.bmin[0], config.bmax[0]),
|
||||
|
@ -224,13 +224,15 @@ namespace
|
|||
0, 2, 3,
|
||||
};
|
||||
|
||||
const std::array<unsigned char, 2> areas {areaType, areaType};
|
||||
|
||||
return rcRasterizeTriangles(
|
||||
&context,
|
||||
vertices.data(),
|
||||
static_cast<int>(vertices.size() / 3),
|
||||
indices.data(),
|
||||
areas,
|
||||
static_cast<int>(areasSize),
|
||||
areas.data(),
|
||||
static_cast<int>(areas.size()),
|
||||
solid,
|
||||
config.walkableClimb
|
||||
);
|
||||
|
@ -239,11 +241,10 @@ namespace
|
|||
bool rasterizeTriangles(rcContext& context, const osg::Vec3f& agentHalfExtents, const std::vector<Cell>& cells,
|
||||
const Settings& settings, const rcConfig& config, rcHeightfield& solid)
|
||||
{
|
||||
const std::array<unsigned char, 2> areas {{AreaType_water, AreaType_water}};
|
||||
for (const Cell& cell : cells)
|
||||
{
|
||||
const Rectangle rectangle = getSwimRectangle(cell, settings, agentHalfExtents);
|
||||
if (!rasterizeTriangles(context, rectangle, config, areas.data(), areas.size(), solid))
|
||||
if (!rasterizeTriangles(context, rectangle, config, AreaType_water, solid))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -254,9 +255,8 @@ namespace
|
|||
{
|
||||
for (const FlatHeightfield& heightfield : heightfields)
|
||||
{
|
||||
const std::array<unsigned char, 2> areas {{AreaType_ground, AreaType_ground}};
|
||||
const Rectangle rectangle {heightfield.mBounds, toNavMeshCoordinates(settings, heightfield.mHeight)};
|
||||
if (!rasterizeTriangles(context, rectangle, config, areas.data(), areas.size(), solid))
|
||||
if (!rasterizeTriangles(context, rectangle, config, AreaType_ground, solid))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -132,11 +132,6 @@ namespace DetourNavigator
|
|||
std::vector<FlatHeightfield> mFlatHeightfields;
|
||||
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(Cell)
|
||||
|
|
|
@ -242,7 +242,7 @@ namespace DetourNavigator
|
|||
heightfield.mShift = shift + osg::Vec3f(minX, minY, 0) * stepSize - osg::Vec3f(halfCellSize, halfCellSize, 0);
|
||||
heightfield.mScale = stepSize;
|
||||
heightfield.mHeights = std::move(tileHeights);
|
||||
mHeightfields.emplace_back(heightfield);
|
||||
mHeightfields.push_back(std::move(heightfield));
|
||||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> RecastMeshBuilder::create(std::size_t generation, std::size_t revision) &&
|
||||
|
|
Loading…
Reference in a new issue