mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 05:17:24 +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) {
|
void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
_mouseX = event->x();
|
_mouseX = event->x();
|
||||||
_mouseY = event->y();
|
_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) {
|
void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
|
@ -797,8 +803,6 @@ void Application::idle() {
|
||||||
|
|
||||||
_mouseVoxel.s = 0.0f;
|
_mouseVoxel.s = 0.0f;
|
||||||
if (checkedVoxelModeAction() != 0) {
|
if (checkedVoxelModeAction() != 0) {
|
||||||
glm::vec3 oldMouseVoxelPos(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z);
|
|
||||||
|
|
||||||
float distance;
|
float distance;
|
||||||
BoxFace face;
|
BoxFace face;
|
||||||
if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
|
if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
|
||||||
|
@ -1948,6 +1952,9 @@ void Application::addVoxelUnderCursor() {
|
||||||
// create the voxel locally so it appears immediately
|
// create the voxel locally so it appears immediately
|
||||||
_voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s,
|
_voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s,
|
||||||
_mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, _destructiveAddVoxel);
|
_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
|
// delete the voxel locally so it disappears immediately
|
||||||
_voxels.deleteVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
|
_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;
|
int _mouseY;
|
||||||
bool _mousePressed; // true if mouse has been pressed (clear when finished)
|
bool _mousePressed; // true if mouse has been pressed (clear when finished)
|
||||||
|
|
||||||
VoxelDetail _mouseVoxel; // details of the voxel under the mouse cursor
|
VoxelDetail _mouseVoxel; // details of the voxel under the mouse cursor
|
||||||
float _mouseVoxelScale; // the scale for adding/removing voxels
|
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
|
bool _paintOn; // Whether to paint voxels as you fly around
|
||||||
unsigned char _dominantColor; // The dominant color of the voxel we're painting
|
unsigned char _dominantColor; // The dominant color of the voxel we're painting
|
||||||
|
|
Loading…
Reference in a new issue