diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index 1f1f7ee7..93de9409 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -169,7 +169,6 @@ void Sapphire::Entity::BNpc::step() { // Reached step in path m_naviPathStep++; - Logger::debug( "Reached step {0}", m_naviPathStep ); stepPos = m_naviLastPath[m_naviPathStep]; } @@ -218,9 +217,6 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos ) if( !path.empty() ) { - for( int i = 0; i < path.size(); i++ ) - Logger::debug( "[MOVETO] {0}: {1} {2} {3}", i, path[i].x, path[i].y, path[i].z ); - m_naviLastPath = path; m_naviTarget = pos; m_naviPathStep = 0; @@ -228,11 +224,11 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos ) } else { - Logger::debug( "No path found for target: {0} {1} {2}", pos.x, pos.y, pos.z ); + Logger::debug( "No path found for target: {0} {1} {2} in ", pos.x, pos.y, pos.z, m_pCurrentZone->getInternalName() ); } } /* - float rot = Util::calcAngFrom( getPos().x, getPos().z, pos.x, pos.z ); + float rot = Util::calcAngFrom( getPos().x, getPos().z, pos.x, pos.z ); float newRot = PI - rot + ( PI / 2 ); face( pos ); @@ -379,7 +375,7 @@ void Sapphire::Entity::BNpc::update( int64_t currTime ) { const uint8_t minActorDistance = 4; const uint8_t aggroRange = 8; - const uint8_t maxDistanceToOrigin = 1000; + const uint8_t maxDistanceToOrigin = 40; if( m_status == ActorStatus::Dead ) return; diff --git a/src/world/Navi/NaviProvider.cpp b/src/world/Navi/NaviProvider.cpp index e50660c3..dbba2801 100644 --- a/src/world/Navi/NaviProvider.cpp +++ b/src/world/Navi/NaviProvider.cpp @@ -1,17 +1,16 @@ #include -#include +#include +#include +#include -#include "Framework.h" #include "NaviProvider.h" + #include #include -#include -#include - -#include "../Territory/Zone.h" -#include #include #include +#include + Sapphire::NaviProvider::NaviProvider( std::string internalName ) : m_naviMesh( nullptr ), @@ -26,28 +25,15 @@ Sapphire::NaviProvider::NaviProvider( std::string internalName ) : bool Sapphire::NaviProvider::init() { - auto meshesFolder = std::filesystem::path( "navi" ); - auto meshFolder = meshesFolder / std::filesystem::path( m_internalName ); + auto meshesFolder = std::experimental::filesystem::path( "navi" ); + auto meshFolder = meshesFolder / std::experimental::filesystem::path( m_internalName ); - if( std::filesystem::exists( meshFolder ) ) + if( std::experimental::filesystem::exists( meshFolder ) ) { - auto baseMesh = meshFolder / std::filesystem::path( m_internalName + ".nav" ); + auto baseMesh = meshFolder / std::experimental::filesystem::path( m_internalName + ".nav" ); loadMesh( baseMesh.string() ); - // Load all meshes for testing - - /* - for( const auto & entry : std::filesystem::directory_iterator( meshFolder ) ) - { - if( entry.path().extension().string() == ".nav" ) - { - Logger::debug( "Loading " + entry.path().string() ); - LoadMesh( entry.path().string() ); - } - } - */ - initQuery(); return true; @@ -70,7 +56,7 @@ void Sapphire::NaviProvider::initQuery() m_naviMeshQuery->init( m_naviMesh, 2048 ); } -static int fixupCorridor( dtPolyRef* path, const int npath, const int maxPath, +int Sapphire::NaviProvider::fixupCorridor( dtPolyRef* path, const int npath, const int maxPath, const dtPolyRef* visited, const int nvisited ) { int furthestPath = -1; @@ -115,7 +101,7 @@ static int fixupCorridor( dtPolyRef* path, const int npath, const int maxPath, return req + size; } -static int fixupShortcuts( dtPolyRef* path, int npath, dtNavMeshQuery* navQuery ) +int Sapphire::NaviProvider::fixupShortcuts( dtPolyRef* path, int npath, dtNavMeshQuery* navQuery ) { if( npath < 3 ) return npath; @@ -164,7 +150,7 @@ static int fixupShortcuts( dtPolyRef* path, int npath, dtNavMeshQuery* navQuery return npath; } -inline bool inRange( const float* v1, const float* v2, const float r, const float h ) +bool Sapphire::NaviProvider::inRange( const float* v1, const float* v2, const float r, const float h ) { const float dx = v2[0] - v1[0]; const float dy = v2[1] - v1[1]; @@ -172,11 +158,11 @@ inline bool inRange( const float* v1, const float* v2, const float r, const floa return ( dx*dx + dz * dz ) < r*r && fabsf( dy ) < h; } -static bool getSteerTarget( dtNavMeshQuery* navQuery, const float* startPos, const float* endPos, +bool Sapphire::NaviProvider::getSteerTarget( dtNavMeshQuery* navQuery, const float* startPos, const float* endPos, const float minTargetDist, const dtPolyRef* path, const int pathSize, float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef, - float* outPoints = 0, int* outPointCount = 0 ) + float* outPoints, int* outPointCount ) { // Find steer target. static const int MAX_STEER_POINTS = 3; @@ -219,22 +205,6 @@ static bool getSteerTarget( dtNavMeshQuery* navQuery, const float* startPos, con return true; } -void Sapphire::NaviProvider::toDetourPos( const Sapphire::Common::FFXIVARR_POSITION3 pos, float* out ) { - float y = pos.y; - float z = pos.z; - - out[0] = pos.x; - out[1] = y * -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 ) { if( !m_naviMesh || !m_naviMeshQuery ) diff --git a/src/world/Navi/NaviProvider.h b/src/world/Navi/NaviProvider.h index 3b0424db..3108a47a 100644 --- a/src/world/Navi/NaviProvider.h +++ b/src/world/Navi/NaviProvider.h @@ -53,6 +53,18 @@ namespace Sapphire dtNavMeshQuery* m_naviMeshQuery; float m_polyFindRange[3]; + + private: + static int fixupCorridor( dtPolyRef* path, const int npath, const int maxPath, + const dtPolyRef* visited, const int nvisited ); + static int fixupShortcuts( dtPolyRef* path, int npath, dtNavMeshQuery* navQuery ); + inline static bool inRange( const float* v1, const float* v2, const float r, const float h ); + static bool getSteerTarget( dtNavMeshQuery* navQuery, const float* startPos, const float* endPos, + const float minTargetDist, + const dtPolyRef* path, const int pathSize, + float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef, + float* outPoints = 0, int* outPointCount = 0 ); + }; } diff --git a/src/world/Territory/Zone.cpp b/src/world/Territory/Zone.cpp index 6dcad395..f5be48e3 100644 --- a/src/world/Territory/Zone.cpp +++ b/src/world/Territory/Zone.cpp @@ -722,7 +722,7 @@ void Sapphire::Zone::registerEObj( Entity::EventObjectPtr object ) onRegisterEObj( object ); - //Logger::debug( "Registered instance eobj: " + std::to_string( object->getId() ) ); + Logger::debug( "Registered instance eobj: " + std::to_string( object->getId() ) ); } Sapphire::Entity::EventObjectPtr Sapphire::Zone::getEObj( uint32_t objId ) @@ -782,7 +782,7 @@ bool Sapphire::Zone::loadSpawnGroups() m_spawnGroups.emplace_back( id, templateId, level, maxHp ); - //Logger::debug( "id: {0}, template: {1}, level: {2}, maxHp: {3}", id, m_spawnGroups.back().getTemplateId(), level, maxHp ); + Logger::debug( "id: {0}, template: {1}, level: {2}, maxHp: {3}", id, m_spawnGroups.back().getTemplateId(), level, maxHp ); } res.reset(); diff --git a/src/world/Territory/Zone.h b/src/world/Territory/Zone.h index ac436be7..657b99c9 100644 --- a/src/world/Territory/Zone.h +++ b/src/world/Territory/Zone.h @@ -6,7 +6,6 @@ #include "Cell.h" #include "CellHandler.h" -#include "Navi/NaviProvider.h" #include "ForwardsZone.h"