mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-12 04:36:43 +00:00
Merge branch 'navmesh_cleanup' into 'master'
Small cleanup for navmesh related code See merge request OpenMW/openmw!3734
This commit is contained in:
commit
bb22c6e739
2 changed files with 18 additions and 36 deletions
|
@ -189,42 +189,18 @@ namespace DetourNavigator
|
||||||
void RecastMeshBuilder::addObject(const btBoxShape& shape, const btTransform& transform, const AreaType areaType)
|
void RecastMeshBuilder::addObject(const btBoxShape& shape, const btTransform& transform, const AreaType areaType)
|
||||||
{
|
{
|
||||||
constexpr std::array<int, 36> indices{ {
|
constexpr std::array<int, 36> indices{ {
|
||||||
0,
|
0, 2, 3, // triangle 0
|
||||||
2,
|
3, 1, 0, // triangle 1
|
||||||
3,
|
0, 4, 6, // triangle 2
|
||||||
3,
|
6, 2, 0, // triangle 3
|
||||||
1,
|
0, 1, 5, // triangle 4
|
||||||
0,
|
5, 4, 0, // triangle 5
|
||||||
0,
|
7, 5, 1, // triangle 6
|
||||||
4,
|
1, 3, 7, // triangle 7
|
||||||
6,
|
7, 3, 2, // triangle 8
|
||||||
6,
|
2, 6, 7, // triangle 9
|
||||||
2,
|
7, 6, 4, // triangle 10
|
||||||
0,
|
4, 5, 7, // triangle 11
|
||||||
0,
|
|
||||||
1,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
4,
|
|
||||||
0,
|
|
||||||
7,
|
|
||||||
5,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
3,
|
|
||||||
7,
|
|
||||||
7,
|
|
||||||
3,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
6,
|
|
||||||
7,
|
|
||||||
7,
|
|
||||||
6,
|
|
||||||
4,
|
|
||||||
4,
|
|
||||||
5,
|
|
||||||
7,
|
|
||||||
} };
|
} };
|
||||||
|
|
||||||
for (std::size_t i = 0; i < indices.size(); i += 3)
|
for (std::size_t i = 0; i < indices.size(); i += 3)
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace DetourNavigator
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns value in NavMesh coordinates
|
||||||
inline float getTileSize(const RecastSettings& settings)
|
inline float getTileSize(const RecastSettings& settings)
|
||||||
{
|
{
|
||||||
return static_cast<float>(settings.mTileSize) * settings.mCellSize;
|
return static_cast<float>(settings.mTileSize) * settings.mCellSize;
|
||||||
|
@ -62,16 +63,19 @@ namespace DetourNavigator
|
||||||
return static_cast<int>(v);
|
return static_cast<int>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns integer tile position for position in navmesh coordinates
|
||||||
inline TilePosition getTilePosition(const RecastSettings& settings, const osg::Vec2f& position)
|
inline TilePosition getTilePosition(const RecastSettings& settings, const osg::Vec2f& position)
|
||||||
{
|
{
|
||||||
return TilePosition(getTilePosition(settings, position.x()), getTilePosition(settings, position.y()));
|
return TilePosition(getTilePosition(settings, position.x()), getTilePosition(settings, position.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns integer tile position for position in navmesh coordinates
|
||||||
inline TilePosition getTilePosition(const RecastSettings& settings, const osg::Vec3f& position)
|
inline TilePosition getTilePosition(const RecastSettings& settings, const osg::Vec3f& position)
|
||||||
{
|
{
|
||||||
return getTilePosition(settings, osg::Vec2f(position.x(), position.z()));
|
return getTilePosition(settings, osg::Vec2f(position.x(), position.z()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns tile bounds in navmesh coordinates
|
||||||
inline TileBounds makeTileBounds(const RecastSettings& settings, const TilePosition& tilePosition)
|
inline TileBounds makeTileBounds(const RecastSettings& settings, const TilePosition& tilePosition)
|
||||||
{
|
{
|
||||||
return TileBounds{
|
return TileBounds{
|
||||||
|
@ -80,6 +84,7 @@ namespace DetourNavigator
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns border size relative to cell size
|
||||||
inline float getBorderSize(const RecastSettings& settings)
|
inline float getBorderSize(const RecastSettings& settings)
|
||||||
{
|
{
|
||||||
return static_cast<float>(settings.mBorderSize) * settings.mCellSize;
|
return static_cast<float>(settings.mBorderSize) * settings.mCellSize;
|
||||||
|
@ -95,6 +100,7 @@ namespace DetourNavigator
|
||||||
return std::floor(std::sqrt(settings.mMaxTilesNumber / osg::PI)) - 1;
|
return std::floor(std::sqrt(settings.mMaxTilesNumber / osg::PI)) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns tile bounds in real coordinates
|
||||||
inline TileBounds makeRealTileBoundsWithBorder(const RecastSettings& settings, const TilePosition& tilePosition)
|
inline TileBounds makeRealTileBoundsWithBorder(const RecastSettings& settings, const TilePosition& tilePosition)
|
||||||
{
|
{
|
||||||
TileBounds result = makeTileBounds(settings, tilePosition);
|
TileBounds result = makeTileBounds(settings, tilePosition);
|
||||||
|
|
Loading…
Reference in a new issue