mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 05:57:29 +02:00
Merge pull request #511 from Geenz/19361
#19361 Don't select voxels when in motion or displaying other window on top, and don't show if too
This commit is contained in:
commit
5efe323c5e
1 changed files with 329 additions and 308 deletions
|
@ -428,6 +428,7 @@ static void sendVoxelServerAddScene() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::keyPressEvent(QKeyEvent* event) {
|
void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
|
if (activeWindow() == _window) {
|
||||||
if (_chatEntryOn) {
|
if (_chatEntryOn) {
|
||||||
if (_chatEntry.keyPressEvent(event)) {
|
if (_chatEntry.keyPressEvent(event)) {
|
||||||
_myAvatar.setKeyState(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete ?
|
_myAvatar.setKeyState(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete ?
|
||||||
|
@ -632,9 +633,11 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::keyReleaseEvent(QKeyEvent* event) {
|
void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
|
if (activeWindow() == _window) {
|
||||||
if (_chatEntryOn) {
|
if (_chatEntryOn) {
|
||||||
_myAvatar.setKeyState(NO_KEY_DOWN);
|
_myAvatar.setKeyState(NO_KEY_DOWN);
|
||||||
return;
|
return;
|
||||||
|
@ -689,9 +692,11 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::mouseMoveEvent(QMouseEvent* event) {
|
void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
if (activeWindow() == _window) {
|
||||||
_mouseX = event->x();
|
_mouseX = event->x();
|
||||||
_mouseY = event->y();
|
_mouseY = event->y();
|
||||||
|
|
||||||
|
@ -705,9 +710,11 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
deleteVoxelUnderCursor();
|
deleteVoxelUnderCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::mousePressEvent(QMouseEvent* event) {
|
void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
|
if (activeWindow() == _window) {
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
_mouseX = event->x();
|
_mouseX = event->x();
|
||||||
_mouseY = event->y();
|
_mouseY = event->y();
|
||||||
|
@ -717,17 +724,21 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
} else if (event->button() == Qt::RightButton && checkedVoxelModeAction() != 0) {
|
} else if (event->button() == Qt::RightButton && checkedVoxelModeAction() != 0) {
|
||||||
deleteVoxelUnderCursor();
|
deleteVoxelUnderCursor();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::mouseReleaseEvent(QMouseEvent* event) {
|
void Application::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
|
if (activeWindow() == _window) {
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
_mouseX = event->x();
|
_mouseX = event->x();
|
||||||
_mouseY = event->y();
|
_mouseY = event->y();
|
||||||
_mousePressed = false;
|
_mousePressed = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::wheelEvent(QWheelEvent* event) {
|
void Application::wheelEvent(QWheelEvent* event) {
|
||||||
|
if (activeWindow() == _window) {
|
||||||
if (checkedVoxelModeAction() == 0) {
|
if (checkedVoxelModeAction() == 0) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
|
@ -737,6 +748,7 @@ void Application::wheelEvent(QWheelEvent* event) {
|
||||||
} else {
|
} else {
|
||||||
decreaseVoxelSize();
|
decreaseVoxelSize();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every second, check the frame rates and other stuff
|
// Every second, check the frame rates and other stuff
|
||||||
|
@ -792,7 +804,6 @@ void Application::idle() {
|
||||||
_lastTimeIdle = check;
|
_lastTimeIdle = check;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::terminate() {
|
void Application::terminate() {
|
||||||
// Close serial port
|
// Close serial port
|
||||||
// close(serial_fd);
|
// close(serial_fd);
|
||||||
|
@ -1381,6 +1392,9 @@ void Application::init() {
|
||||||
sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
|
sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
|
||||||
|
const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
|
||||||
|
|
||||||
void Application::update(float deltaTime) {
|
void Application::update(float deltaTime) {
|
||||||
// Use Transmitter Hand to move hand if connected, else use mouse
|
// Use Transmitter Hand to move hand if connected, else use mouse
|
||||||
if (_myTransmitter.isConnected()) {
|
if (_myTransmitter.isConnected()) {
|
||||||
|
@ -1407,10 +1421,14 @@ void Application::update(float deltaTime) {
|
||||||
_myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection);
|
_myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection);
|
||||||
|
|
||||||
_mouseVoxel.s = 0.0f;
|
_mouseVoxel.s = 0.0f;
|
||||||
if (checkedVoxelModeAction() != 0) {
|
if (checkedVoxelModeAction() != 0 &&
|
||||||
|
(fabs(_myAvatar.getVelocity().x) +
|
||||||
|
fabs(_myAvatar.getVelocity().y) +
|
||||||
|
fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
|
||||||
float distance;
|
float distance;
|
||||||
BoxFace face;
|
BoxFace face;
|
||||||
if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
|
if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
|
||||||
|
if (distance < MAX_VOXEL_EDIT_DISTANCE) {
|
||||||
// find the nearest voxel with the desired scale
|
// find the nearest voxel with the desired scale
|
||||||
if (_mouseVoxelScale > _mouseVoxel.s) {
|
if (_mouseVoxelScale > _mouseVoxel.s) {
|
||||||
// choose the larger voxel that encompasses the one selected
|
// choose the larger voxel that encompasses the one selected
|
||||||
|
@ -1437,6 +1455,9 @@ void Application::update(float deltaTime) {
|
||||||
_mouseVoxel.z += faceVector.z * _mouseVoxel.s;
|
_mouseVoxel.z += faceVector.z * _mouseVoxel.s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_mouseVoxel.s = 0.0f;
|
||||||
|
}
|
||||||
} else if (_addVoxelMode->isChecked() || _selectVoxelMode->isChecked()) {
|
} else if (_addVoxelMode->isChecked() || _selectVoxelMode->isChecked()) {
|
||||||
// place the voxel a fixed distance away
|
// place the voxel a fixed distance away
|
||||||
float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE;
|
float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE;
|
||||||
|
|
Loading…
Reference in a new issue