mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-16 07:20:54 +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
@ -296,6 +296,13 @@ namespace MWWorld
|
||||
|
||||
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());
|
||||
preloadCells(duration);
|
||||
|
||||
@ -515,7 +522,12 @@ namespace MWWorld
|
||||
|
||||
osg::Vec2i newCell = getNewGridCenter(pos, &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)
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
||||
#include <components/misc/constants.hpp>
|
||||
|
||||
@ -74,6 +75,12 @@ namespace MWWorld
|
||||
using CellStoreCollection = std::set<CellStore *>;
|
||||
|
||||
private:
|
||||
struct ChangeCellGridRequest
|
||||
{
|
||||
osg::Vec3f mPosition;
|
||||
osg::Vec2i mCell;
|
||||
bool mChangeEvent;
|
||||
};
|
||||
|
||||
CellStore* mCurrentCell; // the cell the player is in
|
||||
CellStoreCollection mActiveCells;
|
||||
@ -99,12 +106,16 @@ namespace MWWorld
|
||||
|
||||
std::vector<osg::ref_ptr<SceneUtil::WorkItem>> mWorkItems;
|
||||
|
||||
std::optional<ChangeCellGridRequest> mChangeCellGridRequest;
|
||||
|
||||
void insertCell(CellStore &cell, Loading::Listener* loadingListener);
|
||||
osg::Vec2i mCurrentGridCenter;
|
||||
|
||||
// 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 requestChangeCellGrid(const osg::Vec3f &position, const osg::Vec2i& cell, bool changeEvent = true);
|
||||
|
||||
typedef std::pair<osg::Vec3f, osg::Vec4i> PositionCellGrid;
|
||||
|
||||
void preloadCells(float dt);
|
||||
@ -131,7 +142,7 @@ namespace MWWorld
|
||||
|
||||
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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user