From fa3c3448f4689d6b6bf61e205e559c8e0c95bb69 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 23 Jan 2014 10:55:51 -0800 Subject: [PATCH] Adding option to disable hand collisions against their own avatar. --- interface/src/Menu.cpp | 1 + interface/src/Menu.h | 1 + interface/src/avatar/Hand.cpp | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 1723e10f61..740effcf1c 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -352,6 +352,7 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false); addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::VoxelDrumming, 0, false); addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::PlaySlaps, 0, false); + addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandsCollideWithSelf, 0, false); addDisabledActionAndSeparator(developerMenu, "Testing"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index b356f29a85..dd3d5b7588 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -188,6 +188,7 @@ namespace MenuOption { const QString ExportVoxels = "Export Voxels"; const QString DontFadeOnVoxelServerChanges = "Don't Fade In/Out on Voxel Server Changes"; const QString HeadMouse = "Head Mouse"; + const QString HandsCollideWithSelf = "Collide With Self"; const QString FaceshiftTCP = "Faceshift (TCP)"; const QString FalseColorByDistance = "FALSE Color By Distance"; const QString FalseColorBySource = "FALSE Color By Source"; diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 51f1bc10de..e5aa33ad40 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -231,14 +231,16 @@ void Hand::updateCollisions() { } } - // and the current avatar (ignoring everything below the parent of the parent of the last free joint) - glm::vec3 owningPenetration; - const Model& skeletonModel = _owningAvatar->getSkeletonModel(); - int skipIndex = skeletonModel.getParentJointIndex(skeletonModel.getParentJointIndex( - skeletonModel.getLastFreeJointIndex((i == leftPalmIndex) ? skeletonModel.getLeftHandJointIndex() : - (i == rightPalmIndex) ? skeletonModel.getRightHandJointIndex() : -1))); - if (_owningAvatar->findSpherePenetration(palm.getPosition(), scaledPalmRadius, owningPenetration, skipIndex)) { - totalPenetration = addPenetrations(totalPenetration, owningPenetration); + if (Menu::getInstance()->isOptionChecked(MenuOption::HandsCollideWithSelf)) { + // and the current avatar (ignoring everything below the parent of the parent of the last free joint) + glm::vec3 owningPenetration; + const Model& skeletonModel = _owningAvatar->getSkeletonModel(); + int skipIndex = skeletonModel.getParentJointIndex(skeletonModel.getParentJointIndex( + skeletonModel.getLastFreeJointIndex((i == leftPalmIndex) ? skeletonModel.getLeftHandJointIndex() : + (i == rightPalmIndex) ? skeletonModel.getRightHandJointIndex() : -1))); + if (_owningAvatar->findSpherePenetration(palm.getPosition(), scaledPalmRadius, owningPenetration, skipIndex)) { + totalPenetration = addPenetrations(totalPenetration, owningPenetration); + } } // un-penetrate