mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:01:18 +02:00
add fade effect to voxel add and delete, fix crash with audio injector
This commit is contained in:
parent
4c9467a806
commit
facc9e1ee7
2 changed files with 100 additions and 69 deletions
|
@ -3702,24 +3702,12 @@ void Application::shiftPaintingColor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Application::maybeEditVoxelUnderCursor() {
|
void Application::injectVoxelAddedSoundEffect() {
|
||||||
if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) {
|
|
||||||
if (_mouseVoxel.s != 0) {
|
|
||||||
PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ?
|
|
||||||
PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL);
|
|
||||||
sendVoxelEditMessage(message, _mouseVoxel);
|
|
||||||
|
|
||||||
// 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->isChecked());
|
|
||||||
|
|
||||||
// remember the position for drag detection
|
|
||||||
_justEditedVoxel = true;
|
|
||||||
|
|
||||||
AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025);
|
AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025);
|
||||||
|
|
||||||
|
if (voxelInjector) {
|
||||||
voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z));
|
voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z));
|
||||||
//_myAvatar.getPosition()
|
//voxelInjector->setBearing(-1 * _myAvatar.getAbsoluteHeadYaw());
|
||||||
// voxelInjector->setBearing(-1 * _myAvatar.getAbsoluteHeadYaw());
|
|
||||||
voxelInjector->setVolume (16 * pow (_mouseVoxel.s, 2) / .0000001); //255 is max, and also default value
|
voxelInjector->setVolume (16 * pow (_mouseVoxel.s, 2) / .0000001); //255 is max, and also default value
|
||||||
|
|
||||||
/* for (int i = 0; i
|
/* for (int i = 0; i
|
||||||
|
@ -3735,7 +3723,6 @@ bool Application::maybeEditVoxelUnderCursor() {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
const float BIG_VOXEL_MIN_SIZE = .01f;
|
const float BIG_VOXEL_MIN_SIZE = .01f;
|
||||||
|
|
||||||
for (int i = 0; i < 11025; i++) {
|
for (int i = 0; i < 11025; i++) {
|
||||||
|
@ -3769,8 +3756,47 @@ bool Application::maybeEditVoxelUnderCursor() {
|
||||||
|
|
||||||
AudioInjectionManager::threadInjector(voxelInjector);
|
AudioInjectionManager::threadInjector(voxelInjector);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Application::maybeEditVoxelUnderCursor() {
|
||||||
|
if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) {
|
||||||
|
if (_mouseVoxel.s != 0) {
|
||||||
|
PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ?
|
||||||
|
PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL);
|
||||||
|
sendVoxelEditMessage(message, _mouseVoxel);
|
||||||
|
|
||||||
|
// 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->isChecked());
|
||||||
|
|
||||||
|
// Implement voxel fade effect
|
||||||
|
VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f);
|
||||||
|
const float VOXEL_BOUNDS_ADJUST = 0.01f;
|
||||||
|
float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST;
|
||||||
|
fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger;
|
||||||
|
fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger;
|
||||||
|
fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger;
|
||||||
|
fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger;
|
||||||
|
_voxelFades.push_back(fade);
|
||||||
|
|
||||||
|
// inject a sound effect
|
||||||
|
injectVoxelAddedSoundEffect();
|
||||||
|
|
||||||
|
// remember the position for drag detection
|
||||||
|
_justEditedVoxel = true;
|
||||||
|
|
||||||
|
}
|
||||||
} else if (_deleteVoxelMode->isChecked()) {
|
} else if (_deleteVoxelMode->isChecked()) {
|
||||||
deleteVoxelUnderCursor();
|
deleteVoxelUnderCursor();
|
||||||
|
VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
|
||||||
|
const float VOXEL_BOUNDS_ADJUST = 0.01f;
|
||||||
|
float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST;
|
||||||
|
fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger;
|
||||||
|
fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger;
|
||||||
|
fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger;
|
||||||
|
fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger;
|
||||||
|
_voxelFades.push_back(fade);
|
||||||
|
|
||||||
} else if (_eyedropperMode->isChecked()) {
|
} else if (_eyedropperMode->isChecked()) {
|
||||||
eyedropperVoxelUnderCursor();
|
eyedropperVoxelUnderCursor();
|
||||||
} else {
|
} else {
|
||||||
|
@ -3785,8 +3811,10 @@ void Application::deleteVoxelUnderCursor() {
|
||||||
// sending delete to the server is sufficient, server will send new version so we see updates soon enough
|
// sending delete to the server is sufficient, server will send new version so we see updates soon enough
|
||||||
sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, _mouseVoxel);
|
sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, _mouseVoxel);
|
||||||
AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(5000);
|
AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(5000);
|
||||||
|
|
||||||
|
if (voxelInjector) {
|
||||||
voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z));
|
voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z));
|
||||||
// voxelInjector->setBearing(0); //straight down the z axis
|
//voxelInjector->setBearing(0); //straight down the z axis
|
||||||
voxelInjector->setVolume (255); //255 is max, and also default value
|
voxelInjector->setVolume (255); //255 is max, and also default value
|
||||||
|
|
||||||
|
|
||||||
|
@ -3797,6 +3825,7 @@ void Application::deleteVoxelUnderCursor() {
|
||||||
|
|
||||||
AudioInjectionManager::threadInjector(voxelInjector);
|
AudioInjectionManager::threadInjector(voxelInjector);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// remember the position for drag detection
|
// remember the position for drag detection
|
||||||
_justEditedVoxel = true;
|
_justEditedVoxel = true;
|
||||||
}
|
}
|
||||||
|
@ -3907,10 +3936,6 @@ void Application::nodeKilled(Node* node) {
|
||||||
jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s);
|
jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s);
|
||||||
|
|
||||||
// Add the jurisditionDetails object to the list of "fade outs"
|
// Add the jurisditionDetails object to the list of "fade outs"
|
||||||
const float NODE_KILLED_RED = 1.0f;
|
|
||||||
const float NODE_KILLED_GREEN = 0.0f;
|
|
||||||
const float NODE_KILLED_BLUE = 0.0f;
|
|
||||||
|
|
||||||
VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
|
VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
|
||||||
fade.voxelDetails = jurisditionDetails;
|
fade.voxelDetails = jurisditionDetails;
|
||||||
_voxelFades.push_back(fade);
|
_voxelFades.push_back(fade);
|
||||||
|
@ -3937,10 +3962,6 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng
|
||||||
jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s);
|
jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s);
|
||||||
|
|
||||||
// Add the jurisditionDetails object to the list of "fade outs"
|
// Add the jurisditionDetails object to the list of "fade outs"
|
||||||
const float NODE_ADDED_RED = 0.0f;
|
|
||||||
const float NODE_ADDED_GREEN = 1.0f;
|
|
||||||
const float NODE_ADDED_BLUE = 0.0f;
|
|
||||||
|
|
||||||
VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE);
|
VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE);
|
||||||
fade.voxelDetails = jurisditionDetails;
|
fade.voxelDetails = jurisditionDetails;
|
||||||
_voxelFades.push_back(fade);
|
_voxelFades.push_back(fade);
|
||||||
|
|
|
@ -60,6 +60,15 @@ class QWheelEvent;
|
||||||
class Node;
|
class Node;
|
||||||
class ProgramObject;
|
class ProgramObject;
|
||||||
|
|
||||||
|
static const float NODE_ADDED_RED = 0.0f;
|
||||||
|
static const float NODE_ADDED_GREEN = 1.0f;
|
||||||
|
static const float NODE_ADDED_BLUE = 0.0f;
|
||||||
|
static const float NODE_KILLED_RED = 1.0f;
|
||||||
|
static const float NODE_KILLED_GREEN = 0.0f;
|
||||||
|
static const float NODE_KILLED_BLUE = 0.0f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Application : public QApplication, public NodeListHook {
|
class Application : public QApplication, public NodeListHook {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -240,6 +249,7 @@ private:
|
||||||
void deleteVoxelUnderCursor();
|
void deleteVoxelUnderCursor();
|
||||||
void eyedropperVoxelUnderCursor();
|
void eyedropperVoxelUnderCursor();
|
||||||
void resetSensors();
|
void resetSensors();
|
||||||
|
void injectVoxelAddedSoundEffect();
|
||||||
|
|
||||||
void setMenuShortcutsEnabled(bool enabled);
|
void setMenuShortcutsEnabled(bool enabled);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue