-
-
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
[feature request] ofPolyline addVertex accepting glm::vec2 #7831
Comments
definitely. I've skimmed through #5440 and TLDR is that ofPolyline is templated and things are not simple because T may == glm::vec2. this branch has work to support compile-time enabling by checking the types: then enabling the correct interpretation on the different glm::vec2 inputs such as: (but the branch has many other things going; perhaps the relevant bits can be pulled?) |
a new pr with relevant changes would be great! |
I've stumbled in this again and there are some things in the way of having a this initialization void setRightVector(T v = T(0, 0, -1)); and this doesn't work ofGetCurrentRenderer()->draw(*this); because the template is already initialized with ofDefaultVertexType using ofPolyline = ofPolyline_<ofDefaultVertexType>;
using ofDefaultVertexType = ofDefaultVec3; |
yes as mentionned above #5739 addresses all these problems but the work is not "done" — the PR is actually closed unfinished and it's scope is wider than 2d vs 3d (or maybe solving that pulls other things in). not clear if extracting the relevant bits is more productive than just redoing it ( |
I'd love easier glm::vec3 to glm::vec2 conversion in general!!! It is often a hangup with functions arguments and it often triggers really hard to decipher error messages. Wish there was a glm define to allow for automatic downgrading of glm::vec3 to vec2 and vice versa. |
the problem with ofPolyLine is not strictly conversion per se but that the code design of the class makes assumptions that the data is 3D. it should currently be named otherwise glm::vec3 -> 2 already works; 2 -> 3 does not because there is no unique correct way to default the value for 3rd member (often 0 but no necessarily). the old openFrameworks/libs/openFrameworks/math/ofVec3f.h Lines 111 to 112 in 24d166e
we could patch #ifdef GLM_ALLOW_IMPLICIT_VEC2_TO_VEC3_CONVERSION_DEFAULTING_Z_TO_ZERO
operator glm::vec3() const {
return glm::vec3(x, y, 0.0f);
}
#endif but while that might help, in itself it will not solve also, if we focus on this specific issue as defined by it's title it's more of an user interface issue: it's simple to overload |
@ofTheo I'm going in the opposite direction :D
it is probably converting glm::vec3 to ofVec3f to be able to multiply by int. |
@dimitre if you don't know "what is going on" FYI it has nothing to do with implicit conversion — glm::vec3 implements operator + and * and / on scalars (and a large number of other operators) so I'm not sure where the idea that "probably converting glm::vec3 to ofVec3f" comes from. that being said I don't understand why implicit conversion is problematic. glm supports implicit conversion from glm::vec3 to ::vec2 — are you suggesting to remove that from glm? |
@artificiel I actually found this issues while removing implicit conversion, it is not from float, it is from double and int. and glm is more strict with types conversion. edit: |
@dimitre i am getting more confused
glm::vec3 v3 {1,1,1};
glm::vec2 v2 = v3;
glm::vec3 v3b = v2; |
it should just work, as ofPolyline is usually a 2d drawing.
some related discussion here:
The text was updated successfully, but these errors were encountered: