From d68a551940fe522797a8f76ac796a88fb535251b Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 18 Dec 2013 17:13:51 -0800 Subject: [PATCH 1/7] =?UTF-8?q?Switched=20voxel=20size=20(back)=20to=20key?= =?UTF-8?q?=20+,-=20because=20ZoomIn=20and=20ZoomOut=20don=E2=80=99t=20see?= =?UTF-8?q?m=20to=20trigger=20(at=20least=20on=20my=20mac)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interface/src/Application.cpp | 15 +++++++++++++-- interface/src/Menu.cpp | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d5c874ba6b..fb9df6dbcd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -995,12 +995,23 @@ void Application::keyPressEvent(QKeyEvent* event) { deleteVoxelUnderCursor(); } break; + case Qt::Key_Plus: - _myAvatar.increaseSize(); + increaseVoxelSize(); break; + case Qt::Key_Minus: - _myAvatar.decreaseSize(); + decreaseVoxelSize(); break; + + case QKeySequence::ZoomIn: + break; + _myAvatar.increaseSize(); + + case QKeySequence::ZoomOut: + break; + _myAvatar.decreaseSize(); + case Qt::Key_1: case Qt::Key_2: diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index ab725da812..618736eca8 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -210,12 +210,12 @@ Menu::Menu() : addActionToQMenuAndActionHash(toolsMenu, MenuOption::DecreaseVoxelSize, - QKeySequence::ZoomOut, + Qt::Key_Minus, appInstance, SLOT(decreaseVoxelSize())); addActionToQMenuAndActionHash(toolsMenu, MenuOption::IncreaseVoxelSize, - QKeySequence::ZoomIn, + Qt::Key_Plus, appInstance, SLOT(increaseVoxelSize())); addActionToQMenuAndActionHash(toolsMenu, MenuOption::ResetSwatchColors, 0, this, SLOT(resetSwatchColors())); @@ -237,12 +237,12 @@ Menu::Menu() : addActionToQMenuAndActionHash(avatarSizeMenu, MenuOption::IncreaseAvatarSize, - Qt::Key_Plus, + QKeySequence::ZoomIn, appInstance->getAvatar(), SLOT(increaseSize())); addActionToQMenuAndActionHash(avatarSizeMenu, MenuOption::DecreaseAvatarSize, - Qt::Key_Minus, + QKeySequence::ZoomOut, appInstance->getAvatar(), SLOT(decreaseSize())); addActionToQMenuAndActionHash(avatarSizeMenu, From 09e5b8ea4af4bad5aaedac113adff75dfded4d39 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 18 Dec 2013 20:55:27 -0800 Subject: [PATCH 2/7] slaps sound only on impact with velocity --- interface/src/avatar/Hand.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 2fa59ee43f..09cf461a5e 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -362,6 +362,7 @@ void Hand::updateCollisions() { // Check for palm collisions glm::vec3 myPalmPosition = palm.getPosition(); float palmCollisionDistance = 0.1f; + bool wasColliding = palm.getIsCollidingWithPalm(); palm.setIsCollidingWithPalm(false); // If 'Play Slaps' is enabled, look for palm-to-palm collisions and make sound for (int j = 0; j < otherAvatar->getHand().getNumPalms(); j++) { @@ -372,14 +373,21 @@ void Hand::updateCollisions() { glm::vec3 otherPalmPosition = otherPalm.getPosition(); if (glm::length(otherPalmPosition - myPalmPosition) < palmCollisionDistance) { palm.setIsCollidingWithPalm(true); + if (!wasColliding) { const float PALM_COLLIDE_VOLUME = 1.f; - const float PALM_COLLIDE_FREQUENCY = 150.f; - const float PALM_COLLIDE_DURATION_MAX = 2.f; - const float PALM_COLLIDE_DECAY_PER_SAMPLE = 0.005f; + const float PALM_COLLIDE_FREQUENCY = 1000.f; + const float PALM_COLLIDE_DURATION_MAX = 0.75f; + const float PALM_COLLIDE_DECAY_PER_SAMPLE = 0.01f; Application::getInstance()->getAudio()->startDrumSound(PALM_COLLIDE_VOLUME, PALM_COLLIDE_FREQUENCY, PALM_COLLIDE_DURATION_MAX, PALM_COLLIDE_DECAY_PER_SAMPLE); + // If the other person's palm is in motion, move mine downward to show I was hit + const float MIN_VELOCITY_FOR_SLAP = 0.05f; + if (glm::length(otherPalm.getVelocity()) > MIN_VELOCITY_FOR_SLAP) { + // add slapback here + } + } } From 77751df992e32d8688b742010b02dc03d17e7c5a Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 19 Dec 2013 10:01:55 -0800 Subject: [PATCH 3/7] =?UTF-8?q?Revert=20"Switched=20voxel=20size=20(back)?= =?UTF-8?q?=20to=20key=20+,-=20because=20ZoomIn=20and=20ZoomOut=20don?= =?UTF-8?q?=E2=80=99t=20seem=20to=20trigger=20(at=20least=20on=20my=20mac)?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit d68a551940fe522797a8f76ac796a88fb535251b. --- interface/src/Application.cpp | 15 ++------------- interface/src/Menu.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 45d13b38ce..24cdabe772 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -994,23 +994,12 @@ void Application::keyPressEvent(QKeyEvent* event) { deleteVoxelUnderCursor(); } break; - case Qt::Key_Plus: - increaseVoxelSize(); - break; - - case Qt::Key_Minus: - decreaseVoxelSize(); - break; - - case QKeySequence::ZoomIn: - break; _myAvatar.increaseSize(); - - case QKeySequence::ZoomOut: break; + case Qt::Key_Minus: _myAvatar.decreaseSize(); - + break; case Qt::Key_1: case Qt::Key_2: diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index d22847bcd2..98b807fea2 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -210,12 +210,12 @@ Menu::Menu() : addActionToQMenuAndActionHash(toolsMenu, MenuOption::DecreaseVoxelSize, - Qt::Key_Minus, + QKeySequence::ZoomOut, appInstance, SLOT(decreaseVoxelSize())); addActionToQMenuAndActionHash(toolsMenu, MenuOption::IncreaseVoxelSize, - Qt::Key_Plus, + QKeySequence::ZoomIn, appInstance, SLOT(increaseVoxelSize())); addActionToQMenuAndActionHash(toolsMenu, MenuOption::ResetSwatchColors, 0, this, SLOT(resetSwatchColors())); @@ -237,12 +237,12 @@ Menu::Menu() : addActionToQMenuAndActionHash(avatarSizeMenu, MenuOption::IncreaseAvatarSize, - QKeySequence::ZoomIn, + Qt::Key_Plus, appInstance->getAvatar(), SLOT(increaseSize())); addActionToQMenuAndActionHash(avatarSizeMenu, MenuOption::DecreaseAvatarSize, - QKeySequence::ZoomOut, + Qt::Key_Minus, appInstance->getAvatar(), SLOT(decreaseSize())); addActionToQMenuAndActionHash(avatarSizeMenu, From c287e37691e24649f6c7da891514c71df6224276 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 19 Dec 2013 10:02:43 -0800 Subject: [PATCH 4/7] Reverted key mapping change since Andrzej fixed the underlying problem. --- interface/src/avatar/Hand.cpp | 2 +- libraries/particles/src/ParticleCollisionSystem.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 09cf461a5e..43b0cc4fd1 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -17,7 +17,7 @@ #include "Util.h" #include "renderer/ProgramObject.h" -//#define DEBUG_HAND +#define DEBUG_HAND using namespace std; diff --git a/libraries/particles/src/ParticleCollisionSystem.cpp b/libraries/particles/src/ParticleCollisionSystem.cpp index 8281deb12d..04eaeddbb0 100644 --- a/libraries/particles/src/ParticleCollisionSystem.cpp +++ b/libraries/particles/src/ParticleCollisionSystem.cpp @@ -77,6 +77,7 @@ void ParticleCollisionSystem::updateCollisionWithVoxels(Particle* particle) { if (_voxels->findSpherePenetration(center, radius, penetration, &penetratedVoxel)) { penetration /= (float)TREE_SCALE; updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY); + //qDebug("voxel collision\n"); applyHardCollision(particle, penetration, VOXEL_ELASTICITY, VOXEL_DAMPING); } } @@ -92,6 +93,7 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particle) { if (_particles->findSpherePenetration(center, radius, penetration, &penetratedElement)) { penetration /= (float)TREE_SCALE; updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY); + qDebug("particle collision\n"); applyHardCollision(particle, penetration, VOXEL_ELASTICITY, VOXEL_DAMPING); } } From 9f7e79e3c142c0f361c25c214a52ad47027f53a7 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 19 Dec 2013 14:59:15 -0800 Subject: [PATCH 5/7] bigger catch radius, tweak sounds, different new ball button --- interface/src/avatar/Hand.cpp | 79 ++++++++++++++++------------------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index dfe9776b64..e989cdf6fe 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -31,7 +31,7 @@ const float NO_DAMPING = 0.f; const glm::vec3 TOY_BALL_GRAVITY = glm::vec3(0,-2.0,0); const QString TOY_BALL_UPDATE_SCRIPT(""); const float PALM_COLLISION_RADIUS = 0.03f; -const float CATCH_RADIUS = 0.2f; +const float CATCH_RADIUS = 0.3f; const xColor TOY_BALL_ON_SERVER_COLOR[] = { { 255, 0, 0 }, @@ -81,14 +81,20 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f ParticleTree* particles = app->getParticles()->getTree(); bool ballFromHand = Menu::getInstance()->isOptionChecked(MenuOption::BallFromHand); int handID = palm.getSixenseID(); - - bool grabButtonPressed = (palm.getControllerButtons() & BUTTON_FWD); + + const int NEW_BALL_BUTTON = BUTTON_3; + + float trigger = palm.getTrigger(); + bool grabButtonPressed = ((palm.getControllerButtons() & BUTTON_FWD) || + (palm.getControllerButtons() & BUTTON_3) || + (trigger > 0.f)); + bool ballAlreadyInHand = _toyBallInHand[handID]; glm::vec3 targetPosition = (ballFromHand ? palm.getPosition() : fingerTipPosition) / (float)TREE_SCALE; float targetRadius = CATCH_RADIUS / (float)TREE_SCALE; - // If I don't currently have a ball in my hand, then I can catch this closest particle + // If I don't currently have a ball in my hand, then try to catch closest one if (!ballAlreadyInHand && grabButtonPressed) { const Particle* closestParticle = particles->findClosestParticle(targetPosition, targetRadius); @@ -119,7 +125,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f _ballParticleEditHandles[handID] = caughtParticle; caughtParticle = NULL; // Play a catch sound! - app->getAudio()->startDrumSound(1.0, 300, 0.5, 0.05); + app->getAudio()->startDrumSound(1.0, 300, 0.75, 0.015); } } @@ -133,46 +139,31 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f } } - // Is the controller button being held down.... - if (palm.getControllerButtons() & BUTTON_FWD) { + // If '3' is pressed, and not holding a ball, make a new one + if ((palm.getControllerButtons() & NEW_BALL_BUTTON) && (_toyBallInHand[handID] == false)) { + _toyBallInHand[handID] = true; + // Create a particle on the particle server +#ifdef DEBUG_HAND + qDebug("Created New Ball\n"); +#endif + glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition; + _ballParticleEditHandles[handID] = app->makeParticle( + ballPosition / (float)TREE_SCALE, + TOY_BALL_RADIUS / (float) TREE_SCALE, + TOY_BALL_ON_SERVER_COLOR[_whichBallColor[handID]], + NO_VELOCITY / (float)TREE_SCALE, + TOY_BALL_GRAVITY / (float) TREE_SCALE, + TOY_BALL_DAMPING, + IN_HAND, + TOY_BALL_UPDATE_SCRIPT); + // Play a new ball sound + app->getAudio()->startDrumSound(1.0, 2000, 0.5, 0.02); + } + + if (grabButtonPressed) { // If we don't currently have a ball in hand, then create it... - if (!_toyBallInHand[handID]) { - // Test for whether close enough to catch and catch.... - - // isCaught is also used as "creating" a new ball... for now, this section is the - // create new ball portion of the code... - bool isCaught = false; - - // If we didn't catch something, then create a new ball.... - if (!isCaught) { - _toyBallInHand[handID] = true; - - // create the ball, call MakeParticle, and use the resulting ParticleEditHandle to - // manage the newly created particle. - // Create a particle on the particle server -#ifdef DEBUG_HAND - qDebug("Created New Ball\n"); -#endif - glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition; - _ballParticleEditHandles[handID] = app->makeParticle( - ballPosition / (float)TREE_SCALE, - TOY_BALL_RADIUS / (float) TREE_SCALE, - TOY_BALL_ON_SERVER_COLOR[_whichBallColor[handID]], - NO_VELOCITY / (float)TREE_SCALE, - TOY_BALL_GRAVITY / (float) TREE_SCALE, - TOY_BALL_DAMPING, - IN_HAND, - TOY_BALL_UPDATE_SCRIPT); - // Play a new ball sound - app->getAudio()->startDrumSound(1.0, 2000, 0.5, 0.02); - - } - } else { - // Ball is in hand -#ifdef DEBUG_HAND - //qDebug("Ball in hand\n"); -#endif - + if (_toyBallInHand[handID]) { + // Update ball that is in hand uint32_t particleInHandID = _ballParticleEditHandles[handID]->getID(); const Particle* particleInHand = particles->findParticleByID(particleInHandID); xColor colorForParticleInHand = particleInHand ? particleInHand->getXColor() From b6ac73bb57dc7ec2c6131a0681d88078499a6a60 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 19 Dec 2013 23:12:11 -0800 Subject: [PATCH 6/7] merge --- interface/src/avatar/Hand.cpp | 4 ++++ 1 file changed, 4 insertions(+) mode change 100755 => 100644 interface/src/avatar/Hand.cpp diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp old mode 100755 new mode 100644 index a6cca4c6e5..af86c29345 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -131,6 +131,10 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f _ballParticleEditHandles[handID] = caughtParticle; caughtParticle = NULL; // Play a catch sound! + _catchInjector.setPosition(targetPosition); + + // inject the catch sound to the mixer and play it locally + _catchInjector.injectViaThread(app->getAudio()); app->getAudio()->startDrumSound(1.0, 300, 0.75, 0.015); } } From cf3dc47c18c9d980e4076de4e2039b9452aba6d5 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 19 Dec 2013 23:16:04 -0800 Subject: [PATCH 7/7] debug off --- interface/src/avatar/Hand.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index af86c29345..136d59bc37 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -17,8 +17,6 @@ #include "Util.h" #include "renderer/ProgramObject.h" -#define DEBUG_HAND - using namespace std; const float FINGERTIP_VOXEL_SIZE = 0.05; @@ -111,9 +109,6 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f glm::vec3 newVelocity = NO_VELOCITY; // update the particle with it's new state... -#ifdef DEBUG_HAND - qDebug("Caught!\n"); -#endif caughtParticle->updateParticle(newPosition, closestParticle->getRadius(), closestParticle->getXColor(), @@ -153,9 +148,6 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f if ((palm.getControllerButtons() & NEW_BALL_BUTTON) && (_toyBallInHand[handID] == false)) { _toyBallInHand[handID] = true; // Create a particle on the particle server -#ifdef DEBUG_HAND - qDebug("Created New Ball\n"); -#endif glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition; _ballParticleEditHandles[handID] = app->makeParticle( ballPosition / (float)TREE_SCALE, @@ -201,9 +193,6 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f ballVelocity = avatarRotation * ballVelocity; ballVelocity *= THROWN_VELOCITY_SCALING; -#ifdef DEBUG_HAND - qDebug("Threw ball, v = %.3f\n", glm::length(ballVelocity)); -#endif uint32_t particleInHandID = _ballParticleEditHandles[handID]->getID(); const Particle* particleInHand = particles->findParticleByID(particleInHandID); xColor colorForParticleInHand = particleInHand ? particleInHand->getXColor()