forked from teamnwah/openmw-tes3coop
sync with upstream
This commit is contained in:
parent
2421f23c2f
commit
8fa88f4480
7 changed files with 17 additions and 31 deletions
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QtCore/qnamespace.h>
|
#include <qt4/QtCore/qnamespace.h>
|
||||||
|
|
||||||
#include "../../model/filter/parser.hpp"
|
#include "../../model/filter/parser.hpp"
|
||||||
#include "../../model/filter/node.hpp"
|
#include "../../model/filter/node.hpp"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QtCore/qnamespace.h>
|
#include <qt4/QtCore/qnamespace.h>
|
||||||
|
|
||||||
#include "../../model/filter/node.hpp"
|
#include "../../model/filter/node.hpp"
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QtCore/qnamespace.h>
|
#include <qt4/QtCore/qnamespace.h>
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "../doc/subview.hpp"
|
#include "../doc/subview.hpp"
|
||||||
|
|
||||||
#include <QtCore/qnamespace.h>
|
#include <qt4/QtCore/qnamespace.h>
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
|
|
|
@ -240,21 +240,17 @@ namespace MWMechanics
|
||||||
//target is at far distance: build path to target OR follow target (if previously actor had reached it once)
|
//target is at far distance: build path to target OR follow target (if previously actor had reached it once)
|
||||||
mFollowTarget = false;
|
mFollowTarget = false;
|
||||||
|
|
||||||
buildNewPath(actor); //may fail to build a path, check before use
|
buildNewPath(actor);
|
||||||
|
|
||||||
//delete visited path node
|
//delete visited path node
|
||||||
mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2]);
|
mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2]);
|
||||||
|
|
||||||
//if no new path leave mTargetAngle unchanged
|
//try shortcut
|
||||||
if(!mPathFinder.getPath().empty())
|
if(vDir.length() < mPathFinder.getDistToNext(pos.pos[0],pos.pos[1],pos.pos[2]) && MWBase::Environment::get().getWorld()->getLOS(actor, mTarget))
|
||||||
{
|
mTargetAngle = Ogre::Radian( Ogre::Math::ACos(vDir.y / vDir.length()) * sgn(Ogre::Math::ASin(vDir.x / vDir.length())) ).valueDegrees();
|
||||||
//try shortcut
|
else
|
||||||
if(vDir.length() < mPathFinder.getDistToNext(pos.pos[0],pos.pos[1],pos.pos[2]) && MWBase::Environment::get().getWorld()->getLOS(actor, mTarget))
|
mTargetAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]);
|
||||||
mTargetAngle = Ogre::Radian( Ogre::Math::ACos(vDir.y / vDir.length()) * sgn(Ogre::Math::ASin(vDir.x / vDir.length())) ).valueDegrees();
|
mRotate = true;
|
||||||
else
|
|
||||||
mTargetAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]);
|
|
||||||
mRotate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
mMovement.mPosition[1] = 1;
|
mMovement.mPosition[1] = 1;
|
||||||
mReadyToAttack = false;
|
mReadyToAttack = false;
|
||||||
|
@ -304,13 +300,9 @@ namespace MWMechanics
|
||||||
dest.mZ = mTarget.getRefData().getPosition().pos[2];
|
dest.mZ = mTarget.getRefData().getPosition().pos[2];
|
||||||
Ogre::Vector3 newPathTarget = Ogre::Vector3(dest.mX, dest.mY, dest.mZ);
|
Ogre::Vector3 newPathTarget = Ogre::Vector3(dest.mX, dest.mY, dest.mZ);
|
||||||
|
|
||||||
float dist = -1; //hack to indicate first time, to construct a new path
|
ESM::Pathgrid::Point lastPt = mPathFinder.getPath().back();
|
||||||
if(!mPathFinder.getPath().empty())
|
Ogre::Vector3 currPathTarget(lastPt.mX, lastPt.mY, lastPt.mZ);
|
||||||
{
|
float dist = Ogre::Math::Abs((newPathTarget - currPathTarget).length());
|
||||||
ESM::Pathgrid::Point lastPt = mPathFinder.getPath().back();
|
|
||||||
Ogre::Vector3 currPathTarget(lastPt.mX, lastPt.mY, lastPt.mZ);
|
|
||||||
dist = Ogre::Math::Abs((newPathTarget - currPathTarget).length());
|
|
||||||
}
|
|
||||||
|
|
||||||
float targetPosThreshold;
|
float targetPosThreshold;
|
||||||
bool isOutside = actor.getCell()->mCell->isExterior();
|
bool isOutside = actor.getCell()->mCell->isExterior();
|
||||||
|
@ -319,7 +311,7 @@ namespace MWMechanics
|
||||||
else
|
else
|
||||||
targetPosThreshold = 100;
|
targetPosThreshold = 100;
|
||||||
|
|
||||||
if((dist < 0) || (dist > targetPosThreshold))
|
if(dist > targetPosThreshold)
|
||||||
{
|
{
|
||||||
//construct new path only if target has moved away more than on <targetPosThreshold>
|
//construct new path only if target has moved away more than on <targetPosThreshold>
|
||||||
ESM::Position pos = actor.getRefData().getPosition();
|
ESM::Position pos = actor.getRefData().getPosition();
|
||||||
|
@ -340,11 +332,8 @@ namespace MWMechanics
|
||||||
//maybe here is a mistake (?): PathFinder::getPathSize() returns number of grid points in the path,
|
//maybe here is a mistake (?): PathFinder::getPathSize() returns number of grid points in the path,
|
||||||
//not the actual path length. Here we should know if the new path is actually more effective.
|
//not the actual path length. Here we should know if the new path is actually more effective.
|
||||||
//if(pathFinder2.getPathSize() < mPathFinder.getPathSize())
|
//if(pathFinder2.getPathSize() < mPathFinder.getPathSize())
|
||||||
if(!mPathFinder.getPath().empty())
|
newPathFinder.syncStart(mPathFinder.getPath());
|
||||||
{
|
mPathFinder = newPathFinder;
|
||||||
newPathFinder.syncStart(mPathFinder.getPath());
|
|
||||||
mPathFinder = newPathFinder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,8 +391,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
void PathFinder::syncStart(const std::list<ESM::Pathgrid::Point> &path)
|
void PathFinder::syncStart(const std::list<ESM::Pathgrid::Point> &path)
|
||||||
{
|
{
|
||||||
if (mPath.size() < 2)
|
|
||||||
return; //nothing to pop
|
|
||||||
std::list<ESM::Pathgrid::Point>::const_iterator oldStart = path.begin();
|
std::list<ESM::Pathgrid::Point>::const_iterator oldStart = path.begin();
|
||||||
std::list<ESM::Pathgrid::Point>::iterator iter = ++mPath.begin();
|
std::list<ESM::Pathgrid::Point>::iterator iter = ++mPath.begin();
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ Artem Kotsynyak (greye)
|
||||||
athile
|
athile
|
||||||
Britt Mathis (galdor557)
|
Britt Mathis (galdor557)
|
||||||
BrotherBrick
|
BrotherBrick
|
||||||
cc9cii
|
|
||||||
Chris Robinson (KittyCat)
|
Chris Robinson (KittyCat)
|
||||||
Cory F. Cohen (cfcohen)
|
Cory F. Cohen (cfcohen)
|
||||||
Cris Mihalache (Mirceam)
|
Cris Mihalache (Mirceam)
|
||||||
|
|
Loading…
Reference in a new issue