From 4fffe05b63fe583c78b40f6827e4b2db721a847e Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 27 May 2015 16:25:11 -0700 Subject: [PATCH] Play still sound for still objects and those just created in a script. --- .../entities-renderer/src/EntityTreeRenderer.cpp | 11 +++++++++++ libraries/entities/src/EntityScriptingInterface.cpp | 1 + 2 files changed, 12 insertions(+) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 7b25d20ef3..4a4fd4a0d7 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -1107,6 +1107,17 @@ void EntityTreeRenderer::playEntityCollisionSound(const QUuid& myNodeID, EntityT return; } QUuid simulatorID = entity->getSimulatorID(); + if (simulatorID.isNull()) { + // Can be null if it has never moved since being created or coming out of persistence. + // However, for there to be a collission, one of the two objects must be moving. + const EntityItemID& otherID = (id == collision.idA) ? collision.idB : collision.idA; + EntityItemPointer otherEntity = entityTree->findEntityByEntityItemID(otherID); + if (!otherEntity) { + return; + } + simulatorID = otherEntity->getSimulatorID(); + } + if (simulatorID.isNull() || (simulatorID != myNodeID)) { return; // Only one injector per simulation, please. } diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 7d286a3710..e652c77d78 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -83,6 +83,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties entity->setLastBroadcast(usecTimestampNow()); // This Node is creating a new object. If it's in motion, set this Node as the simulator. bidForSimulationOwnership(propertiesWithSimID); + entity->setSimulatorID(propertiesWithSimID.getSimulatorID()); // and make note of it now, so we can act on it right away. } else { qCDebug(entities) << "script failed to add new Entity to local Octree"; success = false;