History

also guard deleteEntity and getEntityProperties with canEdit. make canEdit available to javascript

Seth Alves committed 11 years ago

Commit bad44c51 parent d19ab4c2 files · +30 −21Browse files

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

Unified · Split

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