Sign in to follow this  

Registering glm::vec3, compilation error

This topic is 1516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

 

I am trying to register a vector class from the glm maths library. I am using the following line when I register the method which returns the x component of the vector:

r = engine->RegisterObjectMethod("Vec3", "float x()", asMETHOD(glm::vec3, x), asCALL_THISCALL); assert(r >= 0);

This however gives me a compilation error saying:


error: C-style cast from 'value_type glm::detail::tvec3<float>::*' to 'void (vec3::*)()' is not allowed

    r = engine->RegisterObjectMethod("Vec3", "float x()", asMETHOD(glm::vec3, x), asCALL_THISCALL); assert(r >= 0);
                                                          ^~~~~~~~~~~~~~~~~~~~~~

 expanded from macro 'asMETHOD'
#define asMETHOD(c,m) asSMethodPtr<sizeof(void (c::*)())>::Convert((void (c::*)())(&c::m))

I am aware that this might be due to glm and not angelscript but I am just wondering if someone has any idea on how this could be solved.

 

Thanks! smile.png

 

Share this post


Link to post
Share on other sites

It looks like GLM only defines swizzles for combinations of dimensions, so access to x, y, and z is done only as members, meaning you're casting a float* into a function pointer. You'll either need to create a global function and register it as a method to AS, or register x, y, and z as properties of the class.

Share this post


Link to post
Share on other sites

This topic is 1516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this