Skip to content
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

Replace generic Graph with concrete implemetation and include ChunkLayout #315

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

patowen
Copy link
Collaborator

@patowen patowen commented Oct 15, 2023

Currently, outside of tests, the only implementation of Graph is DualGraph. This used to not be true, as the server used a Graph<()> instead, but to allow server-side collision checking, this has changed. In the spirit of only using generics when necessary, this PR gets rid of the Graph/DualGraph distinction.

As part of this change, this PR also attaches ChunkLayout data to Graph, as it arguably makes sense for this data to live together, but it was harder to do something like this cleanly when Graph was generic. This can enable additional helper methods, such as one that takes a ChunkId and a set of coordinates and alters corresponding voxel, taking care of adjacent chunk margins and surface invalidation (without needing to repeatedly pass in the dimension as a parameter).

This PR doesn't refactor most code to use the ChunkLayout in Graph instead of the chunk_size in SimConfig, as there isn't a clear benefit. However, to ensure there is at least one usage of this new functionality, this PR alters the collision checking code to use the ChunkLayout in Graph instead of taking it in as a parameter.

@patowen patowen marked this pull request as draft October 15, 2023 02:28
@patowen patowen requested a review from Ralith October 15, 2023 02:30
@Ralith
Copy link
Owner

Ralith commented Oct 23, 2023

My one concern here would be whether making the complexity of Node intrinsic to Graph complicates testing, but it looks like it hasn't, so that seems fine. Fewer types to think about is nice.

@patowen
Copy link
Collaborator Author

patowen commented Oct 23, 2023

My one concern here would be whether making the complexity of Node intrinsic to Graph complicates testing, but it looks like it hasn't, so that seems fine. Fewer types to think about is nice.

This all makes sense to me. I believe the fact that Graph stores Option<Node> types instead of Node types means that many tests don't run into this issue at all.

Eventually, we may want to add back an abstraction so that, for instance, server code doesn't need to store surface as part of the Chunk structure, but when we decide to do that refactor, it seems likely that the abstraction would be done differently.

@patowen patowen marked this pull request as ready for review October 24, 2023 00:51
@Ralith Ralith merged commit 86b6148 into Ralith:master Oct 30, 2023
6 checks passed
@patowen patowen deleted the concrete-graph branch October 30, 2023 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants