diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index cf0f02a930..4d30254693 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -47,7 +47,7 @@ namespace MWScript if (const ESM::Cell *exterior = context.getWorld().getExterior (cell)) { context.getWorld().indexToPosition (exterior->data.gridX, exterior->data.gridY, - pos.pos[0], pos.pos[1]); + pos.pos[0], pos.pos[1], true); context.getWorld().changeToExteriorCell (pos); } else @@ -75,7 +75,7 @@ namespace MWScript ESM::Position pos; - context.getWorld().indexToPosition (x, y, pos.pos[0], pos.pos[1]); + context.getWorld().indexToPosition (x, y, pos.pos[0], pos.pos[1], true); pos.pos[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 056d33c6b1..de3c1ab5cf 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -770,12 +770,18 @@ namespace MWWorld // TODO cell change for non-player ref } - void World::indexToPosition (int cellX, int cellY, float &x, float &y) const + void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const { const int cellSize = 8192; x = cellSize * cellX; y = cellSize * cellY; + + if (centre) + { + x += cellSize/2; + y += cellSize/2; + } } void World::positionToIndex (float x, float y, int &cellX, int &cellY) const diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 395b279d71..832c90bf09 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -157,7 +157,7 @@ namespace MWWorld void moveObject (Ptr ptr, float x, float y, float z); - void indexToPosition (int cellX, int cellY, float &x, float &y) const; + void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) const; ///< Convert cell numbers to position. void positionToIndex (float x, float y, int &cellX, int &cellY) const;