diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 913e344aff5..4927c38188e 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -5,7 +5,6 @@ #include "ofPixels.h" #include "ofGraphics.h" #include "ofConstants.h" -#include "ofMatrix4x4.h" #include "ofUtils.h" // ofGetElapsedTimef #include @@ -587,10 +586,12 @@ void ofxAssimpModelLoader::updateMeshes(aiNode * node, glm::mat4 parentMatrix) { aiMatrix4x4 m = node->mTransformation; m.Transpose(); - ofMatrix4x4 matrix(m.a1, m.a2, m.a3, m.a4, - m.b1, m.b2, m.b3, m.b4, - m.c1, m.c2, m.c3, m.c4, - m.d1, m.d2, m.d3, m.d4); + glm::mat4 matrix( + m.a1, m.a2, m.a3, m.a4, + m.b1, m.b2, m.b3, m.b4, + m.c1, m.c2, m.c3, m.c4, + m.d1, m.d2, m.d3, m.d4 + ); matrix *= parentMatrix; for(unsigned int i = 0; i < node->mNumMeshes; i++) { @@ -685,7 +686,7 @@ void ofxAssimpModelLoader::updateGLResources(){ void ofxAssimpModelLoader::updateModelMatrix() { modelMatrix = glm::identity(); - modelMatrix = glm::translate(modelMatrix, toGlm(pos)); + modelMatrix = glm::translate(modelMatrix, pos); modelMatrix = glm::rotate(modelMatrix, ofDegToRad(180), glm::vec3(0,0,1)); if(normalizeScale) { @@ -696,7 +697,7 @@ void ofxAssimpModelLoader::updateModelMatrix() { modelMatrix = glm::rotate(modelMatrix, ofDegToRad(rotAngle[i]), glm::vec3(rotAxis[i].x, rotAxis[i].y, rotAxis[i].z)); } - modelMatrix = glm::scale(modelMatrix, toGlm(scale)); + modelMatrix = glm::scale(modelMatrix, scale); } //------------------------------------------- animations. diff --git a/addons/ofxGui/src/ofxButton.cpp b/addons/ofxGui/src/ofxButton.cpp index 3e3ee871f5a..5c05a0c9856 100644 --- a/addons/ofxGui/src/ofxButton.cpp +++ b/addons/ofxGui/src/ofxButton.cpp @@ -55,14 +55,14 @@ void ofxButton::generateDraw(){ fg.setFilled(false); fg.setStrokeWidth(1); fg.setStrokeColor(thisFillColor); - fg.rectRounded(b.getPosition()+checkboxRect.getTopLeft()+glm::vec2{1,1},checkboxRect.width-2,checkboxRect.height-2, 5); + fg.rectRounded(b.getPosition()+checkboxRect.getTopLeft()+glm::vec3{1,1,0},checkboxRect.width-2,checkboxRect.height-2, 5); cross.clear(); cross.setStrokeColor(thisTextColor); cross.setFillColor(thisFillColor); cross.setStrokeWidth(2); cross.setFilled(true); - cross.rectRounded(b.getPosition()+checkboxRect.getTopLeft()+glm::vec2{1,1},checkboxRect.width-2,checkboxRect.height-2, 5); + cross.rectRounded(b.getPosition()+checkboxRect.getTopLeft()+glm::vec3{1,1,0},checkboxRect.width-2,checkboxRect.height-2, 5); std::string name; auto textX = b.x + textPadding + checkboxRect.width; diff --git a/addons/ofxGui/src/ofxGuiGroup.cpp b/addons/ofxGui/src/ofxGuiGroup.cpp index d64d9fbd1d5..07ee396c2e0 100644 --- a/addons/ofxGui/src/ofxGuiGroup.cpp +++ b/addons/ofxGui/src/ofxGuiGroup.cpp @@ -83,6 +83,8 @@ ofxGuiGroup * ofxGuiGroup::setup(const ofParameterGroup & _parameters, const of: }else if(type == typeid(ofParameter ).name()){ auto p = _parameters.getVoid(i); add(p); +#ifdef OF_USE_LEGACY_MATH + }else if(type == typeid(ofParameter ).name()){ auto p = _parameters.get(i); add(p); @@ -92,6 +94,8 @@ ofxGuiGroup * ofxGuiGroup::setup(const ofParameterGroup & _parameters, const of: }else if(type == typeid(ofParameter ).name()){ auto p = _parameters.get(i); add(p); + +#endif }else if(type == typeid(ofParameter ).name()){ auto p = _parameters.get(i); add(p); @@ -173,6 +177,7 @@ void ofxGuiGroup::add(ofParameter & parameter){ add(createGuiElement >(parameter)); } +#ifdef OF_USE_LEGACY_MATH void ofxGuiGroup::add(ofParameter & parameter){ add(createGuiElement >(parameter)); } @@ -184,6 +189,7 @@ void ofxGuiGroup::add(ofParameter & parameter){ void ofxGuiGroup::add(ofParameter & parameter){ add(createGuiElement >(parameter)); } +#endif void ofxGuiGroup::add(ofParameter & parameter){ add(createGuiElement >(parameter)); @@ -279,7 +285,7 @@ bool ofxGuiGroup::mouseReleased(ofMouseEventArgs & args){ return true; } } - if(b.inside(ofPoint(args.x, args.y))){ + if(b.inside({args.x, args.y})){ return true; }else{ return false; diff --git a/addons/ofxGui/src/ofxGuiGroup.h b/addons/ofxGui/src/ofxGuiGroup.h index 31aef498817..e42db5a3bb2 100644 --- a/addons/ofxGui/src/ofxGuiGroup.h +++ b/addons/ofxGui/src/ofxGuiGroup.h @@ -32,9 +32,11 @@ class ofxGuiGroup : public ofxBaseGui { ownedCollection.emplace_back(std::make_unique(parameter)); add(ownedCollection.back().get()); } +#ifdef OF_USE_LEGACY_MATH void add(ofParameter & parameter); void add(ofParameter & parameter); void add(ofParameter & parameter); +#endif void add(ofParameter & parameter); void add(ofParameter & parameter); void add(ofParameter & parameter); diff --git a/addons/ofxGui/src/ofxSliderGroup.cpp b/addons/ofxGui/src/ofxSliderGroup.cpp index 9a69f25ede4..5f7780138a7 100644 --- a/addons/ofxGui/src/ofxSliderGroup.cpp +++ b/addons/ofxGui/src/ofxSliderGroup.cpp @@ -74,6 +74,7 @@ size_t ofxVecSlider_::dim(){ return 4; } +#ifdef OF_USE_LEGACY_MATH template<> size_t ofxVecSlider_::dim(){ return 2; @@ -88,6 +89,7 @@ template<> size_t ofxVecSlider_::dim(){ return 4; } +#endif template ofAbstractParameter & ofxVecSlider_::getParameter(){ @@ -110,9 +112,12 @@ const VecType * ofxVecSlider_::operator->(){ return &value.get(); } +#ifdef OF_USE_LEGACY_MATH template class ofxVecSlider_; template class ofxVecSlider_; template class ofxVecSlider_; +#endif + template class ofxVecSlider_; template class ofxVecSlider_; template class ofxVecSlider_; diff --git a/addons/ofxKinect/src/ofxKinect.cpp b/addons/ofxKinect/src/ofxKinect.cpp index 6ddae111a8e..5cabca6d8ae 100644 --- a/addons/ofxKinect/src/ofxKinect.cpp +++ b/addons/ofxKinect/src/ofxKinect.cpp @@ -423,20 +423,20 @@ float ofxKinect::getDistanceAt(int x, int y) const{ } //------------------------------------ -float ofxKinect::getDistanceAt(const ofPoint & p) const{ +float ofxKinect::getDistanceAt(const glm::vec2 & p) const{ return getDistanceAt(p.x, p.y); } //------------------------------------ -ofVec3f ofxKinect::getWorldCoordinateAt(int x, int y) const{ +glm::vec3 ofxKinect::getWorldCoordinateAt(int x, int y) const{ return getWorldCoordinateAt(x, y, getDistanceAt(x, y)); } //------------------------------------ -ofVec3f ofxKinect::getWorldCoordinateAt(float cx, float cy, float wz) const{ +glm::vec3 ofxKinect::getWorldCoordinateAt(float cx, float cy, float wz) const{ double wx, wy; freenect_camera_to_world(kinectDevice, cx, cy, wz, &wx, &wy); - return ofVec3f(wx, wy, wz); + return glm::vec3(wx, wy, wz); } //------------------------------------ @@ -472,7 +472,7 @@ ofColor ofxKinect::getColorAt(int x, int y) const{ } //------------------------------------ -ofColor ofxKinect::getColorAt(const ofPoint & p) const{ +ofColor ofxKinect::getColorAt(const glm::vec2 & p) const{ return getColorAt(p.x, p.y); } @@ -602,12 +602,12 @@ bool ofxKinect::hasLedControl() const{ } //--------------------------------------------------------------------------- -ofPoint ofxKinect::getRawAccel() const{ +glm::vec3 ofxKinect::getRawAccel() const{ return rawAccel; } //--------------------------------------------------------------------------- -ofPoint ofxKinect::getMksAccel() const{ +glm::vec3 ofxKinect::getMksAccel() const{ return mksAccel; } @@ -677,7 +677,7 @@ void ofxKinect::draw(float _x, float _y) const{ } //---------------------------------------------------------- -void ofxKinect::draw(const ofPoint & point) const{ +void ofxKinect::draw(const glm::vec2 & point) const{ draw(point.x, point.y); } @@ -699,7 +699,7 @@ void ofxKinect::drawDepth(float _x, float _y) const{ } //---------------------------------------------------------- -void ofxKinect::drawDepth(const ofPoint & point) const{ +void ofxKinect::drawDepth(const glm::vec2 & point) const{ drawDepth(point.x, point.y); } @@ -866,11 +866,11 @@ void ofxKinect::threadedFunction(){ freenect_raw_tilt_state * tilt = freenect_get_tilt_state(kinectDevice); currentTiltAngleDeg = freenect_get_tilt_degs(tilt); - rawAccel.set(tilt->accelerometer_x, tilt->accelerometer_y, tilt->accelerometer_z); + rawAccel = {tilt->accelerometer_x, tilt->accelerometer_y, tilt->accelerometer_z}; double dx,dy,dz; freenect_get_mks_accel(tilt, &dx, &dy, &dz); - mksAccel.set(dx, dy, dz); + mksAccel = {dx, dy, dz}; } // finish up a tilt on exit diff --git a/addons/ofxKinect/src/ofxKinect.h b/addons/ofxKinect/src/ofxKinect.h index 08ea482d0dc..b5c50c002d1 100644 --- a/addons/ofxKinect/src/ofxKinect.h +++ b/addons/ofxKinect/src/ofxKinect.h @@ -121,13 +121,13 @@ class ofxKinect : public ofxBase3DVideo, protected ofThread { /// get the calulated distance for a depth point float getDistanceAt(int x, int y) const; - float getDistanceAt(const ofPoint & p) const; + float getDistanceAt(const glm::vec2 & p) const; /// calculates the coordinate in the world for the depth point (perspective calculation) /// /// center of image is (0.0) - ofVec3f getWorldCoordinateAt(int cx, int cy) const; - ofVec3f getWorldCoordinateAt(float cx, float cy, float wz) const; + glm::vec3 getWorldCoordinateAt(int cx, int cy) const; + glm::vec3 getWorldCoordinateAt(float cx, float cy, float wz) const; /// \section Intrinsic IR Sensor Parameters @@ -154,7 +154,7 @@ class ofxKinect : public ofxBase3DVideo, protected ofThread { /// /// see setRegistration() for calibrated depth->RGB points ofColor getColorAt(int x, int y) const; - ofColor getColorAt(const ofPoint & p) const; + ofColor getColorAt(const glm::vec2 & p) const; /// \section Pixel Data @@ -226,7 +226,7 @@ class ofxKinect : public ofxBase3DVideo, protected ofThread { /// ... yes, the kinect has an accelerometer /// raw axis values - ofPoint getRawAccel() const; + glm::vec3 getRawAccel() const; /// axis-based gravity adjusted accelerometer values /// @@ -236,7 +236,7 @@ class ofxKinect : public ofxBase3DVideo, protected ofThread { /// /// http://www.kionix.com/Product%20Sheets/KXSD9%20Product%20Brief.pdf /// - ofPoint getMksAccel() const; + glm::vec3 getMksAccel() const; /// get the current pitch (x axis) & roll (z axis) of the kinect in degrees /// @@ -282,13 +282,13 @@ class ofxKinect : public ofxBase3DVideo, protected ofThread { /// draw the video texture void draw(float x, float y, float w, float h) const; void draw(float x, float y) const; - void draw(const ofPoint& point) const; + void draw(const glm::vec2& point) const; void draw(const ofRectangle& rect) const; /// draw the grayscale depth texture void drawDepth(float x, float y, float w, float h) const; void drawDepth(float x, float y) const; - void drawDepth(const ofPoint& point) const; + void drawDepth(const glm::vec2& point) const; void drawDepth(const ofRectangle& rect) const; /// \section Util @@ -354,8 +354,8 @@ class ofxKinect : public ofxBase3DVideo, protected ofThread { ofShortPixels depthPixelsRaw; ofFloatPixels distancePixels; - ofPoint rawAccel; - ofPoint mksAccel; + glm::vec3 rawAccel; + glm::vec3 mksAccel; float targetTiltAngleDeg; float currentTiltAngleDeg; diff --git a/addons/ofxOpenCv/src/ofxCvBlob.h b/addons/ofxOpenCv/src/ofxCvBlob.h index fec526b34fe..d34a90d064f 100644 --- a/addons/ofxOpenCv/src/ofxCvBlob.h +++ b/addons/ofxOpenCv/src/ofxCvBlob.h @@ -13,7 +13,6 @@ #include "ofxCvConstants.h" - class ofxCvBlob { public: @@ -21,10 +20,10 @@ class ofxCvBlob { float area; float length; ofRectangle boundingRect; - ofDefaultVec3 centroid; + ofDefaultVec2 centroid; bool hole; - std::vector pts; // the contour of the blob + std::vector pts; // the contour of the blob int nPts; // number of pts; //---------------------------------------- @@ -40,13 +39,16 @@ class ofxCvBlob { ofPushStyle(); ofNoFill(); ofSetHexColor(0x00FFFF); + ofPushMatrix(); + ofTranslate(x, y); ofBeginShape(); - for (int i = 0; i < nPts; i++){ - ofVertex(x + pts[i].x, y + pts[i].y); + for (const auto & p : pts) { + ofVertex(p); } ofEndShape(true); ofSetHexColor(0xff0099); - ofDrawRectangle(x + boundingRect.x, y + boundingRect.y, boundingRect.width, boundingRect.height); + ofDrawRectangle(boundingRect); + ofPopMatrix(); ofPopStyle(); } }; diff --git a/addons/ofxOpenCv/src/ofxCvColorImage.h b/addons/ofxOpenCv/src/ofxCvColorImage.h index 6426ae47e0c..3ecb5fb162a 100644 --- a/addons/ofxOpenCv/src/ofxCvColorImage.h +++ b/addons/ofxOpenCv/src/ofxCvColorImage.h @@ -116,10 +116,10 @@ class ofxCvColorImage : public ofxCvImage { // float focalX, float focalY, // float centerX, float centerY ); //in base class // virtual void remap( IplImage* mapX, IplImage* mapY ); //in base class - // virtual void warpPerspective( ofPoint& A, ofPoint& B, - // ofPoint& C, ofPoint& D ); //in base class + // virtual void warpPerspective( glm::vec2 & A, glm::vec2 & B, + // glm::vec2 & C, glm::vec2 & D ); //in base class // virtual void warpIntoMe( ofxCvImage& mom, - // ofPoint src[4], ofPoint dst[4] ); //in base class + // glm::vec2 src[4], glm::vec2 dst[4] ); //in base class // Other Image Operations diff --git a/addons/ofxOpenCv/src/ofxCvContourFinder.cpp b/addons/ofxOpenCv/src/ofxCvContourFinder.cpp index 4386ed4c0b7..9c51d1ea8a5 100644 --- a/addons/ofxOpenCv/src/ofxCvContourFinder.cpp +++ b/addons/ofxOpenCv/src/ofxCvContourFinder.cpp @@ -130,7 +130,7 @@ int ofxCvContourFinder::findContours( ofxCvGrayscaleImage& input, for( int j=0; j < cvSeqBlobs[i]->total; j++ ) { CV_READ_SEQ_ELEM( pt, reader ); - blobs[i].pts.push_back( ofPoint((float)pt.x, (float)pt.y) ); + blobs[i].pts.push_back( glm::vec3{(float)pt.x, (float)pt.y, 0.0f} ); } blobs[i].nPts = blobs[i].pts.size(); @@ -219,7 +219,7 @@ void ofxCvContourFinder::setAnchorPoint( float x, float y ){ //-------------------------------------------------------------------------------- void ofxCvContourFinder::resetAnchor(){ - anchor.set(0,0); + anchor = { 0, 0 }; bAnchorIsPct = false; } diff --git a/addons/ofxOpenCv/src/ofxCvContourFinder.h b/addons/ofxOpenCv/src/ofxCvContourFinder.h index 3c8852824d5..173867134fe 100644 --- a/addons/ofxOpenCv/src/ofxCvContourFinder.h +++ b/addons/ofxOpenCv/src/ofxCvContourFinder.h @@ -58,7 +58,7 @@ class ofxCvContourFinder : public ofBaseDraws { CvMoments* myMoments; std::vector cvSeqBlobs; //these will become blobs - ofPoint anchor; + glm::vec2 anchor; bool bAnchorIsPct; virtual void reset(); diff --git a/addons/ofxOpenCv/src/ofxCvFloatImage.h b/addons/ofxOpenCv/src/ofxCvFloatImage.h index 135d01995da..920d6c0476b 100644 --- a/addons/ofxOpenCv/src/ofxCvFloatImage.h +++ b/addons/ofxOpenCv/src/ofxCvFloatImage.h @@ -128,10 +128,10 @@ class ofxCvFloatImage : public ofxCvImage { // float focalX, float focalY, // float centerX, float centerY ); //in base class // virtual void remap( IplImage* mapX, IplImage* mapY ); //in base class - // virtual void warpPerspective( ofPoint& A, ofPoint& B, - // ofPoint& C, ofPoint& D ); //in base class + // virtual void warpPerspective( glm::vec2& A, glm::vec2& B, + // glm::vec2& C, glm::vec2& D ); //in base class // virtual void warpIntoMe( ofxCvImage& mom, - // ofPoint src[4], ofPoint dst[4] ); //in base class + // glm::vec2 src[4], glm::vec2 dst[4] ); //in base class // Other Image Operations diff --git a/addons/ofxOpenCv/src/ofxCvGrayscaleImage.h b/addons/ofxOpenCv/src/ofxCvGrayscaleImage.h index 7dc0ffce4be..d70b8fde19d 100644 --- a/addons/ofxOpenCv/src/ofxCvGrayscaleImage.h +++ b/addons/ofxOpenCv/src/ofxCvGrayscaleImage.h @@ -117,10 +117,10 @@ class ofxCvGrayscaleImage : public ofxCvImage { // float focalX, float focalY, // float centerX, float centerY ); //in base class // virtual void remap( IplImage* mapX, IplImage* mapY ); //in base class - // virtual void warpPerspective( ofPoint& A, ofPoint& B, - // ofPoint& C, ofPoint& D ); //in base class + // virtual void warpPerspective( glm::vec2& A, glm::vec2& B, + // glm::vec2& C, glm::vec2& D ); //in base class // virtual void warpIntoMe( ofxCvImage& mom, - // ofPoint src[4], ofPoint dst[4] ); //in base class + // glm::vec2 src[4], glm::vec2 dst[4] ); //in base class // Other Image Operations diff --git a/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp b/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp index 839c8dca6cd..2832e2da32a 100644 --- a/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp +++ b/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp @@ -237,10 +237,10 @@ int ofxCvHaarFinder::findHaarObjects(const ofxCvGrayscaleImage& input, blob.boundingRect.height = r->height; blob.centroid.x = centerx; blob.centroid.y = centery; - blob.pts.push_back(ofPoint(r->x, r->y)); - blob.pts.push_back(ofPoint(r->x + r->width, r->y)); - blob.pts.push_back(ofPoint(r->x + r->width, r->y + r->height)); - blob.pts.push_back(ofPoint(r->x, r->y + r->height)); + blob.pts.push_back(glm::vec2(r->x, r->y)); + blob.pts.push_back(glm::vec2(r->x + r->width, r->y)); + blob.pts.push_back(glm::vec2(r->x + r->width, r->y + r->height)); + blob.pts.push_back(glm::vec2(r->x, r->y + r->height)); blobs.push_back(blob); } @@ -322,10 +322,10 @@ int ofxCvHaarFinder::findHaarObjects(const ofxCvGrayscaleImage& input, blob.boundingRect.height = r.height; blob.centroid.x = centerx; blob.centroid.y = centery; - blob.pts.push_back(ofPoint(r.x, r.y)); - blob.pts.push_back(ofPoint(r.x + r.width, r.y)); - blob.pts.push_back(ofPoint(r.x + r.width, r.y + r.height)); - blob.pts.push_back(ofPoint(r.x, r.y + r.height)); + blob.pts.push_back(glm::vec2(r.x, r.y)); + blob.pts.push_back(glm::vec2(r.x + r.width, r.y)); + blob.pts.push_back(glm::vec2(r.x + r.width, r.y + r.height)); + blob.pts.push_back(glm::vec2(r.x, r.y + r.height)); blobs.push_back(blob); } diff --git a/addons/ofxOpenCv/src/ofxCvImage.cpp b/addons/ofxOpenCv/src/ofxCvImage.cpp index 536fe6fdfb4..083fb1104c0 100644 --- a/addons/ofxOpenCv/src/ofxCvImage.cpp +++ b/addons/ofxOpenCv/src/ofxCvImage.cpp @@ -7,8 +7,6 @@ #include "ofConstants.h" - - //-------------------------------------------------------------------------------- ofxCvImage::ofxCvImage() { width = 0; @@ -487,7 +485,7 @@ void ofxCvImage::resetAnchor(){ if( bUseTexture ) { tex.resetAnchor(); }else{ - anchor.set(0,0); + anchor = { 0, 0 }; bAnchorIsPct = false; } } @@ -688,7 +686,7 @@ void ofxCvImage::remap( IplImage* mapX, IplImage* mapY ) { */ //-------------------------------------------------------------------------------- -void ofxCvImage::warpPerspective( const ofPoint& A, const ofPoint& B, const ofPoint& C, const ofPoint& D ) { +void ofxCvImage::warpPerspective( const glm::vec2 & A, const glm::vec2 & B, const glm::vec2 & C, const glm::vec2 & D ) { if( !bAllocated ){ ofLogError("ofxCvImage") << "warpPerspective(): image not allocated"; return; @@ -727,7 +725,7 @@ void ofxCvImage::warpPerspective( const ofPoint& A, const ofPoint& B, const ofPo //-------------------------------------------------------------------------------- -void ofxCvImage::warpIntoMe( ofxCvImage& mom, const ofPoint src[4], const ofPoint dst[4] ){ +void ofxCvImage::warpIntoMe( ofxCvImage& mom, const glm::vec2 src[4], const glm::vec2 dst[4] ){ if( !bAllocated ){ ofLogError("ofxCvImage") << "warpIntoMe(): image not allocated"; diff --git a/addons/ofxOpenCv/src/ofxCvImage.h b/addons/ofxOpenCv/src/ofxCvImage.h index 6b7b64dd02d..85711793379 100644 --- a/addons/ofxOpenCv/src/ofxCvImage.h +++ b/addons/ofxOpenCv/src/ofxCvImage.h @@ -140,10 +140,10 @@ class ofxCvImage : public ofBaseImage { virtual void remap( IplImage* mapX, IplImage* mapY ); - virtual void warpPerspective( const ofPoint& A, const ofPoint& B, - const ofPoint& C, const ofPoint& D ); + virtual void warpPerspective( const glm::vec2 & A, const glm::vec2 & B, + const glm::vec2 & C, const glm::vec2 & D ); virtual void warpIntoMe( ofxCvImage& mom, - const ofPoint src[4], const ofPoint dst[4] ); + const glm::vec2 src[4], const glm::vec2 dst[4] ); @@ -188,7 +188,7 @@ class ofxCvImage : public ofBaseImage { mutable bool bTextureDirty; // texture needs to be reloaded before drawing bool bUseTexture; - ofPoint anchor; + glm::vec2 anchor; bool bAnchorIsPct; }; diff --git a/addons/ofxOpenCv/src/ofxCvShortImage.h b/addons/ofxOpenCv/src/ofxCvShortImage.h index 22fee5a8c19..b079be22e5a 100644 --- a/addons/ofxOpenCv/src/ofxCvShortImage.h +++ b/addons/ofxOpenCv/src/ofxCvShortImage.h @@ -107,10 +107,10 @@ class ofxCvShortImage : public ofxCvImage { // float focalX, float focalY, // float centerX, float centerY ); //in base class // virtual void remap( IplImage* mapX, IplImage* mapY ); //in base class - // virtual void warpPerspective( ofPoint& A, ofPoint& B, - // ofPoint& C, ofPoint& D ); //in base class + // virtual void warpPerspective( glm::vec2& A, glm::vec2& B, + // glm::vec2& C, glm::vec2& D ); //in base class // virtual void warpIntoMe( ofxCvImage& mom, - // ofPoint src[4], ofPoint dst[4] ); //in base class + // glm::vec2 src[4], glm::vec2 dst[4] ); //in base class // Other Image Operations diff --git a/examples/android/androidAdvanced3DExample/src/OrthoCamera.cpp b/examples/android/androidAdvanced3DExample/src/OrthoCamera.cpp index dd721e8dce6..cb6c4ba4a5c 100644 --- a/examples/android/androidAdvanced3DExample/src/OrthoCamera.cpp +++ b/examples/android/androidAdvanced3DExample/src/OrthoCamera.cpp @@ -54,9 +54,8 @@ void OrthoCamera::begin(ofRectangle rect) glOrtho(-scalex, scalex, -scaley, scaley, -20 * scale, 20 * scale); #else // note that bottom and top are switched compared to glOrtho - ofMatrix4x4 ortho = ofMatrix4x4::newOrthoMatrix(-scalex, scalex, scaley, -scaley, - -20 * scale, 20 * scale); - glMultMatrixf(ortho.getPtr()); + glm::mat4 ortho = glm::ortho(-scalex, scalex, scaley, -scaley, -20 * scale, 20 * scale); + glMultMatrixf(glm::value_ptr(ortho.getPtr())); #endif glMatrixMode(GL_MODELVIEW); // diff --git a/examples/android/androidTouchExample/src/Ball.h b/examples/android/androidTouchExample/src/Ball.h index 67d97be04ae..dc1b157619a 100644 --- a/examples/android/androidTouchExample/src/Ball.h +++ b/examples/android/androidTouchExample/src/Ball.h @@ -7,14 +7,14 @@ class Ball { public: - ofPoint pos; - ofPoint vel; + glm::vec2 pos; + glm::vec2 vel; ofColor col; bool touched; void init() { - pos.set(ofRandomWidth(), ofRandomHeight(), 0); - vel.set(ofRandomf(), ofRandomf(), 0); + pos = { ofRandomWidth(), ofRandomHeight(), 0 }; + vel = { ofRandomf(), ofRandomf(), 0 }; col.r = ofRandom(0, 255); col.g = ofRandom(0, 255); @@ -57,7 +57,7 @@ class Ball { } void moveTo(int x, int y) { - pos.set(x, y, 0); - vel.set(0, 0, 0); + pos = { x, y, 0 }; + vel = { 0, 0, 0 }; } }; diff --git a/examples/events/rpiTouchExample/src/ofApp.cpp b/examples/events/rpiTouchExample/src/ofApp.cpp index 8886cf2b1cc..36fcddcac15 100644 --- a/examples/events/rpiTouchExample/src/ofApp.cpp +++ b/examples/events/rpiTouchExample/src/ofApp.cpp @@ -73,7 +73,7 @@ void ofApp::mouseExited(int x, int y){ //-------------------------------------------------------------- void ofApp::touchDown(int x, int y, int id){ - touches[id] = ofVec2f(x, y); + touches[id] = glm::vec2(x, y); } //-------------------------------------------------------------- diff --git a/examples/events/rpiTouchExample/src/ofApp.h b/examples/events/rpiTouchExample/src/ofApp.h index a0db59e993d..bbe0716475e 100644 --- a/examples/events/rpiTouchExample/src/ofApp.h +++ b/examples/events/rpiTouchExample/src/ofApp.h @@ -32,6 +32,6 @@ class ofApp : public ofBaseApp{ ofTrueTypeFont vagRounded; string timeString; - map touches; + map touches; }; diff --git a/examples/gl/slowFastRenderingExample/src/ofApp.cpp b/examples/gl/slowFastRenderingExample/src/ofApp.cpp index 4f0bed72eeb..d15411c1123 100644 --- a/examples/gl/slowFastRenderingExample/src/ofApp.cpp +++ b/examples/gl/slowFastRenderingExample/src/ofApp.cpp @@ -71,7 +71,7 @@ void ofApp::draw() { ofMesh mesh; mesh.setMode(OF_PRIMITIVE_POINTS); for (unsigned int i=0; i ofMesh_::icosphere(float radius, std::size_t iteration auto v3 = vertices[i3]; //make 1 vertice at the center of each edge and project it onto the sphere vertices.insert(vertices.end(), { - glm::normalize(toGlm(v1+v2)), - glm::normalize(toGlm(v2+v3)), - glm::normalize(toGlm(v1+v3)), + glm::normalize(v1+v2), + glm::normalize(v2+v3), + glm::normalize(v1+v3), }); //now recreate indices newFaces.insert(newFaces.end(), { @@ -2438,7 +2438,7 @@ ofMesh_ ofMesh_::cylinder( float radius, float height, int rad mesh.addVertex( vert ); mesh.addNormal( normal ); - normal = glm::rotate(toGlm(normal), -angleIncRadius, up); + normal = glm::rotate(normal, -angleIncRadius, up); } } @@ -2585,10 +2585,10 @@ ofMesh_ ofMesh_::cone( float radius, float height, int radiusS vert.z = std::sin((float)ix*angleIncRadius) * newRad; } - auto diff = toGlm(vert - startVec); - auto crossed = glm::cross(up, toGlm(vert)); + auto diff = vert - startVec; + auto crossed = glm::cross(up, vert); normal = glm::cross(crossed, diff); - mesh.addNormal( glm::normalize(toGlm(normal)) ); + mesh.addNormal( glm::normalize(normal) ); } } diff --git a/libs/openFrameworks/3d/ofNode.cpp b/libs/openFrameworks/3d/ofNode.cpp index 13cc516a135..1a9902381fd 100644 --- a/libs/openFrameworks/3d/ofNode.cpp +++ b/libs/openFrameworks/3d/ofNode.cpp @@ -1,4 +1,3 @@ - #include "ofNode.h" #include "of3dGraphics.h" @@ -135,9 +134,11 @@ void ofNode::setParent(ofNode& parent, bool bMaintainGlobalTransform) { clearParent(bMaintainGlobalTransform); } if(bMaintainGlobalTransform) { - auto postParentPosition = position - parent.getGlobalPosition(); + glm::vec3 pos { position }; + glm::vec3 scl { scale }; + auto postParentPosition = pos - parent.getGlobalPosition(); auto postParentOrientation = orientation.get() * glm::inverse(parent.getGlobalOrientation()); - auto postParentScale = scale / parent.getGlobalScale(); + auto postParentScale = scl / parent.getGlobalScale(); parent.addListener(*this); setOrientation(postParentOrientation); setPosition(postParentPosition); @@ -632,7 +633,7 @@ void ofNode::orbitDeg(float longitude, float latitude, float radius, const glm:: p = q * p; // rotate p on unit sphere based on quaternion p = p * radius; // scale p by radius from its position on unit sphere - + setGlobalPosition(centerPoint + p); setOrientation(q); @@ -708,9 +709,12 @@ void ofNode::restoreTransformGL(ofBaseRenderer * renderer) const { //---------------------------------------- void ofNode::createMatrix() { - localTransformMatrix = glm::translate(glm::mat4(1.0), toGlm(position)); + glm::vec3 pos { position }; + glm::vec3 scl { scale }; + + localTransformMatrix = glm::translate(glm::mat4(1.0), pos); localTransformMatrix = localTransformMatrix * glm::toMat4((const glm::quat&)orientation); - localTransformMatrix = glm::scale(localTransformMatrix, toGlm(scale)); + localTransformMatrix = glm::scale(localTransformMatrix, scl); updateAxis(); } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index a44aacb0de2..246e40b6c3a 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -936,7 +936,7 @@ void ofAppGLFWWindow::setup(const ofGLESWindowSettings & settings) { // make sure to save current pos if not specified in settings if (settings.isPositionSet()) { auto pos = getWindowPosition(); - settings.setPosition(ofVec2f(pos.x, pos.y)); + settings.setPosition(pos); } //make sure the window is getting the mouse/key events diff --git a/libs/openFrameworks/gl/ofMaterial.cpp b/libs/openFrameworks/gl/ofMaterial.cpp index 83d565808a3..eb4f13169e5 100644 --- a/libs/openFrameworks/gl/ofMaterial.cpp +++ b/libs/openFrameworks/gl/ofMaterial.cpp @@ -1214,7 +1214,7 @@ void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & right = right - glm::vec3(lightEyePosition); up = glm::cross(right, direction); } - shader.setUniform3f("lights["+idx+"].right", glm::normalize(toGlm(right))); + shader.setUniform3f("lights["+idx+"].right", glm::normalize(right)); shader.setUniform3f("lights["+idx+"].up", glm::normalize(up)); } } diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index b4df3358905..719b4a85b7c 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -1147,13 +1147,17 @@ void ofShader::setUniforms(const ofParameterGroup & parameters) const { setUniform3f(parameters[i].getEscapedName(), parameters[i].cast()); } else if (parameters[i].type() == typeid(ofParameter).name()) { setUniform4f(parameters[i].getEscapedName(), parameters[i].cast()); - } else if (parameters[i].type() == typeid(ofParameter).name()) { + } +#ifdef OF_USE_LEGACY_MATH + else if (parameters[i].type() == typeid(ofParameter).name()) { setUniform2f(parameters[i].getEscapedName(), parameters[i].cast()); } else if (parameters[i].type() == typeid(ofParameter).name()) { setUniform3f(parameters[i].getEscapedName(), parameters[i].cast()); } else if (parameters[i].type() == typeid(ofParameter).name()) { setUniform4f(parameters[i].getEscapedName(), parameters[i].cast()); - } else if (parameters[i].type() == typeid(ofParameterGroup).name()) { + } +#endif + else if (parameters[i].type() == typeid(ofParameterGroup).name()) { setUniforms((ofParameterGroup &)parameters[i]); } } diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index e52cdc18d26..930d4d38651 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -25,7 +25,6 @@ namespace glm { class ofTexture; class ofTextureData; -class ofMatrix3x3; class ofParameterGroup; class ofBufferObject; class ofBaseHasTexture; diff --git a/libs/openFrameworks/gl/ofVbo.cpp b/libs/openFrameworks/gl/ofVbo.cpp index 4770b505d26..1d15689f053 100644 --- a/libs/openFrameworks/gl/ofVbo.cpp +++ b/libs/openFrameworks/gl/ofVbo.cpp @@ -326,21 +326,11 @@ void ofVbo::setVertexData(const glm::vec3 * verts, int total, int usage) { setVertexData(&verts[0].x,3,total,usage,sizeof(glm::vec3)); } -//-------------------------------------------------------------- -void ofVbo::setVertexData(const ofVec3f * verts, int total, int usage) { - setVertexData(&verts[0].x,3,total,usage,sizeof(glm::vec3)); -} - //-------------------------------------------------------------- void ofVbo::setVertexData(const glm::vec2 * verts, int total, int usage) { setVertexData(&verts[0].x,2,total,usage,sizeof(glm::vec2)); } -//-------------------------------------------------------------- -void ofVbo::setVertexData(const ofVec2f * verts, int total, int usage) { - setVertexData(&verts[0].x,2,total,usage,sizeof(glm::vec2)); -} - //-------------------------------------------------------------- void ofVbo::setVertexData(const float * vert0x, int numCoords, int total, int usage, int stride) { positionAttribute.setData(vert0x, numCoords, total, usage, stride); @@ -364,11 +354,6 @@ void ofVbo::setNormalData(const glm::vec3 * normals, int total, int usage) { setNormalData(&normals[0].x,total,usage,sizeof(glm::vec3)); } -//-------------------------------------------------------------- -void ofVbo::setNormalData(const ofVec3f * normals, int total, int usage) { - setNormalData(&normals[0].x,total,usage,sizeof(glm::vec3)); -} - //-------------------------------------------------------------- void ofVbo::setNormalData(const float * normal0x, int total, int usage, int stride) { normalAttribute.setData(normal0x, 3, total, usage, stride); @@ -380,11 +365,6 @@ void ofVbo::setTexCoordData(const glm::vec2 * texCoords, int total, int usage) { setTexCoordData(&texCoords[0].x,total, usage, sizeof(glm::vec2)); } -//-------------------------------------------------------------- -void ofVbo::setTexCoordData(const ofVec2f * texCoords, int total, int usage) { - setTexCoordData(&texCoords[0].x,total, usage, sizeof(glm::vec2)); -} - //-------------------------------------------------------------- void ofVbo::setTexCoordData(const float * texCoord0x, int total, int usage, int stride) { texCoordAttribute.setData(texCoord0x, 2, total, usage, stride); @@ -402,6 +382,28 @@ void ofVbo::setIndexData(const ofIndexType * indices, int total, int usage){ indexAttribute.setData(sizeof(ofIndexType) * total, &indices[0], usage); } +#ifdef OF_USE_LEGACY_MATH +//-------------------------------------------------------------- +void ofVbo::setVertexData(const ofVec3f * verts, int total, int usage) { + setVertexData(&verts[0].x,3,total,usage,sizeof(glm::vec3)); +} + +//-------------------------------------------------------------- +void ofVbo::setVertexData(const ofVec2f * verts, int total, int usage) { + setVertexData(&verts[0].x,2,total,usage,sizeof(glm::vec2)); +} + +//-------------------------------------------------------------- +void ofVbo::setNormalData(const ofVec3f * normals, int total, int usage) { + setNormalData(&normals[0].x,total,usage,sizeof(glm::vec3)); +} + +//-------------------------------------------------------------- +void ofVbo::setTexCoordData(const ofVec2f * texCoords, int total, int usage) { + setTexCoordData(&texCoords[0].x,total, usage, sizeof(glm::vec2)); +} +#endif + //-------------------------------------------------------------- ofVbo::VertexAttribute & ofVbo::getOrCreateAttr(int location){ VertexAttribute * attr = nullptr; @@ -471,21 +473,11 @@ void ofVbo::updateVertexData(const glm::vec3 * verts, int total) { updateVertexData(&verts[0].x,total); } -//-------------------------------------------------------------- -void ofVbo::updateVertexData(const ofVec3f * verts, int total) { - updateVertexData(&verts[0].x,total); -} - //-------------------------------------------------------------- void ofVbo::updateVertexData(const glm::vec2 * verts, int total) { updateVertexData(&verts[0].x,total); } -//-------------------------------------------------------------- -void ofVbo::updateVertexData(const ofVec2f * verts, int total) { - updateVertexData(&verts[0].x,total); -} - //-------------------------------------------------------------- void ofVbo::updateVertexData(const float * vert0x, int total) { positionAttribute.updateData(0, total * positionAttribute.stride, vert0x); @@ -506,11 +498,6 @@ void ofVbo::updateNormalData(const glm::vec3 * normals, int total) { updateNormalData(&normals[0].x,total); } -//-------------------------------------------------------------- -void ofVbo::updateNormalData(const ofVec3f * normals, int total) { - updateNormalData(&normals[0].x,total); -} - //-------------------------------------------------------------- void ofVbo::updateNormalData(const float * normal0x, int total) { normalAttribute.updateData(0, total * normalAttribute.stride, normal0x); @@ -521,11 +508,6 @@ void ofVbo::updateTexCoordData(const glm::vec2 * texCoords, int total) { updateTexCoordData(&texCoords[0].x,total); } -//-------------------------------------------------------------- -void ofVbo::updateTexCoordData(const ofVec2f * texCoords, int total) { - updateTexCoordData(&texCoords[0].x,total); -} - //-------------------------------------------------------------- void ofVbo::updateTexCoordData(const float * texCoord0x, int total) { texCoordAttribute.updateData(0, total * texCoordAttribute.stride, texCoord0x); @@ -538,6 +520,28 @@ void ofVbo::updateIndexData(const ofIndexType * indices, int total) { } } +#ifdef OF_USE_LEGACY_MATH +//-------------------------------------------------------------- +void ofVbo::updateVertexData(const ofVec3f * verts, int total) { + updateVertexData(&verts[0].x,total); +} + +//-------------------------------------------------------------- +void ofVbo::updateVertexData(const ofVec2f * verts, int total) { + updateVertexData(&verts[0].x,total); +} + +//-------------------------------------------------------------- +void ofVbo::updateNormalData(const ofVec3f * normals, int total) { + updateNormalData(&normals[0].x,total); +} + +//-------------------------------------------------------------- +void ofVbo::updateTexCoordData(const ofVec2f * texCoords, int total) { + updateTexCoordData(&texCoords[0].x,total); +} +#endif + void ofVbo::updateAttributeData(int location, const float * attr0x, int total){ VertexAttribute * attr = nullptr; if (ofIsGLProgrammableRenderer()) { diff --git a/libs/openFrameworks/gl/ofVbo.h b/libs/openFrameworks/gl/ofVbo.h index 1f76fe27168..ada27871b58 100644 --- a/libs/openFrameworks/gl/ofVbo.h +++ b/libs/openFrameworks/gl/ofVbo.h @@ -12,16 +12,12 @@ template class ofColor_; typedef ofColor_ ofFloatColor; -class ofVec2f; -class ofVec3f; - template class ofMesh_; using ofMesh = ofMesh_; class ofVbo { public: - ofVbo(); ofVbo(const ofVbo & mom); ofVbo & operator=(const ofVbo& mom); @@ -32,16 +28,18 @@ class ofVbo { void setVertexData(const glm::vec3 * verts, int total, int usage); void setVertexData(const glm::vec2 * verts, int total, int usage); - void setVertexData(const ofVec3f * verts, int total, int usage); - void setVertexData(const ofVec2f * verts, int total, int usage); void setColorData(const ofFloatColor * colors, int total, int usage); void setNormalData(const glm::vec3 * normals, int total, int usage); - void setNormalData(const ofVec3f * normals, int total, int usage); void setTexCoordData(const glm::vec2 * texCoords, int total, int usage); - void setTexCoordData(const ofVec2f * texCoords, int total, int usage); void setIndexData(const ofIndexType * indices, int total, int usage); +#ifdef OF_USE_LEGACY_MATH + void setVertexData(const ofVec3f * verts, int total, int usage); + void setVertexData(const ofVec2f * verts, int total, int usage); + void setNormalData(const ofVec3f * normals, int total, int usage); + void setTexCoordData(const ofVec2f * texCoords, int total, int usage); +#endif void setVertexData(const float * vert0x, int numCoords, int total, int usage, int stride=0); void setColorData(const float * color0r, int total, int usage, int stride=0); void setNormalData(const float * normal0x, int total, int usage, int stride=0); @@ -85,15 +83,18 @@ class ofVbo { void updateVertexData(const glm::vec3 * verts, int total); void updateVertexData(const glm::vec2 * verts, int total); - void updateVertexData(const ofVec3f * verts, int total); - void updateVertexData(const ofVec2f * verts, int total); void updateColorData(const ofFloatColor * colors, int total); void updateNormalData(const glm::vec3 * normals, int total); - void updateNormalData(const ofVec3f * normals, int total); void updateTexCoordData(const glm::vec2 * texCoords, int total); - void updateTexCoordData(const ofVec2f * texCoords, int total); void updateIndexData(const ofIndexType * indices, int total); - + +#ifdef OF_USE_LEGACY_MATH + void updateVertexData(const ofVec3f * verts, int total); + void updateVertexData(const ofVec2f * verts, int total); + void updateNormalData(const ofVec3f * normals, int total); + void updateTexCoordData(const ofVec2f * texCoords, int total); +#endif + void updateVertexData(const float * ver0x, int total); void updateColorData(const float * color0r, int total); void updateNormalData(const float * normal0x, int total); diff --git a/libs/openFrameworks/graphics/ofGraphics.cpp b/libs/openFrameworks/graphics/ofGraphics.cpp index b7e45922cd5..cd582deafb1 100644 --- a/libs/openFrameworks/graphics/ofGraphics.cpp +++ b/libs/openFrameworks/graphics/ofGraphics.cpp @@ -1120,6 +1120,7 @@ void ofVertices(const vector & polyPoints) { } } +#ifdef OF_USE_LEGACY_MATH //---------------------------------------------------------- void ofVertices(const vector & polyPoints) { for (const auto & p : polyPoints) { @@ -1133,6 +1134,7 @@ void ofVertices(const vector & polyPoints) { ofGetCurrentRenderer()->getPath().lineTo(p); } } +#endif //--------------------------------------------------- void ofCurveVertex(float x, float y) { @@ -1158,6 +1160,7 @@ void ofCurveVertices(const vector & curvePoints) { } } +#ifdef OF_USE_LEGACY_MATH //---------------------------------------------------------- void ofCurveVertices(const vector & curvePoints) { for (const auto & p : curvePoints) { @@ -1171,6 +1174,7 @@ void ofCurveVertices(const vector & curvePoints) { ofGetCurrentRenderer()->getPath().curveTo(p); } } +#endif //--------------------------------------------------- void ofCurveVertex(const glm::vec3 & p) { diff --git a/libs/openFrameworks/graphics/ofGraphics.h b/libs/openFrameworks/graphics/ofGraphics.h index f65cc4536d3..cef766d843b 100644 --- a/libs/openFrameworks/graphics/ofGraphics.h +++ b/libs/openFrameworks/graphics/ofGraphics.h @@ -9,9 +9,6 @@ namespace glm { typedef vec<3, float, defaultp> vec3; } -class ofVec3f; -class ofVec2f; - template std::string ofToString(const T &); @@ -602,8 +599,10 @@ void ofVertex(const glm::vec3 & p); void ofVertex(const glm::vec2 & p); void ofVertices(const std::vector & polyPoints); void ofVertices(const std::vector & polyPoints); +#ifdef OF_USE_LEGACY_MATH void ofVertices(const std::vector & polyPoints); void ofVertices(const std::vector & polyPoints); +#endif /// \brief Specifies a single point of a shape. The difference from ofVertex is that /// the line describing the edge of the shape between two points will be a @@ -620,8 +619,10 @@ void ofCurveVertex(const glm::vec2 & p); /// ofPoints. Should be called between ofBeginShape() and ofEndShape(). void ofCurveVertices(const std::vector & curvePoints); void ofCurveVertices(const std::vector & curvePoints); +#ifdef OF_USE_LEGACY_MATH void ofCurveVertices(const std::vector & curvePoints); void ofCurveVertices(const std::vector & curvePoints); +#endif /// \brief Describes a bezier curve through three points of a shape. To be called /// between ofBeginShape() and ofEndShape(). diff --git a/libs/openFrameworks/graphics/ofPath.cpp b/libs/openFrameworks/graphics/ofPath.cpp index 222bcd1e090..f327a263f4b 100644 --- a/libs/openFrameworks/graphics/ofPath.cpp +++ b/libs/openFrameworks/graphics/ofPath.cpp @@ -833,7 +833,7 @@ void ofPath::rotateDeg(float degrees, const glm::vec3& axis ){ }else{ for(int i=0;i<(int)polylines.size();i++){ for(int j=0;j<(int)polylines[i].size();j++){ - polylines[i][j] = glm::rotate(toGlm(polylines[i][j]), radians, axis); + polylines[i][j] = glm::rotate(polylines[i][j], radians, axis); } } } diff --git a/libs/openFrameworks/graphics/ofPolyline.inl b/libs/openFrameworks/graphics/ofPolyline.inl index a02ff15d6d2..31d0b1620d2 100644 --- a/libs/openFrameworks/graphics/ofPolyline.inl +++ b/libs/openFrameworks/graphics/ofPolyline.inl @@ -560,7 +560,7 @@ inline T getClosestPointUtil(const T& p1, const T& p2, const T& p3, float* norma float u = (p3.x - p1.x) * (p2.x - p1.x); u += (p3.y - p1.y) * (p2.y - p1.y); // perfect place for fast inverse sqrt... - float len = glm::length(toGlm(p2 - p1)); + float len = glm::length(p2 - p1); u /= (len * len); // clamp u @@ -572,7 +572,7 @@ inline T getClosestPointUtil(const T& p1, const T& p2, const T& p3, float* norma if(normalizedPosition != nullptr) { *normalizedPosition = u; } - return glm::mix(toGlm(p1), toGlm(p2), u); + return glm::mix(p1, p2, u); } //---------------------------------------------------------- @@ -605,7 +605,7 @@ T ofPolyline_::getClosestPoint(const T& target, unsigned int* nearestIndex) c float curNormalizedPosition = 0; auto curNearestPoint = getClosestPointUtil(cur, next, target, &curNormalizedPosition); - float curDistance = glm::distance(toGlm(curNearestPoint), toGlm(target)); + float curDistance = glm::distance(curNearestPoint, target); if(i == 0 || curDistance < distance) { distance = curDistance; nearest = i; @@ -710,7 +710,7 @@ namespace of{ float tol2 = tol * tol; // tolerance squared Segment S = {v[j], v[k]}; // segment from v[j] to v[k] auto u = S.P1 - S.P0; // segment direction vector - double cu = glm::dot(toGlm(u), toGlm(u)); // segment length squared + double cu = glm::dot(u, u); // segment length squared // test each vertex v[i] for max distance from S // compute using the Feb 2001 Algorithm's dist_ofPoint_to_Segment() @@ -722,13 +722,13 @@ namespace of{ for (int i=j+1; i::rotateDeg(float degrees, const glm::vec3& axis){ template void ofPolyline_::rotateRad(float radians, const glm::vec3& axis){ for(auto & point : points){ - point = glm::rotate(toGlm(point), radians, axis); + point = glm::rotate(point, radians, axis); } flagHasChanged(); } @@ -970,7 +970,7 @@ T ofPolyline_::getPointAtIndexInterpolated(float findex) const { getInterpolationParams(findex, i1, i2, t); T leftPoint(points[i1]); T rightPoint(points[i2]); - return glm::mix(toGlm(leftPoint), toGlm(rightPoint), t); + return glm::mix(leftPoint, rightPoint, t); } @@ -1039,7 +1039,7 @@ T ofPolyline_::getRotationAtIndexInterpolated(float findex) const { int i1, i2; float t; getInterpolationParams(findex, i1, i2, t); - return glm::mix(toGlm(getRotationAtIndex(i1)), toGlm(getRotationAtIndex(i2)), t); + return glm::mix(getRotationAtIndex(i1), getRotationAtIndex(i2), t); } //-------------------------------------------------- @@ -1057,7 +1057,7 @@ T ofPolyline_::getTangentAtIndexInterpolated(float findex) const { int i1, i2; float t; getInterpolationParams(findex, i1, i2, t); - return glm::mix(toGlm(getTangentAtIndex(i1)), toGlm(getTangentAtIndex(i2)), t); + return glm::mix(getTangentAtIndex(i1), getTangentAtIndex(i2), t); } //-------------------------------------------------- @@ -1075,7 +1075,7 @@ T ofPolyline_::getNormalAtIndexInterpolated(float findex) const { int i1, i2; float t; getInterpolationParams(findex, i1, i2, t); - return glm::mix(toGlm(getNormalAtIndex(i1)), toGlm(getNormalAtIndex(i2)), t); + return glm::mix(getNormalAtIndex(i1), getNormalAtIndex(i2), t); } @@ -1086,9 +1086,9 @@ void ofPolyline_::calcData(int index, T &tangent, float &angle, T &rotation, int i2 = getWrappedIndex( index ); int i3 = getWrappedIndex( index + 1 ); - const auto &p1 = toGlm(points[i1]); - const auto &p2 = toGlm(points[i2]); - const auto &p3 = toGlm(points[i3]); + const auto &p1 = points[i1]; + const auto &p2 = points[i2]; + const auto &p3 = points[i3]; auto v1(p1 - p2); // vector to previous point auto v2(p3 - p2); // vector to next point @@ -1103,9 +1103,9 @@ void ofPolyline_::calcData(int index, T &tangent, float &angle, T &rotation, bool noSegmentHasZeroLength = (v1 == v1 && v2 == v2); if ( noSegmentHasZeroLength ){ - tangent = toOf( glm::length2(v2 - v1) > 0 ? glm::normalize(v2 - v1) : -v1 ); - normal = toOf( glm::normalize( glm::cross( toGlm( rightVector ), toGlm( tangent ) ) ) ); - rotation = toOf( glm::cross( v1, v2 ) ); + tangent = ( glm::length2(v2 - v1) > 0 ? glm::normalize(v2 - v1) : -v1 ); + normal = ( glm::normalize( glm::cross( rightVector , tangent ) ) ); + rotation = ( glm::cross( v1, v2 ) ); angle = glm::pi() - acosf( ofClamp( glm::dot( v1, v2 ), -1.f, 1.f ) ); } else{ rotation = tangent = normal = T( 0.f ); @@ -1194,7 +1194,7 @@ void ofPolyline_::updateCache(bool bForceUpdate) const { rotations[i] = rotation; normals[i] = normal; - length += glm::distance(toGlm(points[i]), toGlm(points[getWrappedIndex(i + 1)])); + length += glm::distance(points[i], points[getWrappedIndex(i + 1)]); } if(isClosed()) lengths.push_back(length); diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index 943c08fae5e..81257c7727d 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -1262,7 +1262,7 @@ glm::vec2 ofTrueTypeFont::getFirstGlyphPosForTexture(const string & str, bool vf }else{ int width = 0; int lineWidth = 0; - iterateString(str, 0, 0, vflip, [&](uint32_t c, ofVec2f){ + iterateString(str, 0, 0, vflip, [&](uint32_t c, glm::vec2){ try{ if (c != '\n') { auto g = loadGlyph(c); @@ -1296,7 +1296,7 @@ ofTexture ofTrueTypeFont::getStringTexture(const string& str, bool vflip) const{ float height = 0; float width = 0; float lineWidth = 0; - iterateString(str, 0, 0, vflip, [&](uint32_t c, ofVec2f pos){ + iterateString(str, 0, 0, vflip, [&](uint32_t c, glm::vec2 pos){ try{ if (c != '\n') { auto g = loadGlyph(c); diff --git a/libs/openFrameworks/math/ofVectorMath.h b/libs/openFrameworks/math/ofVectorMath.h index 36a3da86232..c4e2f28bfb5 100644 --- a/libs/openFrameworks/math/ofVectorMath.h +++ b/libs/openFrameworks/math/ofVectorMath.h @@ -1,9 +1,5 @@ #pragma once -class ofMatrix3x3; -#include "ofMatrix4x4.h" -#include "ofQuaternion.h" - #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL #include @@ -29,80 +25,6 @@ class ofMatrix3x3; #include -//-------------------------------------------------------------- -inline const ofVec2f & toOf(const glm::vec2 & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const ofVec3f & toOf(const glm::vec3 & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const ofVec4f & toOf(const glm::vec4 & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const ofMatrix4x4 & toOf(const glm::mat4 & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const ofMatrix3x3 & toOf(const glm::mat3 & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const glm::vec2 & toGlm(const ofVec2f & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const glm::vec3 & toGlm(const ofVec3f & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const glm::vec4 & toGlm(const ofVec4f & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const glm::mat4 & toGlm(const ofMatrix4x4 & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const glm::mat3 & toGlm(const ofMatrix3x3 & v){ - return *reinterpret_cast(&v); -} - -//-------------------------------------------------------------- -inline const glm::vec2 & toGlm(const glm::vec2 & v){ - return v; -} - -//-------------------------------------------------------------- -inline const glm::vec3 & toGlm(const glm::vec3 & v){ - return v; -} - -//-------------------------------------------------------------- -inline const glm::vec4 & toGlm(const glm::vec4 & v){ - return v; -} - -//-------------------------------------------------------------- -inline const glm::quat toGlm(const ofQuaternion & q){ - return glm::quat(q.w(), glm::vec3(q.x(), q.y(), q.z())); -} - -//-------------------------------------------------------------- -inline const glm::quat & toGlm(const glm::quat & q){ - return q; -} namespace glm { //-------------------------------------------------------------- @@ -274,6 +196,92 @@ namespace glm { } } + + +#ifdef OF_USE_LEGACY_MATH + +class ofMatrix3x3; +#include "ofMatrix4x4.h" +#include "ofQuaternion.h" + + +// FIXME: - +//-------------------------------------------------------------- +inline const ofVec2f & toOf(const glm::vec2 & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const ofVec3f & toOf(const glm::vec3 & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const ofVec4f & toOf(const glm::vec4 & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const ofMatrix4x4 & toOf(const glm::mat4 & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const ofMatrix3x3 & toOf(const glm::mat3 & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const glm::vec2 & toGlm(const ofVec2f & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const glm::vec3 & toGlm(const ofVec3f & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const glm::vec4 & toGlm(const ofVec4f & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const glm::mat4 & toGlm(const ofMatrix4x4 & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const glm::mat3 & toGlm(const ofMatrix3x3 & v){ + return *reinterpret_cast(&v); +} + +//-------------------------------------------------------------- +inline const glm::vec2 & toGlm(const glm::vec2 & v){ + return v; +} + +//-------------------------------------------------------------- +inline const glm::vec3 & toGlm(const glm::vec3 & v){ + return v; +} + +//-------------------------------------------------------------- +inline const glm::vec4 & toGlm(const glm::vec4 & v){ + return v; +} + +//-------------------------------------------------------------- +inline const glm::quat toGlm(const ofQuaternion & q){ + return glm::quat(q.w(), glm::vec3(q.x(), q.y(), q.z())); +} + +//-------------------------------------------------------------- +inline const glm::quat & toGlm(const glm::quat & q){ + return q; +} + + //-------------------------------------------------------------- inline glm::vec3 operator+(const glm::vec3 & v1, const ofVec3f & v2){ return v1 + glm::vec3(v2); @@ -363,3 +371,16 @@ inline glm::vec2 & operator/=(glm::vec2 & v1, const ofVec2f & v2){ } +#endif + + +//-------------------------------------------------------------- +inline glm::vec3 operator+(const glm::vec3 & v1, const glm::vec4 & v2){ + return v1 + glm::vec3(v2.x, v2.y, v2.z); +} + +// addons/ofxGui/src/ofxButton.cpp:58:65 +//-------------------------------------------------------------- +inline glm::vec2 operator+(const glm::vec2 & v1, const glm::vec3 & v2){ + return v1 + glm::vec2(v2.x, v2.y); +} diff --git a/libs/openFrameworks/ofMain.h b/libs/openFrameworks/ofMain.h index 602116e0589..9cf35e2255a 100644 --- a/libs/openFrameworks/ofMain.h +++ b/libs/openFrameworks/ofMain.h @@ -23,7 +23,9 @@ #include "ofColor.h" #include "ofGraphicsBaseTypes.h" #include "ofParameter.h" +#ifdef OF_USE_LEGACY_MATH #include "ofPoint.h" +#endif #include "ofRectangle.h" #include "ofTypes.h" diff --git a/libs/openFrameworks/types/ofParameter.cpp b/libs/openFrameworks/types/ofParameter.cpp index bcf2b7167db..ff569b17aa6 100644 --- a/libs/openFrameworks/types/ofParameter.cpp +++ b/libs/openFrameworks/types/ofParameter.cpp @@ -1,5 +1,5 @@ #include "ofParameter.h" -#include "ofPoint.h" +//#include "ofPoint.h" #include "ofUtils.h" using std::string; diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 27fa0c4a733..cf68e5c85b3 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -1,16 +1,12 @@ #pragma once -#include - #include "ofEvents.h" -// FIXME: crossed references. ofPoint adds ofVec3f which adds ofVec2f and ofVec4f -#include "ofPoint.h" - #include "ofColor.h" #include "ofLog.h" #include "ofMathConstants.h" #include "ofRectangle.h" #include "ofUtils.h" // ofToString +#include #ifdef TARGET_WIN32 #include @@ -128,7 +124,9 @@ class ofParameterGroup : public ofAbstractParameter { const ofParameter & getFloat(const std::string & name) const; const ofParameter & getChar(const std::string & name) const; const ofParameter & getString(const std::string & name) const; +#ifdef OF_USE_LEGACY_MATH const ofParameter & getPoint(const std::string & name) const; +#endif const ofParameter & getVec2f(const std::string & name) const; const ofParameter & getVec3f(const std::string & name) const; const ofParameter & getVec4f(const std::string & name) const; @@ -144,7 +142,9 @@ class ofParameterGroup : public ofAbstractParameter { const ofParameter & getFloat(std::size_t pos) const; const ofParameter & getChar(std::size_t pos) const; const ofParameter & getString(std::size_t pos) const; +#ifdef OF_USE_LEGACY_MATH const ofParameter & getPoint(std::size_t pos) const; +#endif const ofParameter & getVec2f(std::size_t pos) const; const ofParameter & getVec3f(std::size_t pos) const; const ofParameter & getVec4f(std::size_t pos) const; @@ -160,7 +160,9 @@ class ofParameterGroup : public ofAbstractParameter { ofParameter & getFloat(const std::string & name); ofParameter & getChar(const std::string & name); ofParameter & getString(const std::string & name); +#ifdef OF_USE_LEGACY_MATH ofParameter & getPoint(const std::string & name); +#endif ofParameter & getVec2f(const std::string & name); ofParameter & getVec3f(const std::string & name); ofParameter & getVec4f(const std::string & name); @@ -176,7 +178,9 @@ class ofParameterGroup : public ofAbstractParameter { ofParameter & getFloat(std::size_t pos); ofParameter & getChar(std::size_t pos); ofParameter & getString(std::size_t pos); +#ifdef OF_USE_LEGACY_MATH ofParameter & getPoint(std::size_t pos); +#endif ofParameter & getVec2f(std::size_t pos); ofParameter & getVec3f(std::size_t pos); ofParameter & getVec4f(std::size_t pos); @@ -380,12 +384,14 @@ template struct TypeInfo : public of::priv::TypeInfo_::is_specialized> { }; +#ifdef OF_USE_LEGACY_MATH // Here we provide some of our own specializations: template <> struct TypeInfo { static ofVec2f min() { return ofVec2f(0); } static ofVec2f max() { return ofVec2f(1); } }; +#endif template <> struct TypeInfo { @@ -393,11 +399,13 @@ struct TypeInfo { static glm::vec2 max() { return glm::vec2(1); } }; +#ifdef OF_USE_LEGACY_MATH template <> struct TypeInfo { static ofVec3f min() { return ofVec3f(0); } static ofVec3f max() { return ofVec3f(1); } }; +#endif template <> struct TypeInfo { @@ -405,11 +413,13 @@ struct TypeInfo { static glm::vec3 max() { return glm::vec3(1); } }; +#ifdef OF_USE_LEGACY_MATH template <> struct TypeInfo { static ofVec4f min() { return ofVec4f(0); } static ofVec4f max() { return ofVec4f(1); } }; +#endif template <> struct TypeInfo { diff --git a/libs/openFrameworks/types/ofParameterGroup.cpp b/libs/openFrameworks/types/ofParameterGroup.cpp index 63e60d341ff..c542f0fbfe3 100644 --- a/libs/openFrameworks/types/ofParameterGroup.cpp +++ b/libs/openFrameworks/types/ofParameterGroup.cpp @@ -80,9 +80,11 @@ const ofParameter & ofParameterGroup::getString(const std::string & return get(name); } +#ifdef OF_USE_LEGACY_MATH const ofParameter & ofParameterGroup::getPoint(const std::string & name) const { return get(name); } +#endif const ofParameter & ofParameterGroup::getVec2f(const std::string & name) const { return get(name); @@ -140,9 +142,11 @@ const ofParameter & ofParameterGroup::getString(std::size_t pos) co return get(pos); } +#ifdef OF_USE_LEGACY_MATH const ofParameter & ofParameterGroup::getPoint(std::size_t pos) const { return get(pos); } +#endif const ofParameter & ofParameterGroup::getVec2f(std::size_t pos) const { return get(pos); @@ -208,9 +212,11 @@ ofParameter & ofParameterGroup::getString(const std::string & name) return get(name); } +#ifdef OF_USE_LEGACY_MATH ofParameter & ofParameterGroup::getPoint(const std::string & name) { return get(name); } +#endif ofParameter & ofParameterGroup::getVec2f(const std::string & name) { return get(name); @@ -267,9 +273,11 @@ ofParameter & ofParameterGroup::getString(std::size_t pos) { return get(pos); } +#ifdef OF_USE_LEGACY_MATH ofParameter & ofParameterGroup::getPoint(std::size_t pos) { return get(pos); } +#endif ofParameter & ofParameterGroup::getVec2f(std::size_t pos) { return get(pos); diff --git a/libs/openFrameworks/video/ofAVFoundationGrabber.mm b/libs/openFrameworks/video/ofAVFoundationGrabber.mm index fbd80266464..4631b31bd2c 100644 --- a/libs/openFrameworks/video/ofAVFoundationGrabber.mm +++ b/libs/openFrameworks/video/ofAVFoundationGrabber.mm @@ -3,7 +3,6 @@ */ #include "ofAVFoundationGrabber.h" -//#include "ofVectorMath.h" #include "ofRectangle.h" #include "ofGLUtils.h" #include diff --git a/scripts/apothecary b/scripts/apothecary index 313b213ede6..b8b8325f8d0 160000 --- a/scripts/apothecary +++ b/scripts/apothecary @@ -1 +1 @@ -Subproject commit 313b213ede658eb6ae3fa5c4fb21a7bdcbe2230a +Subproject commit b8b8325f8d060e5474248cb6c5c6bd24a6698307 diff --git a/tests/math/ofNodeRegressionTests/src/main.cpp b/tests/math/ofNodeRegressionTests/src/main.cpp index f5cf7c9346d..23733194950 100644 --- a/tests/math/ofNodeRegressionTests/src/main.cpp +++ b/tests/math/ofNodeRegressionTests/src/main.cpp @@ -86,7 +86,10 @@ class ofApp: public ofxUnitTestsApp{ mNode2.orbitDeg(angle, 0, 100, mNode); mNode1.dolly(100); - mNode1.rotateAround(ofQuaternion(angle, { 0.f,1.f,0.f }), mNode.getGlobalPosition()); + + glm::quat rot = glm::angleAxis(glm::radians(angle), glm::normalize(glm::vec3(0.f, 1.f, 0.f))); + + mNode1.rotateAround(rot, mNode.getGlobalPosition()); auto pos1 = mNode1.getGlobalPosition(); auto pos2 = mNode2.getGlobalPosition(); @@ -103,7 +106,9 @@ class ofApp: public ofxUnitTestsApp{ ofNode n1; ofNode n2; n1.setGlobalPosition({ 100.f,0.f,0.f }); - n1.setGlobalOrientation(ofQuaternion(-90, { 0.f,-1.f,1.f })); + glm::quat rot = glm::angleAxis(glm::radians(-90.0f), glm::normalize(glm::vec3(0.f, -1.f, 1.f))); + + n1.setGlobalOrientation(rot); n2.setParent(n1); n2.truck(50.f); auto pos = n2.getGlobalPosition(); diff --git a/tests/math/quaternionTests/src/main.cpp b/tests/math/quaternionTests/src/main.cpp index 8a8d9eeadad..7a63c42684e 100644 --- a/tests/math/quaternionTests/src/main.cpp +++ b/tests/math/quaternionTests/src/main.cpp @@ -2,7 +2,7 @@ #include "ofxUnitTests.h" #include "ofAppNoWindow.h" -bool aprox_eq(const ofVec3f & v1, const ofVec3f & v2){ +bool aprox_eq(const glm::vec3 & v1, const glm::vec3 & v2){ bool eq = abs(v1.x - v2.x) < 0.0001 && abs(v1.y - v2.y) < 0.0001 && abs(v1.z - v2.z) < 0.0001; @@ -16,10 +16,10 @@ bool aprox_eq(const ofVec3f & v1, const ofVec3f & v2){ class ofApp: public ofxUnitTestsApp{ public: void run(){ - ofQuaternion q1(30,ofVec3f(1,0,0)); - ofQuaternion q2(30,ofVec3f(0,0,1)); - ofQuaternion q3(30,ofVec3f(0,1,0)); - ofVec3f v(100,100,100); + glm::quat q1 = glm::angleAxis(glm::radians(30.0f),glm::normalize(glm::vec3(1,0,0))); + glm::quat q2 = glm::angleAxis(glm::radians(30.0f),glm::normalize(glm::vec3(0,0,1))); + glm::quat q3 = glm::angleAxis(glm::radians(30.0f),glm::normalize(glm::vec3(0,1,0))); + glm::vec3 v(100,100,100); auto q12 = q1 * q2; auto q13 = q1 * q3; auto q23 = q2 * q3;