From 4946ec18b6be68b73d88ce41013498244b74ef4c Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 9 Jan 2015 09:28:01 -0800 Subject: [PATCH 01/15] remove some TODO comments --- libraries/entities/src/EntityItem.cpp | 1 - libraries/physics/src/ObjectMotionState.cpp | 2 -- libraries/physics/src/ObjectMotionState.h | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index a744d39f05..48ceed863e 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1015,7 +1015,6 @@ void EntityItem::recalculateCollisionShape() { entityAACube.scale(TREE_SCALE); // scale to meters _collisionShape.setTranslation(entityAACube.calcCenter()); _collisionShape.setScale(entityAACube.getScale()); - // TODO: use motionState to update physics object } const float MIN_POSITION_DELTA = 0.0001f; diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index f8f0712d5e..46c67c0ec2 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -154,8 +154,6 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame, float subStep // NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame // due to _worldOffset. - // TODO: Andrew to reconcile Bullet and legacy damping coefficients. - // compute position error if (glm::length2(_sentVelocity) > 0.0f) { _sentVelocity += _sentAcceleration * dt; diff --git a/libraries/physics/src/ObjectMotionState.h b/libraries/physics/src/ObjectMotionState.h index c0d3d2cabf..cb19babc1d 100644 --- a/libraries/physics/src/ObjectMotionState.h +++ b/libraries/physics/src/ObjectMotionState.h @@ -111,7 +111,7 @@ protected: glm::vec3 _sentPosition; // in simulation-frame (not world-frame) glm::quat _sentRotation;; glm::vec3 _sentVelocity; - glm::vec3 _sentAngularVelocity; + glm::vec3 _sentAngularVelocity; // radians per second glm::vec3 _sentAcceleration; }; From 05d2887c9491e1fcdf640db8d4c9e2ccb85a0e9d Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 9 Jan 2015 11:15:01 -0800 Subject: [PATCH 02/15] Move Torso twist to HeadData with Lean --- interface/src/avatar/Head.cpp | 1 - interface/src/avatar/Head.h | 5 ----- libraries/avatars/src/HeadData.cpp | 1 + libraries/avatars/src/HeadData.h | 3 +++ 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 32594a7225..296b4ab68a 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -54,7 +54,6 @@ Head::Head(Avatar* owningAvatar) : _deltaRoll(0.0f), _deltaLeanSideways(0.0f), _deltaLeanForward(0.0f), - _torsoTwist(0.0f), _isCameraMoving(false), _isLookingAtMe(false), _faceModel(this), diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index dece0a8565..255ea823e9 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -76,9 +76,6 @@ public: float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; } float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; } - float getTorsoTwist() const { return _torsoTwist; } - void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; } - glm::quat getEyeRotation(const glm::vec3& eyePosition) const; const glm::vec3& getRightEyePosition() const { return _rightEyePosition; } @@ -151,8 +148,6 @@ private: // delta lean angles for lean perturbations (driven by collisions) float _deltaLeanSideways; float _deltaLeanForward; - - float _torsoTwist; bool _isCameraMoving; bool _isLookingAtMe; diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index 511ab50c11..5bf33d1153 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -24,6 +24,7 @@ HeadData::HeadData(AvatarData* owningAvatar) : _baseRoll(0.0f), _leanSideways(0.0f), _leanForward(0.0f), + _torsoTwist(0.0f), _lookAtPosition(0.0f, 0.0f, 0.0f), _audioLoudness(0.0f), _isFaceshiftConnected(false), diff --git a/libraries/avatars/src/HeadData.h b/libraries/avatars/src/HeadData.h index 3a4eb3c808..cef5d5fbca 100644 --- a/libraries/avatars/src/HeadData.h +++ b/libraries/avatars/src/HeadData.h @@ -71,11 +71,13 @@ public: float getLeanSideways() const { return _leanSideways; } float getLeanForward() const { return _leanForward; } + float getTorsoTwist() const { return _torsoTwist; } virtual float getFinalLeanSideways() const { return _leanSideways; } virtual float getFinalLeanForward() const { return _leanForward; } void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; } void setLeanForward(float leanForward) { _leanForward = leanForward; } + void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; } friend class AvatarData; @@ -86,6 +88,7 @@ protected: float _baseRoll; float _leanSideways; float _leanForward; + float _torsoTwist; glm::vec3 _lookAtPosition; float _audioLoudness; From 16e1fc8c3a5f7d042574a195e8851aed3d45ae92 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 9 Jan 2015 11:16:05 -0800 Subject: [PATCH 03/15] Added isMyAvatar to AvatarData too --- libraries/avatars/src/AvatarData.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 84653ef673..a429a7af93 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -152,6 +152,8 @@ class AvatarData : public QObject { public: AvatarData(); virtual ~AvatarData(); + + virtual bool isMyAvatar() { return false; } const QUuid& getSessionUUID() const { return _sessionUUID; } From f2b7cb005a4b546482016d535194d5f9be3ade09 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 9 Jan 2015 11:16:49 -0800 Subject: [PATCH 04/15] Removed leans/Changed Head rotation in avatardata packets --- libraries/avatars/src/AvatarData.cpp | 50 ++++++++++------------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index cc45da610f..22976be715 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -158,15 +158,18 @@ QByteArray AvatarData::toByteArray() { destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale); // Head rotation (NOTE: This needs to become a quaternion to save two bytes) - destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalYaw()); - destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalPitch()); - destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalRoll()); - - // Head lean X,Z (head lateral and fwd/back motion relative to torso) - memcpy(destinationBuffer, &_headData->_leanSideways, sizeof(_headData->_leanSideways)); - destinationBuffer += sizeof(_headData->_leanSideways); - memcpy(destinationBuffer, &_headData->_leanForward, sizeof(_headData->_leanForward)); - destinationBuffer += sizeof(_headData->_leanForward); + glm::vec3 pitchYawRoll = glm::vec3(_headData->getFinalPitch(), + _headData->getFinalYaw(), + _headData->getFinalRoll()); + if (this->isMyAvatar()) { + glm::vec3 lean = glm::radians(glm::vec3(_headData->getFinalLeanForward(), + _headData->getTorsoTwist(), + _headData->getFinalLeanSideways())); + pitchYawRoll -= lean; + } + destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.x); + destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.y); + destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.z); // Lookat Position memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition)); @@ -287,18 +290,16 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) { // bodyPitch = 2 (compressed float) // bodyRoll = 2 (compressed float) // targetScale = 2 (compressed float) - // headYaw = 2 (compressed float) // headPitch = 2 (compressed float) + // headYaw = 2 (compressed float) // headRoll = 2 (compressed float) - // leanSideways = 4 - // leanForward = 4 // lookAt = 12 // audioLoudness = 4 // } // + 1 byte for pupilSize // + 1 byte for numJoints (0) - // = 53 bytes - int minPossibleSize = 52; + // = 45 bytes + int minPossibleSize = 45; int maxAvailableSize = packet.size() - offset; if (minPossibleSize > maxAvailableSize) { @@ -356,8 +357,8 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) { { // Head rotation //(NOTE: This needs to become a quaternion to save two bytes) float headYaw, headPitch, headRoll; - sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headPitch); + sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headRoll); if (glm::isnan(headYaw) || glm::isnan(headPitch) || glm::isnan(headRoll)) { if (shouldLogError(now)) { @@ -365,27 +366,10 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) { } return maxAvailableSize; } - _headData->setBaseYaw(headYaw); _headData->setBasePitch(headPitch); + _headData->setBaseYaw(headYaw); _headData->setBaseRoll(headRoll); } // 6 bytes - - // Head lean (relative to pelvis) - { - float leanSideways, leanForward; - memcpy(&leanSideways, sourceBuffer, sizeof(float)); - sourceBuffer += sizeof(float); - memcpy(&leanForward, sourceBuffer, sizeof(float)); - sourceBuffer += sizeof(float); - if (glm::isnan(leanSideways) || glm::isnan(leanForward)) { - if (shouldLogError(now)) { - qDebug() << "Discard nan AvatarData::leanSideways,leanForward; displayName = '" << _displayName << "'"; - } - return maxAvailableSize; - } - _headData->_leanSideways = leanSideways; - _headData->_leanForward = leanForward; - } // 8 bytes { // Lookat Position glm::vec3 lookAt; From 02b9aaacf829c1a2e11f8b99e5f3382a9fc457a0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 9 Jan 2015 11:16:58 -0800 Subject: [PATCH 05/15] Bump packet version --- libraries/networking/src/PacketHeaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index f2c292b528..54368b1423 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -57,7 +57,7 @@ PacketVersion versionForPacketType(PacketType type) { case PacketTypeInjectAudio: return 1; case PacketTypeAvatarData: - return 4; + return 5; case PacketTypeAvatarIdentity: return 1; case PacketTypeEnvironmentData: From 063e95bd79b1502351c13e29f169fbac0484c0a9 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 9 Jan 2015 14:31:34 -0800 Subject: [PATCH 06/15] Clement doesn't know how to use radians --- libraries/avatars/src/AvatarData.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 22976be715..d2108c79e2 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -162,9 +162,9 @@ QByteArray AvatarData::toByteArray() { _headData->getFinalYaw(), _headData->getFinalRoll()); if (this->isMyAvatar()) { - glm::vec3 lean = glm::radians(glm::vec3(_headData->getFinalLeanForward(), - _headData->getTorsoTwist(), - _headData->getFinalLeanSideways())); + glm::vec3 lean = glm::vec3(_headData->getFinalLeanForward(), + _headData->getTorsoTwist(), + _headData->getFinalLeanSideways()); pitchYawRoll -= lean; } destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.x); From 6d67b8e20c54505a61164cd5bf5f107a5bfc7447 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 9 Jan 2015 15:32:08 -0800 Subject: [PATCH 07/15] Don't call delete later unless you have to --- libraries/shared/src/DependencyManager.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/shared/src/DependencyManager.h b/libraries/shared/src/DependencyManager.h index fdf8030199..2ccbe18dd8 100644 --- a/libraries/shared/src/DependencyManager.h +++ b/libraries/shared/src/DependencyManager.h @@ -13,6 +13,7 @@ #define hifi_DependencyManager_h #include +#include #include @@ -22,10 +23,12 @@ public:\ private:\ void customDeleter() {\ QObject* thisObject = dynamic_cast(this);\ - if (thisObject) {\ + if (thisObject && thisObject->parent()) {\ thisObject->deleteLater();\ + qDebug() << "Delete later:" << #T;\ } else {\ delete this;\ + qDebug() << "Deleted:" << #T;\ }\ }\ friend class DependencyManager; From 58b965c9a2b97eba1d8f3e6b022f1d4c9a1b673b Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 9 Jan 2015 16:12:43 -0800 Subject: [PATCH 08/15] lock Octree higher when extracting things from bag --- assignment-client/src/octree/OctreeSendThread.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index ae34d54198..f0b4170cc6 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -404,6 +404,13 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus bool lastNodeDidntFit = false; // assume each node fits if (!nodeData->elementBag.isEmpty()) { + + quint64 lockWaitStart = usecTimestampNow(); + _myServer->getOctree()->lockForRead(); + quint64 lockWaitEnd = usecTimestampNow(); + lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart); + quint64 encodeStart = usecTimestampNow(); + OctreeElement* subTree = nodeData->elementBag.extract(); /* TODO: Looking for a way to prevent locking and encoding a tree that is not @@ -447,12 +454,6 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus // it seems like it may be a good idea to include the lock time as part of the encode time // are reported to client. Since you can encode without the lock nodeData->stats.encodeStarted(); - - quint64 lockWaitStart = usecTimestampNow(); - _myServer->getOctree()->lockForRead(); - quint64 lockWaitEnd = usecTimestampNow(); - lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart); - quint64 encodeStart = usecTimestampNow(); bytesWritten = _myServer->getOctree()->encodeTreeBitstream(subTree, &_packetData, nodeData->elementBag, params); From 99e1fdd46e227cde5412a21496db593ef6219648 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Sat, 10 Jan 2015 07:44:26 -0800 Subject: [PATCH 09/15] fix for EntityServer crash adding EntityItem::_element backpointer for easier add/remove logic --- .../src/EntityTreeRenderer.cpp | 2 + libraries/entities/src/EntityItem.cpp | 3 + libraries/entities/src/EntityItem.h | 4 ++ libraries/entities/src/EntityTreeElement.cpp | 13 ++++- .../entities/src/MovingEntitiesOperator.cpp | 15 +++-- .../entities/src/UpdateEntityOperator.cpp | 57 ++++++++----------- 6 files changed, 55 insertions(+), 39 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 47e9237ddc..3518e7b75c 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -98,7 +98,9 @@ void EntityTreeRenderer::init() { } QScriptValue EntityTreeRenderer::loadEntityScript(const EntityItemID& entityItemID) { + _tree->lockForRead(); EntityItem* entity = static_cast(_tree)->findEntityByEntityItemID(entityItemID); + _tree->unlock(); return loadEntityScript(entity); } diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index a744d39f05..6917dc1e7d 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -95,6 +95,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) { _physicsInfo = NULL; _dirtyFlags = 0; _changedOnServer = 0; + _element = NULL; initFromEntityItemID(entityItemID); } @@ -110,6 +111,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert _physicsInfo = NULL; _dirtyFlags = 0; _changedOnServer = 0; + _element = NULL; initFromEntityItemID(entityItemID); setProperties(properties); } @@ -117,6 +119,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert EntityItem::~EntityItem() { // be sure to clean up _physicsInfo before calling this dtor assert(_physicsInfo == NULL); + assert(_element == NULL); } EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& params) const { diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index e52be1707a..6d422ab257 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -39,6 +39,7 @@ class EntityTreeElementExtraEncodeData; /// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate /// one directly, instead you must only construct one of it's derived classes with additional features. class EntityItem { + friend class EntityTreeElement; public: enum EntityDirtyFlags { @@ -301,6 +302,7 @@ public: void* getPhysicsInfo() const { return _physicsInfo; } void setPhysicsInfo(void* data) { _physicsInfo = data; } + EntityTreeElement* getElement() const { return _element; } protected: virtual void initFromEntityItemID(const EntityItemID& entityItemID); // maybe useful to allow subclasses to init @@ -362,6 +364,8 @@ protected: // 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 + + EntityTreeElement* _element; // back pointer to containing Element }; diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index 5f072164a0..4ced5fe844 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -682,6 +682,7 @@ void EntityTreeElement::cleanupEntities() { uint16_t numberOfEntities = _entityItems->size(); for (uint16_t i = 0; i < numberOfEntities; i++) { EntityItem* entity = (*_entityItems)[i]; + entity->_element = NULL; delete entity; } _entityItems->clear(); @@ -693,6 +694,7 @@ bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) { for (uint16_t i = 0; i < numberOfEntities; i++) { if ((*_entityItems)[i]->getEntityItemID() == id) { foundEntity = true; + (*_entityItems)[i]->_element = NULL; _entityItems->removeAt(i); break; } @@ -701,7 +703,13 @@ bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) { } bool EntityTreeElement::removeEntityItem(EntityItem* entity) { - return _entityItems->removeAll(entity) > 0; + int numEntries = _entityItems->removeAll(entity); + if (numEntries > 0) { + assert(entity->_element == this); + entity->_element = NULL; + return true; + } + return false; } @@ -808,7 +816,10 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int } void EntityTreeElement::addEntityItem(EntityItem* entity) { + assert(entity); + assert(entity->_element == NULL); _entityItems->push_back(entity); + entity->_element = this; } // will average a "common reduced LOD view" from the the child elements... diff --git a/libraries/entities/src/MovingEntitiesOperator.cpp b/libraries/entities/src/MovingEntitiesOperator.cpp index 1ec67967b6..48ba8e4ec2 100644 --- a/libraries/entities/src/MovingEntitiesOperator.cpp +++ b/libraries/entities/src/MovingEntitiesOperator.cpp @@ -179,7 +179,7 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) { // If this is one of the old elements we're looking for, then ask it to remove the old entity if (!details.oldFound && entityTreeElement == details.oldContainingElement) { - entityTreeElement->removeEntityItem(details.entity); + // DO NOT remove the entity here. It will be removed when added to the destination element. _foundOldCount++; //details.oldFound = true; // TODO: would be nice to add this optimization if (_wantDebug) { @@ -193,8 +193,15 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) { // If this element is the best fit for the new bounds of this entity then add the entity to the element if (!details.newFound && entityTreeElement->bestFitBounds(details.newCube)) { EntityItemID entityItemID = details.entity->getEntityItemID(); - entityTreeElement->addEntityItem(details.entity); - _tree->setContainingElement(entityItemID, entityTreeElement); + // remove from the old before adding + EntityTreeElement* oldElement = details.entity->getElement(); + if (oldElement != entityTreeElement) { + if (oldElement) { + oldElement->removeEntityItem(details.entity); + } + entityTreeElement->addEntityItem(details.entity); + _tree->setContainingElement(entityItemID, entityTreeElement); + } _foundNewCount++; //details.newFound = true; // TODO: would be nice to add this optimization if (_wantDebug) { @@ -227,7 +234,7 @@ bool MovingEntitiesOperator::postRecursion(OctreeElement* element) { - // It's not OK to prune if we have the potential of deleting the original containig element. + // It's not OK to prune if we have the potential of deleting the original containing element // because if we prune the containing element then new might end up reallocating the same memory later // and that will confuse our logic. // diff --git a/libraries/entities/src/UpdateEntityOperator.cpp b/libraries/entities/src/UpdateEntityOperator.cpp index 9cee11d73c..c85c4235de 100644 --- a/libraries/entities/src/UpdateEntityOperator.cpp +++ b/libraries/entities/src/UpdateEntityOperator.cpp @@ -231,18 +231,19 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) { qDebug() << " *** REMOVING from ELEMENT ***"; } - entityTreeElement->removeEntityItem(_existingEntity); // NOTE: only removes the entity, doesn't delete it + // the entity knows what element it's in, so we remove it from that one + // NOTE: we know we haven't yet added it to its new element because _removeOld is true + EntityTreeElement* oldElement = _existingEntity->getElement(); + oldElement->removeEntityItem(_existingEntity); + _tree->setContainingElement(_entityItemID, NULL); - // If we haven't yet found the new location, then we need to - // make sure to remove our entity to element map, because for - // now we're not in that map - if (!_foundNew) { - _tree->setContainingElement(_entityItemID, NULL); - - if (_wantDebug) { - qDebug() << " *** REMOVING from MAP ***"; - } + if (oldElement != _containingElement) { + qDebug() << "WARNING entity moved during UpdateEntityOperator recursion"; + assert(! _containingElement->removeEntityItem(_existingEntity)); + } + if (_wantDebug) { + qDebug() << " *** REMOVING from MAP ***"; } } _foundOld = true; @@ -263,7 +264,6 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) { qDebug() << " entityTreeElement->bestFitBounds(_newEntityBox)=" << entityTreeElement->bestFitBounds(_newEntityBox); } - // If this element is the best fit for the new entity properties, then add/or update it if (entityTreeElement->bestFitBounds(_newEntityBox)) { @@ -271,33 +271,14 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) { qDebug() << " *** THIS ELEMENT IS BEST FIT ***"; } + EntityTreeElement* oldElement = _existingEntity->getElement(); // if we are the existing containing element, then we can just do the update of the entity properties - if (entityTreeElement == _containingElement) { + if (entityTreeElement == oldElement) { if (_wantDebug) { qDebug() << " *** This is the same OLD ELEMENT ***"; } - // TODO: We shouldn't be in a remove old case and also be the new best fit. This indicates that - // we have some kind of a logic error in this operator. But, it can handle it properly by setting - // the new properties for the entity and moving on. Still going to output a warning that if we - // see consistently we will want to address this. - if (_removeOld) { - qDebug() << "UNEXPECTED - UpdateEntityOperator - " - "we thought we needed to removeOld, but the old entity is our best fit."; - _removeOld = false; - - // if we thought we were supposed to remove the old item, and we already did, then we need - // to repair this case. - if (_foundOld) { - if (_wantDebug) { - qDebug() << " *** REPAIRING PREVIOUS REMOVAL from ELEMENT and MAP ***"; - } - entityTreeElement->addEntityItem(_existingEntity); - _tree->setContainingElement(_entityItemID, entityTreeElement); - } - } - // set the entity properties and mark our element as changed. _existingEntity->setProperties(_properties); if (_wantDebug) { @@ -305,14 +286,22 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) { } } else { // otherwise, this is an add case. + if (oldElement) { + oldElement->removeEntityItem(_existingEntity); + if (oldElement != _containingElement) { + qDebug() << "WARNING entity moved during UpdateEntityOperator recursion"; + } + } entityTreeElement->addEntityItem(_existingEntity); - _existingEntity->setProperties(_properties); // still need to update the properties! _tree->setContainingElement(_entityItemID, entityTreeElement); + + _existingEntity->setProperties(_properties); // still need to update the properties! if (_wantDebug) { qDebug() << " *** ADDING ENTITY to ELEMENT and MAP and SETTING PROPERTIES ***"; } } - _foundNew = true; // we found the new item! + _foundNew = true; // we found the new element + _removeOld = false; // and it has already been removed from the old } else { keepSearching = true; } From 25e64d619ca9041b54dc9fd98449db8c0953ae01 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Sat, 10 Jan 2015 11:46:42 -0800 Subject: [PATCH 10/15] move statics out of EntityItem This makes for much more readable core dumps --- libraries/entities/src/EntityItem.cpp | 2 + libraries/entities/src/EntityItem.h | 49 ++++++++++--------- .../entities/src/EntityItemProperties.cpp | 30 ++++++------ 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 48ceed863e..73509305ed 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -21,6 +21,7 @@ #include "EntityItem.h" #include "EntityTree.h" +/* const float EntityItem::IMMORTAL = -1.0f; /// special lifetime which means the entity lives for ever. default lifetime const float EntityItem::DEFAULT_GLOW_LEVEL = 0.0f; const float EntityItem::DEFAULT_LOCAL_RENDER_ALPHA = 1.0f; @@ -45,6 +46,7 @@ const bool EntityItem::DEFAULT_VISIBLE = true; const bool EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS = false; const bool EntityItem::DEFAULT_COLLISIONS_WILL_MOVE = false; const bool EntityItem::DEFAULT_LOCKED = false; +*/ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) { _id = entityItemID.id; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index e52be1707a..365bc1b0f5 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -35,6 +35,31 @@ class EntityTreeElementExtraEncodeData; #define DONT_ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() = 0; #define ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() { }; +const glm::vec3 DEFAULT_DIMENSIONS = glm::vec3(0.1f); +const glm::quat DEFAULT_ROTATION; +const float DEFAULT_GLOW_LEVEL = 0.0f; +const float DEFAULT_LOCAL_RENDER_ALPHA = 1.0f; +const float DEFAULT_MASS = 1.0f; +const glm::vec3 NO_VELOCITY= glm::vec3(0.0f); +const glm::vec3 DEFAULT_VELOCITY = NO_VELOCITY; +const float EPSILON_VELOCITY_LENGTH = 0.001f / (float)TREE_SCALE; +const glm::vec3 NO_GRAVITY = glm::vec3(0.0f); +const glm::vec3 DEFAULT_GRAVITY = NO_GRAVITY; +const glm::vec3 REGULAR_GRAVITY = glm::vec3(0, -9.8f / (float)TREE_SCALE, 0); +const float DEFAULT_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header) +const float IMMORTAL = -1.0f; /// special lifetime which means the entity lives for ever. default lifetime +const float DEFAULT_LIFETIME = IMMORTAL; +const QString DEFAULT_SCRIPT = QString(""); +const glm::vec3 DEFAULT_REGISTRATION_POINT = glm::vec3(0.5f, 0.5f, 0.5f); // center +const glm::vec3 NO_ANGULAR_VELOCITY = glm::vec3(0.0f); +const glm::vec3 DEFAULT_ANGULAR_VELOCITY = NO_ANGULAR_VELOCITY; +const float DEFAULT_ANGULAR_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header) +const bool DEFAULT_VISIBLE = true; +const bool DEFAULT_IGNORE_FOR_COLLISIONS = false; +const bool DEFAULT_COLLISIONS_WILL_MOVE = false; +const bool DEFAULT_LOCKED = false; +const QString DEFAULT_USER_DATA = QString(""); + /// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available /// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate /// one directly, instead you must only construct one of it's derived classes with additional features. @@ -148,7 +173,6 @@ public: glm::vec3 getCenter() const; /// calculates center of the entity in domain scale units (0.0 - 1.0) glm::vec3 getCenterInMeters() const { return getCenter() * (float) TREE_SCALE; } - static const glm::vec3 DEFAULT_DIMENSIONS; const glm::vec3& getDimensions() const { return _dimensions; } /// get dimensions in domain scale units (0.0 - 1.0) glm::vec3 getDimensionsInMeters() const { return _dimensions * (float) TREE_SCALE; } /// get dimensions in meters float getDistanceToBottomOfEntity() const; /// get the distance from the position of the entity to its "bottom" in y axis @@ -160,34 +184,24 @@ public: /// set dimensions in meter units (0.0 - TREE_SCALE) this will also reset radius appropriately void setDimensionsInMeters(const glm::vec3& value) { setDimensions(value / (float) TREE_SCALE); } - static const glm::quat DEFAULT_ROTATION; const glm::quat& getRotation() const { return _rotation; } void setRotation(const glm::quat& rotation) { _rotation = rotation; recalculateCollisionShape(); } - static const float DEFAULT_GLOW_LEVEL; float getGlowLevel() const { return _glowLevel; } void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; } - static const float DEFAULT_LOCAL_RENDER_ALPHA; float getLocalRenderAlpha() const { return _localRenderAlpha; } void setLocalRenderAlpha(float localRenderAlpha) { _localRenderAlpha = localRenderAlpha; } - static const float DEFAULT_MASS; float getMass() const { return _mass; } void setMass(float value) { _mass = value; } - static const glm::vec3 DEFAULT_VELOCITY; - static const glm::vec3 NO_VELOCITY; - static const float EPSILON_VELOCITY_LENGTH; const glm::vec3& getVelocity() const { return _velocity; } /// velocity in domain scale units (0.0-1.0) per second glm::vec3 getVelocityInMeters() const { return _velocity * (float) TREE_SCALE; } /// get velocity in meters void setVelocity(const glm::vec3& value) { _velocity = value; } /// velocity in domain scale units (0.0-1.0) per second void setVelocityInMeters(const glm::vec3& value) { _velocity = value / (float) TREE_SCALE; } /// velocity in meters bool hasVelocity() const { return _velocity != NO_VELOCITY; } - static const glm::vec3 DEFAULT_GRAVITY; - static const glm::vec3 REGULAR_GRAVITY; - static const glm::vec3 NO_GRAVITY; const glm::vec3& getGravity() const { return _gravity; } /// gravity in domain scale units (0.0-1.0) per second squared glm::vec3 getGravityInMeters() const { return _gravity * (float) TREE_SCALE; } /// get gravity in meters void setGravity(const glm::vec3& value) { _gravity = value; } /// gravity in domain scale units (0.0-1.0) per second squared @@ -197,13 +211,10 @@ public: // TODO: this should eventually be updated to support resting on collisions with other surfaces bool isRestingOnSurface() const; - static const float DEFAULT_DAMPING; float getDamping() const { return _damping; } void setDamping(float value) { _damping = value; } // lifetime related properties. - static const float IMMORTAL; /// special lifetime which means the entity lives for ever. default lifetime - static const float DEFAULT_LIFETIME; float getLifetime() const { return _lifetime; } /// get the lifetime in seconds for the entity void setLifetime(float value) { _lifetime = value; } /// set the lifetime in seconds for the entity @@ -224,46 +235,36 @@ public: AACube getMinimumAACube() const; AABox getAABox() const; /// axis aligned bounding box in domain scale units (0.0 - 1.0) - static const QString DEFAULT_SCRIPT; const QString& getScript() const { return _script; } void setScript(const QString& value) { _script = value; } - static const glm::vec3 DEFAULT_REGISTRATION_POINT; const glm::vec3& getRegistrationPoint() const { return _registrationPoint; } /// registration point as ratio of entity /// registration point as ratio of entity void setRegistrationPoint(const glm::vec3& value) { _registrationPoint = glm::clamp(value, 0.0f, 1.0f); recalculateCollisionShape(); } - static const glm::vec3 NO_ANGULAR_VELOCITY; - static const glm::vec3 DEFAULT_ANGULAR_VELOCITY; const glm::vec3& getAngularVelocity() const { return _angularVelocity; } void setAngularVelocity(const glm::vec3& value) { _angularVelocity = value; } bool hasAngularVelocity() const { return _angularVelocity != NO_ANGULAR_VELOCITY; } - static const float DEFAULT_ANGULAR_DAMPING; float getAngularDamping() const { return _angularDamping; } void setAngularDamping(float value) { _angularDamping = value; } - static const bool DEFAULT_VISIBLE; bool getVisible() const { return _visible; } void setVisible(bool value) { _visible = value; } bool isVisible() const { return _visible; } bool isInvisible() const { return !_visible; } - static const bool DEFAULT_IGNORE_FOR_COLLISIONS; bool getIgnoreForCollisions() const { return _ignoreForCollisions; } void setIgnoreForCollisions(bool value) { _ignoreForCollisions = value; } - static const bool DEFAULT_COLLISIONS_WILL_MOVE; bool getCollisionsWillMove() const { return _collisionsWillMove; } void setCollisionsWillMove(bool value) { _collisionsWillMove = value; } - static const bool DEFAULT_LOCKED; bool getLocked() const { return _locked; } void setLocked(bool value) { _locked = value; } - static const QString DEFAULT_USER_DATA; const QString& getUserData() const { return _userData; } void setUserData(const QString& value) { _userData = value; } diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 58b110c4b0..be6fe01841 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -24,27 +24,27 @@ EntityItemProperties::EntityItemProperties() : - CONSTRUCT_PROPERTY(visible, EntityItem::DEFAULT_VISIBLE), + CONSTRUCT_PROPERTY(visible, DEFAULT_VISIBLE), CONSTRUCT_PROPERTY(position, 0), - CONSTRUCT_PROPERTY(dimensions, EntityItem::DEFAULT_DIMENSIONS), - CONSTRUCT_PROPERTY(rotation, EntityItem::DEFAULT_ROTATION), - CONSTRUCT_PROPERTY(mass, EntityItem::DEFAULT_MASS), - CONSTRUCT_PROPERTY(velocity, EntityItem::DEFAULT_VELOCITY), - CONSTRUCT_PROPERTY(gravity, EntityItem::DEFAULT_GRAVITY), - CONSTRUCT_PROPERTY(damping, EntityItem::DEFAULT_DAMPING), - CONSTRUCT_PROPERTY(lifetime, EntityItem::DEFAULT_LIFETIME), - CONSTRUCT_PROPERTY(script, EntityItem::DEFAULT_SCRIPT), + CONSTRUCT_PROPERTY(dimensions, DEFAULT_DIMENSIONS), + CONSTRUCT_PROPERTY(rotation, DEFAULT_ROTATION), + CONSTRUCT_PROPERTY(mass, DEFAULT_MASS), + CONSTRUCT_PROPERTY(velocity, DEFAULT_VELOCITY), + CONSTRUCT_PROPERTY(gravity, DEFAULT_GRAVITY), + CONSTRUCT_PROPERTY(damping, DEFAULT_DAMPING), + CONSTRUCT_PROPERTY(lifetime, DEFAULT_LIFETIME), + CONSTRUCT_PROPERTY(script, DEFAULT_SCRIPT), CONSTRUCT_PROPERTY(color, ), CONSTRUCT_PROPERTY(modelURL, ""), CONSTRUCT_PROPERTY(animationURL, ""), CONSTRUCT_PROPERTY(animationFPS, ModelEntityItem::DEFAULT_ANIMATION_FPS), CONSTRUCT_PROPERTY(animationFrameIndex, ModelEntityItem::DEFAULT_ANIMATION_FRAME_INDEX), CONSTRUCT_PROPERTY(animationIsPlaying, ModelEntityItem::DEFAULT_ANIMATION_IS_PLAYING), - CONSTRUCT_PROPERTY(registrationPoint, EntityItem::DEFAULT_REGISTRATION_POINT), - CONSTRUCT_PROPERTY(angularVelocity, EntityItem::DEFAULT_ANGULAR_VELOCITY), - CONSTRUCT_PROPERTY(angularDamping, EntityItem::DEFAULT_ANGULAR_DAMPING), - CONSTRUCT_PROPERTY(ignoreForCollisions, EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS), - CONSTRUCT_PROPERTY(collisionsWillMove, EntityItem::DEFAULT_COLLISIONS_WILL_MOVE), + CONSTRUCT_PROPERTY(registrationPoint, DEFAULT_REGISTRATION_POINT), + CONSTRUCT_PROPERTY(angularVelocity, DEFAULT_ANGULAR_VELOCITY), + CONSTRUCT_PROPERTY(angularDamping, DEFAULT_ANGULAR_DAMPING), + CONSTRUCT_PROPERTY(ignoreForCollisions, DEFAULT_IGNORE_FOR_COLLISIONS), + CONSTRUCT_PROPERTY(collisionsWillMove, DEFAULT_COLLISIONS_WILL_MOVE), CONSTRUCT_PROPERTY(isSpotlight, false), CONSTRUCT_PROPERTY(diffuseColor, ), CONSTRUCT_PROPERTY(ambientColor, ), @@ -57,7 +57,7 @@ EntityItemProperties::EntityItemProperties() : CONSTRUCT_PROPERTY(locked, false), CONSTRUCT_PROPERTY(textures, ""), CONSTRUCT_PROPERTY(animationSettings, ""), - CONSTRUCT_PROPERTY(userData, EntityItem::DEFAULT_USER_DATA), + CONSTRUCT_PROPERTY(userData, DEFAULT_USER_DATA), CONSTRUCT_PROPERTY(text, TextEntityItem::DEFAULT_TEXT), CONSTRUCT_PROPERTY(lineHeight, TextEntityItem::DEFAULT_LINE_HEIGHT), CONSTRUCT_PROPERTY(textColor, TextEntityItem::DEFAULT_TEXT_COLOR), From e711b86519e99eaf855a33788468689b3f434da1 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Sat, 10 Jan 2015 19:07:58 -0800 Subject: [PATCH 11/15] scale DEFAULT_DIMENSIONS correctly also remove a block of commented out cruft --- libraries/entities/src/EntityItem.cpp | 27 --------------------------- libraries/entities/src/EntityItem.h | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index b89f5fedc0..4bf394314b 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -21,33 +21,6 @@ #include "EntityItem.h" #include "EntityTree.h" -/* -const float EntityItem::IMMORTAL = -1.0f; /// special lifetime which means the entity lives for ever. default lifetime -const float EntityItem::DEFAULT_GLOW_LEVEL = 0.0f; -const float EntityItem::DEFAULT_LOCAL_RENDER_ALPHA = 1.0f; -const float EntityItem::DEFAULT_MASS = 1.0f; -const float EntityItem::DEFAULT_LIFETIME = EntityItem::IMMORTAL; -const QString EntityItem::DEFAULT_USER_DATA = QString(""); -const float EntityItem::DEFAULT_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header) -const glm::vec3 EntityItem::NO_VELOCITY = glm::vec3(0, 0, 0); -const float EntityItem::EPSILON_VELOCITY_LENGTH = (1.0f / 1000.0f) / (float)TREE_SCALE; // really small: 1mm/second -const glm::vec3 EntityItem::DEFAULT_VELOCITY = EntityItem::NO_VELOCITY; -const glm::vec3 EntityItem::NO_GRAVITY = glm::vec3(0, 0, 0); -const glm::vec3 EntityItem::REGULAR_GRAVITY = glm::vec3(0, (-9.8f / TREE_SCALE), 0); -const glm::vec3 EntityItem::DEFAULT_GRAVITY = EntityItem::NO_GRAVITY; -const QString EntityItem::DEFAULT_SCRIPT = QString(""); -const glm::quat EntityItem::DEFAULT_ROTATION; -const glm::vec3 EntityItem::DEFAULT_DIMENSIONS = glm::vec3(0.1f, 0.1f, 0.1f); -const glm::vec3 EntityItem::DEFAULT_REGISTRATION_POINT = glm::vec3(0.5f, 0.5f, 0.5f); // center -const glm::vec3 EntityItem::NO_ANGULAR_VELOCITY = glm::vec3(0.0f, 0.0f, 0.0f); -const glm::vec3 EntityItem::DEFAULT_ANGULAR_VELOCITY = NO_ANGULAR_VELOCITY; -const float EntityItem::DEFAULT_ANGULAR_DAMPING = 2.0f; -const bool EntityItem::DEFAULT_VISIBLE = true; -const bool EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS = false; -const bool EntityItem::DEFAULT_COLLISIONS_WILL_MOVE = false; -const bool EntityItem::DEFAULT_LOCKED = false; -*/ - void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) { _id = entityItemID.id; _creatorTokenID = entityItemID.creatorTokenID; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 9bdd73c503..1b8afa930b 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -35,7 +35,7 @@ class EntityTreeElementExtraEncodeData; #define DONT_ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() = 0; #define ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() { }; -const glm::vec3 DEFAULT_DIMENSIONS = glm::vec3(0.1f); +const glm::vec3 DEFAULT_DIMENSIONS = glm::vec3(0.1f) / (float)TREE_SCALE; const glm::quat DEFAULT_ROTATION; const float DEFAULT_GLOW_LEVEL = 0.0f; const float DEFAULT_LOCAL_RENDER_ALPHA = 1.0f; From 5309fb6a43dbf9183f55087a1a5393dfe8e2f9fc Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Sun, 11 Jan 2015 10:44:36 -0800 Subject: [PATCH 12/15] remove lock at EntityTreeRenderer::loadEntityScript --- libraries/entities-renderer/src/EntityTreeRenderer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 3518e7b75c..47e9237ddc 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -98,9 +98,7 @@ void EntityTreeRenderer::init() { } QScriptValue EntityTreeRenderer::loadEntityScript(const EntityItemID& entityItemID) { - _tree->lockForRead(); EntityItem* entity = static_cast(_tree)->findEntityByEntityItemID(entityItemID); - _tree->unlock(); return loadEntityScript(entity); } From 60f55c7f3fd3f4dcaa1a30a3e5ffd6dd33753423 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sun, 11 Jan 2015 12:07:16 -0800 Subject: [PATCH 13/15] remove important code from assert so it still runs in release build --- libraries/entities/src/DeleteEntityOperator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/entities/src/DeleteEntityOperator.cpp b/libraries/entities/src/DeleteEntityOperator.cpp index 890c301682..698ef18936 100644 --- a/libraries/entities/src/DeleteEntityOperator.cpp +++ b/libraries/entities/src/DeleteEntityOperator.cpp @@ -92,7 +92,8 @@ bool DeleteEntityOperator::preRecursion(OctreeElement* element) { // and we can stop searching. if (entityTreeElement == details.containingElement) { EntityItem* theEntity = details.entity; - assert(entityTreeElement->removeEntityItem(theEntity)); // remove it from the element + bool entityDeleted = entityTreeElement->removeEntityItem(theEntity); // remove it from the element + assert(entityDeleted); _tree->setContainingElement(details.entity->getEntityItemID(), NULL); // update or id to element lookup _foundCount++; } From 89a782c55a70701d58101c1b6131e8787bc6b7f6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Sun, 11 Jan 2015 13:31:37 -0800 Subject: [PATCH 14/15] remove functional code from inside assert --- libraries/entities/src/UpdateEntityOperator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities/src/UpdateEntityOperator.cpp b/libraries/entities/src/UpdateEntityOperator.cpp index c85c4235de..29ed430f7a 100644 --- a/libraries/entities/src/UpdateEntityOperator.cpp +++ b/libraries/entities/src/UpdateEntityOperator.cpp @@ -239,7 +239,7 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) { if (oldElement != _containingElement) { qDebug() << "WARNING entity moved during UpdateEntityOperator recursion"; - assert(! _containingElement->removeEntityItem(_existingEntity)); + _containingElement->removeEntityItem(_existingEntity); } if (_wantDebug) { From 69f5c769b8c4f930e3b02c19e644223adee9203b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 12 Jan 2015 10:07:20 -0800 Subject: [PATCH 15/15] don't play muzak from lobby to avoid error --- examples/lobby.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index b03be7c29b..e34d119502 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -139,10 +139,10 @@ function drawLobby() { MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15); // start the drone sound - currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME }); + // currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME }); // start one of our muzak sounds - playRandomMuzak(); + // playRandomMuzak(); } } @@ -353,9 +353,9 @@ function update(deltaTime) { Overlays.editOverlay(descriptionText, { position: textOverlayPosition() }); // if the reticle is up then we may need to play the next muzak - if (!Audio.isInjectorPlaying(currentMuzakInjector)) { - playNextMuzak(); - } + // if (!Audio.isInjectorPlaying(currentMuzakInjector)) { +// playNextMuzak(); +// } } }