-
Notifications
You must be signed in to change notification settings - Fork 311
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
Update to latest google3 version #312
Conversation
* Use absl::flags and absl::log instead of gflags/glog * Use ABSL_UNREACHABLE, requires abseil/abseil-cpp@6a87605 * New edge/circle intersection ordering predicates * New functions `GetUVCoordOfEdge` and `GetIJCoordOfEdge` * S2PolylineAlignment: Use Norm instead of Norm2 * S2Polygon::DestructiveUnion: Use priority_queue internally * Update CONTRIBUTING.md with more detailed instructions * Replace `const char *` with `absl::string_view` * Replace most `gtl::dense_hash_set` uses with `absl::flat_hash_set` * Replace most `std::set` and `std::map` with `absl::flat_hash_set` and `flat_hash_map`
Update to latest google3 version * Use absl::flags and absl::log instead of gflags/glog * Use ABSL_UNREACHABLE, requires abseil/abseil-cpp@6a87605 * New edge/circle intersection ordering predicates * New functions `GetUVCoordOfEdge` and `GetIJCoordOfEdge` * S2PolylineAlignment: Use Norm instead of Norm2 * S2Polygon::DestructiveUnion: Use priority_queue internally * Update CONTRIBUTING.md with more detailed instructions * Replace `const char *` with `absl::string_view` * Replace most `gtl::dense_hash_set` uses with `absl::flat_hash_set` * Replace most `std::set` and `std::map` with `absl::flat_hash_set` and `flat_hash_map`
add_definitions(-DS2_USE_GFLAGS) | ||
endif() | ||
# Don't output anything for LOG(INFO). | ||
add_definitions(-DABSL_MIN_LOG_LEVEL=1) |
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.
Looks like now impossible to disable s2 log, flags, asserts without patching
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.
Is that going to be a problem for you?
The main reason there was S2_USE_GFLAGS
was in case someone didn't have it installed. Since it's all part of absl, it's less important now, but I can imagine people wanting to swap in another flags/logging package or save the size.
I think -DABSL_MIN_LOG_LEVEL=99 -DDABSL_MAX_VLOG_VERBOSITY=0
will disable logging. I don't think there's currently an "absl flags are just constants" option.
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.
I don't know, just noticed it can be big behavior change
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.
We'll see if anyone complains.
// The XYZ -> UV conversion is a single division per coordinate, which is | ||
// promised to be at most 0.5*DBL_EPSILON absolute error for values with | ||
// magnitude less than two. | ||
constexpr double kMaxXYZtoUVError = 0.5 * DBL_EPSILON; |
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.
inline constexpr? Or maybe at least todo if you're using C++14
https://quuxplusone.github.io/blog/2022/07/08/inline-constexpr/
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.
There's an implicit TODO for all these C++17 features when we bump the minimum version.
extern const double kFaceClipErrorRadians; | ||
extern const double kFaceClipErrorUVDist; | ||
extern const double kFaceClipErrorUVCoord; | ||
constexpr double kFaceClipErrorRadians = 3 * DBL_EPSILON; |
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.
Same for all these variables
using PriorityQueue = priority_queue<Pair, vector<Pair>, greater<Pair>>; | ||
PriorityQueue queue; // Least vertices is `top`. | ||
for (size_t i = 0; i < polygons.size(); ++i) { | ||
queue.emplace(polygons[i]->num_vertices(), i); |
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.
Size of polygons
doesn't change here, so you can use address instead of compute it in loop with index
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.
That makes the resulting polygon depend on the addresses of the input polygons, which some clients complained about.
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.
Hmm I probably should looked how union polygons work.
Ok
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.
Hmm I understand, above exist comment, I missed it
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.
But wait, addresses of polygon in vector is monotonically increasing.
So I think this comment was about elements itself (addresses of polygons, not their cell in vector)
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.
I see. Yeah, the comment was about S2Polygon *
. You want to use a unique_ptr<S2Polygon> *
? Yeah, that's probably better since it can't be confused with num_vertices.
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.
I need the index to put the polygon back into the array. Subtracting the pointers to get the index seems a bit roundabout.
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.
We'll probably do this in a future release.
// right angles, that would get a different matching of points for distance | ||
// cost versus squared distance cost. If we had used squared distance for the | ||
// cost the path would be {{0, 0}, {1, 0}, {2, 0}, {3, 1}, {3, 2}}; See | ||
// https://screenshot.googleplex.com/7eeMjdSc5HeSeTD for the costs between the |
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.
Should probably add a check for internal URL's for screenshot.googleplex.com
return ExactIntersectionOrdering( // | ||
ToExact(a), ToExact(b), ToExact(c), ToExact(d), ToExact(m), ToExact(n)); | ||
|
||
return 0; |
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.
There two returns here (line 913 && 916)
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.
Shocked the linter doesn't catch this, I'll get it fixed for the next roll. Glad to see you're still contributing btw =D
GetUVCoordOfEdge
andGetIJCoordOfEdge
const char *
withabsl::string_view
gtl::dense_hash_set
uses withabsl::flat_hash_set
std::set
andstd::map
withabsl::flat_hash_set
and
flat_hash_map