You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw/components/detournavigator/heightfieldshape.hpp

45 lines
1.3 KiB
C++

#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_HEIGHFIELDSHAPE_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_HEIGHFIELDSHAPE_H
#include <components/bullethelpers/heightfield.hpp>
#include <osg/Vec2i>
#include <cstddef>
#include <variant>
namespace DetourNavigator
{
struct HeightfieldPlane
{
float mHeight;
};
struct HeightfieldSurface
{
const float* mHeights;
std::size_t mSize;
float mMinHeight;
float mMaxHeight;
};
using HeightfieldShape = std::variant<HeightfieldPlane, HeightfieldSurface>;
inline btVector3 getHeightfieldShift(const HeightfieldPlane& v, const osg::Vec2i& cellPosition, int cellSize)
{
return BulletHelpers::getHeightfieldShift(cellPosition.x(), cellPosition.y(), cellSize, v.mHeight, v.mHeight);
}
inline btVector3 getHeightfieldShift(const HeightfieldSurface& v, const osg::Vec2i& cellPosition, int cellSize)
{
return BulletHelpers::getHeightfieldShift(cellPosition.x(), cellPosition.y(), cellSize, v.mMinHeight, v.mMaxHeight);
}
inline btVector3 getHeightfieldShift(const HeightfieldShape& v, const osg::Vec2i& cellPosition, int cellSize)
{
return std::visit([&] (const auto& w) { return getHeightfieldShift(w, cellPosition, cellSize); }, v);
}
}
#endif