forked from teamnwah/openmw-tes3coop
Fixed errors pointed out by Zini.
1. Removed "Actor" from name of function isActorNearInactiveCell(). 2. Corrected case of CoordinateConverter member function names.
This commit is contained in:
parent
10eabc9d51
commit
8e2fe1985d
7 changed files with 19 additions and 19 deletions
|
@ -36,7 +36,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
|
||||||
//... At current time, this test is unnecessary. AI shuts down when actor is more than 7168
|
//... At current time, this test is unnecessary. AI shuts down when actor is more than 7168
|
||||||
//... units from player, and exterior cells are 8192 units long and wide.
|
//... units from player, and exterior cells are 8192 units long and wide.
|
||||||
//... But AI processing distance may increase in the future.
|
//... But AI processing distance may increase in the future.
|
||||||
if (isActorNearInactiveCell(pos))
|
if (isNearInactiveCell(pos))
|
||||||
{
|
{
|
||||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
return false;
|
return false;
|
||||||
|
@ -114,14 +114,14 @@ bool MWMechanics::AiPackage::isTargetMagicallyHidden(const MWWorld::Ptr& target)
|
||||||
|| (magicEffects.get(ESM::MagicEffect::Chameleon).getMagnitude() > 75);
|
|| (magicEffects.get(ESM::MagicEffect::Chameleon).getMagnitude() > 75);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWMechanics::AiPackage::isActorNearInactiveCell(const ESM::Position& actorPos)
|
bool MWMechanics::AiPackage::isNearInactiveCell(const ESM::Position& actorPos)
|
||||||
{
|
{
|
||||||
const ESM::Cell* playerCell(getPlayer().getCell()->getCell());
|
const ESM::Cell* playerCell(getPlayer().getCell()->getCell());
|
||||||
if (playerCell->isExterior())
|
if (playerCell->isExterior())
|
||||||
{
|
{
|
||||||
// get actor's distance from origin of center cell
|
// get actor's distance from origin of center cell
|
||||||
osg::Vec3f actorOffset(actorPos.asVec3());
|
osg::Vec3f actorOffset(actorPos.asVec3());
|
||||||
CoordinateConverter(playerCell).ToLocal(actorOffset);
|
CoordinateConverter(playerCell).toLocal(actorOffset);
|
||||||
|
|
||||||
// currently assumes 3 x 3 grid for exterior cells, with player at center cell.
|
// currently assumes 3 x 3 grid for exterior cells, with player at center cell.
|
||||||
// ToDo: (Maybe) use "exterior cell load distance" setting to get count of actual active cells
|
// ToDo: (Maybe) use "exterior cell load distance" setting to get count of actual active cells
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void evadeObstacles(const MWWorld::Ptr& actor, float duration, ESM::Position& pos);
|
void evadeObstacles(const MWWorld::Ptr& actor, float duration, ESM::Position& pos);
|
||||||
bool isActorNearInactiveCell(const ESM::Position& actorPos);
|
bool isNearInactiveCell(const ESM::Position& actorPos);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -588,7 +588,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
void AiWander::ToWorldCoordinates(ESM::Pathgrid::Point& point, const ESM::Cell * cell)
|
void AiWander::ToWorldCoordinates(ESM::Pathgrid::Point& point, const ESM::Cell * cell)
|
||||||
{
|
{
|
||||||
CoordinateConverter(cell).ToWorld(point);
|
CoordinateConverter(cell).toWorld(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AiWander::trimAllowedNodes(std::vector<ESM::Pathgrid::Point>& nodes,
|
void AiWander::trimAllowedNodes(std::vector<ESM::Pathgrid::Point>& nodes,
|
||||||
|
@ -746,7 +746,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
// get NPC's position in local (i.e. cell) co-ordinates
|
// get NPC's position in local (i.e. cell) co-ordinates
|
||||||
osg::Vec3f npcPos(mInitialActorPosition);
|
osg::Vec3f npcPos(mInitialActorPosition);
|
||||||
CoordinateConverter(cell).ToLocal(npcPos);
|
CoordinateConverter(cell).toLocal(npcPos);
|
||||||
|
|
||||||
// mAllowedNodes for this actor with pathgrid point indexes based on mDistance
|
// mAllowedNodes for this actor with pathgrid point indexes based on mDistance
|
||||||
// NOTE: mPoints and mAllowedNodes are in local co-ordinates
|
// NOTE: mPoints and mAllowedNodes are in local co-ordinates
|
||||||
|
|
|
@ -15,25 +15,25 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoordinateConverter::ToWorld(ESM::Pathgrid::Point& point)
|
void CoordinateConverter::toWorld(ESM::Pathgrid::Point& point)
|
||||||
{
|
{
|
||||||
point.mX += mCellX;
|
point.mX += mCellX;
|
||||||
point.mY += mCellY;
|
point.mY += mCellY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoordinateConverter::ToWorld(osg::Vec3f& point)
|
void CoordinateConverter::toWorld(osg::Vec3f& point)
|
||||||
{
|
{
|
||||||
point.x() += static_cast<float>(mCellX);
|
point.x() += static_cast<float>(mCellX);
|
||||||
point.y() += static_cast<float>(mCellY);
|
point.y() += static_cast<float>(mCellY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoordinateConverter::ToLocal(osg::Vec3f& point)
|
void CoordinateConverter::toLocal(osg::Vec3f& point)
|
||||||
{
|
{
|
||||||
point.x() -= static_cast<float>(mCellX);
|
point.x() -= static_cast<float>(mCellX);
|
||||||
point.y() -= static_cast<float>(mCellY);
|
point.y() -= static_cast<float>(mCellY);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec3f CoordinateConverter::ToLocalVec3(const ESM::Pathgrid::Point& point)
|
osg::Vec3f CoordinateConverter::toLocalVec3(const ESM::Pathgrid::Point& point)
|
||||||
{
|
{
|
||||||
return osg::Vec3f(
|
return osg::Vec3f(
|
||||||
static_cast<float>(point.mX - mCellX),
|
static_cast<float>(point.mX - mCellX),
|
||||||
|
|
|
@ -18,15 +18,15 @@ namespace MWMechanics
|
||||||
CoordinateConverter(const ESM::Cell* cell);
|
CoordinateConverter(const ESM::Cell* cell);
|
||||||
|
|
||||||
/// in-place conversion from local to world
|
/// in-place conversion from local to world
|
||||||
void ToWorld(ESM::Pathgrid::Point& point);
|
void toWorld(ESM::Pathgrid::Point& point);
|
||||||
|
|
||||||
/// in-place conversion from local to world
|
/// in-place conversion from local to world
|
||||||
void ToWorld(osg::Vec3f& point);
|
void toWorld(osg::Vec3f& point);
|
||||||
|
|
||||||
/// in-place conversion from world to local
|
/// in-place conversion from world to local
|
||||||
void ToLocal(osg::Vec3f& point);
|
void toLocal(osg::Vec3f& point);
|
||||||
|
|
||||||
osg::Vec3f ToLocalVec3(const ESM::Pathgrid::Point& point);
|
osg::Vec3f toLocalVec3(const ESM::Pathgrid::Point& point);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mCellX;
|
int mCellX;
|
||||||
|
|
|
@ -207,10 +207,10 @@ namespace MWMechanics
|
||||||
// outside an area enclosed by walls, but there is a pathgrid
|
// outside an area enclosed by walls, but there is a pathgrid
|
||||||
// point right behind the wall that is closer than any pathgrid
|
// point right behind the wall that is closer than any pathgrid
|
||||||
// point outside the wall
|
// point outside the wall
|
||||||
osg::Vec3f startPointInLocalCoords(converter.ToLocalVec3(startPoint));
|
osg::Vec3f startPointInLocalCoords(converter.toLocalVec3(startPoint));
|
||||||
int startNode = getClosestPoint(mPathgrid, startPointInLocalCoords);
|
int startNode = getClosestPoint(mPathgrid, startPointInLocalCoords);
|
||||||
|
|
||||||
osg::Vec3f endPointInLocalCoords(converter.ToLocalVec3(endPoint));
|
osg::Vec3f endPointInLocalCoords(converter.toLocalVec3(endPoint));
|
||||||
std::pair<int, bool> endNode = getClosestReachablePoint(mPathgrid, cell,
|
std::pair<int, bool> endNode = getClosestReachablePoint(mPathgrid, cell,
|
||||||
endPointInLocalCoords,
|
endPointInLocalCoords,
|
||||||
startNode);
|
startNode);
|
||||||
|
@ -223,7 +223,7 @@ namespace MWMechanics
|
||||||
if(startNode == endNode.first)
|
if(startNode == endNode.first)
|
||||||
{
|
{
|
||||||
ESM::Pathgrid::Point temp(mPathgrid->mPoints[startNode]);
|
ESM::Pathgrid::Point temp(mPathgrid->mPoints[startNode]);
|
||||||
converter.ToWorld(temp);
|
converter.toWorld(temp);
|
||||||
mPath.push_back(temp);
|
mPath.push_back(temp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -233,7 +233,7 @@ namespace MWMechanics
|
||||||
// convert supplied path to world co-ordinates
|
// convert supplied path to world co-ordinates
|
||||||
for (std::list<ESM::Pathgrid::Point>::iterator iter(mPath.begin()); iter != mPath.end(); ++iter)
|
for (std::list<ESM::Pathgrid::Point>::iterator iter(mPath.begin()); iter != mPath.end(); ++iter)
|
||||||
{
|
{
|
||||||
converter.ToWorld(*iter);
|
converter.toWorld(*iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ void Pathgrid::enableCellPathgrid(const MWWorld::CellStore *store)
|
||||||
if (!pathgrid) return;
|
if (!pathgrid) return;
|
||||||
|
|
||||||
osg::Vec3f cellPathGridPos(0, 0, 0);
|
osg::Vec3f cellPathGridPos(0, 0, 0);
|
||||||
MWMechanics::CoordinateConverter(store->getCell()).ToWorld(cellPathGridPos);
|
MWMechanics::CoordinateConverter(store->getCell()).toWorld(cellPathGridPos);
|
||||||
|
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> cellPathGrid = new osg::PositionAttitudeTransform;
|
osg::ref_ptr<osg::PositionAttitudeTransform> cellPathGrid = new osg::PositionAttitudeTransform;
|
||||||
cellPathGrid->setPosition(cellPathGridPos);
|
cellPathGrid->setPosition(cellPathGridPos);
|
||||||
|
|
Loading…
Reference in a new issue