Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

slerp function ambiguity when including both gtc/quaternion.hpp and gtx/compatibility.hpp #286

Closed
Pankoi opened this issue Dec 10, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@Pankoi
Copy link

Pankoi commented Dec 10, 2014

Hi,

When attempting to compile code which includes both glm/gtc/quaternion.hpp and glm/gtx/compatibility.hpp, I receive the following error:

error: call of overloaded ‘slerp(const quat&, const quat&, const float&)’ is ambiguous
       const glm::quat slerped_quat = glm::slerp(first_keyframe_rot, second_keyframe_rot, interpolation_value);

.../animation.cpp:67:109: note: candidates are:
In file included from /usr/local/include/glm/gtc/quaternion.hpp:365:0,
                 from .../keyframe.h:9,
                 from .../animation.h:6,
                 from .../animation.cpp:1:
/usr/local/include/glm/gtc/quaternion.inl:485:33: note: glm::tquat<T, P> glm::slerp(const glm::tquat<T, P>&, const glm::tquat<T, P>&, const T&) [with T = float; glm::precision P = (glm::precision)0u]
  GLM_FUNC_QUALIFIER tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
                                 ^
In file included from .../animation.cpp:7:0:
/usr/local/include/glm/gtx/compatibility.hpp:76:58: note: T glm::slerp(const glm::tquat<T, P>&, const glm::tquat<T, P>&, const T&) [with T = float; glm::precision P = (glm::precision)0u]
  template <typename T, precision P> GLM_FUNC_QUALIFIER T slerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a){return mix(x, y, a);} //!< \brief Returns the slurp interpolation between two quaternions.

And here's the function call I'm making, with the definitions of the relevant variables:

const float first_keyframe_time = m_keyframes[i-1].Time();
const glm::quat first_keyframe_rot = m_keyframes[i-1].GetRotation(bone_name);
const float second_keyframe_time = m_keyframes[i].Time();
const glm::quat second_keyframe_rot = m_keyframes[i].GetRotation(bone_name);

const float interpolation_value = (normalised_time - first_keyframe_time)/(second_keyframe_time - first_keyframe_time);

const glm::quat slerped_quat = glm::slerp(first_keyframe_rot, second_keyframe_rot, interpolation_value);

If I remove either include (and comment out the functions from that header), the code compiles fine. I get the same results in both 0.9.6 and 0.9.5.

I'm afraid I'm not the most experienced with this sort of thing, so if it's a mistake on my end, I apologise in advance for taking up your time. If there's anything else I can provide, please let me know.

Thanks for your great work on GLM,
~Richard Williams

Edit: I've fixed where I accidentally referred to gtc/quaternion as gtx/quaternion and then subsequently referred to a function from gtx/quaternion.

@Pankoi Pankoi changed the title slerp function ambiguity when including both gtx/quaternion.hpp and gtx/compatibility.hpp slerp function ambiguity when including both gtc/quaternion.hpp and gtx/compatibility.hpp Dec 10, 2014
@Groovounet
Copy link
Member

Hi,

I have submitted a tentative fix but I actually failed to reproduce your issue.
Please, give it a try: https://github.com/g-truc/glm/archive/0.9.6.zip

What compiler are you using? Could you declare GLM_MESSAGES before including GLM and report the GLM messages from compilation log?

Thanks,
Christophe

@Pankoi
Copy link
Author

Pankoi commented Dec 10, 2014

Hi Christophe,

Thanks for the quick reply - I really appreciate it.

The fix you've submitted seems to work just fine, thanks! However, for reference purposes, I'll provide the information you requested:

I'm using GCC 4.9.2. The output from GLM_MESSAGES is here. Please note that this is after applying the fix you've provided. If the output from using GLM_MESSAGES with the currently-released build is of more interest to you, I can certainly provide that too.

Thanks again for your time and dedication,
~Richard Williams

@Groovounet Groovounet added the bug label Dec 10, 2014
@Groovounet Groovounet added this to the GLM 0.9.6 milestone Dec 10, 2014
@Groovounet Groovounet self-assigned this Dec 10, 2014
@Groovounet
Copy link
Member

Awesome, thanks for contributing!
Christophe

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants