From 0ddc8eb448b0abbdc43181e6835d9f826312b3fe Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 16:40:14 -0700 Subject: [PATCH 01/13] fix signed/unsigned comparison --- libraries/octree/src/OctreeEditPacketSender.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index 78b9e29f12..65308f906f 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -275,7 +275,7 @@ void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, unsigned ch // If we're switching type, then we send the last one and start over if ((type != packetBuffer._currentType && packetBuffer._currentSize > 0) || - (packetBuffer._currentSize + length >= _maxPacketSize)) { + (packetBuffer._currentSize + length >= (size_t)_maxPacketSize)) { releaseQueuedPacket(packetBuffer); initializePacket(packetBuffer, type); } From 62438bae6ac21c4fcc6798c3db62f11de3c71c51 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 16:41:01 -0700 Subject: [PATCH 02/13] fixed signed/unsigned comparison and unused variable --- libraries/octree/src/Octree.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index ff9ebbcd87..9569296502 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -242,7 +242,7 @@ int Octree::readElementData(OctreeElement* destinationElement, const unsigned ch // give this destination element the child mask from the packet const unsigned char ALL_CHILDREN_ASSUMED_TO_EXIST = 0xFF; - if (bytesLeftToRead < sizeof(unsigned char)) { + if ((size_t)bytesLeftToRead < sizeof(unsigned char)) { qDebug() << "UNEXPECTED: readElementData() only had " << bytesLeftToRead << " bytes. Not enough for meaningful data."; return bytesAvailable; // assume we read the entire buffer... } @@ -1865,7 +1865,6 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element, bool Octree::readFromSVOFile(const char* fileName) { bool fileOk = false; - bool hasBufferBreaks = false; PacketVersion gotVersion = 0; std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); From 3ae78da593fde573dbe491a89ad031ec323b76cc Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 16:41:51 -0700 Subject: [PATCH 03/13] fixed signed/unsigned comparison --- libraries/entities/src/EntityTree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index b7fd267c30..a571a17a20 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -492,7 +492,7 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char void EntityTree::notifyNewlyCreatedEntity(const EntityItem& newEntity, const SharedNodePointer& senderNode) { _newlyCreatedHooksLock.lockForRead(); - for (size_t i = 0; i < _newlyCreatedHooks.size(); i++) { + for (int i = 0; i < _newlyCreatedHooks.size(); i++) { _newlyCreatedHooks[i]->entityCreated(newEntity, senderNode); } _newlyCreatedHooksLock.unlock(); @@ -506,7 +506,7 @@ void EntityTree::addNewlyCreatedHook(NewlyCreatedEntityHook* hook) { void EntityTree::removeNewlyCreatedHook(NewlyCreatedEntityHook* hook) { _newlyCreatedHooksLock.lockForWrite(); - for (size_t i = 0; i < _newlyCreatedHooks.size(); i++) { + for (int i = 0; i < _newlyCreatedHooks.size(); i++) { if (_newlyCreatedHooks[i] == hook) { _newlyCreatedHooks.erase(_newlyCreatedHooks.begin() + i); break; From e7b39ae1193648687ea3ca9d868acd116c7d99f4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 16:42:24 -0700 Subject: [PATCH 04/13] removed unused variable --- libraries/entities/src/EntityTreeElement.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index e1aa9b33e1..8f223abf7e 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -723,7 +723,6 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int int bytesForThisEntity = 0; EntityItemID entityItemID; EntityItem* entityItem = NULL; - bool newEntity = false; // Old model files don't have UUIDs in them. So we don't want to try to read those IDs from the stream. // Since this can only happen on loading an old file, we can safely treat these as new entity cases, @@ -768,7 +767,6 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int addEntityItem(entityItem); // add this new entity to this elements entities entityItemID = entityItem->getEntityItemID(); _myTree->setContainingElement(entityItemID, this); - newEntity = true; EntityItem::SimulationState newState = entityItem->getSimulationState(); _myTree->changeEntityState(entityItem, EntityItem::Static, newState); } @@ -826,4 +824,4 @@ void EntityTreeElement::debugDump() { entity->debugDump(); } } - \ No newline at end of file + From c089dbb0bb39c6b94ec8d80362b92a731e056511 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 16:44:33 -0700 Subject: [PATCH 05/13] removed signed/unsigned comparisons --- libraries/script-engine/src/TypedArrayPrototype.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/script-engine/src/TypedArrayPrototype.cpp b/libraries/script-engine/src/TypedArrayPrototype.cpp index 37274dd080..bb612b393f 100644 --- a/libraries/script-engine/src/TypedArrayPrototype.cpp +++ b/libraries/script-engine/src/TypedArrayPrototype.cpp @@ -30,11 +30,11 @@ void TypedArrayPrototype::set(QScriptValue array, qint32 offset) { engine()->evaluate("throw \"ArgumentError: negative offset\""); } quint32 length = array.property("length").toInt32(); - if (offset + length > thisObject().data().property(typedArray->_lengthName).toInt32()) { + if (offset + (qint32)length > thisObject().data().property(typedArray->_lengthName).toInt32()) { engine()->evaluate("throw \"ArgumentError: array does not fit\""); return; } - for (int i = 0; i < length; ++i) { + for (quint32 i = 0; i < length; ++i) { thisObject().setProperty(QString::number(offset + i), array.property(QString::number(i))); } } else { From 2fdfb125f2c52ad635508e65506bad3faa0e3e28 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 16:55:24 -0700 Subject: [PATCH 06/13] removed signed/unsigned comparisons --- libraries/script-engine/src/TypedArrays.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/script-engine/src/TypedArrays.cpp b/libraries/script-engine/src/TypedArrays.cpp index 751d1385e5..c9663556d9 100644 --- a/libraries/script-engine/src/TypedArrays.cpp +++ b/libraries/script-engine/src/TypedArrays.cpp @@ -50,7 +50,7 @@ QScriptValue TypedArray::newInstance(QScriptValue array) { if (array.property(ARRAY_LENGTH_HANDLE).isValid()) { quint32 length = array.property(ARRAY_LENGTH_HANDLE).toInt32(); QScriptValue newArray = newInstance(length); - for (int i = 0; i < length; ++i) { + for (quint32 i = 0; i < length; ++i) { QScriptValue value = array.property(QString::number(i)); setProperty(newArray, engine()->toStringHandle(QString::number(i)), i * _bytesPerElement, (value.isNumber()) ? value : QScriptValue(0)); @@ -119,7 +119,7 @@ QScriptValue TypedArray::construct(QScriptContext* context, QScriptEngine* engin return QScriptValue(); } if (lengthArg.toInt32() < 0 || - byteOffsetArg.toInt32() + lengthArg.toInt32() * cls->_bytesPerElement > arrayBuffer->size()) { + byteOffsetArg.toInt32() + lengthArg.toInt32() * (qint32)(cls->_bytesPerElement) > arrayBuffer->size()) { engine->evaluate("throw \"RangeError: byteLength out of range\""); return QScriptValue(); } @@ -155,7 +155,7 @@ QScriptClass::QueryFlags TypedArray::queryProperty(const QScriptValue& object, quint32 byteOffset = object.data().property(_byteOffsetName).toInt32(); quint32 length = object.data().property(_lengthName).toInt32(); bool ok = false; - int pos = name.toArrayIndex(&ok); + quint32 pos = name.toArrayIndex(&ok); // Check that name is a valid index and arrayBuffer exists if (ok && pos >= 0 && pos < length) { From 51dca12a7b2b4a00eafb4b509067e68e96e7016e Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 16:55:42 -0700 Subject: [PATCH 07/13] added default case for switch statements which avoids warnings about unhandled enum values --- libraries/script-engine/src/XMLHttpRequestClass.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/script-engine/src/XMLHttpRequestClass.cpp b/libraries/script-engine/src/XMLHttpRequestClass.cpp index cb891c2ab1..fc8216551b 100644 --- a/libraries/script-engine/src/XMLHttpRequestClass.cpp +++ b/libraries/script-engine/src/XMLHttpRequestClass.cpp @@ -71,6 +71,8 @@ QScriptValue XMLHttpRequestClass::getStatus() const { return QScriptValue(408); case QNetworkReply::ContentOperationNotPermittedError: return QScriptValue(501); + default: + break; } } return QScriptValue(0); @@ -92,6 +94,8 @@ QString XMLHttpRequestClass::getStatusText() const { return "Timeout"; case QNetworkReply::ContentOperationNotPermittedError: return "Not Implemented"; + default: + break; } } return ""; From be4ec8920d35f75e5cf2e67632e46cab335744c7 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 16:58:25 -0700 Subject: [PATCH 08/13] reorderd init of data members in ctor --- assignment-client/src/AssignmentClient.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index 3e3c7c0609..24b6127d63 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -37,8 +37,8 @@ int hifiSockAddrMeta = qRegisterMetaType("HifiSockAddr"); AssignmentClient::AssignmentClient(int &argc, char **argv) : QCoreApplication(argc, argv), - _assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME), - _shutdownEventListener(this) + _shutdownEventListener(this), + _assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME) { LogUtils::init(); From 2f03f0fb0d86438362f0540aa17fe94cbb2dbd64 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 17:00:23 -0700 Subject: [PATCH 09/13] removed unused variables --- assignment-client/src/audio/AudioMixer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 3f5829b72f..044396f844 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -327,7 +327,6 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(PositionalAudioStream* const float FULL_POWER = 1.0f; const float SQUARE_ROOT_OF_TWO_OVER_TWO = 0.71f; const float HALF_POWER = SQUARE_ROOT_OF_TWO_OVER_TWO; - const float QUARTER_POWER = HALF_POWER * HALF_POWER; const float ONE_OVER_TWO_PI = 1.0f / TWO_PI; const float FILTER_CUTOFF_FREQUENCY_HZ = 1000.0f; @@ -344,8 +343,8 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(PositionalAudioStream* ((-1.0 * ONE_OVER_TWO_PI * (bearingRelativeAngleToSource + PI_OVER_TWO)) + HALF_POWER) : ((-1.0 * ONE_OVER_TWO_PI * (bearingRelativeAngleToSource - PI)) + HALF_POWER); - float distanceBetween = glm::length(relativePosition); #if 0 + float distanceBetween = glm::length(relativePosition); qDebug() << "avatar=" << listeningNodeStream << "gainL=" From 5c75b53c0d081bd5e498705bcf30e2c978026157 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 17:06:42 -0700 Subject: [PATCH 10/13] removed singed/unsigned comparisons --- interface/src/avatar/ModelReferential.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/ModelReferential.cpp b/interface/src/avatar/ModelReferential.cpp index 063b872f1f..eb2a61a819 100644 --- a/interface/src/avatar/ModelReferential.cpp +++ b/interface/src/avatar/ModelReferential.cpp @@ -108,7 +108,7 @@ JointReferential::JointReferential(Referential* referential, EntityTree* tree, A const EntityItem* item = _tree->findEntityByID(_entityID); const Model* model = getModel(item); - if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) { + if (!isValid() || model == NULL || _jointIndex >= (uint32_t)(model->getJointStateCount())) { _refScale = item->getRadius(); model->getJointRotationInWorldFrame(_jointIndex, _refRotation); model->getJointPositionInWorldFrame(_jointIndex, _refPosition); @@ -123,7 +123,7 @@ JointReferential::JointReferential(uint32_t jointIndex, const QUuid& entityID, E _type = JOINT; const EntityItem* item = _tree->findEntityByID(_entityID); const Model* model = getModel(item); - if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) { + if (!isValid() || model == NULL || _jointIndex >= (uint32_t)(model->getJointStateCount())) { qDebug() << "JointReferential::constructor(): Not Valid"; _isValid = false; return; @@ -142,7 +142,7 @@ JointReferential::JointReferential(uint32_t jointIndex, const QUuid& entityID, E void JointReferential::update() { const EntityItem* item = _tree->findEntityByID(_entityID); const Model* model = getModel(item); - if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) { + if (!isValid() || model == NULL || _jointIndex >= (uint32_t)(model->getJointStateCount())) { return; } @@ -189,4 +189,4 @@ int JointReferential::unpackExtraData(const unsigned char *sourceBuffer, int siz sourceBuffer += sizeof(_jointIndex); return sourceBuffer - startPosition; -} \ No newline at end of file +} From 1d7ac23aa169bb28f097b0caf563f5331a59f0f6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 17:10:13 -0700 Subject: [PATCH 11/13] removed signed/unsigned comparison --- interface/src/devices/DeviceTracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/devices/DeviceTracker.cpp b/interface/src/devices/DeviceTracker.cpp index 47301ad826..265a77b362 100644 --- a/interface/src/devices/DeviceTracker.cpp +++ b/interface/src/devices/DeviceTracker.cpp @@ -38,7 +38,7 @@ DeviceTracker* DeviceTracker::getDevice(const Name& name) { } DeviceTracker* DeviceTracker::getDevice(DeviceTracker::ID deviceID) { - if ((deviceID >= 0) && (deviceID < Singleton::get()->_devicesVector.size())) { + if ((deviceID >= 0) && (deviceID < (int)(Singleton::get()->_devicesVector.size()))) { return Singleton::get()->_devicesVector[ deviceID ]; } else { return NULL; From 526d998924f4417d47ebdc1fb17c69118759f71d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 17:21:15 -0700 Subject: [PATCH 12/13] removed warnigs about ill-formed narrowing conversion --- tests/octree/src/OctreeTests.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/octree/src/OctreeTests.cpp b/tests/octree/src/OctreeTests.cpp index e564754974..fee8f3ff37 100644 --- a/tests/octree/src/OctreeTests.cpp +++ b/tests/octree/src/OctreeTests.cpp @@ -115,7 +115,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -140,7 +140,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytesB[] = { 136, 30 }; + char expectedBytesB[] = { (char)136, (char)30 }; QByteArray expectedResultB(expectedBytesB, sizeof(expectedBytesB)/sizeof(expectedBytesB[0])); if (encoded == expectedResultB) { @@ -172,7 +172,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { qDebug() << "encoded="; outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -197,7 +197,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytesB[] = { 136, 30 }; + char expectedBytesB[] = { (char)136, (char)30 }; QByteArray expectedResultB(expectedBytesB, sizeof(expectedBytesB)/sizeof(expectedBytesB[0])); if (encoded == expectedResultB) { @@ -231,7 +231,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -264,7 +264,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -296,7 +296,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -329,7 +329,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -362,7 +362,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -395,7 +395,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -432,7 +432,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { outputBufferBits((const unsigned char*)encoded.constData(), encoded.size()); } - char expectedBytes[] = { 196, 15, 2 }; + char expectedBytes[] = { (char)196, (char)15, (char)2 }; QByteArray expectedResult(expectedBytes, sizeof(expectedBytes)/sizeof(expectedBytes[0])); if (encoded == expectedResult) { @@ -642,7 +642,7 @@ void OctreeTests::propertyFlagsTests(bool verbose) { qDebug() << "props.getHasProperty(PARTICLE_PROP_VISIBLE)" << (props.getHasProperty(PARTICLE_PROP_VISIBLE)) << "{ expect true }"; } - char expectedBytesD[] = { 136, 16 }; + char expectedBytesD[] = { (char)136, (char)16 }; QByteArray expectedResultD(expectedBytesD, sizeof(expectedBytesD)/sizeof(expectedBytesD[0])); testsTaken++; From bd8fc75305f546766445e0bd38210ffce12eb117 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 5 Sep 2014 17:51:18 -0700 Subject: [PATCH 13/13] fix bug: zero velocity when teleporting to new locations --- interface/src/avatar/Avatar.cpp | 14 ++++++++++++++ interface/src/avatar/Avatar.h | 3 +++ interface/src/avatar/MyAvatar.cpp | 4 ++-- libraries/avatars/src/AvatarData.h | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index b8def5bebd..b5b238b9d7 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -223,6 +223,20 @@ void Avatar::measureMotionDerivatives(float deltaTime) { _lastOrientation = getOrientation(); } +void Avatar::setPosition(const glm::vec3 position, bool overideReferential) { + AvatarData::setPosition(position, overideReferential); + _lastPosition = position; + _velocity = glm::vec3(0.0f); + _lastVelocity = glm::vec3(0.0f); +} + +void Avatar::slamPosition(const glm::vec3& newPosition) { + _position = newPosition; + _lastPosition = newPosition; + _velocity = glm::vec3(0.0f); + _lastVelocity = glm::vec3(0.0f); +} + void Avatar::setMouseRay(const glm::vec3 &origin, const glm::vec3 &direction) { _mouseRayOrigin = origin; _mouseRayDirection = direction; diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 8923a67994..43b5150a48 100755 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -160,6 +160,9 @@ public: /// Scales a world space position vector relative to the avatar position and scale /// \param vector position to be scaled. Will store the result void scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const; + + void setPosition(const glm::vec3 position, bool overideReferential = false); + void slamPosition(const glm::vec3& newPosition); public slots: void updateCollisionGroups(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b3468a9214..4b0e4eef5a 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1767,7 +1767,7 @@ void MyAvatar::maybeUpdateBillboard() { void MyAvatar::goHome() { qDebug("Going Home!"); - setPosition(START_LOCATION); + slamPosition(START_LOCATION); } void MyAvatar::increaseSize() { @@ -1827,7 +1827,7 @@ void MyAvatar::goToLocationFromAddress(const QJsonObject& locationObject) { const float DISTANCE_TO_USER = 2.0f; glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(), coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER; - setPosition(newPosition); + slamPosition(newPosition); emit transformChanged(); } diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 8e7082fc1e..d70876722b 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -145,7 +145,7 @@ public: const QUuid& getSessionUUID() { return _sessionUUID; } const glm::vec3& getPosition(); - void setPosition(const glm::vec3 position, bool overideReferential = false); + virtual void setPosition(const glm::vec3 position, bool overideReferential = false); glm::vec3 getHandPosition() const; void setHandPosition(const glm::vec3& handPosition);