mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-04 09:47:46 +00:00
Cleanup
This commit is contained in:
parent
9423a8576e
commit
1ac495192a
5 changed files with 32 additions and 55 deletions
|
@ -169,7 +169,6 @@ void Sapphire::Entity::BNpc::step()
|
||||||
{
|
{
|
||||||
// Reached step in path
|
// Reached step in path
|
||||||
m_naviPathStep++;
|
m_naviPathStep++;
|
||||||
Logger::debug( "Reached step {0}", m_naviPathStep );
|
|
||||||
|
|
||||||
stepPos = m_naviLastPath[m_naviPathStep];
|
stepPos = m_naviLastPath[m_naviPathStep];
|
||||||
}
|
}
|
||||||
|
@ -218,9 +217,6 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
||||||
|
|
||||||
if( !path.empty() )
|
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_naviLastPath = path;
|
||||||
m_naviTarget = pos;
|
m_naviTarget = pos;
|
||||||
m_naviPathStep = 0;
|
m_naviPathStep = 0;
|
||||||
|
@ -228,7 +224,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
||||||
}
|
}
|
||||||
else
|
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() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -379,7 +375,7 @@ void Sapphire::Entity::BNpc::update( int64_t currTime )
|
||||||
{
|
{
|
||||||
const uint8_t minActorDistance = 4;
|
const uint8_t minActorDistance = 4;
|
||||||
const uint8_t aggroRange = 8;
|
const uint8_t aggroRange = 8;
|
||||||
const uint8_t maxDistanceToOrigin = 1000;
|
const uint8_t maxDistanceToOrigin = 40;
|
||||||
|
|
||||||
if( m_status == ActorStatus::Dead )
|
if( m_status == ActorStatus::Dead )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
#include <CommonGen.h>
|
#include <Framework.h>
|
||||||
|
#include <Territory/Zone.h>
|
||||||
|
#include <Logging/Logger.h>
|
||||||
|
|
||||||
#include "Framework.h"
|
|
||||||
#include "NaviProvider.h"
|
#include "NaviProvider.h"
|
||||||
|
|
||||||
#include <recastnavigation/Detour/Include/DetourNavMesh.h>
|
#include <recastnavigation/Detour/Include/DetourNavMesh.h>
|
||||||
#include <recastnavigation/Detour/Include/DetourNavMeshQuery.h>
|
#include <recastnavigation/Detour/Include/DetourNavMeshQuery.h>
|
||||||
#include <experimental/filesystem>
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#include "../Territory/Zone.h"
|
|
||||||
#include <Logging/Logger.h>
|
|
||||||
#include <DetourCommon.h>
|
#include <DetourCommon.h>
|
||||||
#include <recastnavigation/Recast/Include/Recast.h>
|
#include <recastnavigation/Recast/Include/Recast.h>
|
||||||
|
#include <experimental/filesystem>
|
||||||
|
|
||||||
|
|
||||||
Sapphire::NaviProvider::NaviProvider( std::string internalName ) :
|
Sapphire::NaviProvider::NaviProvider( std::string internalName ) :
|
||||||
m_naviMesh( nullptr ),
|
m_naviMesh( nullptr ),
|
||||||
|
@ -26,28 +25,15 @@ Sapphire::NaviProvider::NaviProvider( std::string internalName ) :
|
||||||
|
|
||||||
bool Sapphire::NaviProvider::init()
|
bool Sapphire::NaviProvider::init()
|
||||||
{
|
{
|
||||||
auto meshesFolder = std::filesystem::path( "navi" );
|
auto meshesFolder = std::experimental::filesystem::path( "navi" );
|
||||||
auto meshFolder = meshesFolder / std::filesystem::path( m_internalName );
|
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() );
|
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();
|
initQuery();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -70,7 +56,7 @@ void Sapphire::NaviProvider::initQuery()
|
||||||
m_naviMeshQuery->init( m_naviMesh, 2048 );
|
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 )
|
const dtPolyRef* visited, const int nvisited )
|
||||||
{
|
{
|
||||||
int furthestPath = -1;
|
int furthestPath = -1;
|
||||||
|
@ -115,7 +101,7 @@ static int fixupCorridor( dtPolyRef* path, const int npath, const int maxPath,
|
||||||
return req + size;
|
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 )
|
if( npath < 3 )
|
||||||
return npath;
|
return npath;
|
||||||
|
@ -164,7 +150,7 @@ static int fixupShortcuts( dtPolyRef* path, int npath, dtNavMeshQuery* navQuery
|
||||||
return npath;
|
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 dx = v2[0] - v1[0];
|
||||||
const float dy = v2[1] - v1[1];
|
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;
|
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 float minTargetDist,
|
||||||
const dtPolyRef* path, const int pathSize,
|
const dtPolyRef* path, const int pathSize,
|
||||||
float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef,
|
float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef,
|
||||||
float* outPoints = 0, int* outPointCount = 0 )
|
float* outPoints, int* outPointCount )
|
||||||
{
|
{
|
||||||
// Find steer target.
|
// Find steer target.
|
||||||
static const int MAX_STEER_POINTS = 3;
|
static const int MAX_STEER_POINTS = 3;
|
||||||
|
@ -219,22 +205,6 @@ static bool getSteerTarget( dtNavMeshQuery* navQuery, const float* startPos, con
|
||||||
return true;
|
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 )
|
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 )
|
||||||
|
|
|
@ -53,6 +53,18 @@ namespace Sapphire
|
||||||
dtNavMeshQuery* m_naviMeshQuery;
|
dtNavMeshQuery* m_naviMeshQuery;
|
||||||
|
|
||||||
float m_polyFindRange[3];
|
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 );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -722,7 +722,7 @@ void Sapphire::Zone::registerEObj( Entity::EventObjectPtr object )
|
||||||
|
|
||||||
onRegisterEObj( 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 )
|
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 );
|
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();
|
res.reset();
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "Cell.h"
|
#include "Cell.h"
|
||||||
#include "CellHandler.h"
|
#include "CellHandler.h"
|
||||||
#include "Navi/NaviProvider.h"
|
|
||||||
|
|
||||||
#include "ForwardsZone.h"
|
#include "ForwardsZone.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue