mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 15:27:13 -04:00
Replace PathFinder::makeOsgVec3 by Misc::Convert::makeOsgVec3f
This commit is contained in:
parent
50f5bc51c6
commit
927b2bcceb
@ -455,7 +455,8 @@ namespace MWMechanics
|
|||||||
float dist
|
float dist
|
||||||
= (actor.getRefData().getPosition().asVec3() - target.getRefData().getPosition().asVec3()).length();
|
= (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, supportedMovementDirections))
|
|| pathTo(
|
||||||
|
actor, Misc::Convert::makeOsgVec3f(storage.mFleeDest), duration, supportedMovementDirections))
|
||||||
{
|
{
|
||||||
state = AiCombatStorage::FleeState_Idle;
|
state = AiCombatStorage::FleeState_Idle;
|
||||||
}
|
}
|
||||||
|
@ -772,7 +772,7 @@ namespace MWMechanics
|
|||||||
const ESM::Pathgrid::Point& connDest = points[randomIndex];
|
const 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) - dest;
|
osg::Vec3f dir = Misc::Convert::makeOsgVec3f(connDest) - dest;
|
||||||
const float length = dir.length();
|
const float length = dir.length();
|
||||||
dir.normalize();
|
dir.normalize();
|
||||||
|
|
||||||
@ -862,7 +862,7 @@ namespace MWMechanics
|
|||||||
size_t pointIndex = 0;
|
size_t pointIndex = 0;
|
||||||
for (size_t counter = 0; counter < pathgrid->mPoints.size(); counter++)
|
for (size_t counter = 0; counter < pathgrid->mPoints.size(); counter++)
|
||||||
{
|
{
|
||||||
const osg::Vec3f nodePos = PathFinder::makeOsgVec3(pathgrid->mPoints[counter]);
|
const osg::Vec3f nodePos = Misc::Convert::makeOsgVec3f(pathgrid->mPoints[counter]);
|
||||||
if ((npcPos - nodePos).length2() <= mDistance * mDistance
|
if ((npcPos - nodePos).length2() <= mDistance * mDistance
|
||||||
&& getPathGridGraph(pathgrid).isPointConnected(closestPointIndex, counter))
|
&& getPathGridGraph(pathgrid).isPointConnected(closestPointIndex, counter))
|
||||||
{
|
{
|
||||||
@ -905,8 +905,8 @@ namespace MWMechanics
|
|||||||
void AiWander::addPositionBetweenPathgridPoints(
|
void AiWander::addPositionBetweenPathgridPoints(
|
||||||
const ESM::Pathgrid::Point& start, const ESM::Pathgrid::Point& end, AiWanderStorage& storage)
|
const ESM::Pathgrid::Point& start, const ESM::Pathgrid::Point& end, AiWanderStorage& storage)
|
||||||
{
|
{
|
||||||
osg::Vec3f vectorStart = PathFinder::makeOsgVec3(start);
|
osg::Vec3f vectorStart = Misc::Convert::makeOsgVec3f(start);
|
||||||
osg::Vec3f delta = PathFinder::makeOsgVec3(end) - vectorStart;
|
osg::Vec3f delta = Misc::Convert::makeOsgVec3f(end) - vectorStart;
|
||||||
float length = delta.length();
|
float length = delta.length();
|
||||||
delta.normalize();
|
delta.normalize();
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
ESM::Pathgrid::Point temp(pathgrid->mPoints[startNode]);
|
ESM::Pathgrid::Point temp(pathgrid->mPoints[startNode]);
|
||||||
converter.toWorld(temp);
|
converter.toWorld(temp);
|
||||||
*out++ = makeOsgVec3(temp);
|
*out++ = Misc::Convert::makeOsgVec3f(temp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -234,8 +234,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(pathgrid->mPoints[startNode]);
|
osg::Vec3f firstNodeVec3f = Misc::Convert::makeOsgVec3f(pathgrid->mPoints[startNode]);
|
||||||
osg::Vec3f secondNodeVec3f = makeOsgVec3(secondNode);
|
osg::Vec3f secondNodeVec3f = Misc::Convert::makeOsgVec3f(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)
|
||||||
@ -259,7 +259,7 @@ namespace MWMechanics
|
|||||||
// convert supplied path to world coordinates
|
// convert supplied path to world coordinates
|
||||||
std::transform(path.begin(), path.end(), out, [&](ESM::Pathgrid::Point& point) {
|
std::transform(path.begin(), path.end(), out, [&](ESM::Pathgrid::Point& point) {
|
||||||
converter.toWorld(point);
|
converter.toWorld(point);
|
||||||
return makeOsgVec3(point);
|
return Misc::Convert::makeOsgVec3f(point);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <components/detournavigator/status.hpp>
|
#include <components/detournavigator/status.hpp>
|
||||||
#include <components/esm/position.hpp>
|
#include <components/esm/position.hpp>
|
||||||
#include <components/esm3/loadpgrd.hpp>
|
#include <components/esm3/loadpgrd.hpp>
|
||||||
|
#include <components/misc/convert.hpp>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
@ -145,18 +146,13 @@ namespace MWMechanics
|
|||||||
mPath.push_back(point);
|
mPath.push_back(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Slightly cheaper version for comparisons.
|
// Slightly cheaper version for comparisons.
|
||||||
// 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(const ESM::Pathgrid::Point& point, const osg::Vec3f& pos)
|
static float distanceSquared(const ESM::Pathgrid::Point& point, const osg::Vec3f& pos)
|
||||||
{
|
{
|
||||||
return (MWMechanics::PathFinder::makeOsgVec3(point) - pos).length2();
|
return (Misc::Convert::makeOsgVec3f(point) - pos).length2();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the closest pathgrid point index from the specified position
|
// Return the closest pathgrid point index from the specified position
|
||||||
|
Loading…
x
Reference in New Issue
Block a user