From 0c8799bb3db1dbdf77e45c14eec1b05ce32b1114 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 5 Nov 2013 12:12:54 -0800 Subject: [PATCH 1/5] Tweaks to voxel editing: edit from farther away, expand cubes to make sure they show up over voxels, initialize voxel scale with moused-over scale. --- interface/src/Application.cpp | 18 ++++++++++++++---- interface/src/Application.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0e1adc6141..908eee237c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -124,6 +124,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _isHoverVoxel(false), _isHoverVoxelSounding(false), _mouseVoxelScale(1.0f / 1024.0f), + _mouseVoxelScaleInitialized(false), _justEditedVoxel(false), _nudgeStarted(false), _lookingAlongX(false), @@ -1782,7 +1783,7 @@ void Application::shrinkMirrorView() { } const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; -const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; +const float MAX_VOXEL_EDIT_DISTANCE = 50.0f; const float HEAD_SPHERE_RADIUS = 0.07; static QUuid DEFAULT_NODE_ID_REF; @@ -2051,6 +2052,8 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()"); _mouseVoxel.s = 0.0f; + bool wasInitialized = _mouseVoxelScaleInitialized; + _mouseVoxelScaleInitialized = false; if (Menu::getInstance()->isVoxelModeActionChecked() && (fabs(_myAvatar.getVelocity().x) + fabs(_myAvatar.getVelocity().y) + @@ -2058,6 +2061,12 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) { if (distance < MAX_VOXEL_EDIT_DISTANCE) { + // set the voxel scale to that of the first moused-over voxel + if (!wasInitialized) { + _mouseVoxelScale = _mouseVoxel.s; + } + _mouseVoxelScaleInitialized = true; + // find the nearest voxel with the desired scale if (_mouseVoxelScale > _mouseVoxel.s) { // choose the larger voxel that encompasses the one selected @@ -2990,6 +2999,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { glDisable(GL_LIGHTING); glPushMatrix(); glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); + const float CUBE_EXPANSION = 1.01f; if (_nudgeStarted) { renderNudgeGuide(_nudgeGuidePosition.x, _nudgeGuidePosition.y, _nudgeGuidePosition.z, _nudgeVoxel.s); renderNudgeGrid(_nudgeVoxel.x, _nudgeVoxel.y, _nudgeVoxel.z, _nudgeVoxel.s, _mouseVoxel.s); @@ -2999,7 +3009,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { _nudgeVoxel.z + _nudgeVoxel.s * 0.5f); glColor3ub(255, 255, 255); glLineWidth(4.0f); - glutWireCube(_nudgeVoxel.s); + glutWireCube(_nudgeVoxel.s * CUBE_EXPANSION); glPopMatrix(); } else { renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); @@ -3018,13 +3028,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { _nudgeGuidePosition.y + _nudgeVoxel.s*0.5f, _nudgeGuidePosition.z + _nudgeVoxel.s*0.5f); glLineWidth(4.0f); - glutWireCube(_nudgeVoxel.s); + glutWireCube(_nudgeVoxel.s * CUBE_EXPANSION); } else { glTranslatef(_mouseVoxel.x + _mouseVoxel.s*0.5f, _mouseVoxel.y + _mouseVoxel.s*0.5f, _mouseVoxel.z + _mouseVoxel.s*0.5f); glLineWidth(4.0f); - glutWireCube(_mouseVoxel.s); + glutWireCube(_mouseVoxel.s * CUBE_EXPANSION); } glLineWidth(1.0f); glPopMatrix(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 9f46720d84..4e370c9c7f 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -378,6 +378,7 @@ private: VoxelDetail _mouseVoxel; // details of the voxel to be edited float _mouseVoxelScale; // the scale for adding/removing voxels + bool _mouseVoxelScaleInitialized; glm::vec3 _lastMouseVoxelPos; // the position of the last mouse voxel edit bool _justEditedVoxel; // set when we've just added/deleted/colored a voxel From 359083ee9d48e3818b34520e0e3b2a5e3f850e21 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 5 Nov 2013 12:30:38 -0800 Subject: [PATCH 2/5] Sneak in a toggle for chat circling. --- interface/src/Menu.cpp | 1 + interface/src/Menu.h | 1 + interface/src/avatar/MyAvatar.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 0efe582df2..dbae859d24 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -326,6 +326,7 @@ Menu::Menu() : false, appInstance->getFaceshift(), SLOT(setTCPEnabled(bool))); + addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::ChatCircling, 0, true); QMenu* webcamOptionsMenu = developerMenu->addMenu("Webcam Options"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index cf6a35ff2b..987d7ff452 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -146,6 +146,7 @@ namespace MenuOption { const QString AutomaticallyAuditTree = "Automatically Audit Tree Stats"; const QString Bandwidth = "Bandwidth Display"; const QString BandwidthDetails = "Bandwidth Details"; + const QString ChatCircling = "Chat Circling"; const QString Collisions = "Collisions"; const QString CopyVoxels = "Copy"; const QString CoverageMap = "Render Coverage Map"; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 99d77f6aff..5ecc806d6f 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -17,6 +17,7 @@ #include "Application.h" #include "DataServerClient.h" +#include "Menu.h" #include "MyAvatar.h" #include "Physics.h" #include "devices/OculusManager.h" @@ -1110,6 +1111,10 @@ bool operator<(const SortedAvatar& s1, const SortedAvatar& s2) { } void MyAvatar::updateChatCircle(float deltaTime) { + if (!Menu::getInstance()->isOptionChecked(MenuOption::ChatCircling)) { + return; + } + // find all members and sort by distance QVector sortedAvatars; NodeList* nodeList = NodeList::getInstance(); From 6633b6a633e58c572f7214b0dc02b89d0450d623 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 5 Nov 2013 13:56:14 -0800 Subject: [PATCH 3/5] For now, don't perform avatar collisions unless we have a skeleton model. --- interface/src/avatar/MyAvatar.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 5ecc806d6f..7d6877e693 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1060,6 +1060,11 @@ void MyAvatar::updateAvatarCollisions(float deltaTime) { // detect collisions with other avatars and respond void MyAvatar::applyCollisionWithOtherAvatar(Avatar * otherAvatar, float deltaTime) { + // for now, don't collide if we have a new skeleton + if (_skeletonModel.isActive()) { + return; + } + glm::vec3 bodyPushForce = glm::vec3(0.0f, 0.0f, 0.0f); // loop through the body balls of each avatar to check for every possible collision From 092f1fa4c87dce24f879ca9266ad3c744944c2b6 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 5 Nov 2013 14:10:53 -0800 Subject: [PATCH 4/5] Shorten the long term average. --- interface/src/devices/Faceshift.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 4f9670ac50..9a45810cbe 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -68,7 +68,7 @@ void Faceshift::update() { (_eyeGazeLeftPitch + _eyeGazeRightPitch) / 2.0f, (_eyeGazeLeftYaw + _eyeGazeRightYaw) / 2.0f, 0.0f)))); // compute and subtract the long term average - const float LONG_TERM_AVERAGE_SMOOTHING = 0.9999f; + const float LONG_TERM_AVERAGE_SMOOTHING = 0.999f; if (!_longTermAverageInitialized) { _longTermAverageEyePitch = eulers.x; _longTermAverageEyeYaw = eulers.y; From add8ccc877814db5c7c4f5f78c70159bcc41b78e Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 5 Nov 2013 14:31:41 -0800 Subject: [PATCH 5/5] Lower the deflection amount. --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 908eee237c..46be485fc5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1988,8 +1988,8 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& // deflect using Faceshift gaze data glm::vec3 origin = _myAvatar.getHead().calculateAverageEyePosition(); float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; - const float PITCH_SCALE = 0.5f; - const float YAW_SCALE = 0.5f; + const float PITCH_SCALE = 0.25f; + const float YAW_SCALE = 0.25f; lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3( _faceshift.getEstimatedEyePitch() * pitchSign * PITCH_SCALE, _faceshift.getEstimatedEyeYaw() * YAW_SCALE, 0.0f))) * glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);