Browse Source

Create SaveTexCoordPosCmd only if tex coord move has happened

master
Krisjanis Rijnieks 9 years ago
parent
commit
dd19417ad2
  1. 16
      src/Application/Modes/TextureMappingMode.cpp
  2. 2
      src/Application/Modes/TextureMappingMode.h

16
src/Application/Modes/TextureMappingMode.cpp

@ -203,8 +203,8 @@ void TextureMappingMode::onMousePressed(Application * app, ofMouseEventArgs & ar
// TODO: Make the following better, more direct. // TODO: Make the following better, more direct.
// Move this to mouseReleased part as we nee to save the previous location only // Move this to mouseReleased part as we nee to save the previous location only
// if the move has happened. // if the move has happened.
ofVec2f tex = app->getSurfaceManager()->getSelectedSurface()->getTexCoords()[selectedTexCoord]; _texCoordOnClick = app->getSurfaceManager()->getSelectedSurface()->getTexCoords()[selectedTexCoord];
app->getCmdManager()->exec(new SaveTexCoordPosCmd(selectedTexCoord, tex)); //app->getCmdManager()->exec(new SaveTexCoordPosCmd(selectedTexCoord, tex));
}else if(app->getSurfaceManager()->getSelectedSurface()->getTextureHitArea().inside(args.x, args.y)){ }else if(app->getSurfaceManager()->getSelectedSurface()->getTextureHitArea().inside(args.x, args.y)){
_clickPosition = ofPoint(args.x, args.y); _clickPosition = ofPoint(args.x, args.y);
@ -237,13 +237,11 @@ void TextureMappingMode::onMouseReleased(Application * app, ofMouseEventArgs & a
// create an undoable move tex coord command. // create an undoable move tex coord command.
int selectedTexCoord = Gui::instance()->getTextureEditorWidget().getSelectedTexCoord(); int selectedTexCoord = Gui::instance()->getTextureEditorWidget().getSelectedTexCoord();
if(selectedTexCoord >= 0){ if(selectedTexCoord >= 0){
ofPoint mouseReleasePosition = ofPoint(args.x, args.y); ofVec2f texCoordCurrent =
if(_clickPosition != mouseReleasePosition){ app->getSurfaceManager()->getSelectedSurface()->getTexCoords()[selectedTexCoord];
ofVec2f moveBy = ofVec2f(
mouseReleasePosition.x - _clickPosition.x, if(texCoordCurrent != _texCoordOnClick){
mouseReleasePosition.y - _clickPosition.y); app->getCmdManager()->exec(new SaveTexCoordPosCmd(selectedTexCoord, _texCoordOnClick));
//app->getCmdManager()->exec(
// new MvTexCoordCmd(selectedTexCoord, moveBy));
} }
} }

2
src/Application/Modes/TextureMappingMode.h

@ -62,6 +62,8 @@ class TextureMappingMode : public ApplicationBaseMode {
ofPoint _prevCanvasTranslate; // Canvas translate before TranslateCanvasCmd command exec ofPoint _prevCanvasTranslate; // Canvas translate before TranslateCanvasCmd command exec
ofPoint _clickCanvasTranslate; ofPoint _clickCanvasTranslate;
ofVec2f _texCoordOnClick;
}; };
} // namespace piMapper } // namespace piMapper

Loading…
Cancel
Save