From 7feb9910c92bffe4035b7a76123070e6bf7e326a Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Sat, 7 Jul 2018 02:31:26 +0300 Subject: [PATCH] use rotation degrees instead of quaternions for comparison re-query entity properties after editing it to get actual changes --- .../qml/hifi/avatarapp/AvatarsModel.qml | 3 +-- scripts/system/avatarapp.js | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/hifi/avatarapp/AvatarsModel.qml b/interface/resources/qml/hifi/avatarapp/AvatarsModel.qml index c753d65380..6c2219c427 100644 --- a/interface/resources/qml/hifi/avatarapp/AvatarsModel.qml +++ b/interface/resources/qml/hifi/avatarapp/AvatarsModel.qml @@ -163,9 +163,8 @@ ListModel { {'propertyName' : 'marketplaceID'}, {'propertyName' : 'itemName'}, {'propertyName' : 'script'}, - {'propertyName' : 'rotation', 'comparer' : compareNumericObjects}, {'propertyName' : 'localPosition', 'comparer' : compareNumericObjects}, - {'propertyName' : 'localRotation', 'comparer' : compareNumericObjects}, + {'propertyName' : 'localRotationAngles', 'comparer' : compareNumericObjects}, {'propertyName' : 'dimensions', 'comparer' : compareNumericObjects}], 'properties') } diff --git a/scripts/system/avatarapp.js b/scripts/system/avatarapp.js index c8aa69dcb4..de84782471 100644 --- a/scripts/system/avatarapp.js +++ b/scripts/system/avatarapp.js @@ -157,6 +157,14 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See 'currentAvatarSettings' : currentAvatarSettings }; + for(var bookmarkName in message.data.bookmarks) { + var bookmark = message.data.bookmarks[bookmarkName]; + + bookmark.avatarEntites.forEach(function(avatarEntity) { + avatarEntity.properties.localRotationAngles = Quat.safeEulerAngles(avatarEntity.properties.localRotation) + }) + } + sendToQml(message) break; case 'selectAvatar': @@ -172,7 +180,14 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See if(message.properties.localRotationAngles) { message.properties.localRotation = Quat.fromVec3Degrees(message.properties.localRotationAngles) } + Entities.editEntity(message.entityID, message.properties); + message.properties = Entities.getEntityProperties(message.entityID, Object.keys(message.properties)); + + if(message.properties.localRotation) { + message.properties.localRotationAngles = Quat.safeEulerAngles(message.properties.localRotation); + } + sendToQml({'method' : 'wearableUpdated', 'entityID' : message.entityID, wearableIndex : message.wearableIndex, properties : message.properties, updateUI : false}) break; case 'adjustWearablesOpened': @@ -395,7 +410,12 @@ function onBookmarkDeleted(bookmarkName) { } function onBookmarkAdded(bookmarkName) { - sendToQml({ 'method': 'bookmarkAdded', 'bookmarkName': bookmarkName, 'bookmark': AvatarBookmarks.getBookmark(bookmarkName) }); + var bookmark = AvatarBookmarks.getBookmark(bookmarkName); + bookmark.avatarEntites.forEach(function(avatarEntity) { + avatarEntity.properties.localRotationAngles = Quat.safeEulerAngles(avatarEntity.properties.localRotation) + }) + + sendToQml({ 'method': 'bookmarkAdded', 'bookmarkName': bookmarkName, 'bookmark': bookmark }); } //