11/*
2- NavPower.h - v1.2 .0
2+ NavPower.h - v2.0 .0
33A header file for use with NavPower's binary navmesh files.
44
55Licensed under the MIT License
@@ -149,11 +149,11 @@ namespace NavPower
149149 uint32_t m_kdTreeBytes;
150150 uint32_t m_linkRecordBytes = 0 ;
151151 uint32_t m_totalBytes;
152- float m_buildScale = 2.0 ;
153- float m_voxSize = 0.1 ;
154- float m_radius = 0.2 ;
155- float m_stepHeight = 0.3 ;
156- float m_height = 1.8 ; // Human Height
152+ float m_buildScale = 2 .0f ;
153+ float m_voxSize = 0 .1f ;
154+ float m_radius = 0 .2f ;
155+ float m_stepHeight = 0 .3f ;
156+ float m_height = 1 .8f ; // Human Height
157157 BBox m_bbox;
158158 Axis m_buildUpAxis = Axis::Z;
159159 // In NAVPs from Hitman WoA the padding isn't just 0x00
@@ -408,22 +408,19 @@ namespace NavPower
408408 bool compareY (Area& a1, Area& a2);
409409 bool compareZ (Area& a1, Area& a2);
410410
411- class NavMesh
411+ class NavGraph
412412 {
413413 public:
414- Binary::Header* m_hdr;
415- Binary::SectionHeader* m_sectHdr;
416- Binary::NavSetHeader* m_setHdr;
417- Binary::NavGraphHeader* m_graphHdr;
414+ Binary::NavGraphHeader* m_hdr;
418415 std::vector<Area> m_areas;
419416 Binary::KDTreeData* m_kdTreeData;
420417 Binary::KDNode* m_rootKDNode;
421418
422- NavMesh () {};
423- NavMesh ( const char * p_NavMeshPath) { readJson (p_NavMeshPath);} ;
419+ NavGraph () {};
420+ NavGraph ( auto s_NavGraphJson) ;
424421
425422
426- NavMesh (uintptr_t p_data, uint32_t p_filesize ) { read (p_data, p_filesize ); };
423+ NavGraph (uintptr_t p_data) { read (p_data); };
427424
428425 // Build m_areas pointer to index map so the pointers can be replaced with indices (+1) in the JSON file
429426 std::map<Binary::Area*, uint32_t > AreaPointerToIndexMap ();
@@ -451,10 +448,10 @@ namespace NavPower
451448 uint32_t generateKdTree (uintptr_t s_nodePtr, std::vector<Area>& s_areas, std::map<Binary::Area*, uint32_t >& p_AreaPointerToNavGraphOffsetMap);
452449
453450 void writeJson (std::ostream& f);
454- void readJson (const char * p_NavMeshPath );
451+ void readJson (auto s_NavGraphJson );
455452 void writeBinary (std::ostream& f);
456453
457- void read (uintptr_t p_data, uint32_t p_filesize );
454+ void read (uintptr_t & p_data);
458455
459456 // This parses the k-d tree and outputs it as a vector of bounding boxes
460457 std::map<uint32_t , std::vector<std::pair<uint32_t , BBox>>> ParseKDTree ()
@@ -507,6 +504,44 @@ namespace NavPower
507504 }
508505 };
509506
507+ class Section
508+ {
509+ public:
510+ Binary::SectionHeader* m_hdr;
511+ Binary::NavSetHeader* m_setHdr;
512+ std::vector<NavGraph> m_aNavGraphs;
513+
514+ Section (){};
515+ Section (uintptr_t & p_data) { read (p_data); };
516+
517+ void read (uintptr_t & p_data);
518+
519+ void readJson (auto p_SectionJson);
520+
521+ void writeJson (std::ofstream& f);
522+
523+ void writeBinary (std::ostream& f);
524+ };
525+
526+ class NavMesh
527+ {
528+ public:
529+ Binary::Header* m_hdr;
530+ std::vector<Section> m_aSections;
531+
532+ NavMesh () {};
533+ NavMesh (const char * p_NavGraphJsonPath);
534+ NavMesh (uintptr_t p_data, uint32_t p_filesize) { read (p_data, p_filesize); };
535+
536+ void read (uintptr_t p_data, uint32_t p_filesize);
537+
538+ void readJson (const char * p_NavGraphJsonPath);
539+
540+ void writeJson (std::ofstream& f);
541+
542+ void writeBinary (std::ostream& f);
543+ };
544+
510545 // This function was made by github.com/OrfeasZ aka NoFaTe
511546 uint32_t CalculateChecksum (void * p_Data, uint32_t p_Size);
512547} // namespace NavPower
0 commit comments