From 31b2a6c9ec9da8c70a269f19ccccbef177643332 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 20 Jul 2022 12:35:13 +0200 Subject: [PATCH] Force always reachable again Reachability still doesn't work properly. Something shifts it in memory but I don't know yet what it is. They however did add something. --- r5dev/naveditor/Sample.cpp | 69 ++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/r5dev/naveditor/Sample.cpp b/r5dev/naveditor/Sample.cpp index cd62621a..fc2d3807 100644 --- a/r5dev/naveditor/Sample.cpp +++ b/r5dev/naveditor/Sample.cpp @@ -174,7 +174,7 @@ void Sample::resetCommonSettings() m_detailSampleDist = 6.0f; m_detailSampleMaxError = 1.0f; m_partitionType = SAMPLE_PARTITION_WATERSHED; - m_reachabilityTableCount = 1; + m_reachabilityTableCount = 4; } hulldef hulls[5] = { {"small",8,72*0.5,70,512.0f}, @@ -651,33 +651,36 @@ void Sample::saveAll(std::string path, dtNavMesh* mesh) header.numTiles++; } memcpy(&header.params, mesh->getParams(), sizeof(dtNavMeshParams)); - header.params.disjointPolyGroupCount = 3; - LinkTableData link_data; - build_link_table(mesh, link_data); - int table_size = ((link_data.setCount + 31) / 32) * link_data.setCount * 32; + //LinkTableData link_data; + //build_link_table(mesh, link_data); + //int table_size = ((link_data.setCount + 31) / 32) * link_data.setCount * 32; - std::vector reachability(table_size, 0); - for (int i = 0; i < link_data.setCount; i++) - set_reachable(reachability, link_data.setCount, i, i, true); + //std::vector reachability(table_size, 0); + //for (int i = 0; i < link_data.setCount; i++) + // set_reachable(reachability, link_data.setCount, i, i, true); - if (reachability.size() > 0) - { - for (size_t i = reachability.size() - 1; i >= 0; i--) - { - if (reachability[i] == 0) - { - reachability.erase(reachability.begin() + i); - table_size--; - } - else - break; - } - } + //if (reachability.size() > 0) + //{ + // for (size_t i = reachability.size() - 1; i >= 0; i--) + // { + // if (reachability[i] == 0) + // { + // reachability.erase(reachability.begin() + i); + // table_size--; + // } + // else + // break; + // } + //} - header.params.disjointPolyGroupCount = link_data.setCount; + //header.params.disjointPolyGroupCount = link_data.setCount; + //header.params.reachabilityTableCount = m_reachabilityTableCount; + //header.params.reachabilityTableSize = table_size; + + header.params.disjointPolyGroupCount = 4; header.params.reachabilityTableCount = m_reachabilityTableCount; - header.params.reachabilityTableSize = table_size; + header.params.reachabilityTableSize = ((header.params.disjointPolyGroupCount + 31) / 32) * header.params.disjointPolyGroupCount * 32; if (*is_tf2)unpatch_headertf2(header); fwrite(&header, sizeof(NavMeshSetHeader), 1, fp); @@ -698,13 +701,23 @@ void Sample::saveAll(std::string path, dtNavMesh* mesh) if (*is_tf2)patch_tiletf2(const_cast(tile)); } - //still dont know what this thing is... - int header_sth = 0; - for (int i = 0; i < link_data.setCount; i++) - fwrite(&header_sth, sizeof(int), 1, fp); + ////still dont know what this thing is... + //int header_sth = 0; + //for (int i = 0; i < link_data.setCount; i++) + // fwrite(&header_sth, sizeof(int), 1, fp); + + //for (int i = 0; i < header.params.reachabilityTableCount; i++) + // fwrite(reachability.data(), sizeof(int), table_size, fp); + + int header_sth[4] = { 0,0,0 }; + fwrite(header_sth, sizeof(int), 4, fp); + + unsigned int reachability[32 * 4]; + for (int i = 0; i < 32 * 4; i++) + reachability[i] = 0xffffffff; for (int i = 0; i < header.params.reachabilityTableCount; i++) - fwrite(reachability.data(), sizeof(int), table_size, fp); + fwrite(reachability, sizeof(int), (header.params.reachabilityTableSize / 4), fp); fclose(fp); } \ No newline at end of file