mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 03:40:24 +00:00
Merge branch 'delay_cell_changing' into 'master'
Delay cell grid change until scene update See merge request OpenMW/openmw!1734
This commit is contained in:
commit
964f288c13
2 changed files with 25 additions and 2 deletions
|
@ -296,6 +296,13 @@ namespace MWWorld
|
||||||
|
|
||||||
void Scene::update (float duration, bool paused)
|
void Scene::update (float duration, bool paused)
|
||||||
{
|
{
|
||||||
|
if (mChangeCellGridRequest.has_value())
|
||||||
|
{
|
||||||
|
changeCellGrid(mChangeCellGridRequest->mPosition, mChangeCellGridRequest->mCell.x(),
|
||||||
|
mChangeCellGridRequest->mCell.y(), mChangeCellGridRequest->mChangeEvent);
|
||||||
|
mChangeCellGridRequest.reset();
|
||||||
|
}
|
||||||
|
|
||||||
mPreloader->updateCache(mRendering.getReferenceTime());
|
mPreloader->updateCache(mRendering.getReferenceTime());
|
||||||
preloadCells(duration);
|
preloadCells(duration);
|
||||||
|
|
||||||
|
@ -515,7 +522,12 @@ namespace MWWorld
|
||||||
|
|
||||||
osg::Vec2i newCell = getNewGridCenter(pos, &mCurrentGridCenter);
|
osg::Vec2i newCell = getNewGridCenter(pos, &mCurrentGridCenter);
|
||||||
if (newCell != mCurrentGridCenter)
|
if (newCell != mCurrentGridCenter)
|
||||||
changeCellGrid(pos, newCell.x(), newCell.y());
|
requestChangeCellGrid(pos, newCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::requestChangeCellGrid(const osg::Vec3f &position, const osg::Vec2i& cell, bool changeEvent)
|
||||||
|
{
|
||||||
|
mChangeCellGridRequest = ChangeCellGridRequest {position, cell, changeEvent};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::changeCellGrid (const osg::Vec3f &pos, int playerCellX, int playerCellY, bool changeEvent)
|
void Scene::changeCellGrid (const osg::Vec3f &pos, int playerCellX, int playerCellY, bool changeEvent)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include <components/misc/constants.hpp>
|
#include <components/misc/constants.hpp>
|
||||||
|
|
||||||
|
@ -74,6 +75,12 @@ namespace MWWorld
|
||||||
using CellStoreCollection = std::set<CellStore *>;
|
using CellStoreCollection = std::set<CellStore *>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct ChangeCellGridRequest
|
||||||
|
{
|
||||||
|
osg::Vec3f mPosition;
|
||||||
|
osg::Vec2i mCell;
|
||||||
|
bool mChangeEvent;
|
||||||
|
};
|
||||||
|
|
||||||
CellStore* mCurrentCell; // the cell the player is in
|
CellStore* mCurrentCell; // the cell the player is in
|
||||||
CellStoreCollection mActiveCells;
|
CellStoreCollection mActiveCells;
|
||||||
|
@ -99,12 +106,16 @@ namespace MWWorld
|
||||||
|
|
||||||
std::vector<osg::ref_ptr<SceneUtil::WorkItem>> mWorkItems;
|
std::vector<osg::ref_ptr<SceneUtil::WorkItem>> mWorkItems;
|
||||||
|
|
||||||
|
std::optional<ChangeCellGridRequest> mChangeCellGridRequest;
|
||||||
|
|
||||||
void insertCell(CellStore &cell, Loading::Listener* loadingListener);
|
void insertCell(CellStore &cell, Loading::Listener* loadingListener);
|
||||||
osg::Vec2i mCurrentGridCenter;
|
osg::Vec2i mCurrentGridCenter;
|
||||||
|
|
||||||
// Load and unload cells as necessary to create a cell grid with "X" and "Y" in the center
|
// Load and unload cells as necessary to create a cell grid with "X" and "Y" in the center
|
||||||
void changeCellGrid (const osg::Vec3f &pos, int playerCellX, int playerCellY, bool changeEvent = true);
|
void changeCellGrid (const osg::Vec3f &pos, int playerCellX, int playerCellY, bool changeEvent = true);
|
||||||
|
|
||||||
|
void requestChangeCellGrid(const osg::Vec3f &position, const osg::Vec2i& cell, bool changeEvent = true);
|
||||||
|
|
||||||
typedef std::pair<osg::Vec3f, osg::Vec4i> PositionCellGrid;
|
typedef std::pair<osg::Vec3f, osg::Vec4i> PositionCellGrid;
|
||||||
|
|
||||||
void preloadCells(float dt);
|
void preloadCells(float dt);
|
||||||
|
@ -131,7 +142,7 @@ namespace MWWorld
|
||||||
|
|
||||||
void playerMoved (const osg::Vec3f& pos);
|
void playerMoved (const osg::Vec3f& pos);
|
||||||
|
|
||||||
void changePlayerCell (CellStore* newCell, const ESM::Position& position, bool adjustPlayerPos);
|
void changePlayerCell(CellStore* newCell, const ESM::Position& position, bool adjustPlayerPos);
|
||||||
|
|
||||||
CellStore *getCurrentCell();
|
CellStore *getCurrentCell();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue