Change rescaling to be more inline with vanilla (fixes #5214) (#2635)

* move rescaling to loadData

* clamp on save
pull/2638/head
Assumeru 5 years ago committed by Alexei Dobrohotov
parent f3e8fbfded
commit dfbe0021a5

@ -204,12 +204,11 @@ namespace
struct InsertVisitor struct InsertVisitor
{ {
MWWorld::CellStore& mCell; MWWorld::CellStore& mCell;
bool mRescale;
Loading::Listener& mLoadingListener; Loading::Listener& mLoadingListener;
std::vector<MWWorld::Ptr> mToInsert; std::vector<MWWorld::Ptr> mToInsert;
InsertVisitor (MWWorld::CellStore& cell, bool rescale, Loading::Listener& loadingListener); InsertVisitor (MWWorld::CellStore& cell, Loading::Listener& loadingListener);
bool operator() (const MWWorld::Ptr& ptr); bool operator() (const MWWorld::Ptr& ptr);
@ -217,8 +216,8 @@ namespace
void insert(AddObject&& addObject); void insert(AddObject&& addObject);
}; };
InsertVisitor::InsertVisitor (MWWorld::CellStore& cell, bool rescale, Loading::Listener& loadingListener) InsertVisitor::InsertVisitor (MWWorld::CellStore& cell, Loading::Listener& loadingListener)
: mCell (cell), mRescale (rescale), mLoadingListener (loadingListener) : mCell (cell), mLoadingListener (loadingListener)
{} {}
bool InsertVisitor::operator() (const MWWorld::Ptr& ptr) bool InsertVisitor::operator() (const MWWorld::Ptr& ptr)
@ -234,14 +233,6 @@ namespace
{ {
for (MWWorld::Ptr& ptr : mToInsert) for (MWWorld::Ptr& ptr : mToInsert)
{ {
if (mRescale)
{
if (ptr.getCellRef().getScale()<0.5)
ptr.getCellRef().setScale(0.5);
else if (ptr.getCellRef().getScale()>2)
ptr.getCellRef().setScale(2);
}
if (!ptr.getRefData().isDeleted() && ptr.getRefData().isEnabled()) if (!ptr.getRefData().isDeleted() && ptr.getRefData().isEnabled())
{ {
try try
@ -427,8 +418,7 @@ namespace MWWorld
cell->respawn(); cell->respawn();
// ... then references. This is important for adjustPosition to work correctly. // ... then references. This is important for adjustPosition to work correctly.
/// \todo rescale depending on the state of a new GMST insertCell (*cell, loadingListener);
insertCell (*cell, true, loadingListener);
mRendering.addCell(cell); mRendering.addCell(cell);
MWBase::Environment::get().getWindowManager()->addCell(cell); MWBase::Environment::get().getWindowManager()->addCell(cell);
@ -769,9 +759,9 @@ namespace MWWorld
mCellChanged = false; mCellChanged = false;
} }
void Scene::insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener) void Scene::insertCell (CellStore &cell, Loading::Listener* loadingListener)
{ {
InsertVisitor insertVisitor (cell, rescale, *loadingListener); InsertVisitor insertVisitor (cell, *loadingListener);
cell.forEach (insertVisitor); cell.forEach (insertVisitor);
insertVisitor.insert([&] (const MWWorld::Ptr& ptr) { addObject(ptr, *mPhysics, mRendering); }); insertVisitor.insert([&] (const MWWorld::Ptr& ptr) { addObject(ptr, *mPhysics, mRendering); });
insertVisitor.insert([&] (const MWWorld::Ptr& ptr) { addObject(ptr, *mPhysics, mNavigator); }); insertVisitor.insert([&] (const MWWorld::Ptr& ptr) { addObject(ptr, *mPhysics, mNavigator); });

@ -85,7 +85,7 @@ namespace MWWorld
osg::Vec3f mLastPlayerPos; osg::Vec3f mLastPlayerPos;
void insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener); void insertCell (CellStore &cell, Loading::Listener* loadingListener);
// 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 (int playerCellX, int playerCellY, bool changeEvent = true); void changeCellGrid (int playerCellX, int playerCellY, bool changeEvent = true);

@ -67,6 +67,10 @@ void ESM::CellRef::loadData(ESMReader &esm, bool &isDeleted)
break; break;
case ESM::FourCC<'X','S','C','L'>::value: case ESM::FourCC<'X','S','C','L'>::value:
esm.getHT(mScale); esm.getHT(mScale);
if (mScale < 0.5)
mScale = 0.5;
else if (mScale > 2)
mScale = 2;
break; break;
case ESM::FourCC<'A','N','A','M'>::value: case ESM::FourCC<'A','N','A','M'>::value:
mOwner = esm.getHString(); mOwner = esm.getHString();
@ -141,7 +145,12 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool
} }
if (mScale != 1.0) { if (mScale != 1.0) {
esm.writeHNT("XSCL", mScale); float scale = mScale;
if (scale < 0.5)
scale = 0.5;
else if (scale > 2)
scale = 2;
esm.writeHNT("XSCL", scale);
} }
esm.writeHNOCString("ANAM", mOwner); esm.writeHNOCString("ANAM", mOwner);

Loading…
Cancel
Save