mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 00:45:36 +00:00
Clamp node positions in exterior cells.
This commit is contained in:
parent
cd3b96b3e8
commit
d2d22e2f23
2 changed files with 32 additions and 6 deletions
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <components/sceneutil/pathgridutil.hpp>
|
#include <components/sceneutil/pathgridutil.hpp>
|
||||||
|
|
||||||
|
#include "../../model/world/cell.hpp"
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/world/commandmacro.hpp"
|
#include "../../model/world/commandmacro.hpp"
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
|
@ -45,6 +46,7 @@ namespace CSVRender
|
||||||
, mPathgridCollection(mData.getPathgrids())
|
, mPathgridCollection(mData.getPathgrids())
|
||||||
, mId(pathgridId)
|
, mId(pathgridId)
|
||||||
, mCoords(coordinates)
|
, mCoords(coordinates)
|
||||||
|
, mInterior(false)
|
||||||
, mConnectionIndicator(false)
|
, mConnectionIndicator(false)
|
||||||
, mConnectionNode(0)
|
, mConnectionNode(0)
|
||||||
, mParent(parent)
|
, mParent(parent)
|
||||||
|
@ -70,6 +72,13 @@ namespace CSVRender
|
||||||
mSelectedNode->addChild(mSelectedGeode);
|
mSelectedNode->addChild(mSelectedGeode);
|
||||||
|
|
||||||
recreateGeometry();
|
recreateGeometry();
|
||||||
|
|
||||||
|
int index = mData.getCells().searchId(mId);
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
const CSMWorld::Cell& cell = mData.getCells().getRecord(index).get();
|
||||||
|
mInterior = cell.mData.mFlags & ESM::Cell::Interior;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pathgrid::~Pathgrid()
|
Pathgrid::~Pathgrid()
|
||||||
|
@ -187,9 +196,9 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
osg::Vec3d localCoords = worldPos - mBaseNode->getPosition();
|
osg::Vec3d localCoords = worldPos - mBaseNode->getPosition();
|
||||||
|
|
||||||
int posX = static_cast<int>(localCoords.x());
|
int posX = clampToCell(static_cast<int>(localCoords.x()));
|
||||||
int posY = static_cast<int>(localCoords.y());
|
int posY = clampToCell(static_cast<int>(localCoords.y()));
|
||||||
int posZ = static_cast<int>(localCoords.z());
|
int posZ = clampToCell(static_cast<int>(localCoords.z()));
|
||||||
|
|
||||||
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(
|
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(
|
||||||
CSMWorld::UniversalId::Type_Pathgrids));
|
CSMWorld::UniversalId::Type_Pathgrids));
|
||||||
|
@ -254,13 +263,13 @@ namespace CSVRender
|
||||||
int row = static_cast<int>(mSelected[i]);
|
int row = static_cast<int>(mSelected[i]);
|
||||||
|
|
||||||
commands.push(new CSMWorld::ModifyCommand(*model, model->index(row, posXColumn, parent),
|
commands.push(new CSMWorld::ModifyCommand(*model, model->index(row, posXColumn, parent),
|
||||||
point.mX + offsetX));
|
clampToCell(point.mX + offsetX)));
|
||||||
|
|
||||||
commands.push(new CSMWorld::ModifyCommand(*model, model->index(row, posYColumn, parent),
|
commands.push(new CSMWorld::ModifyCommand(*model, model->index(row, posYColumn, parent),
|
||||||
point.mY + offsetY));
|
clampToCell(point.mY + offsetY)));
|
||||||
|
|
||||||
commands.push(new CSMWorld::ModifyCommand(*model, model->index(row, posZColumn, parent),
|
commands.push(new CSMWorld::ModifyCommand(*model, model->index(row, posZColumn, parent),
|
||||||
point.mZ + offsetZ));
|
clampToCell(point.mZ + offsetZ)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,4 +490,18 @@ namespace CSVRender
|
||||||
commands.push(new CSMWorld::ModifyCommand(*model, model->index(row, edge1Column, parent), node1));
|
commands.push(new CSMWorld::ModifyCommand(*model, model->index(row, edge1Column, parent), node1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Pathgrid::clampToCell(int v)
|
||||||
|
{
|
||||||
|
const int CellExtent = ESM::Land::REAL_SIZE;
|
||||||
|
|
||||||
|
if (mInterior)
|
||||||
|
return v;
|
||||||
|
else if (v > CellExtent)
|
||||||
|
return CellExtent;
|
||||||
|
else if (v < 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ namespace CSVRender
|
||||||
CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& mPathgridCollection;
|
CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& mPathgridCollection;
|
||||||
std::string mId;
|
std::string mId;
|
||||||
CSMWorld::CellCoordinates mCoords;
|
CSMWorld::CellCoordinates mCoords;
|
||||||
|
bool mInterior;
|
||||||
|
|
||||||
NodeList mSelected;
|
NodeList mSelected;
|
||||||
bool mConnectionIndicator;
|
bool mConnectionIndicator;
|
||||||
|
@ -117,6 +118,8 @@ namespace CSVRender
|
||||||
unsigned short node2);
|
unsigned short node2);
|
||||||
void removeEdge(CSMWorld::CommandMacro& commands, const CSMWorld::Pathgrid& source, unsigned short node1,
|
void removeEdge(CSMWorld::CommandMacro& commands, const CSMWorld::Pathgrid& source, unsigned short node1,
|
||||||
unsigned short node2);
|
unsigned short node2);
|
||||||
|
|
||||||
|
int clampToCell(int v);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue