History

entity scripting call to get the nestable-type of an object, by id

Seth Alves committed 9 years ago

Commit a7c684e1 parent 51cb5792 files · +29 −6Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+27−6
@@ -466,9 +466,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 465 unmodified lines
466 });466 });
467 }467 }
468 });468 });
469 if (entityFound) {469 if (!entityFound) {
470 queueEntityMessage(PacketType::EntityEdit, entityID, properties);
471 } else {
472 // attempt to get a name for the mystery ID470 // attempt to get a name for the mystery ID
473 QString name = "unknown";471 QString name = "unknown";
474 QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();472 QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
@@ -478,13 +476,18 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 3 unmodified lines
478 if (success) {476 if (success) {
479 auto nestable = nestableWP.lock();477 auto nestable = nestableWP.lock();
480 if (nestable) {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 return id;491 return id;
489}492}
490 493
@@ -1535,6 +1538,24 @@ bool EntityScriptingInterface::isChildOfParent(QUuid childID, QUuid parentID) { · 1044 unmodified lines
1535 return isChild;1538 return isChild;
1536}1539}
1537 1540
1541QString 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
1538QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) {1559QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) {
1539 QVector<QUuid> result;1560 QVector<QUuid> result;
1540 if (!_entityTree) {1561 if (!_entityTree) {