Merge pull request #12763 from sethalves/ess-can-edit-localX

allow ESS to make relative-to-parent edits when entity is not in ESS's octree
This commit is contained in:
John Conklin II 2018-04-11 12:08:35 -07:00 committed by GitHub
commit 88a151481d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -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, "");

View file

@ -477,6 +477,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) {