mirror of https://github.com/OpenMW/openmw.git
Remove unnecessary loops from path
This prevents actors going back when a new shortest path includes a point behind them where they were right before. Such situation can happen when path includes off mesh connection. Resulting cost of such path can be lower than the real one because off mesh connections are straight lines and walking surface usually is not a plane but a surface. Skip to path point where distance from current position to the line between previous and this point is less than point tolerance. Which means actor is standing very close to the edge between those points. Additionally check by navmesh raycasting to make sure there is actually a valid path.C++20
parent
c263bbf0f6
commit
7ec7c57879
@ -0,0 +1,16 @@
|
||||
#ifndef OPENMW_COMPONENTS_MISC_MATH_H
|
||||
#define OPENMW_COMPONENTS_MISC_MATH_H
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
inline osg::Vec3f getVectorToLine(const osg::Vec3f& position, const osg::Vec3f& a, const osg::Vec3f& b)
|
||||
{
|
||||
osg::Vec3f direction = b - a;
|
||||
direction.normalize();
|
||||
return (position - a) ^ direction;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue