mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-28 20:06:41 +00:00
Fix functions name style
This commit is contained in:
parent
2f424f6be2
commit
31340a212a
4 changed files with 34 additions and 34 deletions
|
@ -303,7 +303,7 @@ namespace MWMechanics
|
||||||
osg::Vec3f localPos = actor.getRefData().getPosition().asVec3();
|
osg::Vec3f localPos = actor.getRefData().getPosition().asVec3();
|
||||||
coords.toLocal(localPos);
|
coords.toLocal(localPos);
|
||||||
|
|
||||||
int closestPointIndex = PathFinder::GetClosestPoint(pathgrid, localPos);
|
int closestPointIndex = PathFinder::getClosestPoint(pathgrid, localPos);
|
||||||
for (int i = 0; i < static_cast<int>(pathgrid->mPoints.size()); i++)
|
for (int i = 0; i < static_cast<int>(pathgrid->mPoints.size()); i++)
|
||||||
{
|
{
|
||||||
if (i != closestPointIndex && getPathGridGraph(storage.mCell).isPointConnected(closestPointIndex, i))
|
if (i != closestPointIndex && getPathGridGraph(storage.mCell).isPointConnected(closestPointIndex, i))
|
||||||
|
@ -355,7 +355,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
float dist = (actor.getRefData().getPosition().asVec3() - target.getRefData().getPosition().asVec3()).length();
|
float dist = (actor.getRefData().getPosition().asVec3() - target.getRefData().getPosition().asVec3()).length();
|
||||||
if ((dist > fFleeDistance && !storage.mLOS)
|
if ((dist > fFleeDistance && !storage.mLOS)
|
||||||
|| pathTo(actor, PathFinder::MakeOsgVec3(storage.mFleeDest), duration))
|
|| pathTo(actor, PathFinder::makeOsgVec3(storage.mFleeDest), duration))
|
||||||
{
|
{
|
||||||
state = AiCombatStorage::FleeState_Idle;
|
state = AiCombatStorage::FleeState_Idle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -593,7 +593,7 @@ namespace MWMechanics
|
||||||
const auto start = actorPos.asVec3();
|
const auto start = actorPos.asVec3();
|
||||||
|
|
||||||
// don't take shortcuts for wandering
|
// don't take shortcuts for wandering
|
||||||
const auto destVec3f = PathFinder::MakeOsgVec3(dest);
|
const auto destVec3f = PathFinder::makeOsgVec3(dest);
|
||||||
mPathFinder.buildSyncedPath(start, destVec3f, actor.getCell(), getPathGridGraph(actor.getCell()));
|
mPathFinder.buildSyncedPath(start, destVec3f, actor.getCell(), getPathGridGraph(actor.getCell()));
|
||||||
|
|
||||||
if (mPathFinder.isPathConstructed())
|
if (mPathFinder.isPathConstructed())
|
||||||
|
@ -730,7 +730,7 @@ namespace MWMechanics
|
||||||
ESM::Pathgrid::Point worldDest = dest;
|
ESM::Pathgrid::Point worldDest = dest;
|
||||||
ToWorldCoordinates(worldDest, actor.getCell()->getCell());
|
ToWorldCoordinates(worldDest, actor.getCell()->getCell());
|
||||||
|
|
||||||
bool isPathGridOccupied = MWBase::Environment::get().getMechanicsManager()->isAnyActorInRange(PathFinder::MakeOsgVec3(worldDest), 60);
|
bool isPathGridOccupied = MWBase::Environment::get().getMechanicsManager()->isAnyActorInRange(PathFinder::makeOsgVec3(worldDest), 60);
|
||||||
|
|
||||||
// add offset only if the selected pathgrid is occupied by another actor
|
// add offset only if the selected pathgrid is occupied by another actor
|
||||||
if (isPathGridOccupied)
|
if (isPathGridOccupied)
|
||||||
|
@ -751,18 +751,18 @@ namespace MWMechanics
|
||||||
ESM::Pathgrid::Point connDest = points[randomIndex];
|
ESM::Pathgrid::Point connDest = points[randomIndex];
|
||||||
|
|
||||||
// add an offset towards random neighboring node
|
// add an offset towards random neighboring node
|
||||||
osg::Vec3f dir = PathFinder::MakeOsgVec3(connDest) - PathFinder::MakeOsgVec3(dest);
|
osg::Vec3f dir = PathFinder::makeOsgVec3(connDest) - PathFinder::makeOsgVec3(dest);
|
||||||
float length = dir.length();
|
float length = dir.length();
|
||||||
dir.normalize();
|
dir.normalize();
|
||||||
|
|
||||||
for (int j = 1; j <= 3; j++)
|
for (int j = 1; j <= 3; j++)
|
||||||
{
|
{
|
||||||
// move for 5-15% towards random neighboring node
|
// move for 5-15% towards random neighboring node
|
||||||
dest = PathFinder::MakePathgridPoint(PathFinder::MakeOsgVec3(dest) + dir * (j * 5 * length / 100.f));
|
dest = PathFinder::makePathgridPoint(PathFinder::makeOsgVec3(dest) + dir * (j * 5 * length / 100.f));
|
||||||
worldDest = dest;
|
worldDest = dest;
|
||||||
ToWorldCoordinates(worldDest, actor.getCell()->getCell());
|
ToWorldCoordinates(worldDest, actor.getCell()->getCell());
|
||||||
|
|
||||||
isOccupied = MWBase::Environment::get().getMechanicsManager()->isAnyActorInRange(PathFinder::MakeOsgVec3(worldDest), 60);
|
isOccupied = MWBase::Environment::get().getMechanicsManager()->isAnyActorInRange(PathFinder::makeOsgVec3(worldDest), 60);
|
||||||
|
|
||||||
if (!isOccupied)
|
if (!isOccupied)
|
||||||
break;
|
break;
|
||||||
|
@ -798,7 +798,7 @@ namespace MWMechanics
|
||||||
const ESM::Pathgrid *pathgrid =
|
const ESM::Pathgrid *pathgrid =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*currentCell->getCell());
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*currentCell->getCell());
|
||||||
|
|
||||||
int index = PathFinder::GetClosestPoint(pathgrid, PathFinder::MakeOsgVec3(dest));
|
int index = PathFinder::getClosestPoint(pathgrid, PathFinder::makeOsgVec3(dest));
|
||||||
|
|
||||||
getPathGridGraph(currentCell).getNeighbouringPoints(index, points);
|
getPathGridGraph(currentCell).getNeighbouringPoints(index, points);
|
||||||
}
|
}
|
||||||
|
@ -831,7 +831,7 @@ namespace MWMechanics
|
||||||
CoordinateConverter(cell).toLocal(npcPos);
|
CoordinateConverter(cell).toLocal(npcPos);
|
||||||
|
|
||||||
// Find closest pathgrid point
|
// Find closest pathgrid point
|
||||||
int closestPointIndex = PathFinder::GetClosestPoint(pathgrid, npcPos);
|
int closestPointIndex = PathFinder::getClosestPoint(pathgrid, npcPos);
|
||||||
|
|
||||||
// mAllowedNodes for this actor with pathgrid point indexes based on mDistance
|
// mAllowedNodes for this actor with pathgrid point indexes based on mDistance
|
||||||
// and if the point is connected to the closest current point
|
// and if the point is connected to the closest current point
|
||||||
|
@ -839,7 +839,7 @@ namespace MWMechanics
|
||||||
int pointIndex = 0;
|
int pointIndex = 0;
|
||||||
for(unsigned int counter = 0; counter < pathgrid->mPoints.size(); counter++)
|
for(unsigned int counter = 0; counter < pathgrid->mPoints.size(); counter++)
|
||||||
{
|
{
|
||||||
osg::Vec3f nodePos(PathFinder::MakeOsgVec3(pathgrid->mPoints[counter]));
|
osg::Vec3f nodePos(PathFinder::makeOsgVec3(pathgrid->mPoints[counter]));
|
||||||
if((npcPos - nodePos).length2() <= mDistance * mDistance &&
|
if((npcPos - nodePos).length2() <= mDistance * mDistance &&
|
||||||
getPathGridGraph(cellStore).isPointConnected(closestPointIndex, counter))
|
getPathGridGraph(cellStore).isPointConnected(closestPointIndex, counter))
|
||||||
{
|
{
|
||||||
|
@ -866,7 +866,7 @@ namespace MWMechanics
|
||||||
// 2. Partway along the path between the point and its connected points.
|
// 2. Partway along the path between the point and its connected points.
|
||||||
void AiWander::AddNonPathGridAllowedPoints(osg::Vec3f npcPos, const ESM::Pathgrid * pathGrid, int pointIndex, AiWanderStorage& storage)
|
void AiWander::AddNonPathGridAllowedPoints(osg::Vec3f npcPos, const ESM::Pathgrid * pathGrid, int pointIndex, AiWanderStorage& storage)
|
||||||
{
|
{
|
||||||
storage.mAllowedNodes.push_back(PathFinder::MakePathgridPoint(npcPos));
|
storage.mAllowedNodes.push_back(PathFinder::makePathgridPoint(npcPos));
|
||||||
for (std::vector<ESM::Pathgrid::Edge>::const_iterator it = pathGrid->mEdges.begin(); it != pathGrid->mEdges.end(); ++it)
|
for (std::vector<ESM::Pathgrid::Edge>::const_iterator it = pathGrid->mEdges.begin(); it != pathGrid->mEdges.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->mV0 == pointIndex)
|
if (it->mV0 == pointIndex)
|
||||||
|
@ -878,8 +878,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
void AiWander::AddPointBetweenPathGridPoints(const ESM::Pathgrid::Point& start, const ESM::Pathgrid::Point& end, AiWanderStorage& storage)
|
void AiWander::AddPointBetweenPathGridPoints(const ESM::Pathgrid::Point& start, const ESM::Pathgrid::Point& end, AiWanderStorage& storage)
|
||||||
{
|
{
|
||||||
osg::Vec3f vectorStart = PathFinder::MakeOsgVec3(start);
|
osg::Vec3f vectorStart = PathFinder::makeOsgVec3(start);
|
||||||
osg::Vec3f delta = PathFinder::MakeOsgVec3(end) - vectorStart;
|
osg::Vec3f delta = PathFinder::makeOsgVec3(end) - vectorStart;
|
||||||
float length = delta.length();
|
float length = delta.length();
|
||||||
delta.normalize();
|
delta.normalize();
|
||||||
|
|
||||||
|
@ -888,7 +888,7 @@ namespace MWMechanics
|
||||||
// must not travel longer than distance between waypoints or NPC goes past waypoint
|
// must not travel longer than distance between waypoints or NPC goes past waypoint
|
||||||
distance = std::min(distance, static_cast<int>(length));
|
distance = std::min(distance, static_cast<int>(length));
|
||||||
delta *= distance;
|
delta *= distance;
|
||||||
storage.mAllowedNodes.push_back(PathFinder::MakePathgridPoint(vectorStart + delta));
|
storage.mAllowedNodes.push_back(PathFinder::makePathgridPoint(vectorStart + delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AiWander::SetCurrentNodeToClosestAllowedNode(const osg::Vec3f& npcPos, AiWanderStorage& storage)
|
void AiWander::SetCurrentNodeToClosestAllowedNode(const osg::Vec3f& npcPos, AiWanderStorage& storage)
|
||||||
|
@ -897,7 +897,7 @@ namespace MWMechanics
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
for (unsigned int counterThree = 0; counterThree < storage.mAllowedNodes.size(); counterThree++)
|
for (unsigned int counterThree = 0; counterThree < storage.mAllowedNodes.size(); counterThree++)
|
||||||
{
|
{
|
||||||
osg::Vec3f nodePos(PathFinder::MakeOsgVec3(storage.mAllowedNodes[counterThree]));
|
osg::Vec3f nodePos(PathFinder::makeOsgVec3(storage.mAllowedNodes[counterThree]));
|
||||||
float tempDist = (npcPos - nodePos).length2();
|
float tempDist = (npcPos - nodePos).length2();
|
||||||
if (tempDist < distanceToClosestNode)
|
if (tempDist < distanceToClosestNode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace
|
||||||
// points to a quadtree may help
|
// points to a quadtree may help
|
||||||
for(unsigned int counter = 0; counter < grid->mPoints.size(); counter++)
|
for(unsigned int counter = 0; counter < grid->mPoints.size(); counter++)
|
||||||
{
|
{
|
||||||
float potentialDistBetween = MWMechanics::PathFinder::DistanceSquared(grid->mPoints[counter], pos);
|
float potentialDistBetween = MWMechanics::PathFinder::distanceSquared(grid->mPoints[counter], pos);
|
||||||
if (potentialDistBetween < closestDistanceReachable)
|
if (potentialDistBetween < closestDistanceReachable)
|
||||||
{
|
{
|
||||||
// found a closer one
|
// found a closer one
|
||||||
|
@ -108,7 +108,7 @@ namespace MWMechanics
|
||||||
* pathgrid point (e.g. wander) then it may be worth while to call
|
* pathgrid point (e.g. wander) then it may be worth while to call
|
||||||
* pop_back() to remove the redundant entry.
|
* pop_back() to remove the redundant entry.
|
||||||
*
|
*
|
||||||
* NOTE: coordinates must be converted prior to calling GetClosestPoint()
|
* NOTE: coordinates must be converted prior to calling getClosestPoint()
|
||||||
*
|
*
|
||||||
* |
|
* |
|
||||||
* | cell
|
* | cell
|
||||||
|
@ -148,16 +148,16 @@ namespace MWMechanics
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: GetClosestPoint expects local coordinates
|
// NOTE: getClosestPoint expects local coordinates
|
||||||
CoordinateConverter converter(mCell->getCell());
|
CoordinateConverter converter(mCell->getCell());
|
||||||
|
|
||||||
// NOTE: It is possible that GetClosestPoint returns a pathgrind point index
|
// NOTE: It is possible that getClosestPoint returns a pathgrind point index
|
||||||
// that is unreachable in some situations. e.g. actor is standing
|
// that is unreachable in some situations. e.g. actor is standing
|
||||||
// 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, &pathgridGraph,
|
std::pair<int, bool> endNode = getClosestReachablePoint(mPathgrid, &pathgridGraph,
|
||||||
|
@ -167,8 +167,8 @@ namespace MWMechanics
|
||||||
// if it's shorter for actor to travel from start to end, than to travel from either
|
// if it's shorter for actor to travel from start to end, than to travel from either
|
||||||
// start or end to nearest pathgrid point, just travel from start to end.
|
// start or end to nearest pathgrid point, just travel from start to end.
|
||||||
float startToEndLength2 = (endPointInLocalCoords - startPointInLocalCoords).length2();
|
float startToEndLength2 = (endPointInLocalCoords - startPointInLocalCoords).length2();
|
||||||
float endTolastNodeLength2 = DistanceSquared(mPathgrid->mPoints[endNode.first], endPointInLocalCoords);
|
float endTolastNodeLength2 = distanceSquared(mPathgrid->mPoints[endNode.first], endPointInLocalCoords);
|
||||||
float startTo1stNodeLength2 = DistanceSquared(mPathgrid->mPoints[startNode], startPointInLocalCoords);
|
float startTo1stNodeLength2 = distanceSquared(mPathgrid->mPoints[startNode], startPointInLocalCoords);
|
||||||
if ((startToEndLength2 < startTo1stNodeLength2) || (startToEndLength2 < endTolastNodeLength2))
|
if ((startToEndLength2 < startTo1stNodeLength2) || (startToEndLength2 < endTolastNodeLength2))
|
||||||
{
|
{
|
||||||
mPath.push_back(endPoint);
|
mPath.push_back(endPoint);
|
||||||
|
@ -184,7 +184,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
ESM::Pathgrid::Point temp(mPathgrid->mPoints[startNode]);
|
ESM::Pathgrid::Point temp(mPathgrid->mPoints[startNode]);
|
||||||
converter.toWorld(temp);
|
converter.toWorld(temp);
|
||||||
mPath.push_back(MakeOsgVec3(temp));
|
mPath.push_back(makeOsgVec3(temp));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -195,8 +195,8 @@ namespace MWMechanics
|
||||||
if (path.size() > 1)
|
if (path.size() > 1)
|
||||||
{
|
{
|
||||||
ESM::Pathgrid::Point secondNode = *(++path.begin());
|
ESM::Pathgrid::Point secondNode = *(++path.begin());
|
||||||
osg::Vec3f firstNodeVec3f = MakeOsgVec3(mPathgrid->mPoints[startNode]);
|
osg::Vec3f firstNodeVec3f = makeOsgVec3(mPathgrid->mPoints[startNode]);
|
||||||
osg::Vec3f secondNodeVec3f = MakeOsgVec3(secondNode);
|
osg::Vec3f secondNodeVec3f = makeOsgVec3(secondNode);
|
||||||
osg::Vec3f toSecondNodeVec3f = secondNodeVec3f - firstNodeVec3f;
|
osg::Vec3f toSecondNodeVec3f = secondNodeVec3f - firstNodeVec3f;
|
||||||
osg::Vec3f toStartPointVec3f = startPointInLocalCoords - firstNodeVec3f;
|
osg::Vec3f toStartPointVec3f = startPointInLocalCoords - firstNodeVec3f;
|
||||||
if (toSecondNodeVec3f * toStartPointVec3f > 0)
|
if (toSecondNodeVec3f * toStartPointVec3f > 0)
|
||||||
|
@ -217,7 +217,7 @@ namespace MWMechanics
|
||||||
[&] (ESM::Pathgrid::Point& point)
|
[&] (ESM::Pathgrid::Point& point)
|
||||||
{
|
{
|
||||||
converter.toWorld(point);
|
converter.toWorld(point);
|
||||||
return MakeOsgVec3(point);
|
return makeOsgVec3(point);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,18 +118,18 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
/// utility function to convert a osg::Vec3f to a Pathgrid::Point
|
/// utility function to convert a osg::Vec3f to a Pathgrid::Point
|
||||||
static ESM::Pathgrid::Point MakePathgridPoint(const osg::Vec3f& v)
|
static ESM::Pathgrid::Point makePathgridPoint(const osg::Vec3f& v)
|
||||||
{
|
{
|
||||||
return ESM::Pathgrid::Point(static_cast<int>(v[0]), static_cast<int>(v[1]), static_cast<int>(v[2]));
|
return ESM::Pathgrid::Point(static_cast<int>(v[0]), static_cast<int>(v[1]), static_cast<int>(v[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// utility function to convert an ESM::Position to a Pathgrid::Point
|
/// utility function to convert an ESM::Position to a Pathgrid::Point
|
||||||
static ESM::Pathgrid::Point MakePathgridPoint(const ESM::Position& p)
|
static ESM::Pathgrid::Point makePathgridPoint(const ESM::Position& p)
|
||||||
{
|
{
|
||||||
return ESM::Pathgrid::Point(static_cast<int>(p.pos[0]), static_cast<int>(p.pos[1]), static_cast<int>(p.pos[2]));
|
return ESM::Pathgrid::Point(static_cast<int>(p.pos[0]), static_cast<int>(p.pos[1]), static_cast<int>(p.pos[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static osg::Vec3f MakeOsgVec3(const ESM::Pathgrid::Point& p)
|
static osg::Vec3f makeOsgVec3(const ESM::Pathgrid::Point& p)
|
||||||
{
|
{
|
||||||
return osg::Vec3f(static_cast<float>(p.mX), static_cast<float>(p.mY), static_cast<float>(p.mZ));
|
return osg::Vec3f(static_cast<float>(p.mX), static_cast<float>(p.mY), static_cast<float>(p.mZ));
|
||||||
}
|
}
|
||||||
|
@ -138,9 +138,9 @@ namespace MWMechanics
|
||||||
// Caller needs to be careful for very short distances (i.e. less than 1)
|
// Caller needs to be careful for very short distances (i.e. less than 1)
|
||||||
// or when accumuating the results i.e. (a + b)^2 != a^2 + b^2
|
// or when accumuating the results i.e. (a + b)^2 != a^2 + b^2
|
||||||
//
|
//
|
||||||
static float DistanceSquared(ESM::Pathgrid::Point point, const osg::Vec3f& pos)
|
static float distanceSquared(ESM::Pathgrid::Point point, const osg::Vec3f& pos)
|
||||||
{
|
{
|
||||||
return (MWMechanics::PathFinder::MakeOsgVec3(point) - pos).length2();
|
return (MWMechanics::PathFinder::makeOsgVec3(point) - pos).length2();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the closest pathgrid point index from the specified position
|
// Return the closest pathgrid point index from the specified position
|
||||||
|
@ -149,18 +149,18 @@ namespace MWMechanics
|
||||||
//
|
//
|
||||||
// NOTE: pos is expected to be in local coordinates, as is grid->mPoints
|
// NOTE: pos is expected to be in local coordinates, as is grid->mPoints
|
||||||
//
|
//
|
||||||
static int GetClosestPoint(const ESM::Pathgrid* grid, const osg::Vec3f& pos)
|
static int getClosestPoint(const ESM::Pathgrid* grid, const osg::Vec3f& pos)
|
||||||
{
|
{
|
||||||
assert(grid && !grid->mPoints.empty());
|
assert(grid && !grid->mPoints.empty());
|
||||||
|
|
||||||
float distanceBetween = DistanceSquared(grid->mPoints[0], pos);
|
float distanceBetween = distanceSquared(grid->mPoints[0], pos);
|
||||||
int closestIndex = 0;
|
int closestIndex = 0;
|
||||||
|
|
||||||
// TODO: if this full scan causes performance problems mapping pathgrid
|
// TODO: if this full scan causes performance problems mapping pathgrid
|
||||||
// points to a quadtree may help
|
// points to a quadtree may help
|
||||||
for(unsigned int counter = 1; counter < grid->mPoints.size(); counter++)
|
for(unsigned int counter = 1; counter < grid->mPoints.size(); counter++)
|
||||||
{
|
{
|
||||||
float potentialDistBetween = DistanceSquared(grid->mPoints[counter], pos);
|
float potentialDistBetween = distanceSquared(grid->mPoints[counter], pos);
|
||||||
if(potentialDistBetween < distanceBetween)
|
if(potentialDistBetween < distanceBetween)
|
||||||
{
|
{
|
||||||
distanceBetween = potentialDistBetween;
|
distanceBetween = potentialDistBetween;
|
||||||
|
|
Loading…
Reference in a new issue