Replace NodeId implementation with global hash #309
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Having
NodeId
be the global hash that is guaranteed to be consistent across the server and its clients allows simpler reasoning about code. The main downsides areu128
instead of au32
internally, which could potentially impact performance.The advantages are
NodeId
, removing ambiguity in discussions and in variable names etc.NodeId
means the same on the server and client.I don't expect
NodeId
's size to be the source of any bottlenecks, as each node is a large enough part of the data structure, that the handling of individual voxels and/or the matrix math for each node is likely to take much more processing time. Because of this, I think it's likely that this change is worthwhile, but I'm not 100% convinced.The most complicated change is the rewriting of the
tree()
traversal function inGraph
, since the original design was not compatible with the hashmap-based graph implementation, so it was replaced with a breadth-first search. It is only used for synchronizing the graph between the server and client. Ideally, we wouldn't need to do that anymore, but trying to naively remove this functionality would introduce a subtle bug because the server could move the player or another entity to a node the client doesn't know about, and the client does not and cannot properly handle that.