Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -73,30 +73,33 @@ EntityItemID EntityScriptingInterface::identifyEntity(EntityItemID entityID) { · 72 unmodified lines | ||
| 73 | 73 | |
| 74 | 74 | EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID entityID) { |
| 75 | 75 | EntityItemProperties results; |
| 76 | − EntityItemID identity = identifyEntity(entityID); | |
| 77 | − if (_entityTree) { | |
| 78 | − _entityTree->lockForRead(); | |
| 79 | − EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(identity)); | |
| 76 | + | |
| 77 | + if (canEdit()) { | |
| 78 | + EntityItemID identity = identifyEntity(entityID); | |
| 79 | + if (_entityTree) { | |
| 80 | + _entityTree->lockForRead(); | |
| 81 | + EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(identity)); | |
| 80 | 82 | |
| 81 | − if (entity) { | |
| 82 | − results = entity->getProperties(); | |
| 83 | − | |
| 84 | − // TODO: improve sitting points and naturalDimensions in the future, | |
| 85 | − // for now we've included the old sitting points model behavior for entity types that are models | |
| 86 | − // we've also added this hack for setting natural dimensions of models | |
| 87 | − if (entity->getType() == EntityTypes::Model) { | |
| 88 | − const FBXGeometry* geometry = _entityTree->getGeometryForEntity(entity); | |
| 89 | − if (geometry) { | |
| 90 | − results.setSittingPoints(geometry->sittingPoints); | |
| 91 | − Extents meshExtents = geometry->getUnscaledMeshExtents(); | |
| 92 | − results.setNaturalDimensions(meshExtents.maximum - meshExtents.minimum); | |
| 83 | + if (entity) { | |
| 84 | + results = entity->getProperties(); | |
| 85 | + | |
| 86 | + // TODO: improve sitting points and naturalDimensions in the future, | |
| 87 | + // for now we've included the old sitting points model behavior for entity types that are models | |
| 88 | + // we've also added this hack for setting natural dimensions of models | |
| 89 | + if (entity->getType() == EntityTypes::Model) { | |
| 90 | + const FBXGeometry* geometry = _entityTree->getGeometryForEntity(entity); | |
| 91 | + if (geometry) { | |
| 92 | + results.setSittingPoints(geometry->sittingPoints); | |
| 93 | + Extents meshExtents = geometry->getUnscaledMeshExtents(); | |
| 94 | + results.setNaturalDimensions(meshExtents.maximum - meshExtents.minimum); | |
| 95 | + } | |
| 93 | 96 | } |
| 94 | − } | |
| 95 | 97 | |
| 96 | − } else { | |
| 97 | − results.setIsUnknownID(); | |
| 98 | + } else { | |
| 99 | + results.setIsUnknownID(); | |
| 100 | + } | |
| 101 | + _entityTree->unlock(); | |
| 98 | 102 | } |
| 99 | − _entityTree->unlock(); | |
| 100 | 103 | } |
| 101 | 104 | |
| 102 | 105 | return results; |
| @@ -148,6 +151,9 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E · 45 unmodified lines | ||
| 148 | 151 | |
| 149 | 152 | void EntityScriptingInterface::deleteEntity(EntityItemID entityID) { |
| 150 | 153 | |
| 154 | + if (! canEdit()) | |
| 155 | + return; | |
| 156 | + | |
| 151 | 157 | EntityItemID actualID = entityID; |
| 152 | 158 | |
| 153 | 159 | // if the entity is unknown, attempt to look it up |