Operator overload

Hello guys, I had an error operator 2 overloads have similar conversions in line 1767

How can I resolve this problem?

Thank you all very much

Hey it looks like you’re trying to move a polyline. ofPolyline does have a .translate() method that will take a glm::vec2 or glm::vec3 as an argument.

I think T is too broad. T could be a float, or a glm::vec2 or a string, but that of course won’t work because ofPolyline::addVertex() needs a glm::vec3 or equivalent. Maybe try changing T to glm::vec3, and then let the glm::vec3 template do its job.

Edit: this code worked for me (oF 0.11.2; macOS):
in ofApp.h

ofPolyline plineSource;
ofPolyline pline;

template <typename T>
ofPolyline ofApp::translate_ofPolyline(ofPolyline srcPoly, T point){
    ofPolyline dstPoly;
    for(size_t i{0}; i < srcPoly.getVertices().size(); ++i){
        dstPoly.addVertex(srcPoly.getVertices().at(i) + point);
    return dstPoly;

in ofApp::setup:

// give plineSource some vertices
for(size_t i{0}; i < 10; ++i){
    glm::vec3 point(ofRandom(1.f));

pline = translate_ofPolyline<>(plineSource, glm::vec3(10.f)); // this works
// pline = translate_ofPolyline<>(plineSource, ofVec3f(10.f)); // this works too
// pline = translate_ofPolyline<>(plineSource, glm::vec2(10.f)); // and this too
// pline = translate_ofPolyline<glm::vec3>(plineSource, glm::vec3(10.f)); // so does this, specifying T
// pline = translate_ofPolyline<>(plineSource, ofVec2f(10.f)); // doesn't work because it can't figure out how to add a ofVec2f to an ofVec3f (?)
1 Like

Thank you bod!

Your sol work well!!!