History

Merge branch master into protocol_changes

HifiExperiments committed 2 years ago

Commit ee705d21 parent f9e729b370 files · +11827 −6045Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 370 files). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+13−5
@@ -97,6 +97,7 @@ EntityScriptingInterface::EntityScriptingInterface(bool bidOnSimulationOwnership · 96 unmodified lines
97 connect(nodeList.data(), &NodeList::canWriteAssetsChanged, this, &EntityScriptingInterface::canWriteAssetsChanged);97 connect(nodeList.data(), &NodeList::canWriteAssetsChanged, this, &EntityScriptingInterface::canWriteAssetsChanged);
98 connect(nodeList.data(), &NodeList::canGetAndSetPrivateUserDataChanged, this, &EntityScriptingInterface::canGetAndSetPrivateUserDataChanged);98 connect(nodeList.data(), &NodeList::canGetAndSetPrivateUserDataChanged, this, &EntityScriptingInterface::canGetAndSetPrivateUserDataChanged);
99 connect(nodeList.data(), &NodeList::canRezAvatarEntitiesChanged, this, &EntityScriptingInterface::canRezAvatarEntitiesChanged);99 connect(nodeList.data(), &NodeList::canRezAvatarEntitiesChanged, this, &EntityScriptingInterface::canRezAvatarEntitiesChanged);
100 connect(nodeList.data(), &NodeList::canViewAssetURLsChanged, this, &EntityScriptingInterface::canViewAssetURLsChanged);
100 101
101 auto& packetReceiver = nodeList->getPacketReceiver();102 auto& packetReceiver = nodeList->getPacketReceiver();
102 packetReceiver.registerListener(PacketType::EntityScriptCallMethod,103 packetReceiver.registerListener(PacketType::EntityScriptCallMethod,
@@ -291,6 +292,11 @@ bool EntityScriptingInterface::canRezAvatarEntities() { · 188 unmodified lines
291 return nodeList->getThisNodeCanRezAvatarEntities();292 return nodeList->getThisNodeCanRezAvatarEntities();
292}293}
293 294
295bool EntityScriptingInterface::canViewAssetURLs() {
296 auto nodeList = DependencyManager::get<NodeList>();
297 return nodeList->getThisNodeCanViewAssetURLs();
298}
299
294void EntityScriptingInterface::setEntityTree(EntityTreePointer elementTree) {300void EntityScriptingInterface::setEntityTree(EntityTreePointer elementTree) {
295 if (_entityTree) {301 if (_entityTree) {
296 disconnect(_entityTree.get(), &EntityTree::addingEntityPointer, this, &EntityScriptingInterface::onAddingEntity);302 disconnect(_entityTree.get(), &EntityTree::addingEntityPointer, this, &EntityScriptingInterface::onAddingEntity);
@@ -785,7 +791,7 @@ QUuid EntityScriptingInterface::cloneEntity(const QUuid& entityIDToClone) { · 488 unmodified lines
785 791
786EntityItemProperties EntityScriptingInterface::getEntityProperties(const QUuid& entityID) {792EntityItemProperties EntityScriptingInterface::getEntityProperties(const QUuid& entityID) {
787 const EntityPropertyFlags noSpecificProperties;793 const EntityPropertyFlags noSpecificProperties;
788 return getEntityPropertiesInternal(entityID, noSpecificProperties);794 return getEntityPropertiesInternal(entityID, noSpecificProperties, false);
789}795}
790 796
791ScriptValue EntityScriptingInterface::getEntityProperties(const QUuid& entityID, const ScriptValue& extendedDesiredProperties) {797ScriptValue EntityScriptingInterface::getEntityProperties(const QUuid& entityID, const ScriptValue& extendedDesiredProperties) {
@@ -810,12 +816,14 @@ ScriptValue EntityScriptingInterface::getEntityProperties(const QUuid& entityID, · 18 unmodified lines
810 }816 }
811 }817 }
812 818
813 EntityItemProperties properties = getEntityPropertiesInternal(entityID, desiredProperties);819 EntityItemProperties properties = getEntityPropertiesInternal(entityID, desiredProperties, !desiredPseudoPropertyFlags.none());
814 820
815 return properties.copyToScriptValue(extendedDesiredProperties.engine().get(), false, false, false, desiredPseudoPropertyFlags);821 return properties.copyToScriptValue(extendedDesiredProperties.engine().get(), false, false, false, desiredPseudoPropertyFlags);
816}822}
817 823
818EntityItemProperties EntityScriptingInterface::getEntityPropertiesInternal(const QUuid& entityID, EntityPropertyFlags desiredProperties) {824EntityItemProperties EntityScriptingInterface::getEntityPropertiesInternal(const QUuid& entityID,
825 EntityPropertyFlags desiredProperties,
826 bool returnNothingOnEmptyPropertyFlags) {
819 827
820 PROFILE_RANGE(script_entities, __FUNCTION__);828 PROFILE_RANGE(script_entities, __FUNCTION__);
821 829
@@ -838,7 +846,7 @@ EntityItemProperties EntityScriptingInterface::getEntityPropertiesInternal(const · 16 unmodified lines
838 desiredProperties.setHasProperty(PROP_PARENT_JOINT_INDEX);846 desiredProperties.setHasProperty(PROP_PARENT_JOINT_INDEX);
839 }847 }
840 848
841 if (desiredProperties.isEmpty()) {849 if (desiredProperties.isEmpty() && !returnNothingOnEmptyPropertyFlags) {
842 // these are left out of EntityItem::getEntityProperties so that localPosition and localRotation850 // these are left out of EntityItem::getEntityProperties so that localPosition and localRotation
843 // don't end up in json saves, etc. We still want them here, though.851 // don't end up in json saves, etc. We still want them here, though.
844 EncodeBitstreamParams params; // unknown852 EncodeBitstreamParams params; // unknown
@@ -850,7 +858,7 @@ EntityItemProperties EntityScriptingInterface::getEntityPropertiesInternal(const · 5 unmodified lines
850 desiredProperties.setHasProperty(PROP_LOCAL_DIMENSIONS);858 desiredProperties.setHasProperty(PROP_LOCAL_DIMENSIONS);
851 }859 }
852 860
853 results = entity->getProperties(desiredProperties);861 results = entity->getProperties(desiredProperties, true);
854 }862 }
855 });863 });
856 }864 }