I'm using GLM and Bullet Physics and they each have their own type of vector types - glm::vec3
and btVector3
. They are exactly the same data structures but they annoy me because they don't go together nicely. A lot of manual conversions have to happen.
Suppose I have a function foo(btVector3 f)
and I want to pass a glm::vec3
as the parameter without having convert it to btVector3
beforehand, similar to how you can pass a const char *
into a function that requires an std::string
without having to cast it to string first.
Now I don't want to go into each of these libraries and put operator
s into the classes manually, only for that to be ruined if I update the libraries (assuming that's even allowed by their license). How would I make one type of vector automatically cast to the other and vice versa from within my own project, without going inside and editing the libraries themselves?