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

Adding constexpr qualifier for helper functions #1050

Closed
wants to merge 21 commits into from

Conversation

RohacekD
Copy link

@RohacekD RohacekD commented Dec 8, 2020

  • Added constexpr qualifier for vec sign(vec) function
  • Added constexpr qualifier for mix(scalar, scalar, scalar), mix(vec, vec, scalar), mix(vec, vec, vec) functions
  • Added constexpr qualifier for mat translate(mat, vec) function
  • Added constexpr qualifier for qua lerp(qua, qua, scalar a) function
  • Added constexpr qualifier for qua conjugate(qua) function
  • Added constexpr qualifier for qua inverse(qua) function
  • Added constexpr qualifier for scalar dot(qua, qua) function
  • Added constexpr qualifier for qua cross(qua, qua) function
  • Added constexpr qualifier for vec<bool> lessThan(qua, qua) function
  • Added constexpr qualifier for vec<bool> lessThanEqual(qua, qua) function
  • Added constexpr qualifier for vec<bool> greaterThan(qua, qua) function
  • Added constexpr qualifier for vec<bool> greaterThanEqual(qua, qua) function
  • Added constexpr qualifier for vec<bool> greaterThanEqual(qua, qua) function
  • Added constexpr qualifier for exterior_product function
  • Added constexpr qualifier for vec3 cross(qua, vec) function
  • Added constexpr qualifier for vec3 cross(vec, qua) function

I tried functions in constexpr context and had no errors. I had to do a small change in comparison functions to avoid warning about default constructed object by initialising results to false. False values will be rewritten by following for cycles but GCC complained anyway.

@RohacekD
Copy link
Author

I don't think that my code failed tests.

@christophe-lunarg
Copy link

Would you mind to rebase your commit to master branch that is fixed?

@RohacekD
Copy link
Author

Of course, I'll do it later.

Have a nice holidays!

@@ -91,7 +91,7 @@ namespace detail
template<length_t L, typename T, qualifier Q, bool Aligned>
struct compute_mix_vector<L, T, bool, Q, Aligned>
{
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, bool, Q> const& a)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<L, T, Q> call(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, bool, Q> const& a)
{
vec<L, T, Q> Result;
Copy link

@AndyMender AndyMender Dec 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be failing the GCC6 C++14 builds in Travis. I think it's the C++14 vs C++17 discrepancy in what's allowed inside constexpr functions. This StackOverflow issue sheds some extra light: https://stackoverflow.com/questions/41618576/what-is-allowed-in-a-constexpr-function

In this case, Result should be initialized.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've seen it. My bad. I'll fix it this evening.

@RohacekD
Copy link
Author

RohacekD commented Jan 5, 2021

The only way to init the result variable is vec<L, T, Q> Result = vec<L, T, Q>(); or init it from either x or y. This will, unfortunately, lead to copy ctor.

@christophe-lunarg
Copy link

Hi,
Sorry for the very long delay reply... C.I. is working again, it would be nice for you to rebase you branch to get it tested.
Thanks!

@christophe-lunarg
Copy link

I created a new PR #1184 to run the unit tests

Thanks for contributing!

christophe-lunarg added a commit that referenced this pull request Dec 22, 2023
* Adding constexpr for exterior product

* Adding constexpr for conjugate

* Adding constexpr for dot, cross and inverse quaternion functions

* Adding constexpr for quat lerp

* Adding constexpr to quaternion comparison functions

lessThan, lessThanEqual, greaterThan, greaterThanEqual

* Adding constexpr for mix functions

mix(scalar, scalar), mix(vec, vec, vec), mix(vec,vec,scalar)

* Adding constexpr for sign(vec) and sign(genFIType)

* Initialize result lessThan, lessThanEqual, greaterThan, greaterThanEqual

Default ctor used in constexpr contex generates warning on gcc

* Adding constexpr to cross(vec, qua) and cross(qua, vec)

* Adding constexpr to glm::translate

* Adding constexpr for exterior product

* Adding constexpr for conjugate

* Adding constexpr for dot, cross and inverse quaternion functions

* Adding constexpr for quat lerp

* Adding constexpr to quaternion comparison functions

lessThan, lessThanEqual, greaterThan, greaterThanEqual

* Adding constexpr for mix functions

mix(scalar, scalar), mix(vec, vec, vec), mix(vec,vec,scalar)

* Adding constexpr for sign(vec) and sign(genFIType)

* Initialize result lessThan, lessThanEqual, greaterThan, greaterThanEqual

Default ctor used in constexpr contex generates warning on gcc

* Adding constexpr to cross(vec, qua) and cross(qua, vec)

* Adding constexpr to glm::translate

---------

Co-authored-by: RohacekD <[email protected]>
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.

3 participants