From b5c318adf9645f976193bf72c113746264bf6073 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sun, 11 May 2014 23:46:44 +0200 Subject: [PATCH] Fix non updating surface joint locations after custom surface setup as well as texture and projection area updates --- src/ofxSurfaceGui.cpp | 57 ++++++++++++++++++++++++++------------- src/ofxSurfaceGui.h | 7 +++-- src/ofxSurfaceManager.cpp | 2 ++ 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/ofxSurfaceGui.cpp b/src/ofxSurfaceGui.cpp index 1d590a3..f44a7af 100644 --- a/src/ofxSurfaceGui.cpp +++ b/src/ofxSurfaceGui.cpp @@ -213,6 +213,45 @@ void ofxSurfaceGui::unselect() bSelected = false; } +void ofxSurfaceGui::updateTextureHitarea() +{ + textureHitarea.clear(); + for ( int i=0; igetVertex(i); + } + updateProjectionHitarea(); + + ofVec2f textureSize = ofVec2f(surface->getTexture()->getWidth(), surface->getTexture()->getHeight()); + for ( int i=0; igetTexCoord(i) * textureSize; + } + updateTextureHitarea(); +} + bool ofxSurfaceGui::hitTest(float x, float y) { if (mode == PROJECTION_MAPPING){ @@ -300,24 +339,6 @@ void ofxSurfaceGui::addNumTextureMappingJoints(int num) } } -void ofxSurfaceGui::updateTextureHitarea() -{ - textureHitarea.clear(); - for ( int i=0; isetup(v1, v2, v3, t1, t2, t3, triangleSurfaces.back()->getTexture()); + surfaceGuis.back()->updateJoints(); } void ofxSurfaceManager::addTriangleSurface(ofVec2f v1, ofVec2f v2, ofVec2f v3, ofVec2f t1, ofVec2f t2, ofVec2f t3, ofTexture* texturePtr) { addTriangleSurface(); triangleSurfaces.back()->setup(v1, v2, v3, t1, t2, t3, texturePtr); + surfaceGuis.back()->updateJoints(); } \ No newline at end of file