-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 macros / constants in examples (but with what?) #5641
Comments
I'm up to use glm constants and tau instead of TWO_PI :) |
@bakercp the PR looks good to me - going to leave one comment in there - but otherwise good to merge. |
I think the PR could get merged and we could work on a better user facing solution? ( I don't think #defines for PI etc in a global namespace are tenable ).
|
sure -- it def feels like we could use a friendly user facing option -- for sure this
is going to make a lot of beginner oriented code feel a lot less friendly. |
one quick thought, I don't know if this reasonable, could we keep these constants in the ofApp class / ofApp namespace as consts, constexpressions etc -- so example and older sample code can stay as is? Then elsewhere, say in another class, you could write ofApp::PI ? The goal would be to not have code break as much as possible and keep things simple. I don't know if this is simpler, or even could work, but just thinking out loud. happy to take a look at this... |
Jumping back to the namespace thoughts Constants in the of namespace More nested Unity style ( note this is sort of weird, but would mimic the Unity approach, also not sure this can be done in C++ in a non hackey way ) @ofZach Either way I think it is safer to just keep the current defines/macros for now ( with a deprecation warning ), but switch over to using the newer api for OF core and examples? The ofApp solution is clever but it wouldn't account for classes in people's projects or addons and probably better to have an Anyway, it is a great excuse to circle back to the namespace discussion 🙂 |
my 2 cents, In terms of friendliness |
Good point @roymacdonald ! Wondering though if If we want to keep ie: Will try this out though and do a PR for people to test with. |
C++20 define std::numbers::pi (float,double and long double). It does not have 2pi. can we have something more like of::numbers::pi ? #if __cplusplus >= 202002L
using namespace std::numbers;
#else
using namespace of::numbers;
#endif
perimeter = 2 * pi * radius; And that does not prevent |
now we are using namespace of for of::filesystem |
This PR is meant to minimize the use of Math constants in the core #7413 |
Related to #5624, but I believe we need to decide what the correct solution is on the user side for our PI, TWO_PI, constants as the feedback for something like
glm::pi<float>
indicates a need for something simpler.See also #5163 and #1007 for previous discussions.
The text was updated successfully, but these errors were encountered: