mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 23:36:41 +00:00
restores the concept of worldspace for MWWorld::Cell
This commit is contained in:
parent
6c6dbccd0a
commit
6895a452ef
7 changed files with 29 additions and 16 deletions
|
@ -174,8 +174,8 @@ namespace MWMechanics
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if (Misc::StringUtils::ciEqual(
|
||||
mCellId, actor.getCell()->getCell()->getNameId())) // Cell to travel to
|
||||
else if (Misc::StringUtils::ciEqual(mCellId,
|
||||
actor.getCell()->getCell()->getWorldSpace().getRefIdString())) // Cell to travel to
|
||||
{
|
||||
mRemainingDuration = mDuration;
|
||||
return true;
|
||||
|
|
|
@ -87,8 +87,7 @@ namespace MWScript
|
|||
float distance;
|
||||
// If the objects are in different worldspaces, return a large value (just like vanilla)
|
||||
if (!to.isInCell() || !from.isInCell()
|
||||
|| !Misc::StringUtils::ciEqual(
|
||||
to.getCell()->getCell()->getNameId(), from.getCell()->getCell()->getNameId()))
|
||||
|| to.getCell()->getCell()->getWorldSpace() != from.getCell()->getCell()->getWorldSpace())
|
||||
distance = std::numeric_limits<float>::max();
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "cell.hpp"
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/esm3/loadcell.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/misc/algorithm.hpp>
|
||||
|
@ -17,6 +18,7 @@ namespace MWWorld
|
|||
, mNameID(cell.mEditorId)
|
||||
, mRegion(ESM::RefId()) // Unimplemented for now
|
||||
, mId(cell.mId)
|
||||
, mParent(cell.mParent)
|
||||
,mMood{
|
||||
.mAmbiantColor = cell.mLighting.ambient,
|
||||
.mDirectionalColor = cell.mLighting.directional,
|
||||
|
@ -38,6 +40,7 @@ namespace MWWorld
|
|||
, mNameID(cell.mName)
|
||||
, mRegion(cell.mRegion)
|
||||
, mId(cell.mId)
|
||||
, mParent(ESM::RefId::stringRefId(ESM::CellId::sDefaultWorldspace))
|
||||
, mMood{
|
||||
.mAmbiantColor = cell.mAmbi.mAmbient,
|
||||
.mDirectionalColor = cell.mAmbi.mSunlight,
|
||||
|
@ -56,4 +59,11 @@ namespace MWWorld
|
|||
},
|
||||
*this);
|
||||
}
|
||||
ESM::RefId Cell::getWorldSpace() const
|
||||
{
|
||||
if (isExterior())
|
||||
return mParent;
|
||||
else
|
||||
return mId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace MWWorld
|
|||
const MoodData& getMood() const { return mMood; }
|
||||
float getWaterHeight() const { return mWaterHeight; }
|
||||
const ESM::RefId& getId() const { return mId; }
|
||||
ESM::RefId getWorldSpace() const;
|
||||
|
||||
private:
|
||||
bool mIsExterior;
|
||||
|
@ -61,6 +62,7 @@ namespace MWWorld
|
|||
std::string mNameID; // The name that will be used by the script and console commands
|
||||
ESM::RefId mRegion;
|
||||
ESM::RefId mId;
|
||||
ESM::RefId mParent;
|
||||
MoodData mMood;
|
||||
|
||||
float mWaterHeight;
|
||||
|
|
|
@ -552,9 +552,11 @@ namespace MWWorld
|
|||
unloadCell(cell, navigatorUpdateGuard.get());
|
||||
}
|
||||
|
||||
mNavigator.setWorldspace(
|
||||
Misc::StringUtils::lowerCase(
|
||||
mWorld.getWorldModel().getExterior(playerCellX, playerCellY)->getCell()->getNameId()),
|
||||
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(mWorld.getWorldModel()
|
||||
.getExterior(playerCellX, playerCellY)
|
||||
->getCell()
|
||||
->getWorldSpace()
|
||||
.getRefIdString()),
|
||||
navigatorUpdateGuard.get());
|
||||
mNavigator.updateBounds(pos, navigatorUpdateGuard.get());
|
||||
|
||||
|
@ -675,8 +677,8 @@ namespace MWWorld
|
|||
"Testing exterior cells (" + std::to_string(i) + "/" + std::to_string(cells.getExtSize()) + ")...");
|
||||
|
||||
CellStore* cell = mWorld.getWorldModel().getExterior(it->mData.mX, it->mData.mY);
|
||||
mNavigator.setWorldspace(
|
||||
Misc::StringUtils::lowerCase(cell->getCell()->getNameId()), navigatorUpdateGuard.get());
|
||||
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(cell->getCell()->getWorldSpace().getRefIdString()),
|
||||
navigatorUpdateGuard.get());
|
||||
const osg::Vec3f position
|
||||
= osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits;
|
||||
mNavigator.updateBounds(position, navigatorUpdateGuard.get());
|
||||
|
@ -733,8 +735,8 @@ namespace MWWorld
|
|||
"Testing interior cells (" + std::to_string(i) + "/" + std::to_string(cells.getIntSize()) + ")...");
|
||||
|
||||
CellStore* cell = mWorld.getWorldModel().getInterior(it->mName);
|
||||
mNavigator.setWorldspace(
|
||||
Misc::StringUtils::lowerCase(cell->getCell()->getNameId()), navigatorUpdateGuard.get());
|
||||
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(cell->getCell()->getWorldSpace().getRefIdString()),
|
||||
navigatorUpdateGuard.get());
|
||||
ESM::Position position;
|
||||
mWorld.findInteriorPosition(it->mName, position);
|
||||
mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get());
|
||||
|
@ -750,7 +752,7 @@ namespace MWWorld
|
|||
{
|
||||
assert(!(*iter)->getCell()->isExterior());
|
||||
|
||||
if (it->mName == (*iter)->getCell()->getNameId())
|
||||
if (it->mName == (*iter)->getCell()->getWorldSpace().getRefIdString())
|
||||
{
|
||||
unloadCell(*iter, navigatorUpdateGuard.get());
|
||||
break;
|
||||
|
@ -889,8 +891,8 @@ namespace MWWorld
|
|||
|
||||
loadingListener->setProgressRange(cell->count());
|
||||
|
||||
mNavigator.setWorldspace(
|
||||
Misc::StringUtils::lowerCase(cell->getCell()->getNameId()), navigatorUpdateGuard.get());
|
||||
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(cell->getCell()->getWorldSpace().getRefIdString()),
|
||||
navigatorUpdateGuard.get());
|
||||
mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get());
|
||||
|
||||
// Load cell.
|
||||
|
|
|
@ -53,7 +53,7 @@ void ESM4::Cell::load(ESM4::Reader& reader)
|
|||
reader.adjustFormId(mFormId);
|
||||
mId = ESM::RefId::formIdRefId(mFormId);
|
||||
mFlags = reader.hdr().record.flags;
|
||||
mParent = reader.currWorld();
|
||||
mParent = ESM::RefId::formIdRefId(reader.currWorld());
|
||||
|
||||
reader.clearCellGrid(); // clear until XCLC FIXME: somehow do this automatically?
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace ESM4
|
|||
ESM::RefId mId;
|
||||
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
|
||||
|
||||
FormId mParent; // world formId (for grouping cells), from the loading sequence
|
||||
ESM::RefId mParent; // world formId (for grouping cells), from the loading sequence
|
||||
|
||||
std::string mEditorId;
|
||||
std::string mFullName;
|
||||
|
|
Loading…
Reference in a new issue