From 6af2b7aadf62ad0701d6f2d7e3f5d3bae30cff4f Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 12 Nov 2014 07:33:59 -0800 Subject: [PATCH] remove buckyballs and face shift lean driving (should be a script if desired) --- examples/Test.js | 104 ----------------- interface/src/Application.cpp | 12 -- interface/src/Application.h | 3 - interface/src/BuckyBalls.cpp | 179 ------------------------------ interface/src/BuckyBalls.h | 47 -------- interface/src/Menu.cpp | 2 - interface/src/Menu.h | 2 - interface/src/avatar/MyAvatar.cpp | 35 ------ interface/src/avatar/MyAvatar.h | 1 - 9 files changed, 385 deletions(-) delete mode 100644 examples/Test.js delete mode 100644 interface/src/BuckyBalls.cpp delete mode 100644 interface/src/BuckyBalls.h diff --git a/examples/Test.js b/examples/Test.js deleted file mode 100644 index 612c56d10b..0000000000 --- a/examples/Test.js +++ /dev/null @@ -1,104 +0,0 @@ -// -// Test.js -// examples -// -// Created by Ryan Huffman on 5/4/14 -// Copyright 2014 High Fidelity, Inc. -// -// This provides very basic unit testing functionality. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -test = function(name, func) { - print("Running test: " + name); - - var unitTest = new UnitTest(name, func); - - try { - unitTest.run(); - print(" Success: " + unitTest.numAssertions + " assertions passed"); - } catch (error) { - print(" Failure: " + error.name + " " + error.message); - } -}; - -AssertionException = function(expected, actual, message) { - print("Creating exception"); - this.message = message + "\n: " + actual + " != " + expected; - this.name = 'AssertionException'; -}; - -UnthrownException = function(message) { - print("Creating exception"); - this.message = message + "\n"; - this.name = 'UnthrownException'; -}; - -UnitTest = function(name, func) { - this.numAssertions = 0; - this.func = func; -}; - -UnitTest.prototype.run = function() { - this.func(); -}; - -UnitTest.prototype.assertNotEquals = function(expected, actual, message) { - this.numAssertions++; - if (expected == actual) { - throw new AssertionException(expected, actual, message); - } -}; - -UnitTest.prototype.assertEquals = function(expected, actual, message) { - this.numAssertions++; - if (expected != actual) { - throw new AssertionException(expected, actual, message); - } -}; - -UnitTest.prototype.assertContains = function (expected, actual, message) { - this.numAssertions++; - if (actual.indexOf(expected) == -1) { - throw new AssertionException(expected, actual, message); - } -}; - -UnitTest.prototype.assertHasProperty = function(property, actual, message) { - this.numAssertions++; - if (actual[property] === undefined) { - throw new AssertionException(property, actual, message); - } -}; - -UnitTest.prototype.assertNull = function(value, message) { - this.numAssertions++; - if (value !== null) { - throw new AssertionException(value, null, message); - } -} - -UnitTest.prototype.arrayEqual = function(array1, array2, message) { - this.numAssertions++; - if (array1.length !== array2.length) { - throw new AssertionException(array1.length , array2.length , message); - } - for (var i = 0; i < array1.length; ++i) { - if (array1[i] !== array2[i]) { - throw new AssertionException(array1[i], array2[i], i + " " + message); - } - } -} - -UnitTest.prototype.raises = function(func, message) { - this.numAssertions++; - try { - func(); - } catch (error) { - return; - } - - throw new UnthrownException(message); -} \ No newline at end of file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index bb19ce3ca5..26037800df 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1533,11 +1533,6 @@ void Application::idle() { _idleLoopStdev.reset(); } - if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { - PerformanceTimer perfTimer("buckyBalls"); - _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); - } - // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. idleTimer->start(2); @@ -2986,13 +2981,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { _audioReflector.render(); } - if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { - PerformanceTimer perfTimer("buckyBalls"); - PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), - "Application::displaySide() ... bucky balls..."); - _buckyBalls.render(); - } - // Draw voxels if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { PerformanceTimer perfTimer("voxels"); diff --git a/interface/src/Application.h b/interface/src/Application.h index eee2581e2e..31d4fd8da2 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -43,7 +43,6 @@ #include "MainWindow.h" #include "Audio.h" #include "AudioReflector.h" -#include "BuckyBalls.h" #include "Camera.h" #include "DatagramProcessor.h" #include "Environment.h" @@ -481,8 +480,6 @@ private: bool _justStarted; Stars _stars; - BuckyBalls _buckyBalls; - VoxelSystem _voxels; VoxelTree _clipboard; // if I copy/paste VoxelImportDialog* _voxelImportDialog; diff --git a/interface/src/BuckyBalls.cpp b/interface/src/BuckyBalls.cpp deleted file mode 100644 index ece9dd7dda..0000000000 --- a/interface/src/BuckyBalls.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// -// BuckyBalls.cpp -// interface/src -// -// Created by Philip on 1/2/14. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "BuckyBalls.h" - -#include "Application.h" -#include "Util.h" -#include "world.h" -#include "devices/SixenseManager.h" - -const int NUM_ELEMENTS = 3; -const float RANGE_BBALLS = 0.5f; -const float SIZE_BBALLS = 0.02f; -const float CORNER_BBALLS = 2.f; -const float GRAVITY_BBALLS = -0.25f; -const float BBALLS_ATTRACTION_DISTANCE = SIZE_BBALLS / 2.f; -const float COLLISION_RADIUS = 0.01f; -const float INITIAL_VELOCITY = 0.3f; - -glm::vec3 colors[NUM_ELEMENTS]; - -// Make some bucky balls for the avatar -BuckyBalls::BuckyBalls() { - _bballIsGrabbed[0] = 0; - _bballIsGrabbed[1] = 0; - colors[0] = glm::vec3(0.13f, 0.55f, 0.13f); - colors[1] = glm::vec3(0.64f, 0.16f, 0.16f); - colors[2] = glm::vec3(0.31f, 0.58f, 0.80f); - - for (int i = 0; i < NUM_BBALLS; i++) { - _bballPosition[i] = CORNER_BBALLS + randVector() * RANGE_BBALLS; - int element = (rand() % NUM_ELEMENTS); - if (element == 0) { - _bballRadius[i] = SIZE_BBALLS; - _bballColor[i] = colors[0]; - } else if (element == 1) { - _bballRadius[i] = SIZE_BBALLS / 2.f; - _bballColor[i] = colors[1]; - } else { - _bballRadius[i] = SIZE_BBALLS * 2.f; - _bballColor[i] = colors[2]; - } - _bballColliding[i] = 0.f; - _bballElement[i] = element; - if (_bballElement[i] != 1) { - _bballVelocity[i] = randVector() * INITIAL_VELOCITY; - } else { - _bballVelocity[i] = glm::vec3(0); - } - } -} - -void BuckyBalls::grab(PalmData& palm, float deltaTime) { - float penetration; - glm::vec3 fingerTipPosition = palm.getTipPosition(); - - if (palm.getControllerButtons() & BUTTON_FWD) { - if (!_bballIsGrabbed[palm.getSixenseID()]) { - // Look for a ball to grab - for (int i = 0; i < NUM_BBALLS; i++) { - glm::vec3 diff = _bballPosition[i] - fingerTipPosition; - penetration = glm::length(diff) - (_bballRadius[i] + COLLISION_RADIUS); - if (penetration < 0.f) { - _bballIsGrabbed[palm.getSixenseID()] = i; - } - } - } - if (_bballIsGrabbed[palm.getSixenseID()]) { - // If ball being grabbed, move with finger - glm::vec3 diff = _bballPosition[_bballIsGrabbed[palm.getSixenseID()]] - fingerTipPosition; - penetration = glm::length(diff) - (_bballRadius[_bballIsGrabbed[palm.getSixenseID()]] + COLLISION_RADIUS); - _bballPosition[_bballIsGrabbed[palm.getSixenseID()]] -= glm::normalize(diff) * penetration; - glm::vec3 fingerTipVelocity = palm.getTipVelocity(); - if (_bballElement[_bballIsGrabbed[palm.getSixenseID()]] != 1) { - _bballVelocity[_bballIsGrabbed[palm.getSixenseID()]] = fingerTipVelocity; - } - _bballPosition[_bballIsGrabbed[palm.getSixenseID()]] = fingerTipPosition; - _bballColliding[_bballIsGrabbed[palm.getSixenseID()]] = 1.f; - } - } else { - _bballIsGrabbed[palm.getSixenseID()] = 0; - } -} - -const float COLLISION_BLEND_RATE = 0.5f; -const float ATTRACTION_BLEND_RATE = 0.9f; -const float ATTRACTION_VELOCITY_BLEND_RATE = 0.10f; - -void BuckyBalls::simulate(float deltaTime, const HandData* handData) { - // First, update the grab behavior from the hand controllers - for (size_t i = 0; i < handData->getNumPalms(); ++i) { - PalmData palm = handData->getPalms()[i]; - grab(palm, deltaTime); - } - - // Look for collisions - for (int i = 0; i < NUM_BBALLS; i++) { - if (_bballElement[i] != 1) { - // For 'interacting' elements, look for other balls to interact with - for (int j = 0; j < NUM_BBALLS; j++) { - if (i != j) { - glm::vec3 diff = _bballPosition[i] - _bballPosition[j]; - - float diffLength = glm::length(diff); - float penetration = diffLength - (_bballRadius[i] + _bballRadius[j]); - - if (diffLength != 0) { - if (penetration < 0.f) { - // Colliding - move away and transfer velocity - _bballPosition[i] -= glm::normalize(diff) * penetration * COLLISION_BLEND_RATE; - if (glm::dot(_bballVelocity[i], diff) < 0.f) { - _bballVelocity[i] = _bballVelocity[i] * (1.f - COLLISION_BLEND_RATE) + - glm::reflect(_bballVelocity[i], glm::normalize(diff)) * COLLISION_BLEND_RATE; - } - } else if ((penetration > EPSILON) && (penetration < BBALLS_ATTRACTION_DISTANCE)) { - // If they get close to each other, bring them together with magnetic force - _bballPosition[i] -= glm::normalize(diff) * penetration * ATTRACTION_BLEND_RATE; - - // Also make their velocities more similar - _bballVelocity[i] = _bballVelocity[i] * (1.f - ATTRACTION_VELOCITY_BLEND_RATE) + _bballVelocity[j] * ATTRACTION_VELOCITY_BLEND_RATE; - } - } - } - } - } - } - // Update position and bounce on walls - const float BBALL_CONTINUOUS_DAMPING = 0.00f; - const float BBALL_WALL_COLLISION_DAMPING = 0.2f; - const float COLLISION_DECAY_RATE = 0.8f; - - for (int i = 0; i < NUM_BBALLS; i++) { - _bballPosition[i] += _bballVelocity[i] * deltaTime; - if (_bballElement[i] != 1) { - _bballVelocity[i].y += GRAVITY_BBALLS * deltaTime; - } - _bballVelocity[i] -= _bballVelocity[i] * BBALL_CONTINUOUS_DAMPING * deltaTime; - for (int j = 0; j < 3; j++) { - if ((_bballPosition[i][j] + _bballRadius[i]) > (CORNER_BBALLS + RANGE_BBALLS)) { - _bballPosition[i][j] = (CORNER_BBALLS + RANGE_BBALLS) - _bballRadius[i]; - _bballVelocity[i][j] *= -(1.f - BBALL_WALL_COLLISION_DAMPING); - } - if ((_bballPosition[i][j] - _bballRadius[i]) < (CORNER_BBALLS -RANGE_BBALLS)) { - _bballPosition[i][j] = (CORNER_BBALLS -RANGE_BBALLS) + _bballRadius[i]; - _bballVelocity[i][j] *= -(1.f - BBALL_WALL_COLLISION_DAMPING); - } - } - _bballColliding[i] *= COLLISION_DECAY_RATE; - if (_bballColliding[i] < 0.1f) { - _bballColliding[i] = 0.f; - } - } -} - -void BuckyBalls::render() { - glEnable(GL_LIGHTING); - for (int i = 0; i < NUM_BBALLS; i++) { - if (_bballColliding[i] > 0.f) { - const float GRAB_BRIGHTEN = 1.15f; - glColor3f(_bballColor[i].x * GRAB_BRIGHTEN, _bballColor[i].y * GRAB_BRIGHTEN, _bballColor[i].z * GRAB_BRIGHTEN); - } else { - glColor3f(_bballColor[i].x, _bballColor[i].y, _bballColor[i].z); - } - glPushMatrix(); - glTranslatef(_bballPosition[i].x, _bballPosition[i].y, _bballPosition[i].z); - Application::getInstance()->getGeometryCache()->renderSphere(_bballRadius[i], 15, 15); - glPopMatrix(); - } -} - - diff --git a/interface/src/BuckyBalls.h b/interface/src/BuckyBalls.h deleted file mode 100644 index d46245c9bf..0000000000 --- a/interface/src/BuckyBalls.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// BuckyBalls.h -// interface/src -// -// Created by Philip on 1/2/14. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_BuckyBalls_h -#define hifi_BuckyBalls_h - -#include - -#include - -#include -#include - -#include "GeometryUtil.h" -#include "InterfaceConfig.h" -#include "Util.h" - -const int NUM_BBALLS = 200; - -class BuckyBalls { -public: - BuckyBalls(); - void grab(PalmData& palm, float deltaTime); - void simulate(float deltaTime, const HandData* handData); - void render(); - - -private: - - glm::vec3 _bballPosition[NUM_BBALLS]; - glm::vec3 _bballVelocity[NUM_BBALLS]; - glm::vec3 _bballColor[NUM_BBALLS]; - float _bballRadius[NUM_BBALLS]; - float _bballColliding[NUM_BBALLS]; - int _bballElement[NUM_BBALLS]; - int _bballIsGrabbed[2]; -}; - -#endif // hifi_BuckyBalls_h diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index cd074805b6..f973ad7983 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -348,7 +348,6 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::OffAxisProjection, 0, false); addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::TurnWithHead, 0, false); - addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::MoveWithLean, 0, false); addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::HeadMouse, 0, false); @@ -717,7 +716,6 @@ Menu::Menu() : connect(appInstance->getAudio(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled())); QMenu* experimentalOptionsMenu = developerMenu->addMenu("Experimental"); - addCheckableActionToQMenuAndActionHash(experimentalOptionsMenu, MenuOption::BuckyBalls, 0, false); addCheckableActionToQMenuAndActionHash(experimentalOptionsMenu, MenuOption::StringHair, 0, false); addActionToQMenuAndActionHash(developerMenu, MenuOption::PasteToVoxel, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 8af91ccae4..ee29833d78 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -364,7 +364,6 @@ namespace MenuOption { const QString Bandwidth = "Bandwidth Display"; const QString BandwidthDetails = "Bandwidth Details"; const QString BlueSpeechSphere = "Blue Sphere While Speaking"; - const QString BuckyBalls = "Bucky Balls"; const QString CascadedShadows = "Cascaded"; const QString Chat = "Chat..."; const QString ChatCircling = "Chat Circling"; @@ -430,7 +429,6 @@ namespace MenuOption { const QString MetavoxelEditor = "Metavoxel Editor..."; const QString Metavoxels = "Metavoxels"; const QString Mirror = "Mirror"; - const QString MoveWithLean = "Move with Lean"; const QString MuteAudio = "Mute Microphone"; const QString MuteEnvironment = "Mute Environment"; const QString MyLocations = "My Locations..."; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 9ceb073167..a5c388e7f2 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -144,11 +144,6 @@ void MyAvatar::update(float deltaTime) { Head* head = getHead(); head->relaxLean(deltaTime); updateFromTrackers(deltaTime); - if (Menu::getInstance()->isOptionChecked(MenuOption::MoveWithLean)) { - // Faceshift drive is enabled, set the avatar drive based on the head position - moveWithLean(); - } - // Get audio loudness data from audio input device Audio* audio = Application::getInstance()->getAudio(); head->setAudioLoudness(audio->getLastInputLoudness()); @@ -373,36 +368,6 @@ void MyAvatar::updateFromTrackers(float deltaTime) { -MAX_LEAN, MAX_LEAN)); } -void MyAvatar::moveWithLean() { - // Move with Lean by applying thrust proportional to leaning - Head* head = getHead(); - glm::quat orientation = head->getCameraOrientation(); - glm::vec3 front = orientation * IDENTITY_FRONT; - glm::vec3 right = orientation * IDENTITY_RIGHT; - float leanForward = head->getLeanForward(); - float leanSideways = head->getLeanSideways(); - - // Degrees of 'dead zone' when leaning, and amount of acceleration to apply to lean angle - const float LEAN_FWD_DEAD_ZONE = 15.0f; - const float LEAN_SIDEWAYS_DEAD_ZONE = 10.0f; - const float LEAN_FWD_THRUST_SCALE = 4.0f; - const float LEAN_SIDEWAYS_THRUST_SCALE = 3.0f; - - if (fabs(leanForward) > LEAN_FWD_DEAD_ZONE) { - if (leanForward > 0.0f) { - addThrust(front * -(leanForward - LEAN_FWD_DEAD_ZONE) * LEAN_FWD_THRUST_SCALE); - } else { - addThrust(front * -(leanForward + LEAN_FWD_DEAD_ZONE) * LEAN_FWD_THRUST_SCALE); - } - } - if (fabs(leanSideways) > LEAN_SIDEWAYS_DEAD_ZONE) { - if (leanSideways > 0.0f) { - addThrust(right * -(leanSideways - LEAN_SIDEWAYS_DEAD_ZONE) * LEAN_SIDEWAYS_THRUST_SCALE); - } else { - addThrust(right * -(leanSideways + LEAN_SIDEWAYS_DEAD_ZONE) * LEAN_SIDEWAYS_THRUST_SCALE); - } - } -} void MyAvatar::renderDebugBodyPoints() { glm::vec3 torsoPosition(getPosition()); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 326e0e2665..01bbb556a1 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -47,7 +47,6 @@ public: void update(float deltaTime); void simulate(float deltaTime); void updateFromTrackers(float deltaTime); - void moveWithLean(); void render(const glm::vec3& cameraPosition, RenderMode renderMode = NORMAL_RENDER_MODE, bool postLighting = false); void renderBody(RenderMode renderMode, bool postLighting, float glowLevel = 0.0f);