Split ESM headers

master
elsid 3 weeks ago
parent a57c350c08
commit 01166b1f26
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -2,7 +2,8 @@
#define OPENMW_ESSIMPORT_IMPORTPROJ_H
#include <components/esm/esmcommon.hpp>
#include <components/esm/util.hpp>
#include <components/esm/vector3.hpp>
#include <cstdint>
#include <vector>

@ -1,5 +1,6 @@
#include "aiescort.hpp"
#include <components/esm/util.hpp>
#include <components/esm3/aisequence.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/misc/algorithm.hpp>

@ -3,7 +3,9 @@
#include <atomic>
#include <condition_variable>
#include <memory>
#include <optional>
#include <set>
#include <shared_mutex>
#include <thread>
#include <unordered_set>

@ -6,7 +6,6 @@
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <span>
#include <unordered_map>
#include <variant>
@ -16,8 +15,6 @@
#include <osg/Timer>
#include <osg/ref_ptr>
#include <components/esm/util.hpp>
#include "../mwworld/ptr.hpp"
#include "collisiontype.hpp"

@ -3,7 +3,7 @@
#include <osg/Object>
#include <components/esm/util.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/esmterrain/storage.hpp>
#include <components/resource/resourcemanager.hpp>

@ -11,6 +11,8 @@
#include <components/misc/strings/algorithm.hpp>
#include <components/esm/util.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/statemanager.hpp"
#include "../mwbase/windowmanager.hpp"
@ -123,7 +125,7 @@ namespace MWScript
MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Ptr playerPtr = world->getPlayerPtr();
osg::Vec2 posFromIndex
const osg::Vec2f posFromIndex
= ESM::indexToPosition(ESM::ExteriorCellLocation(x, y, ESM::Cell::sDefaultWorldspaceId), true);
pos.pos[0] = posFromIndex.x();
pos.pos[1] = posFromIndex.y();

@ -4,6 +4,8 @@
#include <components/esm3/loadcell.hpp>
#include <components/esm/util.hpp>
#include <components/compiler/opcodes.hpp>
#include <components/interpreter/interpreter.hpp>

