Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -466,9 +466,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 465 unmodified lines | ||
| 466 | 466 | }); |
| 467 | 467 | } |
| 468 | 468 | }); |
| 469 | − if (entityFound) { | |
| 470 | − queueEntityMessage(PacketType::EntityEdit, entityID, properties); | |
| 471 | − } else { | |
| 469 | + if (!entityFound) { | |
| 472 | 470 | // attempt to get a name for the mystery ID |
| 473 | 471 | QString name = "unknown"; |
| 474 | 472 | QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>(); |
| @@ -478,13 +476,18 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 3 unmodified lines | ||
| 478 | 476 | if (success) { |
| 479 | 477 | auto nestable = nestableWP.lock(); |
| 480 | 478 | if (nestable) { |
| 481 | − name = nestable->getName(); | |
| 479 | + NestableType nestableType = nestable->getNestableType(); | |
| 480 | + if (nestableType == NestableType::Overlay || nestableType == NestableType::Avatar) { | |
| 481 | + qCWarning(entities) << "attempted edit on non-entity: " << id << name; | |
| 482 | + return QUuid(); // null UUID to indicate failure | |
| 483 | + } | |
| 482 | 484 | } |
| 483 | 485 | } |
| 484 | 486 | } |
| 485 | − qCWarning(entities) << "attempted edit on unknown entity: " << id << name; | |
| 486 | − return QUuid(); // null UUID to indicate failure | |
| 487 | 487 | } |
| 488 | + // we queue edit packets even if we don't know about the entity. This is to allow AC agents | |
| 489 | + // to edit entities they know only by ID. | |
| 490 | + queueEntityMessage(PacketType::EntityEdit, entityID, properties); | |
| 488 | 491 | return id; |
| 489 | 492 | } |
| 490 | 493 | |
| @@ -1535,6 +1538,24 @@ bool EntityScriptingInterface::isChildOfParent(QUuid childID, QUuid parentID) { · 1044 unmodified lines | ||
| 1535 | 1538 | return isChild; |
| 1536 | 1539 | } |
| 1537 | 1540 | |
| 1541 | +QString EntityScriptingInterface::getNestableType(QUuid id) { | |
| 1542 | + QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>(); | |
| 1543 | + if (!parentFinder) { | |
| 1544 | + return "unknown"; | |
| 1545 | + } | |
| 1546 | + bool success; | |
| 1547 | + SpatiallyNestableWeakPointer objectWP = parentFinder->find(id, success); | |
| 1548 | + if (!success) { | |
| 1549 | + return "unknown"; | |
| 1550 | + } | |
| 1551 | + SpatiallyNestablePointer object = objectWP.lock(); | |
| 1552 | + if (!object) { | |
| 1553 | + return "unknown"; | |
| 1554 | + } | |
| 1555 | + NestableType nestableType = object->getNestableType(); | |
| 1556 | + return SpatiallyNestable::nestableTypeToString(nestableType); | |
| 1557 | +} | |
| 1558 | + | |
| 1538 | 1559 | QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) { |
| 1539 | 1560 | QVector<QUuid> result; |
| 1540 | 1561 | if (!_entityTree) { |