mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-15 11:58:10 +00:00
Merge branch 'main' into fix/cmake-libs-2
This commit is contained in:
@@ -9,6 +9,21 @@
|
||||
#include "Logger.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
#include "dNavMesh.h"
|
||||
|
||||
namespace {
|
||||
dpGrid* m_Grid = nullptr;
|
||||
dNavMesh* m_NavMesh = nullptr;
|
||||
int32_t phys_sp_tilesize = 205;
|
||||
int32_t phys_sp_tilecount = 12;
|
||||
|
||||
uint32_t m_ZoneID = 0;
|
||||
|
||||
std::vector<dpEntity*> m_StaticEntities;
|
||||
std::vector<dpEntity*> m_DynamicEntites;
|
||||
bool phys_spatial_partitioning = true;
|
||||
};
|
||||
|
||||
void dpWorld::Initialize(unsigned int zoneID, bool generateNewNavMesh) {
|
||||
const auto physSpTilecount = Game::config->GetValue("phys_sp_tilecount");
|
||||
if (!physSpTilecount.empty()) GeneralUtils::TryParse(physSpTilecount, phys_sp_tilecount);
|
||||
@@ -51,7 +66,7 @@ void dpWorld::Reload() {
|
||||
}
|
||||
}
|
||||
|
||||
dpWorld::~dpWorld() {
|
||||
void dpWorld::Shutdown() {
|
||||
if (m_Grid) {
|
||||
// Triple check this is true
|
||||
m_Grid->SetDeleteGrid(true);
|
||||
@@ -65,6 +80,10 @@ dpWorld::~dpWorld() {
|
||||
}
|
||||
}
|
||||
|
||||
bool dpWorld::IsLoaded() {
|
||||
return m_NavMesh->GetdtNavMesh() != nullptr;
|
||||
}
|
||||
|
||||
void dpWorld::StepWorld(float deltaTime) {
|
||||
if (m_Grid) {
|
||||
m_Grid->Update(deltaTime);
|
||||
@@ -91,6 +110,10 @@ void dpWorld::StepWorld(float deltaTime) {
|
||||
}
|
||||
}
|
||||
|
||||
dNavMesh* dpWorld::GetNavMesh() {
|
||||
return m_NavMesh;
|
||||
}
|
||||
|
||||
void dpWorld::AddEntity(dpEntity* entity) {
|
||||
if (m_Grid) entity->SetGrid(m_Grid); //This sorts this entity into the right cell
|
||||
else { //old method, slow
|
||||
@@ -125,7 +148,7 @@ void dpWorld::RemoveEntity(dpEntity* entity) {
|
||||
}
|
||||
}
|
||||
|
||||
bool dpWorld::ShouldUseSP(unsigned int zoneID) {
|
||||
bool dpWorld::ShouldUseSP(uint32_t zoneID) {
|
||||
if (!phys_spatial_partitioning) return false;
|
||||
|
||||
// TODO: Add to this list as needed.
|
||||
|
@@ -1,48 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "Singleton.h"
|
||||
#include <cstdint>
|
||||
|
||||
//Navmesh includes:
|
||||
#include "Recast.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "DetourNavMeshBuilder.h"
|
||||
#include "DetourNavMeshQuery.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "dNavMesh.h"
|
||||
|
||||
class NiPoint3;
|
||||
class dNavMesh;
|
||||
class dpEntity;
|
||||
class dpGrid;
|
||||
|
||||
class dpWorld : public Singleton<dpWorld> {
|
||||
public:
|
||||
void Initialize(unsigned int zoneID, bool generateNewNavMesh = true);
|
||||
namespace dpWorld {
|
||||
void Initialize(uint32_t zoneID, bool generateNewNavMesh = true);
|
||||
void Shutdown();
|
||||
void Reload();
|
||||
|
||||
~dpWorld();
|
||||
|
||||
bool ShouldUseSP(unsigned int zoneID);
|
||||
bool IsLoaded() const { return m_NavMesh->GetdtNavMesh() != nullptr; }
|
||||
bool ShouldUseSP(uint32_t zoneID);
|
||||
bool IsLoaded();
|
||||
|
||||
void StepWorld(float deltaTime);
|
||||
|
||||
void AddEntity(dpEntity* entity);
|
||||
void RemoveEntity(dpEntity* entity);
|
||||
|
||||
dNavMesh* GetNavMesh() { return m_NavMesh; }
|
||||
|
||||
private:
|
||||
dpGrid* m_Grid;
|
||||
bool phys_spatial_partitioning = true;
|
||||
int phys_sp_tilesize = 205;
|
||||
int phys_sp_tilecount = 12;
|
||||
|
||||
std::vector<dpEntity*> m_StaticEntities;
|
||||
std::vector<dpEntity*> m_DynamicEntites;
|
||||
|
||||
dNavMesh* m_NavMesh = nullptr;
|
||||
uint32_t m_ZoneID = 0;
|
||||
dNavMesh* GetNavMesh();
|
||||
};
|
||||
|
Reference in New Issue
Block a user