From 71d6dbf9bfb0219d44ba527d0db17eaa7cc9133a Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 2 Apr 2018 15:52:28 -0700 Subject: [PATCH] allow ESS to edit local version of properties even if the entity isn't in the ESS's local octree --- libraries/entities/src/EntityItemProperties.h | 6 ++++++ .../entities/src/EntityScriptingInterface.cpp | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 9e5d6ddc79..713eedbd5d 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -502,6 +502,12 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) { DEBUG_PROPERTY_IF_CHANGED(debug, properties, CertificateID, certificateID, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, StaticCertificateVersion, staticCertificateVersion, ""); + DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalPosition, localPosition, ""); + DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalRotation, localRotation, ""); + DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalVelocity, localVelocity, ""); + DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalAngularVelocity, localAngularVelocity, ""); + DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalDimensions, localDimensions, ""); + DEBUG_PROPERTY_IF_CHANGED(debug, properties, HazeMode, hazeMode, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, KeyLightMode, keyLightMode, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, AmbientLightMode, ambientLightMode, ""); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 7e15e78624..70a4218607 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -523,6 +523,27 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& } } }); + } else { + // Sometimes ESS don't have the entity they are trying to edit in their local tree. In this case, + // convertPropertiesFromScriptSemantics doesn't get called and local* edits will get dropped. + // This is because, on the script side, "position" is in world frame, but in the network + // protocol and in the internal data-structures, "position" is "relative to parent". + // Compensate here. The local* versions will get ignored during the edit-packet encoding. + if (properties.localPositionChanged()) { + properties.setPosition(properties.getLocalPosition()); + } + if (properties.localRotationChanged()) { + properties.setRotation(properties.getLocalRotation()); + } + if (properties.localVelocityChanged()) { + properties.setVelocity(properties.getLocalVelocity()); + } + if (properties.localAngularVelocityChanged()) { + properties.setAngularVelocity(properties.getLocalAngularVelocity()); + } + if (properties.localDimensionsChanged()) { + properties.setDimensions(properties.getLocalDimensions()); + } } }); if (!entityFound) {