Improve struct member naming consistency

Improved alignment of class 'Sample' and improved naming consistency.
This commit is contained in:
Kawe Mazidjatari 2022-07-18 19:32:36 +02:00
parent aaec14c3d4
commit 9f27b58f95
6 changed files with 37 additions and 39 deletions

View File

@ -174,7 +174,7 @@ void Sample::resetCommonSettings()
m_detailSampleDist = 6.0f;
m_detailSampleMaxError = 1.0f;
m_partitionType = SAMPLE_PARTITION_WATERSHED;
m_count_reachability_tables = 1;
m_reachabilityTableCount = 1;
}
hulldef hulls[5] = {
{"small",8,72*0.5,70,512.0f},
@ -194,8 +194,8 @@ void Sample::handleCommonSettings()
m_agentMaxClimb = h.climb_height;
m_agentHeight = h.height;
if (is_human)
m_count_reachability_tables = 4;
m_navmesh_name = h.name;
m_reachabilityTableCount = 4;
m_navmeshName = h.name;
}
is_human = false;
}
@ -483,7 +483,7 @@ void build_link_table(dtNavMesh* mesh, LinkTableData& data)
for (int j = 0; j < pcount; j++)
{
auto& poly = tile->polys[j];
poly.link_table_idx = -1;
poly.disjointSetId = -1;
}
}
//first pass
@ -504,18 +504,18 @@ void build_link_table(dtNavMesh* mesh, LinkTableData& data)
const dtPoly* p;
mesh->getTileAndPolyByRefUnsafe(l.ref, &t, &p);
if (p->link_table_idx != (unsigned short)-1)
nlabels.insert(p->link_table_idx);
if (p->disjointSetId != (unsigned short)-1)
nlabels.insert(p->disjointSetId);
plink = l.next;
}
if (nlabels.empty())
{
poly.link_table_idx = data.insert_new();
poly.disjointSetId = data.insert_new();
}
else
{
auto l = *nlabels.begin();
poly.link_table_idx = l;
poly.disjointSetId = l;
for (auto nl : nlabels)
data.set_union(l, nl);
}
@ -531,8 +531,8 @@ void build_link_table(dtNavMesh* mesh, LinkTableData& data)
for (int j = 0; j < pcount; j++)
{
auto& poly = tile->polys[j];
auto id = data.find(poly.link_table_idx);
poly.link_table_idx = id;
auto id = data.find(poly.disjointSetId);
poly.disjointSetId = id;
}
}
}
@ -551,7 +551,7 @@ dtNavMesh* Sample::loadAll(const char* path)
{
char buffer[256];
sprintf(buffer, "%s_%s.nm", path, m_navmesh_name);
sprintf(buffer, "%s_%s.nm", path, m_navmeshName);
FILE* fp = fopen(buffer, "rb");
if (!fp) return 0;
@ -636,7 +636,7 @@ void Sample::saveAll(std::string path, dtNavMesh* mesh)
}
char buffer[256];
sprintf(buffer, "%s_%s.nm", path.c_str(), m_navmesh_name);
sprintf(buffer, "%s_%s.nm", path.c_str(), m_navmeshName);
FILE* fp = fopen(buffer, "wb");
if (!fp)
@ -655,8 +655,8 @@ void Sample::saveAll(std::string path, dtNavMesh* mesh)
header.numTiles++;
}
memcpy(&header.params, mesh->getParams(), sizeof(dtNavMeshParams));
header.params.disjoint_poly_group_count = 3;
header.params.reachability_table_size = ((header.params.disjoint_poly_group_count + 31) / 32) * header.params.disjoint_poly_group_count * 32;
header.params.disjointPolyGroupCount = 3;
header.params.reachabilityTableSize = ((header.params.disjointPolyGroupCount + 31) / 32) * header.params.disjointPolyGroupCount * 32;
if (*is_tf2)unpatch_headertf2(header);
fwrite(&header, sizeof(NavMeshSetHeader), 1, fp);
@ -683,8 +683,8 @@ void Sample::saveAll(std::string path, dtNavMesh* mesh)
for (int i = 0; i < 32 * 3; i++)
reachability[i] = 0xffffffff;
for (int i = 0; i < header.params.reachability_table_count; i++)
fwrite(reachability, sizeof(int), (header.params.reachability_table_size / 4), fp);
for (int i = 0; i < header.params.reachabilityTableCount; i++)
fwrite(reachability, sizeof(int), (header.params.reachabilityTableSize / 4), fp);
fclose(fp);
}
@ -700,7 +700,7 @@ void Sample::saveAll(std::string path, dtNavMesh* mesh)
// }
//
// char buffer[256];
// sprintf(buffer, "%s_%s.nm", path.c_str(), m_navmesh_name);
// sprintf(buffer, "%s_%s.nm", path.c_str(), m_navmeshName);
//
// FILE* fp = fopen(buffer, "wb");
// if (!fp)
@ -719,14 +719,14 @@ void Sample::saveAll(std::string path, dtNavMesh* mesh)
// header.numTiles++;
// }
// memcpy(&header.params, mesh->getParams(), sizeof(dtNavMeshParams));
// header.params.disjoint_poly_group_count = 3;
// 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;
// header.params.disjoint_poly_group_count = link_data.setCount;
// header.params.reachability_table_count = m_count_reachability_tables;
// header.params.reachability_table_size = table_size;
// header.params.disjointPolyGroupCount = link_data.setCount;
// header.params.reachabilityTableCount = m_reachabilityTableCount;
// header.params.reachabilityTableSize = table_size;
//
// if (*is_tf2)unpatch_headertf2(header);
// fwrite(&header, sizeof(NavMeshSetHeader), 1, fp);
@ -755,7 +755,7 @@ void Sample::saveAll(std::string path, dtNavMesh* mesh)
// std::vector<int> reachability(table_size, 0);
// for (int i = 0; i < link_data.setCount; i++)
// set_reachable(reachability, link_data.setCount, i, i, true);
// for (int i = 0; i < header.params.reachability_table_count; i++)
// for (int i = 0; i < header.params.reachabilityTableCount; i++)
// fwrite(reachability.data(), sizeof(int), (table_size / 4), fp);
// fclose(fp);
//}

