From 563cd6f7e369ee29d57979f0ee80aad60efde290 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 5 Dec 2014 10:10:21 -0800 Subject: [PATCH 01/17] watch your language... --- libraries/fbx/src/FBXReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index a750ab53e2..f8451637a8 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1520,7 +1520,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } } else { std::string whatisthat = subobject.name; - if (whatisthat == "WTF") { + if (whatisthat == "Shape") { } } #endif From 3c09ca71cb6915e9fe8460fddbc5c929356b5fa0 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 8 Dec 2014 18:09:49 -0800 Subject: [PATCH 02/17] move emit of collisions to after done moving entities, so that callbacks can delete entities --- examples/collidingEntities.js | 4 +++- libraries/entities/src/EntityCollisionSystem.cpp | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/collidingEntities.js b/examples/collidingEntities.js index 7edbc9fecc..fff41ab65d 100644 --- a/examples/collidingEntities.js +++ b/examples/collidingEntities.js @@ -22,7 +22,7 @@ var velocity = { y: 0, z: 1 }; -var damping = 0.1; +var damping = 0; var color = { red: 255, @@ -43,6 +43,7 @@ function draw(deltaTime) { var properties = { type: "Sphere", + script: "file:///Users/zappoman/Development/HiFi/hifi/examples/entityScripts/changeColorOnCollision.js", collisionsWillMove: true, position: startPosition, dimensions: {x: largeRadius, y: largeRadius, z: largeRadius}, @@ -84,6 +85,7 @@ function draw(deltaTime) { if (numberEntitiesAdded <= MAX_ENTITIES) { var properties = { type: "Sphere", + script: "file:///Users/zappoman/Development/HiFi/hifi/examples/entityScripts/changeColorOnCollision.js", collisionsWillMove: true, position: center, dimensions: {x: entitySize, y: entitySize, z: entitySize}, diff --git a/libraries/entities/src/EntityCollisionSystem.cpp b/libraries/entities/src/EntityCollisionSystem.cpp index f9a9ec733d..7669f73c7d 100644 --- a/libraries/entities/src/EntityCollisionSystem.cpp +++ b/libraries/entities/src/EntityCollisionSystem.cpp @@ -170,12 +170,6 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) { quint64 now = usecTimestampNow(); - Collision collision; - collision.penetration = penetration; - // for now the contactPoint is the average between the the two paricle centers - collision.contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition()); - emitGlobalEntityCollisionWithEntity(entityA, entityB, collision); - glm::vec3 axis = glm::normalize(penetration); glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis; @@ -232,7 +226,13 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) { // thereby waking up static non-moving entities. _entityTree->updateEntity(entityB, propertiesB); _packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB); - } + } + + // NOTE: Do this after updating the entities so that the callback can delete the entities if they want to + Collision collision; + collision.penetration = penetration; + collision.contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition()); + emitGlobalEntityCollisionWithEntity(entityA, entityB, collision); } } } From 343f61044235e6df9e0dd49adbf797369739e353 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 8 Dec 2014 18:45:05 -0800 Subject: [PATCH 03/17] Use the 1450 limit everywhere, in case other places are running into the issue I experienced with metavoxels. --- libraries/metavoxels/src/DatagramSequencer.cpp | 2 +- libraries/networking/src/LimitedNodeList.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/metavoxels/src/DatagramSequencer.cpp b/libraries/metavoxels/src/DatagramSequencer.cpp index 5c5aee49c2..1aeef8e450 100644 --- a/libraries/metavoxels/src/DatagramSequencer.cpp +++ b/libraries/metavoxels/src/DatagramSequencer.cpp @@ -19,7 +19,7 @@ #include "MetavoxelMessages.h" // in sequencer parlance, a "packet" may consist of multiple datagrams. clarify when we refer to actual datagrams -const int MAX_DATAGRAM_SIZE = 1450; +const int MAX_DATAGRAM_SIZE = MAX_PACKET_SIZE; const int DEFAULT_MAX_PACKET_SIZE = 3000; diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 2fc8751e3f..f367cb93ce 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -31,7 +31,7 @@ #include "DomainHandler.h" #include "Node.h" -const int MAX_PACKET_SIZE = 1500; +const int MAX_PACKET_SIZE = 1450; const quint64 NODE_SILENCE_THRESHOLD_MSECS = 2 * 1000; From 895e22fcdbe8aa6e24cb5477693df54bfcff2035 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 9 Dec 2014 12:12:04 -0800 Subject: [PATCH 04/17] removed debug code --- examples/collidingEntities.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/collidingEntities.js b/examples/collidingEntities.js index fff41ab65d..233626df23 100644 --- a/examples/collidingEntities.js +++ b/examples/collidingEntities.js @@ -43,7 +43,6 @@ function draw(deltaTime) { var properties = { type: "Sphere", - script: "file:///Users/zappoman/Development/HiFi/hifi/examples/entityScripts/changeColorOnCollision.js", collisionsWillMove: true, position: startPosition, dimensions: {x: largeRadius, y: largeRadius, z: largeRadius}, @@ -85,7 +84,6 @@ function draw(deltaTime) { if (numberEntitiesAdded <= MAX_ENTITIES) { var properties = { type: "Sphere", - script: "file:///Users/zappoman/Development/HiFi/hifi/examples/entityScripts/changeColorOnCollision.js", collisionsWillMove: true, position: center, dimensions: {x: entitySize, y: entitySize, z: entitySize}, From 5fb9905186ba3ce1042ec7ae67cb50211df119b0 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 9 Dec 2014 12:14:21 -0800 Subject: [PATCH 05/17] Rather than reducing rate on first drop, wait until three consecutive packets have been dropped. --- .../metavoxels/src/DatagramSequencer.cpp | 20 +++++++++++++------ libraries/metavoxels/src/DatagramSequencer.h | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libraries/metavoxels/src/DatagramSequencer.cpp b/libraries/metavoxels/src/DatagramSequencer.cpp index 1aeef8e450..65d548ba1c 100644 --- a/libraries/metavoxels/src/DatagramSequencer.cpp +++ b/libraries/metavoxels/src/DatagramSequencer.cpp @@ -45,7 +45,8 @@ DatagramSequencer::DatagramSequencer(const QByteArray& datagramHeader, QObject* _packetsToWrite(0.0f), _slowStartThreshold(DEFAULT_SLOW_START_THRESHOLD), _packetRateIncreasePacketNumber(0), - _packetRateDecreasePacketNumber(0) { + _packetRateDecreasePacketNumber(0), + _packetDropCount(0) { _outgoingPacketStream.setByteOrder(QDataStream::LittleEndian); _incomingDatagramStream.setByteOrder(QDataStream::LittleEndian); @@ -348,11 +349,18 @@ void DatagramSequencer::sendRecordLost(const SendRecord& record) { } } - // halve the rate and remember as threshold - if (record.packetNumber >= _packetRateDecreasePacketNumber) { - _packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f); - _slowStartThreshold = _packetsPerGroup; - _packetRateDecreasePacketNumber = _outgoingPacketNumber + 1; + // if we've lost three in a row, halve the rate and remember as threshold + if (_packetDropCount == 0 || record.packetNumber == _lastPacketDropped + 1) { + _packetDropCount++; + _lastPacketDropped = record.packetNumber; + const int CONSECUTIVE_DROPS_BEFORE_REDUCTION = 3; + if (_packetDropCount >= CONSECUTIVE_DROPS_BEFORE_REDUCTION && record.packetNumber >= _packetRateDecreasePacketNumber) { + _packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f); + _slowStartThreshold = _packetsPerGroup; + _packetRateDecreasePacketNumber = _outgoingPacketNumber + 1; + } + } else { + _packetDropCount = 0; } } diff --git a/libraries/metavoxels/src/DatagramSequencer.h b/libraries/metavoxels/src/DatagramSequencer.h index 02fbd0f365..d3d37f2621 100644 --- a/libraries/metavoxels/src/DatagramSequencer.h +++ b/libraries/metavoxels/src/DatagramSequencer.h @@ -238,6 +238,8 @@ private: float _slowStartThreshold; int _packetRateIncreasePacketNumber; int _packetRateDecreasePacketNumber; + int _packetDropCount; + int _lastPacketDropped; QHash _reliableOutputChannels; QHash _reliableInputChannels; From 0a4f74cf9c65d2e358306206cd17bc1bdc8f4746 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 9 Dec 2014 16:29:45 -0800 Subject: [PATCH 06/17] Single reticle in the lobby --- examples/lobby.js | 48 ----------------------------------------------- 1 file changed, 48 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index dd011d08a4..6a2d85f64d 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -13,7 +13,6 @@ Script.include("libraries/globals.js"); var panelWall = false; var orbShell = false; -var reticle = false; var descriptionText = false; // used for formating the description text, in meters @@ -23,8 +22,6 @@ var numberOfLines = 2; var textMargin = 0.0625; var lineHeight = (textHeight - (2 * textMargin)) / numberOfLines; -var lastMouseMove = 0; -var IDLE_HOVER_TIME = 2000; // if you haven't moved the mouse in 2 seconds, and in HMD mode, then we use reticle for hover var avatarStickPosition = {}; var orbNaturalExtentsMin = { x: -1.230354, y: -1.22077, z: -1.210487 }; @@ -57,13 +54,6 @@ var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/eleva var currentMuzakInjector = null; var currentSound = null; -var inOculusMode = false; - -function reticlePosition() { - var RETICLE_DISTANCE = 1; - return Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), RETICLE_DISTANCE)); -} - function textOverlayPosition() { var TEXT_DISTANCE_OUT = 6; var TEXT_DISTANCE_DOWN = -2; @@ -124,22 +114,6 @@ function drawLobby() { panelWall = Overlays.addOverlay("model", panelWallProps); orbShell = Overlays.addOverlay("model", orbShellProps); descriptionText = Overlays.addOverlay("text3d", descriptionTextProps); - - inOculusMode = Menu.isOptionChecked("Enable VR Mode"); - - // for HMD wearers, create a reticle in center of screen - if (inOculusMode) { - var CURSOR_SCALE = 0.025; - - reticle = Overlays.addOverlay("billboard", { - url: HIFI_PUBLIC_BUCKET + "images/cursor.svg", - position: reticlePosition(), - ignoreRayIntersection: true, - isFacingAvatar: true, - alpha: 1.0, - scale: CURSOR_SCALE - }); - } // add an attachment on this avatar so other people see them in the lobby MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15); @@ -227,14 +201,8 @@ function cleanupLobby() { Overlays.deleteOverlay(orbShell); Overlays.deleteOverlay(descriptionText); - - if (reticle) { - Overlays.deleteOverlay(reticle); - } - panelWall = false; orbShell = false; - reticle = false; Audio.stopInjector(currentDrone); currentDrone = null; @@ -358,20 +326,6 @@ function handleLookAt(pickRay) { function update(deltaTime) { maybeCleanupLobby(); if (panelWall) { - - if (reticle) { - Overlays.editOverlay(reticle, { - position: reticlePosition() - }); - - var nowDate = new Date(); - var now = nowDate.getTime(); - if (now - lastMouseMove > IDLE_HOVER_TIME) { - var pickRay = Camera.computeViewPickRay(0.5, 0.5); - handleLookAt(pickRay); - } - } - Overlays.editOverlay(descriptionText, { position: textOverlayPosition() }); // if the reticle is up then we may need to play the next muzak @@ -383,8 +337,6 @@ function update(deltaTime) { function mouseMoveEvent(event) { if (panelWall) { - var nowDate = new Date(); - lastMouseMove = nowDate.getTime(); var pickRay = Camera.computePickRay(event.x, event.y); handleLookAt(pickRay); } From 8765d9a9b3fb51238c22ae1592d273dfb25784d5 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 9 Dec 2014 16:30:37 -0800 Subject: [PATCH 07/17] Mouse cursor modifications --- interface/src/Application.cpp | 85 ++++++++-------------------- interface/src/Application.h | 7 +-- interface/src/ui/FramelessDialog.cpp | 6 +- 3 files changed, 30 insertions(+), 68 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3824185f52..8a89444734 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -167,8 +167,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _raiseMirror(0.0f), _lastMouseMove(usecTimestampNow()), _lastMouseMoveWasSimulated(false), - _mouseHidden(false), - _seenMouseMove(false), _touchAvgX(0.0f), _touchAvgY(0.0f), _isTouchPressed(false), @@ -1252,34 +1250,23 @@ void Application::focusOutEvent(QFocusEvent* event) { } void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { - bool showMouse = true; - // Used by application overlay to determine how to draw cursor(s) _lastMouseMoveWasSimulated = deviceID > 0; - - // If this mouse move event is emitted by a controller, dont show the mouse cursor - if (_lastMouseMoveWasSimulated) { - showMouse = false; + if (!_lastMouseMoveWasSimulated) { + _lastMouseMove = usecTimestampNow(); } if (!_aboutToQuit) { - _entities.mouseMoveEvent(event, deviceID); + return; } - + + _entities.mouseMoveEvent(event, deviceID); + _controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts - // if one of our scripts have asked to capture this event, then stop processing it if (_controllerScriptingInterface.isMouseCaptured()) { return; } - - _lastMouseMove = usecTimestampNow(); - - if (_mouseHidden && showMouse && !OculusManager::isConnected() && !TV3DManager::isConnected()) { - getGLWidget()->setCursor(Qt::ArrowCursor); - _mouseHidden = false; - _seenMouseMove = true; - } } void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { @@ -2111,13 +2098,7 @@ void Application::updateMouseRay() { // make sure the frustum is up-to-date loadViewFrustum(_myCamera, _viewFrustum); - // if the mouse pointer isn't visible, act like it's at the center of the screen - float x = 0.5f, y = 0.5f; - if (!_mouseHidden) { - x = getTrueMouseX() / (float)_glWidget->width(); - y = getTrueMouseY() / (float)_glWidget->height(); - } - PickRay pickRay = _myCamera.computeViewPickRay(x, y); + PickRay pickRay = _myCamera.computePickRay(getTrueMouseX(), getTrueMouseY()); _mouseRayOrigin = pickRay.origin; _mouseRayDirection = pickRay.direction; @@ -2313,23 +2294,26 @@ void Application::updateCursor(float deltaTime) { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::updateCursor()"); - // watch mouse position, if it hasn't moved, hide the cursor + bool hideMouse = false; bool underMouse = _glWidget->underMouse(); - if (!_mouseHidden) { - quint64 now = usecTimestampNow(); - int elapsed = now - _lastMouseMove; - const int HIDE_CURSOR_TIMEOUT = 1 * 1000 * 1000; // 1 second - if (elapsed > HIDE_CURSOR_TIMEOUT && (underMouse || !_seenMouseMove)) { - getGLWidget()->setCursor(Qt::BlankCursor); - _mouseHidden = true; - } + + static const int HIDE_CURSOR_TIMEOUT = 1 * USECS_PER_SECOND; // 1 second + int elapsed = usecTimestampNow() - _lastMouseMove; + if ((elapsed > HIDE_CURSOR_TIMEOUT && underMouse) || + (OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) { + hideMouse = true; + } + + if (hideMouse != isMouseHidden()) { + setCursorVisible(!hideMouse); + } +} + +void Application::setCursorVisible(bool visible) { + if (visible) { + _glWidget->setCursor(Qt::ArrowCursor); } else { - // if the mouse is hidden, but we're not inside our window, then consider ourselves to be moving - if (!underMouse && _seenMouseMove) { - _lastMouseMove = usecTimestampNow(); - getGLWidget()->setCursor(Qt::ArrowCursor); - _mouseHidden = false; - } + _glWidget->setCursor(Qt::BlankCursor); } } @@ -2350,17 +2334,6 @@ void Application::update(float deltaTime) { } - static QCursor cursor; - if (OculusManager::isConnected() && - Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)){ - if (_window->cursor().shape() != Qt::BlankCursor) { - cursor = _window->cursor(); - _window->setCursor(QCursor(Qt::BlankCursor)); - } - } else if(_window->cursor().shape() == Qt::BlankCursor) { - _window->setCursor(cursor); - } - // Dispatch input events _controllerScriptingInterface.updateInputControllers(); @@ -4372,14 +4345,6 @@ void Application::skipVersion(QString latestVersion) { skipFile.write(latestVersion.toStdString().c_str()); } -void Application::setCursorVisible(bool visible) { - if (visible) { - restoreOverrideCursor(); - } else { - setOverrideCursor(Qt::BlankCursor); - } -} - void Application::takeSnapshot() { QMediaPlayer* player = new QMediaPlayer(); QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav"); diff --git a/interface/src/Application.h b/interface/src/Application.h index 58dec1da1f..0f0bd91210 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -211,7 +211,8 @@ public: EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; } Environment* getEnvironment() { return &_environment; } bool isMousePressed() const { return _mousePressed; } - bool isMouseHidden() const { return _mouseHidden; } + bool isMouseHidden() const { return _glWidget->cursor().shape() == Qt::BlankCursor; } + void setCursorVisible(bool visible); const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; } const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; } bool mouseOnScreen() const; @@ -309,8 +310,6 @@ public: QStringList getRunningScripts() { return _scriptEnginesHash.keys(); } ScriptEngine* getScriptEngine(QString scriptHash) { return _scriptEnginesHash.contains(scriptHash) ? _scriptEnginesHash[scriptHash] : NULL; } - - void setCursorVisible(bool visible); bool isLookingAtMyAvatar(Avatar* avatar); @@ -567,8 +566,6 @@ private: int _mouseDragStartedY; quint64 _lastMouseMove; bool _lastMouseMoveWasSimulated; - bool _mouseHidden; - bool _seenMouseMove; glm::vec3 _mouseRayOrigin; glm::vec3 _mouseRayDirection; diff --git a/interface/src/ui/FramelessDialog.cpp b/interface/src/ui/FramelessDialog.cpp index 22a0233d76..ab997a0a75 100644 --- a/interface/src/ui/FramelessDialog.cpp +++ b/interface/src/ui/FramelessDialog.cpp @@ -122,21 +122,21 @@ void FramelessDialog::mousePressEvent(QMouseEvent* mouseEvent) { if (hitLeft || hitRight) { _isResizing = true; _resizeInitialWidth = size().width(); - QApplication::setOverrideCursor(Qt::SizeHorCursor); + setCursor(Qt::SizeHorCursor); } } else { bool hitTop = (_position == POSITION_TOP) && (abs(mouseEvent->pos().y() - size().height()) < RESIZE_HANDLE_WIDTH); if (hitTop) { _isResizing = true; _resizeInitialWidth = size().height(); - QApplication::setOverrideCursor(Qt::SizeHorCursor); + setCursor(Qt::SizeHorCursor); } } } } void FramelessDialog::mouseReleaseEvent(QMouseEvent* mouseEvent) { - QApplication::restoreOverrideCursor(); + unsetCursor(); _isResizing = false; } From 426517b072322a0fc68d46a956e8224372a91f26 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 9 Dec 2014 17:11:01 -0800 Subject: [PATCH 08/17] fix a bug in MovingEntitiesOperator that would sometimes leave dangling entities --- libraries/entities/src/EntityItem.h | 3 --- libraries/entities/src/EntitySimulation.cpp | 1 - libraries/entities/src/EntityTree.cpp | 2 -- .../entities/src/MovingEntitiesOperator.cpp | 19 +------------------ .../entities/src/MovingEntitiesOperator.h | 2 -- 5 files changed, 1 insertion(+), 26 deletions(-) diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 915440ee6a..d5a4689657 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -227,8 +227,6 @@ public: float getSize() const; /// get maximum dimension in domain scale units (0.0 - 1.0) AACube getMaximumAACube() const; AACube getMinimumAACube() const; - AACube getOldMaximumAACube() const { return _oldMaximumAACube; } - void setOldMaximumAACube(const AACube& cube) { _oldMaximumAACube = cube; } AABox getAABox() const; /// axis aligned bounding box in domain scale units (0.0 - 1.0) static const QString DEFAULT_SCRIPT; @@ -347,7 +345,6 @@ protected: void setRadius(float value); AACubeShape _collisionShape; - AACube _oldMaximumAACube; // remember this so we know where the entity used to live in the tree // DirtyFlags are set whenever a property changes that the EntitySimulation needs to know about. uint32_t _dirtyFlags; // things that have changed from EXTERNAL changes (via script or packet) but NOT from simulation diff --git a/libraries/entities/src/EntitySimulation.cpp b/libraries/entities/src/EntitySimulation.cpp index 223df588d5..6d3b81715d 100644 --- a/libraries/entities/src/EntitySimulation.cpp +++ b/libraries/entities/src/EntitySimulation.cpp @@ -106,7 +106,6 @@ void EntitySimulation::sortEntitiesThatMoved() { if (moveOperator.hasMovingEntities()) { PerformanceTimer perfTimer("recurseTreeWithOperator"); _entityTree->recurseTreeWithOperator(&moveOperator); - moveOperator.finish(); } } diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 48ea2b7c07..17178ccbed 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -83,7 +83,6 @@ EntityItem* EntityTree::getOrCreateEntityItem(const EntityItemID& entityID, cons /// Adds a new entity item to the tree void EntityTree::postAddEntity(EntityItem* entity) { assert(entity); - entity->setOldMaximumAACube(entity->getMaximumAACube()); // check to see if we need to simulate this entity.. if (_simulation) { _simulation->addEntity(entity); @@ -138,7 +137,6 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro UpdateEntityOperator theOperator(this, containingElement, entity, properties); recurseTreeWithOperator(&theOperator); - entity->setOldMaximumAACube(entity->getMaximumAACube()); _isDirty = true; if (_simulation && entity->getDirtyFlags() != 0) { diff --git a/libraries/entities/src/MovingEntitiesOperator.cpp b/libraries/entities/src/MovingEntitiesOperator.cpp index 86b8de7b10..1ec67967b6 100644 --- a/libraries/entities/src/MovingEntitiesOperator.cpp +++ b/libraries/entities/src/MovingEntitiesOperator.cpp @@ -52,14 +52,10 @@ MovingEntitiesOperator::~MovingEntitiesOperator() { void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACube& newCube) { EntityTreeElement* oldContainingElement = _tree->getContainingElement(entity->getEntityItemID()); AABox newCubeClamped = newCube.clamp(0.0f, 1.0f); - AACube oldCube = entity->getOldMaximumAACube(); - AABox oldCubeClamped = oldCube.clamp(0.0f, 1.0f); if (_wantDebug) { qDebug() << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------"; - qDebug() << " oldCube:" << oldCube; qDebug() << " newCube:" << newCube; - qDebug() << " oldCubeClamped:" << oldCubeClamped; qDebug() << " newCubeClamped:" << newCubeClamped; if (oldContainingElement) { qDebug() << " oldContainingElement:" << oldContainingElement->getAACube(); @@ -86,9 +82,7 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACub details.entity = entity; details.oldFound = false; details.newFound = false; - details.oldCube = oldCube; details.newCube = newCube; - details.oldCubeClamped = oldCubeClamped; details.newCubeClamped = newCubeClamped; _entitiesToMove << details; _lookingCount++; @@ -97,7 +91,6 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACub qDebug() << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------"; qDebug() << " details.entity:" << details.entity->getEntityItemID(); qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube; - qDebug() << " details.oldCube:" << details.oldCube; qDebug() << " details.newCube:" << details.newCube; qDebug() << " details.newCubeClamped:" << details.newCubeClamped; qDebug() << " _lookingCount:" << _lookingCount; @@ -130,17 +123,14 @@ bool MovingEntitiesOperator::shouldRecurseSubTree(OctreeElement* element) { qDebug() << " element:" << element->getAACube(); qDebug() << " details.entity:" << details.entity->getEntityItemID(); qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube; - qDebug() << " details.oldCube:" << details.oldCube; qDebug() << " details.newCube:" << details.newCube; qDebug() << " details.newCubeClamped:" << details.newCubeClamped; - qDebug() << " elementCube.contains(details.oldCube)" << elementCube.contains(details.oldCube); qDebug() << " elementCube.contains(details.newCube)" << elementCube.contains(details.newCube); - qDebug() << " elementCube.contains(details.oldCubeClamped)" << elementCube.contains(details.oldCubeClamped); qDebug() << " elementCube.contains(details.newCubeClamped)" << elementCube.contains(details.newCubeClamped); qDebug() << "--------------------------------------------------------------------------"; } - if (elementCube.contains(details.oldCubeClamped) || elementCube.contains(details.newCubeClamped)) { + if (elementCube.contains(details.oldContainingElementCube) || elementCube.contains(details.newCubeClamped)) { containsEntity = true; break; // if it contains at least one, we're good to go } @@ -179,7 +169,6 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) { qDebug() << " details.entity:" << details.entity->getEntityItemID(); qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube; qDebug() << " entityTreeElement:" << entityTreeElement; - qDebug() << " details.oldCube:" << details.oldCube; qDebug() << " details.newCube:" << details.newCube; qDebug() << " details.newCubeClamped:" << details.newCubeClamped; qDebug() << " _lookingCount:" << _lookingCount; @@ -291,9 +280,3 @@ OctreeElement* MovingEntitiesOperator::possiblyCreateChildAt(OctreeElement* elem } return NULL; } - -void MovingEntitiesOperator::finish() { - foreach(const EntityToMoveDetails& details, _entitiesToMove) { - details.entity->setOldMaximumAACube(details.newCube); - } -} diff --git a/libraries/entities/src/MovingEntitiesOperator.h b/libraries/entities/src/MovingEntitiesOperator.h index bddf5da450..fefda3328e 100644 --- a/libraries/entities/src/MovingEntitiesOperator.h +++ b/libraries/entities/src/MovingEntitiesOperator.h @@ -17,7 +17,6 @@ public: EntityItem* entity; AACube oldCube; AACube newCube; - AABox oldCubeClamped; AABox newCubeClamped; EntityTreeElement* oldContainingElement; AACube oldContainingElementCube; @@ -43,7 +42,6 @@ public: virtual bool postRecursion(OctreeElement* element); virtual OctreeElement* possiblyCreateChildAt(OctreeElement* element, int childIndex); bool hasMovingEntities() const { return _entitiesToMove.size() > 0; } - void finish(); private: EntityTree* _tree; QSet _entitiesToMove; From 96c3a0edbd5455b6709320b14d9efa1091608fda Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 9 Dec 2014 17:39:05 -0800 Subject: [PATCH 09/17] option to suppress lobby text for now, defaults to true --- examples/lobby.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index 9e454eccc9..4ab2841c0e 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -15,6 +15,7 @@ var panelWall = false; var orbShell = false; var reticle = false; var descriptionText = false; +var showText = false; // used for formating the description text, in meters var textWidth = 4; @@ -312,7 +313,7 @@ function handleLookAt(pickRay) { var actionLocation = locations[panelIndex]; if (actionLocation.description == "") { - Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: true }); + Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: showText }); } else { // handle line wrapping var allWords = actionLocation.description.split(" "); @@ -344,7 +345,7 @@ function handleLookAt(pickRay) { } } formatedDescription += currentGoodLine; - Overlays.editOverlay(descriptionText, { text: formatedDescription, visible: true }); + Overlays.editOverlay(descriptionText, { text: formatedDescription, visible: showText }); } } else { Overlays.editOverlay(descriptionText, { text: "", visible: false }); From 43dc35d549db1438c8fb927698848ae6841d31f5 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 9 Dec 2014 17:53:23 -0800 Subject: [PATCH 10/17] Use correct mouse coordinate --- interface/src/Application.cpp | 20 ++++++++++---------- interface/src/ui/ApplicationOverlay.cpp | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8a89444734..4ad8e87204 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1128,7 +1128,8 @@ void Application::keyPressEvent(QKeyEvent* event) { if (!event->isAutoRepeat()) { // this starts an HFActionEvent HFActionEvent startActionEvent(HFActionEvent::startType(), - _myCamera.computeViewPickRay(0.5f, 0.5f)); + _myCamera.computePickRay(getTrueMouseX(), + getTrueMouseY())); sendEvent(this, &startActionEvent); } @@ -1219,10 +1220,11 @@ void Application::keyReleaseEvent(QKeyEvent* event) { case Qt::Key_Space: { if (!event->isAutoRepeat()) { // this ends the HFActionEvent - HFActionEvent endActionEvent(HFActionEvent::endType(), _myCamera.computeViewPickRay(0.5f, 0.5f)); + HFActionEvent endActionEvent(HFActionEvent::endType(), + _myCamera.computePickRay(getTrueMouseX(), + getTrueMouseY())); sendEvent(this, &endActionEvent); } - break; } case Qt::Key_Escape: { @@ -1231,7 +1233,6 @@ void Application::keyReleaseEvent(QKeyEvent* event) { HFBackEvent endBackEvent(HFBackEvent::endType()); sendEvent(this, &endBackEvent); } - break; } default: @@ -1256,7 +1257,7 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { _lastMouseMove = usecTimestampNow(); } - if (!_aboutToQuit) { + if (_aboutToQuit) { return; } @@ -1267,6 +1268,7 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { if (_controllerScriptingInterface.isMouseCaptured()) { return; } + } void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { @@ -2297,21 +2299,19 @@ void Application::updateCursor(float deltaTime) { bool hideMouse = false; bool underMouse = _glWidget->underMouse(); - static const int HIDE_CURSOR_TIMEOUT = 1 * USECS_PER_SECOND; // 1 second + static const int HIDE_CURSOR_TIMEOUT = 3 * USECS_PER_SECOND; // 3 second int elapsed = usecTimestampNow() - _lastMouseMove; if ((elapsed > HIDE_CURSOR_TIMEOUT && underMouse) || (OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) { hideMouse = true; } - if (hideMouse != isMouseHidden()) { - setCursorVisible(!hideMouse); - } + setCursorVisible(!hideMouse); } void Application::setCursorVisible(bool visible) { if (visible) { - _glWidget->setCursor(Qt::ArrowCursor); + _glWidget->unsetCursor(); } else { _glWidget->setCursor(Qt::BlankCursor); } diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 602e99ac31..f4e0c9769d 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -536,7 +536,7 @@ void ApplicationOverlay::renderPointers() { glm::vec2 screenPos = sphericalToScreen(glm::vec2(yaw, -pitch)); position = QPoint(screenPos.x, screenPos.y); - QCursor::setPos(application->getGLWidget()->mapToGlobal(position)); + application->getGLWidget()->cursor().setPos(application->getGLWidget()->mapToGlobal(position)); } _reticlePosition[MOUSE] = position; From 01c13cd6f114fcc36b1e03c70c24d077142c5e1e Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 9 Dec 2014 17:58:17 -0800 Subject: [PATCH 11/17] Fix the broken shadows by simply calling the needed setViewTransform which is used for rendering the ENitites and avatars --- interface/src/Application.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3824185f52..ba2f806c29 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2874,8 +2874,13 @@ void Application::updateShadowMap() { // store view matrix without translation, which we'll use for precision-sensitive objects updateUntranslatedViewMatrix(); - // TODO: assign an equivalent viewTransform object to the application to match the current path which uses glMatrixStack - // setViewTransform(viewTransform); + + // Equivalent to what is happening with _untranslatedViewMatrix and the _viewMatrixTranslation + // the viewTransofmr object is updatded with the correct values and saved, + // this is what is used for rendering the Entities and avatars + Transform viewTransform; + viewTransform.setRotation(rotation); + setViewTransform(viewTransform); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.1f, 4.0f); // magic numbers courtesy http://www.eecs.berkeley.edu/~ravir/6160/papers/shadowmaps.ppt From dc4c9cd545db08fccfeaaa9f18f98d4cba123bff Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 9 Dec 2014 18:00:14 -0800 Subject: [PATCH 12/17] Correctly Hide/Show cursor --- interface/src/Application.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4ad8e87204..facdeb59ec 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2311,9 +2311,15 @@ void Application::updateCursor(float deltaTime) { void Application::setCursorVisible(bool visible) { if (visible) { - _glWidget->unsetCursor(); + if (overrideCursor() != NULL) { + restoreOverrideCursor(); + } } else { - _glWidget->setCursor(Qt::BlankCursor); + if (overrideCursor() != NULL) { + changeOverrideCursor(Qt::BlankCursor); + } else { + setOverrideCursor(Qt::BlankCursor); + } } } From 628046f13cac685286d7e9a6e2f295e199e8027c Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 9 Dec 2014 18:26:59 -0800 Subject: [PATCH 13/17] potential fix to crash on windows startup --- libraries/networking/src/ReceivedPacketProcessor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/ReceivedPacketProcessor.cpp b/libraries/networking/src/ReceivedPacketProcessor.cpp index 59e1ecd456..db4c97f8d6 100644 --- a/libraries/networking/src/ReceivedPacketProcessor.cpp +++ b/libraries/networking/src/ReceivedPacketProcessor.cpp @@ -44,7 +44,9 @@ bool ReceivedPacketProcessor::process() { NetworkPacket& packet = _packets.front(); // get the oldest packet NetworkPacket temporary = packet; // make a copy of the packet in case the vector is resized on us _packets.erase(_packets.begin()); // remove the oldest packet - _nodePacketCounts[temporary.getNode()->getUUID()]--; + if (!temporary.getNode().isNull()) { + _nodePacketCounts[temporary.getNode()->getUUID()]--; + } unlock(); // let others add to the packets processPacket(temporary.getNode(), temporary.getByteArray()); // process our temporary copy midProcess(); From 88a576f84635e30c18087e4d569eaf25f8857e36 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 9 Dec 2014 19:35:38 -0800 Subject: [PATCH 14/17] fix action events for gamepad; --- interface/src/scripting/JoystickScriptingInterface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/src/scripting/JoystickScriptingInterface.cpp b/interface/src/scripting/JoystickScriptingInterface.cpp index 039dc40961..cbc4fee81c 100644 --- a/interface/src/scripting/JoystickScriptingInterface.cpp +++ b/interface/src/scripting/JoystickScriptingInterface.cpp @@ -132,8 +132,10 @@ void JoystickScriptingInterface::update() { : HFActionEvent::endType(); // global action events fire in the center of the screen - HFActionEvent actionEvent(actionType, - Application::getInstance()->getCamera()->computeViewPickRay(0.5f, 0.5f)); + Application* app = Application::getInstance(); + PickRay pickRay = app->getCamera()->computeViewPickRay(app->getTrueMouseX(), + app->getTrueMouseY()); + HFActionEvent actionEvent(actionType, pickRay); qApp->sendEvent(qApp, &actionEvent); } From 74a6fd5ca7970076068851b9c618952517067299 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 9 Dec 2014 20:03:00 -0800 Subject: [PATCH 15/17] fix joystick pick --- interface/src/scripting/JoystickScriptingInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/scripting/JoystickScriptingInterface.cpp b/interface/src/scripting/JoystickScriptingInterface.cpp index cbc4fee81c..0490b1f704 100644 --- a/interface/src/scripting/JoystickScriptingInterface.cpp +++ b/interface/src/scripting/JoystickScriptingInterface.cpp @@ -133,8 +133,8 @@ void JoystickScriptingInterface::update() { // global action events fire in the center of the screen Application* app = Application::getInstance(); - PickRay pickRay = app->getCamera()->computeViewPickRay(app->getTrueMouseX(), - app->getTrueMouseY()); + PickRay pickRay = app->getCamera()->computePickRay(app->getTrueMouseX(), + app->getTrueMouseY()); HFActionEvent actionEvent(actionType, pickRay); qApp->sendEvent(qApp, &actionEvent); } From 10a6428277f16d997dc13005f83bffe4a966595e Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 10 Dec 2014 10:37:54 -0800 Subject: [PATCH 16/17] Chess board correct orientation --- examples/playChess.js | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/playChess.js b/examples/playChess.js index 57ed24f342..faa32f6cda 100644 --- a/examples/playChess.js +++ b/examples/playChess.js @@ -86,6 +86,7 @@ ChessGame.Board = (function(position, scale) { modelURL: ChessGame.BOARD.modelURL, position: this.position, dimensions: this.dimensions, + rotation: ChessGame.BOARD.rotation, userData: this.buildUserDataString() } this.entity = null; From f2ed1337b5b0417a83b78fe9793c9d88dcf355f7 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Dec 2014 11:04:32 -0800 Subject: [PATCH 17/17] fix ray picking output distance to be meters --- libraries/octree/src/Octree.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index d6aad45b0d..0c92125b53 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -728,6 +728,10 @@ bool Octree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direc } recurseTreeWithOperation(findRayIntersectionOp, &args); + + if (args.found) { + args.distance *= (float)(TREE_SCALE); // scale back up to meters + } if (gotLock) { unlock();