diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8894ccab28..5a2f2fc5d5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1008,10 +1008,6 @@ void Application::mouseMoveEvent(QMouseEvent* event) { _mouseX = event->x(); _mouseY = event->y(); - - if (activeWindow() == _window) { - _pieMenu.mouseMoveEvent(_mouseX, _mouseY); - } } void Application::mousePressEvent(QMouseEvent* event) { @@ -1064,8 +1060,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { checkStatsClick(); } - - _pieMenu.mouseReleaseEvent(_mouseX, _mouseY); } } } @@ -1571,10 +1565,6 @@ void Application::init() { ScriptEngine::getParticlesScriptingInterface(), SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&))); - _pieMenu.init("./resources/images/hifi-interface-tools-v2-pie.svg", - _glWidget->width(), - _glWidget->height()); - _audio.init(_glWidget); _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); @@ -2508,10 +2498,6 @@ void Application::displayOverlay() { drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0, frameTimer, WHITE_TEXT); } - if (_pieMenu.isDisplayed()) { - _pieMenu.render(); - } - _overlays.render2D(); glPopMatrix(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 8c64da86b6..16776a857c 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -43,7 +43,6 @@ #include "MetavoxelSystem.h" #include "PacketHeaders.h" #include "ParticleTreeRenderer.h" -#include "PieMenu.h" #include "Stars.h" #include "ViewFrustum.h" #include "VoxelFade.h" @@ -452,8 +451,6 @@ private: StDev _idleLoopStdev; float _idleLoopMeasuredJitter; - PieMenu _pieMenu; - int parseOctreeStats(const QByteArray& packet, const SharedNodePointer& sendingNode); void trackIncomingVoxelPacket(const QByteArray& packet, const SharedNodePointer& sendingNode, bool wasStatsPacket); diff --git a/interface/src/Field.cpp b/interface/src/Field.cpp deleted file mode 100644 index 1f4024653b..0000000000 --- a/interface/src/Field.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -// Field.cpp -// interface -// -// Created by Philip Rosedale on 8/23/12. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. -// -// A vector-valued field over an array of elements arranged as a 3D lattice - -#include "Field.h" - -int Field::value(float *value, float *pos) { - int index = (int)(pos[0] / _worldSize * 10.0) + - (int)(pos[1] / _worldSize * 10.0) * 10 + - (int)(pos[2] / _worldSize * 10.0) * 100; - - if ((index >= 0) && (index < FIELD_ELEMENTS)) { - value[0] = _field[index].val.x; - value[1] = _field[index].val.y; - value[2] = _field[index].val.z; - return 1; - } else { - return 0; - } -} - -Field::Field(float worldSize, float coupling) { - _worldSize = worldSize; - _coupling = coupling; - //float fx, fy, fz; - for (int i = 0; i < FIELD_ELEMENTS; i++) { - const float FIELD_INITIAL_MAG = 0.0f; - _field[i].val = randVector() * FIELD_INITIAL_MAG * _worldSize; - _field[i].center.x = ((float)(i % 10) + 0.5f); - _field[i].center.y = ((float)(i % 100 / 10) + 0.5f); - _field[i].center.z = ((float)(i / 100) + 0.5f); - _field[i].center *= _worldSize / 10.f; - - } -} - -void Field::add(float* add, float *pos) { - int index = (int)(pos[0] / _worldSize * 10.0) + - (int)(pos[1] / _worldSize * 10.0) * 10 + - (int)(pos[2] / _worldSize * 10.0) * 100; - - if ((index >= 0) && (index < FIELD_ELEMENTS)) { - _field[index].val.x += add[0]; - _field[index].val.y += add[1]; - _field[index].val.z += add[2]; - } -} - -void Field::interact(float deltaTime, const glm::vec3& pos, glm::vec3& vel) { - - int index = (int)(pos.x / _worldSize * 10.0) + - (int)(pos.y / _worldSize*10.0) * 10 + - (int)(pos.z / _worldSize*10.0) * 100; - if ((index >= 0) && (index < FIELD_ELEMENTS)) { - vel += _field[index].val * deltaTime; // Particle influenced by field - _field[index].val += vel * deltaTime * _coupling; // Field influenced by particle - } -} - -void Field::simulate(float deltaTime) { - glm::vec3 neighbors, add, diff; - - for (int i = 0; i < FIELD_ELEMENTS; i++) { - const float CONSTANT_DAMPING = 0.5f; - _field[i].val *= (1.f - CONSTANT_DAMPING * deltaTime); - } -} - -void Field::render() { - int i; - float scale_view = 0.05f * _worldSize; - - glDisable(GL_LIGHTING); - glBegin(GL_LINES); - for (i = 0; i < FIELD_ELEMENTS; i++) { - glColor3f(0, 1, 0); - glVertex3fv(&_field[i].center.x); - glVertex3f(_field[i].center.x + _field[i].val.x * scale_view, - _field[i].center.y + _field[i].val.y * scale_view, - _field[i].center.z + _field[i].val.z * scale_view); - } - glEnd(); - - glColor3f(0, 1, 0); - glPointSize(4.0); - glEnable(GL_POINT_SMOOTH); - glBegin(GL_POINTS); - for (i = 0; i < FIELD_ELEMENTS; i++) { - glVertex3fv(&_field[i].center.x); - } - glEnd(); -} - - - diff --git a/interface/src/Field.h b/interface/src/Field.h deleted file mode 100644 index c85c3d33a4..0000000000 --- a/interface/src/Field.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// Field.h -// interface -// -// Created by Philip Rosedale on 8/23/12. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. -// - -#ifndef __interface__Field__ -#define __interface__Field__ - -#include -#include -#include "InterfaceConfig.h" -#include "world.h" -#include "Util.h" - -const int FIELD_ELEMENTS = 1000; - -/// Field is a lattice of vectors uniformly distributed in 3D with FIELD_ELEMENTS^(1/3) per side -class Field { -public: - struct FieldElement { - glm::vec3 val; - glm::vec3 center; - glm::vec3 fld; - } _field[FIELD_ELEMENTS]; - - Field(float worldSize, float coupling); - /// The field value at a position in space, given simply as the value of the enclosing cell - int value(float *ret, float *pos); - /// Visualize the field as vector lines drawn at each center - void render(); - /// Add to the field value cell enclosing a location - void add(float* add, float *loc); - /// A particle with a position and velocity interacts with the field given the coupling - /// constant passed when creating the field. - void interact(float deltaTime, const glm::vec3& pos, glm::vec3& vel); - /// Field evolves over timestep - void simulate(float deltaTime); -private: - float _worldSize; - float _coupling; -}; - -#endif diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 8c6cdacae1..0586382cb9 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1320,17 +1320,25 @@ void Menu::addSeparator(const QString& menuName, const QString& separatorName) { void Menu::removeSeparator(const QString& menuName, const QString& separatorName) { QMenu* menu = getMenu(menuName); + bool separatorRemoved = false; if (menu) { int textAt = findPositionOfMenuItem(menu, separatorName); QList menuActions = menu->actions(); QAction* separatorText = menuActions[textAt]; - QAction* separatorLine = menuActions[textAt - 1]; - if (separatorLine->isSeparator()) { - menu->removeAction(separatorText); - menu->removeAction(separatorLine); + if (textAt > 0 && textAt < menuActions.size()) { + QAction* separatorLine = menuActions[textAt - 1]; + if (separatorLine) { + if (separatorLine->isSeparator()) { + menu->removeAction(separatorText); + menu->removeAction(separatorLine); + separatorRemoved = true; + } + } } } - QMenuBar::repaint(); + if (separatorRemoved) { + QMenuBar::repaint(); + } } void Menu::addMenuItem(const MenuItemProperties& properties) { diff --git a/interface/src/PieMenu.cpp b/interface/src/PieMenu.cpp deleted file mode 100644 index d62d0447e1..0000000000 --- a/interface/src/PieMenu.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// -// PieMenu.cpp -// hifi -// -// Created by Clement Brisset on 7/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#include "PieMenu.h" - -#include - -#include -#include -#include -#include -#include - -PieMenu::PieMenu() : - _radiusIntern(30), - _radiusExtern(70), - _magnification(1.2f), - _isDisplayed(false) { -} - -void PieMenu::init(const char *fileName, int screenWidth, int screenHeight) { - // Load SVG - switchToResourcesParentIfRequired(); - QSvgRenderer renderer((QString) QString(fileName)); - - // Prepare a QImage with desired characteritisc - QImage image(2 * _radiusExtern, 2 * _radiusExtern, QImage::Format_ARGB32); - image.fill(0x0); - - // Get QPainter that paints to the image - QPainter painter(&image); - renderer.render(&painter); - - //get the OpenGL-friendly image - _textureImage = QGLWidget::convertToGLFormat(image); - - glGenTextures(1, &_textureID); - glBindTexture(GL_TEXTURE_2D, _textureID); - - //generate the texture - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, - _textureImage.width(), - _textureImage.height(), - 0, GL_RGBA, GL_UNSIGNED_BYTE, - _textureImage.bits()); - - //texture parameters - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -} - -void PieMenu::addAction(QAction* action){ - _actions.push_back(action); -} - -void PieMenu::render() { - if (_actions.size() == 0) { - return; - } - - float start = (float)M_PI / 2.0f; - float end = start + 2.0f * (float)M_PI; - float step = 2.0f * (float)M_PI / 100.0f; - float distance = sqrt((float)(_mouseX - _x) * (_mouseX - _x) + (_mouseY - _y) * (_mouseY - _y)); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, _textureID); - - glColor3f(1.0f, 1.0f, 1.0f); - - if (_radiusIntern < distance) { - float angle = atan2((float)(_mouseY - _y), (float)(_mouseX - _x)) - start; - angle = (0.0f < angle) ? angle : angle + 2.0f * M_PI; - - _selectedAction = floor(angle / (2.0f * M_PI / _actions.size())); - - start = start + _selectedAction * 2.0f * M_PI / _actions.size(); - end = start + 2.0f * M_PI / _actions.size(); - glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(0.5f, 0.5f); - glVertex2f(_x, _y); - for (float i = start; i < end; i += step) { - glTexCoord2f(0.5f + 0.5f * cos(i), 0.5f - 0.5f * sin(i)); - glVertex2f(_x + _magnification * _radiusExtern * cos(i), - _y + _magnification * _radiusExtern * sin(i)); - } - glTexCoord2f(0.5f + 0.5f * cos(end), 0.5f + - 0.5f * sin(end)); - glVertex2f(_x + _magnification * _radiusExtern * cos(end), - _y + _magnification * _radiusExtern * sin(end)); - glEnd(); - } else { - _selectedAction = -1; - - glBegin(GL_QUADS); - glTexCoord2f(1, 1); - glVertex2f(_x + _radiusExtern, _y - _radiusExtern); - - glTexCoord2f(1, 0); - glVertex2f(_x + _radiusExtern, _y + _radiusExtern); - - glTexCoord2f(0, 0); - glVertex2f(_x - _radiusExtern, _y + _radiusExtern); - - glTexCoord2f(0, 1); - glVertex2f(_x - _radiusExtern, _y - _radiusExtern); - glEnd(); - } - glDisable(GL_TEXTURE_2D); -} - -void PieMenu::resize(int screenWidth, int screenHeight) { -} - -void PieMenu::mouseMoveEvent(int x, int y) { - _mouseX = x; - _mouseY = y; -} - -void PieMenu::mousePressEvent(int x, int y) { - _x = _mouseX = x; - _y = _mouseY = y; - _selectedAction = -1; - _isDisplayed = true; -} - -void PieMenu::mouseReleaseEvent(int x, int y) { - if (0 <= _selectedAction && _selectedAction < (int)_actions.size() && _actions[_selectedAction]) { - _actions[_selectedAction]->trigger(); - } - - _isDisplayed = false; -} diff --git a/interface/src/PieMenu.h b/interface/src/PieMenu.h deleted file mode 100644 index f80f94f5d4..0000000000 --- a/interface/src/PieMenu.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// PieMenu.h -// hifi -// -// Created by Clement Brisset on 7/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#ifndef __hifi__PieMenu__ -#define __hifi__PieMenu__ - -#include - -#include "InterfaceConfig.h" -#include "Util.h" - -#include - -class QAction; - -class PieMenu { -public: - PieMenu(); - - void init(const char* fileName, int screenWidth, int screenHeight); - void addAction(QAction* action); - void render(); - void resize(int screenWidth, int screenHeight); - - bool isDisplayed() const {return _isDisplayed;} - int getX () const {return _x;} - int getY () const {return _y;} - - void mouseMoveEvent (int x, int y); - void mousePressEvent (int x, int y); - void mouseReleaseEvent(int x, int y); - -private: - QImage _textureImage; - GLuint _textureID; - - // position of the menu - int _x; - int _y; - int _radiusIntern; - int _radiusExtern; - float _magnification; - - int _mouseX; - int _mouseY; - - int _selectedAction; - - bool _isDisplayed; - - std::vector _actions; -}; - -#endif /* defined(__hifi__PieMenu__) */ diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 29416546a6..961fe92ce6 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -923,10 +923,13 @@ void MyAvatar::updateCollisionWithAvatars(float deltaTime) { // HACK: body-body collision uses two coaxial capsules with axes parallel to y-axis // TODO: make the collision work without assuming avatar orientation - Extents myStaticExtents = _skeletonModel.getStaticExtents(); - glm::vec3 staticScale = myStaticExtents.maximum - myStaticExtents.minimum; - float myCapsuleRadius = 0.25f * (staticScale.x + staticScale.z); - float myCapsuleHeight = staticScale.y; + + // TODO: these local variables are not used in the live code, only in the + // commented-outTODO code below. + //Extents myStaticExtents = _skeletonModel.getStaticExtents(); + //glm::vec3 staticScale = myStaticExtents.maximum - myStaticExtents.minimum; + //float myCapsuleRadius = 0.25f * (staticScale.x + staticScale.z); + //float myCapsuleHeight = staticScale.y; CollisionInfo collisionInfo; foreach (const AvatarSharedPointer& avatarPointer, avatars) {