@ -624,7 +624,7 @@ void MWState::StateManager::loadGame(const Character* character, const std::file
Log(Debug::Warning) << "Player character's cell no longer exists, changing to the default cell";
ESM::ExteriorCellLocation cellIndex(0, 0, ESM::Cell::sDefaultWorldspaceId);
MWWorld::CellStore& cell = MWBase::Environment::get().getWorldModel()->getExterior(cellIndex);
osg::Vec2 posFromIndex = ESM::indexToPosition(cellIndex, false);
const osg::Vec2f posFromIndex = ESM::indexToPosition(cellIndex, false);
ESM::Position pos;
pos.pos[0] = posFromIndex.x();
pos.pos[1] = posFromIndex.y();

@ -4,8 +4,8 @@
#include <osg/Vec2i>
#include <components/esm/esmbridge.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/util.hpp>
namespace ESM
{

@ -15,6 +15,9 @@
#include <components/esm3/loadrace.hpp>
#include <components/esm3/projectilestate.hpp>
#include <components/esm/quaternion.hpp>
#include <components/esm/vector3.hpp>
#include <components/misc/constants.hpp>
#include <components/misc/convert.hpp>
#include <components/misc/resourcehelpers.hpp>

@ -542,7 +542,7 @@ namespace MWWorld
= mCurrentCell ? mCurrentCell->getCell()->getWorldSpace() : ESM::Cell::sDefaultWorldspaceId;
if (currentGridCenter)
{
osg::Vec2 center = ESM::indexToPosition(
const osg::Vec2f center = ESM::indexToPosition(
ESM::ExteriorCellLocation(currentGridCenter->x(), currentGridCenter->y(), worldspace), true);
float distance = std::max(std::abs(center.x() - pos.x()), std::abs(center.y() - pos.y()));
float cellSize = ESM::getCellSize(worldspace);
@ -1171,7 +1171,7 @@ namespace MWWorld
&& dx != -halfGridSizePlusOne)
continue; // only care about the outer (not yet loaded) part of the grid
ESM::ExteriorCellLocation cellIndex(cellX + dx, cellY + dy, extWorldspace);
osg::Vec2 thisCellCenter = ESM::indexToPosition(cellIndex, true);
const osg::Vec2f thisCellCenter = ESM::indexToPosition(cellIndex, true);
float dist = std::max(
std::abs(thisCellCenter.x() - playerPos.x()), std::abs(thisCellCenter.y() - playerPos.y()));

@ -10,10 +10,9 @@
#include <memory>
#include <optional>
#include <set>
#include <unordered_map>
#include <vector>
#include <components/esm/util.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/misc/constants.hpp>
namespace osg

@ -2784,7 +2784,7 @@ namespace MWWorld
int x = ext->getGridX();
int y = ext->getGridY();
osg::Vec2 posFromIndex = indexToPosition(ESM::ExteriorCellLocation(x, y, ext->getWorldSpace()), true);
const osg::Vec2f posFromIndex = indexToPosition(ESM::ExteriorCellLocation(x, y, ext->getWorldSpace()), true);
pos.pos[0] = posFromIndex.x();
pos.pos[1] = posFromIndex.y();

@ -7,7 +7,7 @@
#include <string_view>
#include <unordered_map>
#include <components/esm/util.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/misc/algorithm.hpp>
#include "cellstore.hpp"

@ -169,6 +169,9 @@ add_component_dir(esm attr common defs esmcommon records util luascripts format
indexrefid
serializerefid
esm3exteriorcellrefid
quaternion
vector3
exteriorcelllocation
)
add_component_dir(fx pass technique lexer lexer_types parse_constants widgets stateupdater)
@ -186,6 +189,7 @@ add_component_dir (esm3
weatherstate quickkeys fogstate spellstate activespells creaturelevliststate doorstate projectilestate debugprofile
aisequence magiceffects custommarkerstate stolenitems transport animationstate controlsstate mappings readerscache
infoorder timestamp formatversion landrecorddata selectiongroup dialoguecondition
refnum
)
add_component_dir (esmterrain

@ -0,0 +1,53 @@
#ifndef OPENMW_COMPONENTS_ESM_EXTERIORCELLLOCATION_H
#define OPENMW_COMPONENTS_ESM_EXTERIORCELLLOCATION_H
#include "refid.hpp"
#include <components/esm3/loadcell.hpp>
#include <tuple>
namespace ESM
{
struct ExteriorCellLocation
{
int mX = 0;
int mY = 0;
ESM::RefId mWorldspace = ESM::Cell::sDefaultWorldspaceId;
ExteriorCellLocation() = default;
ExteriorCellLocation(int x, int y, ESM::RefId worldspace)
: mX(x)
, mY(y)
, mWorldspace(worldspace)
{
}
friend bool operator==(const ExteriorCellLocation& lhs, const ExteriorCellLocation& rhs) = default;
friend inline bool operator<(const ExteriorCellLocation& lhs, const ExteriorCellLocation& rhs)
{
return std::make_tuple(lhs.mX, lhs.mY, lhs.mWorldspace) < std::make_tuple(rhs.mX, rhs.mY, rhs.mWorldspace);
}
};
}
namespace std
{
template <>
struct hash<ESM::ExteriorCellLocation>
{
std::size_t operator()(const ESM::ExteriorCellLocation& toHash) const
{
// Compute individual hash values for first,
// second and third and combine them using XOR
// and bit shifting:
return ((hash<int>()(toHash.mX) ^ (hash<int>()(toHash.mY) << 1)) >> 1)
^ (hash<ESM::RefId>()(toHash.mWorldspace) << 1);
}
};
}
#endif

@ -0,0 +1,29 @@
#ifndef OPENMW_COMPONENTS_ESM_QUATERNION_H
#define OPENMW_COMPONENTS_ESM_QUATERNION_H
#include <osg/Quat>
namespace ESM
{
// format 0, savegames only
struct Quaternion
{
float mValues[4];
Quaternion() = default;
Quaternion(const osg::Quat& q)
: mValues{
static_cast<float>(q.w()),
static_cast<float>(q.x()),
static_cast<float>(q.y()),
static_cast<float>(q.z()),
}
{
}
operator osg::Quat() const { return osg::Quat(mValues[1], mValues[2], mValues[3], mValues[0]); }
};
}
#endif

@ -1,8 +1,9 @@
#include "util.hpp"
#include <components/esm3/loadland.hpp>
#include <components/esm4/loadland.hpp>
osg::Vec2 ESM::indexToPosition(const ESM::ExteriorCellLocation& cellIndex, bool centre)
osg::Vec2f ESM::indexToPosition(const ESM::ExteriorCellLocation& cellIndex, bool centre)
{
const int cellSize = ESM::getCellSize(cellIndex.mWorldspace);
@ -14,7 +15,8 @@ osg::Vec2 ESM::indexToPosition(const ESM::ExteriorCellLocation& cellIndex, bool
x += cellSize / 2;
y += cellSize / 2;
}
return osg::Vec2(x, y);
return osg::Vec2f(x, y);
}
int ESM::getLandSize(ESM::RefId worldspaceId)

@ -1,79 +1,18 @@
#ifndef OPENMW_ESM_UTIL_H
#define OPENMW_ESM_UTIL_H
#ifndef OPENMW_COMPONENTS_ESM_UTIL_H
#define OPENMW_COMPONENTS_ESM_UTIL_H
#include <cmath>
#include <osg/Quat>
#include <osg/Vec2>
#include <osg/Vec2i>
#include <osg/Vec3f>
#include <osg/Vec2f>
#include "components/esm3/loadcell.hpp"
#include "components/misc/constants.hpp"
#include <components/esm/refid.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/misc/constants.hpp>
#include "exteriorcelllocation.hpp"
#include "refid.hpp"
namespace ESM
{
// format 0, savegames only
struct Quaternion
{
float mValues[4];
Quaternion() = default;
Quaternion(const osg::Quat& q)
{
mValues[0] = q.w();
mValues[1] = q.x();
mValues[2] = q.y();
mValues[3] = q.z();
}
operator osg::Quat() const { return osg::Quat(mValues[1], mValues[2], mValues[3], mValues[0]); }
};
struct Vector3
{
float mValues[3];
Vector3() = default;
Vector3(const osg::Vec3f& v)
{
mValues[0] = v.x();
mValues[1] = v.y();
mValues[2] = v.z();
}
operator osg::Vec3f() const { return osg::Vec3f(mValues[0], mValues[1], mValues[2]); }
};
struct ExteriorCellLocation
{
int mX = 0;
int mY = 0;
ESM::RefId mWorldspace = ESM::Cell::sDefaultWorldspaceId;
ExteriorCellLocation() = default;
ExteriorCellLocation(int x, int y, ESM::RefId worldspace)
: mX(x)
, mY(y)
, mWorldspace(worldspace)
{
}
bool operator==(const ExteriorCellLocation& other) const
{
return mX == other.mX && mY == other.mY && mWorldspace == other.mWorldspace;
}
bool operator<(const ExteriorCellLocation& other) const
{
return std::make_tuple(mX, mY, mWorldspace) < std::make_tuple(other.mX, other.mY, other.mWorldspace);
}
};
inline bool isEsm4Ext(ESM::RefId worldspaceId)
{
return worldspaceId != ESM::Cell::sDefaultWorldspaceId;
@ -81,7 +20,6 @@ namespace ESM
inline int getCellSize(ESM::RefId worldspaceId)
{
return isEsm4Ext(worldspaceId) ? Constants::ESM4CellSizeInUnits : Constants::CellSizeInUnits;
}
@ -95,25 +33,8 @@ namespace ESM
return { static_cast<int>(std::floor(x / cellSize)), static_cast<int>(std::floor(y / cellSize)), worldspaceId };
}
osg::Vec2 indexToPosition(const ESM::ExteriorCellLocation& cellIndex, bool centre = false);
///< Convert cell numbers to position.
}
namespace std
{
template <>
struct hash<ESM::ExteriorCellLocation>
{
std::size_t operator()(const ESM::ExteriorCellLocation& toHash) const
{
// Compute individual hash values for first,
// second and third and combine them using XOR
// and bit shifting:
return ((hash<int>()(toHash.mX) ^ (hash<int>()(toHash.mY) << 1)) >> 1)
^ (hash<ESM::RefId>()(toHash.mWorldspace) << 1);
}
};
// Convert exterior cell location to position.
osg::Vec2f indexToPosition(const ESM::ExteriorCellLocation& cellIndex, bool centre = false);
}
#endif

@ -0,0 +1,24 @@
#ifndef OPENMW_COMPONENTS_ESM_VECTOR3_H
#define OPENMW_COMPONENTS_ESM_VECTOR3_H
#include <osg/Vec3f>
namespace ESM
{
// format 0, savegames only
struct Vector3
{
float mValues[3];
Vector3() = default;
Vector3(const osg::Vec3f& v)
: mValues{ v.x(), v.y(), v.z() }
{
}
operator osg::Vec3f() const { return osg::Vec3f(mValues[0], mValues[1], mValues[2]); }
};
}
#endif

@ -6,8 +6,8 @@
#include <string>
#include <vector>
#include "components/esm/refid.hpp"
#include "components/esm/util.hpp"
#include <components/esm/refid.hpp>
#include <components/esm/vector3.hpp>
namespace ESM
{

@ -8,13 +8,13 @@
#include <components/esm/position.hpp>
#include <components/esm/refid.hpp>
#include "refnum.hpp"
namespace ESM
{
class ESMWriter;
class ESMReader;
using RefNum = ESM::FormId;
/* Cell reference. This represents ONE object (of many) inside the
cell. The cell references are not loaded as part of the normal
loading process, but are rather loaded later on demand when we are

@ -1,18 +1,19 @@
#ifndef OPENMW_ESM_PROJECTILESTATE_H
#define OPENMW_ESM_PROJECTILESTATE_H
#include <string>
#include <osg/Quat>
#include <osg/Vec3f>
#include "effectlist.hpp"
#include "components/esm/quaternion.hpp"
#include "components/esm/refid.hpp"
#include "components/esm/util.hpp"
#include "components/esm/vector3.hpp"
#include "refnum.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, savegames only

@ -0,0 +1,11 @@
#ifndef OPENMW_COMPONENTS_ESM3_REFNUM_H
#define OPENMW_COMPONENTS_ESM3_REFNUM_H
#include <components/esm/formid.hpp>
namespace ESM
{
using RefNum = ESM::FormId;
}
#endif

@ -32,8 +32,8 @@
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/util.hpp>
#include <components/esm4/reader.hpp>
#include <components/misc/constants.hpp>

@ -9,6 +9,7 @@
#include <components/debug/debuglog.hpp>
#include <components/esm/esmterrain.hpp>
#include <components/esm/util.hpp>
#include <components/esm3/loadland.hpp>
#include <components/esm4/loadland.hpp>
#include <components/misc/resourcehelpers.hpp>

@ -7,7 +7,7 @@
#include <components/terrain/storage.hpp>
#include <components/esm/esmterrain.hpp>
#include <components/esm/util.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/esm3/loadltex.hpp>
namespace ESM4

@ -7,6 +7,7 @@
#include <limits>
#include <components/esm/util.hpp>
#include <components/loadinglistener/reporter.hpp>
#include <components/misc/constants.hpp>
#include <components/misc/mathutil.hpp>

@ -8,8 +8,8 @@
#include <osg/Vec3f>
#include <osg/ref_ptr>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/util.hpp>
#include "defs.hpp"

Loading…
Cancel
Save