mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 11:22:24 +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) {
|
||||
if (activeWindow() == _window) {
|
||||
if (_chatEntryOn) {
|
||||
if (_chatEntry.keyPressEvent(event)) {
|
||||
_myAvatar.setKeyState(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete ?
|
||||
|
@ -633,8 +634,10 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (_chatEntryOn) {
|
||||
_myAvatar.setKeyState(NO_KEY_DOWN);
|
||||
return;
|
||||
|
@ -690,8 +693,10 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
_mouseX = event->x();
|
||||
_mouseY = event->y();
|
||||
|
||||
|
@ -706,8 +711,10 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::mousePressEvent(QMouseEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
_mouseX = event->x();
|
||||
_mouseY = event->y();
|
||||
|
@ -718,16 +725,20 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
|||
deleteVoxelUnderCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::mouseReleaseEvent(QMouseEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
_mouseX = event->x();
|
||||
_mouseY = event->y();
|
||||
_mousePressed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::wheelEvent(QWheelEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (checkedVoxelModeAction() == 0) {
|
||||
event->ignore();
|
||||
return;
|
||||
|
@ -738,6 +749,7 @@ void Application::wheelEvent(QWheelEvent* event) {
|
|||
decreaseVoxelSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Every second, check the frame rates and other stuff
|
||||
void Application::timer() {
|
||||
|
@ -792,7 +804,6 @@ void Application::idle() {
|
|||
_lastTimeIdle = check;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::terminate() {
|
||||
// Close serial port
|
||||
// close(serial_fd);
|
||||
|
@ -1381,6 +1392,9 @@ void Application::init() {
|
|||
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) {
|
||||
// Use Transmitter Hand to move hand if connected, else use mouse
|
||||
if (_myTransmitter.isConnected()) {
|
||||
|
@ -1407,10 +1421,14 @@ void Application::update(float deltaTime) {
|
|||
_myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection);
|
||||
|
||||
_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;
|
||||
BoxFace face;
|
||||
if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
|
||||
if (distance < MAX_VOXEL_EDIT_DISTANCE) {
|
||||
// find the nearest voxel with the desired scale
|
||||
if (_mouseVoxelScale > _mouseVoxel.s) {
|
||||
// choose the larger voxel that encompasses the one selected
|
||||
|
@ -1437,6 +1455,9 @@ void Application::update(float deltaTime) {
|
|||
_mouseVoxel.z += faceVector.z * _mouseVoxel.s;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_mouseVoxel.s = 0.0f;
|
||||
}
|
||||
} else if (_addVoxelMode->isChecked() || _selectVoxelMode->isChecked()) {
|
||||
// place the voxel a fixed distance away
|
||||
float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE;
|
||||
|
|
Loading…
Reference in a new issue