-
Notifications
You must be signed in to change notification settings - Fork 18
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
2D Coordinate Type #103
base: main
Are you sure you want to change the base?
2D Coordinate Type #103
Conversation
@@ -34,8 +34,7 @@ int main() { | |||
int min_height = *std::min_element(heights.begin(), heights.end()); | |||
|
|||
// Build rings, diminishing up to pyramid height | |||
mcpp::Coordinate base_pt = heights.base_pt(); | |||
base_pt.y = min_height; | |||
mcpp::Coordinate base_pt = {heights.base_pt(), min_height}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how I feel about this constructor... ordering seems important for an ordered x,y,z coordinate
Also, something like a auto c1 = Coordinate2D(0, 0);
auto c2 = Coordinate2D(100, 100);
auto chunk = mc.getBlocks(c1.filled(), c2.filled()); where each |
How could it do this without accessing the I suppose Perhaps Coordinate2D c1{0, 0};
Coordinate2D c2{100, 100};
Chunk chunk = mc.getBlocks(
mc.withHeight(c1),
mc.withHeight(c2)
); Although this doesn't read as nice (grammatically), so Note that Alternatively, |
I think |
Ah, my bad. Didn't think through that dependency properly. Your suggestion sounds good (with snake case though). |
Introduces a new '2D coordinate' struct which mirrors the existing
Coordinate
struct, but does not contain ay
value.Adds constructors to (often implicitly) convert between
Coordinate
andCoordinate2D
.Replaces some parameters and return values with
Coordinate2D
in relevant functions (getHeight
andgetHeights
inMinecraftConnection
,get_worldspace
andbase_pt
in `HeightMap).Possible changes:
Coordinate2
(mirrors naming style for other libraries, eg.Vec2
,float3
). Likely not ideal sinceCoordinate
keeps the same name regardless.Coordinate2
.Note that overloading function parameters such as
MinecraftConnection::getHeight
to accept aCoordinate
is unnecessary, since aCoordinate
will be implicitly cast to aCoordinate2
in such a context.