View File

@ -777,8 +777,8 @@ void Sample_TileMesh::buildAllHulls()
m_agentMaxClimb = h.climb_height;
m_agentHeight = h.height;
if (is_human)
m_count_reachability_tables = 4;
m_navmesh_name = h.name;
m_reachabilityTableCount = 4;
m_navmeshName = h.name;
is_human = false;
handleSettings();

View File

@ -116,6 +116,9 @@ protected:
class dtCrowd* m_crowd;
unsigned char m_navMeshDrawFlags;
bool m_filterLowHangingObstacles;
bool m_filterLedgeSpans;
bool m_filterWalkableLowHeightSpans;
float m_cellSize;
float m_cellHeight;
@ -131,12 +134,8 @@ protected:
float m_detailSampleDist;
float m_detailSampleMaxError;
int m_partitionType;
int m_count_reachability_tables;
const char* m_navmesh_name="unk";
bool m_filterLowHangingObstacles;
bool m_filterLedgeSpans;
bool m_filterWalkableLowHeightSpans;
int m_reachabilityTableCount;
const char* m_navmeshName="unk";
SampleTool* m_tool;
SampleToolState* m_toolStates[MAX_TOOLS];

View File

@ -177,7 +177,7 @@ struct dtPoly
/// @note Use the structure's set and get methods to acess this value.
unsigned char areaAndtype;
unsigned short link_table_idx; //IDK but looks filled
unsigned short disjointSetId; //IDK but looks filled
unsigned short unk; //IDK but looks filled
unsigned int unk1; //!TODO: debug this if you ever find where this gets used in the engine..
float org[3]; // Seems to be used for AIN file generation (build from large navmesh).
@ -193,6 +193,8 @@ struct dtPoly
/// Gets the polygon type. (See: #dtPolyTypes)
inline unsigned char getType() const { return areaAndtype >> 6; }
inline unsigned char getTest() const { return areaAndtype & 0xc0; }
};
/// Defines the location of detail sub-mesh data within a dtMeshTile.
@ -354,10 +356,10 @@ struct dtNavMeshParams
int maxPolys; ///< The maximum number of polygons each tile can contain. This and maxTiles are used to calculate how many bits are needed to identify tiles and polygons uniquely.
//
//// i hate this
int disjoint_poly_group_count = 0;
int reachability_table_size = 0;
int reachability_table_count = 0;
int unk0 = 0;
int disjointPolyGroupCount = 0;
int reachabilityTableSize = 0;
int reachabilityTableCount = 0;
int allocSize = 0;
};
#pragma pack(push, 4)

View File

@ -250,8 +250,6 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params)
m_tiles[i].next = m_nextFree;
m_nextFree = &m_tiles[i];
}
unk0 = dtIlog2(dtNextPow2((unsigned int)params[1].orig[0]));
// Init ID generator values.
#ifndef DT_POLYREF64
@ -1000,7 +998,6 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags,
unsigned char* d = data + headerSize;
tile->verts = dtGetThenAdvanceBufferPointer<float>(d, vertsSize);
tile->polys = dtGetThenAdvanceBufferPointer<dtPoly>(d, polysSize);
d += header->sth_per_poly*header->polyCount * 4;
tile->links = dtGetThenAdvanceBufferPointer<dtLink>(d, linksSize);
tile->detailMeshes = dtGetThenAdvanceBufferPointer<dtPolyDetail>(d, detailMeshesSize);
tile->detailVerts = dtGetThenAdvanceBufferPointer<float>(d, detailVertsSize);

View File

@ -539,7 +539,7 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
p->setArea(params->polyAreas[i]);
p->setType(DT_POLYTYPE_GROUND);
//p->org=params->polys
p->link_table_idx = 2; //0 is invalid 1 is special?
p->disjointSetId = 2; //0 is invalid 1 is special?
for (int j = 0; j < nvp; ++j)
{
if (src[j] == MESH_NULL_IDX) break;