New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow declaring variables of type dtMeshTile #480
base: main
Are you sure you want to change the base?
Conversation
This is not true, This is managed externally, see here for example. It's a weird design choice that there is no destructor in |
I can't agree with this statement. dtCreateNavMeshData doesn't not have a flag to say who owns the data. It just provides Then this data may or may not be passed to dtNavMesh::addTile. There it's possible to say whether the data ownership will be transferred to Ownership means to have some logic to release owned resource. So I don't agree that
Could you provide some reference how an absence of a private copy constructor declaration and a copy-assignment operator is UB? Or explain what other code constructions may cause it.
This contradicts with your first statement. I assume your arguments are about copying |
Thanks for the detailed elaboration! You're right, the So if I understand you correctly, you consider I can only speculate, but I would guess You mention you need this to check for equivalence between mesh tiles; what does this involve? You need actual inspection beyond just checking for tile identity (via index/ID)? |
I need a partial deep equality. Something similar to: bool operator==(const dtMeshHeader& a, const dtMeshHeader& b) {
return /*...*/ && a.polyCount == b.polyCount && /*...*/
}
bool operator==(const dtMeshTile& a, const dtMeshTile& b) {
return *a.header == *b.header
&& std::equal(a.polys, a.polys + a.header->polyCount, b.polys)
&& /*...*/;
}
bool isEquivalent(const dtMeshTile& a, unsigned char* b) {
return a == asMeshTile(b);
} Without this pr I will need to create another type instead of struct MeshTileView { /* same members as in dtMeshTile */ };
bool isEquivalent(dtMeshTile& a, unsigned char* b) {
return MeshTileView(a) == MeshTileView(b);
} And it's not a problem. But it would be nice to reuse |
In general this change allows to write code like:
With the only private copy constructor it's not possible.
Also it's completely ok to copy and copy-assign object of this type because there is no custom destructor. For example if I need to write custom function to map
unsigned char*
intodtMeshTile
like it's done here I want to write a function:And this is fine because
dtMeshTile
is only a view todata
.All this is required to check equivalence of two navmesh tiles when one tile is dtNavMesh::getTileAt result and the other is dtCreateNavMeshData output.