mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 07:07:45 +00:00
More pathing
This commit is contained in:
parent
8c6c8bc787
commit
1927b2b1a4
3 changed files with 25 additions and 2 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include "BNpcTemplate.h"
|
#include "BNpcTemplate.h"
|
||||||
#include "Manager/TerritoryMgr.h"
|
#include "Manager/TerritoryMgr.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
#include <Logging/Logger.h>
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire::Common;
|
||||||
using namespace Sapphire::Network::Packets;
|
using namespace Sapphire::Network::Packets;
|
||||||
|
@ -155,7 +156,16 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
||||||
|
|
||||||
auto path = m_pCurrentZone->getNaviProvider()->findFollowPath( m_pos, pos );
|
auto path = m_pCurrentZone->getNaviProvider()->findFollowPath( m_pos, pos );
|
||||||
|
|
||||||
//face( path[0] );
|
if(!path.empty())
|
||||||
|
{
|
||||||
|
for(int i = 0; i < path.size(); i++)
|
||||||
|
Logger::debug("{0}: {1} {2} {3}", i, path[i].x, path[i].y, path[i].z);
|
||||||
|
|
||||||
|
face( path[0] );
|
||||||
|
setPos(path[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sendPositionUpdate();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
float rot = Util::calcAngFrom( getPos().x, getPos().z, pos.x, pos.z );
|
float rot = Util::calcAngFrom( getPos().x, getPos().z, pos.x, pos.z );
|
||||||
|
|
|
@ -225,6 +225,13 @@ void Sapphire::NaviProvider::toDetourPos( const Sapphire::Common::FFXIVARR_POSIT
|
||||||
out[2] = z * -1;
|
out[2] = z * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sapphire::Common::FFXIVARR_POSITION3 Sapphire::NaviProvider::toGamePos( float* pos ) {
|
||||||
|
float y = pos[1];
|
||||||
|
float z = pos[2];
|
||||||
|
|
||||||
|
return Common::FFXIVARR_POSITION3 { pos[0], y * -1, z * -1 };
|
||||||
|
}
|
||||||
|
|
||||||
std::vector< Sapphire::Common::FFXIVARR_POSITION3 > Sapphire::NaviProvider::findFollowPath( Common::FFXIVARR_POSITION3 startPos, Common::FFXIVARR_POSITION3 endPos )
|
std::vector< Sapphire::Common::FFXIVARR_POSITION3 > Sapphire::NaviProvider::findFollowPath( Common::FFXIVARR_POSITION3 startPos, Common::FFXIVARR_POSITION3 endPos )
|
||||||
{
|
{
|
||||||
if( !m_naviMesh || !m_naviMeshQuery )
|
if( !m_naviMesh || !m_naviMeshQuery )
|
||||||
|
@ -234,11 +241,16 @@ std::vector< Sapphire::Common::FFXIVARR_POSITION3 > Sapphire::NaviProvider::find
|
||||||
|
|
||||||
dtPolyRef startRef, endRef = 0;
|
dtPolyRef startRef, endRef = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
float spos[3];
|
float spos[3];
|
||||||
NaviProvider::toDetourPos( startPos, spos );
|
NaviProvider::toDetourPos( startPos, spos );
|
||||||
|
|
||||||
float epos[3];
|
float epos[3];
|
||||||
NaviProvider::toDetourPos( endPos, epos );
|
NaviProvider::toDetourPos( endPos, epos );
|
||||||
|
*/
|
||||||
|
|
||||||
|
float spos[3] = {startPos.x, startPos.y, startPos.z};
|
||||||
|
float epos[3] = {endPos.x, endPos.y, endPos.z};
|
||||||
|
|
||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
filter.setIncludeFlags( 0xffff );
|
filter.setIncludeFlags( 0xffff );
|
||||||
|
@ -383,7 +395,7 @@ std::vector< Sapphire::Common::FFXIVARR_POSITION3 > Sapphire::NaviProvider::find
|
||||||
|
|
||||||
for( int i = 0; i < numSmoothPath; i += 3 )
|
for( int i = 0; i < numSmoothPath; i += 3 )
|
||||||
{
|
{
|
||||||
resultCoords.push_back( Common::FFXIVARR_POSITION3{ smoothPath[i], smoothPath[i + 2], smoothPath[i + 3] } );
|
resultCoords.push_back( Common::FFXIVARR_POSITION3{ smoothPath[i], smoothPath[i + 1], smoothPath[i + 2] } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace Sapphire
|
||||||
void initQuery();
|
void initQuery();
|
||||||
|
|
||||||
void toDetourPos(const Common::FFXIVARR_POSITION3 position, float* out);
|
void toDetourPos(const Common::FFXIVARR_POSITION3 position, float* out);
|
||||||
|
Sapphire::Common::FFXIVARR_POSITION3 toGamePos( float* pos );
|
||||||
|
|
||||||
std::vector< Sapphire::Common::FFXIVARR_POSITION3 > findFollowPath(Common::FFXIVARR_POSITION3 startPos, Common::FFXIVARR_POSITION3 endPos);
|
std::vector< Sapphire::Common::FFXIVARR_POSITION3 > findFollowPath(Common::FFXIVARR_POSITION3 startPos, Common::FFXIVARR_POSITION3 endPos);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue