From 0ce9e420855cc3e063cc6d6edc840f3cb6ac84a8 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 15 May 2013 11:48:23 -0700 Subject: [PATCH] Support dragging when in coloring mode. I tried it in add/delete mode, too, but it felt messy. --- interface/src/Application.cpp | 14 ++++++++++++-- interface/src/Application.h | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0545644be0..f954c0a41f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -670,6 +670,12 @@ void Application::keyReleaseEvent(QKeyEvent* event) { void Application::mouseMoveEvent(QMouseEvent* event) { _mouseX = event->x(); _mouseY = event->y(); + + // detect drag + glm::vec3 mouseVoxelPos(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z); + if (_colorVoxelMode->isChecked() && event->buttons().testFlag(Qt::LeftButton) && mouseVoxelPos != _lastMouseVoxelPos) { + addVoxelUnderCursor(); + } } void Application::mousePressEvent(QMouseEvent* event) { @@ -797,8 +803,6 @@ void Application::idle() { _mouseVoxel.s = 0.0f; if (checkedVoxelModeAction() != 0) { - glm::vec3 oldMouseVoxelPos(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z); - float distance; BoxFace face; if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) { @@ -1948,6 +1952,9 @@ void Application::addVoxelUnderCursor() { // create the voxel locally so it appears immediately _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s, _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, _destructiveAddVoxel); + + // remember the position for drag detection + _lastMouseVoxelPos = glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z); } } @@ -1957,6 +1964,9 @@ void Application::deleteVoxelUnderCursor() { // delete the voxel locally so it disappears immediately _voxels.deleteVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); + + // remember the position for drag detection + _lastMouseVoxelPos = glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z); } } diff --git a/interface/src/Application.h b/interface/src/Application.h index 7960eeb51a..fde63ef88c 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -202,8 +202,9 @@ private: int _mouseY; bool _mousePressed; // true if mouse has been pressed (clear when finished) - VoxelDetail _mouseVoxel; // details of the voxel under the mouse cursor - float _mouseVoxelScale; // the scale for adding/removing voxels + VoxelDetail _mouseVoxel; // details of the voxel under the mouse cursor + float _mouseVoxelScale; // the scale for adding/removing voxels + glm::vec3 _lastMouseVoxelPos; // the position of the last mouse voxel edit bool _paintOn; // Whether to paint voxels as you fly around unsigned char _dominantColor; // The dominant color of the voxel we're painting