1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 12:35:46 +00:00
OpenMW/apps/openmw/mwworld/cellutils.hpp
elsid 639bdd5801
Use free function instead of virtual MWBase::World::positionToIndex
The virtual function does the same thing.

* Change return type to osg::Vec2i to avoid dependency on ESM3.
* Rename to positionToCellIndex to make it clear what is the index.
2022-05-24 19:31:23 +02:00

22 lines
430 B
C++

#ifndef OPENMW_MWWORLD_CELLUTILS_H
#define OPENMW_MWWORLD_CELLUTILS_H
#include <components/misc/constants.hpp>
#include <osg/Vec2i>
#include <cmath>
namespace MWWorld
{
inline osg::Vec2i positionToCellIndex(float x, float y)
{
return {
static_cast<int>(std::floor(x / Constants::CellSizeInUnits)),
static_cast<int>(std::floor(y / Constants::CellSizeInUnits))
};
}
}
#endif