mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
Support dragging when in coloring mode. I tried it in add/delete mode, too,
but it felt messy.
This commit is contained in:
parent
6317404249
commit
0ce9e42085
2 changed files with 15 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue