-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 point constants with static class members #77730
Replace point constants with static class members #77730
Conversation
Adding these to POINTS_COORDINATES.md wouldn't hurt |
f0022f7
to
e508928
Compare
b82b871
to
a013acf
Compare
bc4905d
to
764daf8
Compare
@sparr could you please resolve conflicts? |
@Night-Pryanik I've done a few rounds of conflict resolution on my two big open PRs in order to get tests to pass, but then they sit for a week without review, so I kinda burned out on it. I'd be happy to do it one more time, but I can't keep it up. |
I'm trying my best to review all prs that were sitting for a long time and merge them if possible. I understand it's frustrating to do a big work and got no feedback for it for weeks. In any case I appreciate the work you've done here. |
Unfortunately, that's what happens to large PRs. When they get large reviewers shy away from them. It certainly doesn't help that they rarely pass all tests, since there's usually at least one test that fails for unrelated reasons most times for most PRs. |
I'd also maybe use a different PR summary and not use None. Something like Infrastructure "Replace point constants with static class members". This is too big to just use None imo. |
Updated the summary. Compiling and running tests locally now to check my conflict resolutions. |
764daf8
to
6f2033d
Compare
Conflicts resolved, tests passed locally. |
Summary
Infrastructure "Replace point constants with static class members"
Purpose of change
Currently whenever someone needs one of the point constants (zero, min, max, invalid, north, north_east, etc) for a coordinate type that hasn't been needed before, they add it to
coordinate_constants.h
. This file has accumulated over 100 such constants, in a hodge podge with no clear pattern to which constants exist and which constants don't and when it's appropriate to add a new one. This can make the codebase confusing to someone who seestripoint_abs_omt_foo
and wonders whytripoint_rel_ms_foo
doesn't exist. This also leads to scenarios where sometimes the constants are used and sometimes they are created from scratch, e.g.tripoint_bub_ms( tripoint_zero )
.Describe the solution
I have moved the constants into static members of the
point
andtripoint
classes, then exposed them incoord_point_ob
. Now everytripoint_foo_bar
type has::zero
,::min
,::max
, etc. The relative types have::north
,::north_east
, etc. The relative 3d types have::above
and::below
.I also added a helper function to check whether a [tri]point equals the
::invalid
constant, which was the original goal of this effort and led me down the rabbit hole of makingpoint
andtripoint
behave more compatibly.I've attempted to update every usage, including various places that were using
_min
but should have been using_invalid
(which didn't exist in some cases) and are now using::invalid
.I updated the tests that use relative constants with absolute coordinate types, to instead create an absolute coordinate from a relative underlying point.
I described these constants in
POINTS_COORDINATES.md
.Describe alternatives you've considered
I attempted to make the individual members conditional using SFINAE and
std::enable_if_t
but this led down a trail of hurdles in templating and working around compiler bugs.I tried defining the constants inside the coord class definition which worked in clang and gcc but is rejected by MSVC.
Testing
Automated tests pass. I am playing with this change.
Additional context
I'm not sure how best to break this up into multiple PRs. I could put the old constants back, change just a few files to the new constants, PR that, then continue until they are all changed?
This PR should be squash merged; the commits are just my development travails.