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
7373
7474 EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID entityID) {
7575 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));
8082
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+ }
9396 }
94− }
9597
96− } else {
97− results.setIsUnknownID();
98+ } else {
99+ results.setIsUnknownID();
100+ }
101+ _entityTree->unlock();
98102 }
99− _entityTree->unlock();
100103 }
101104
102105 return results;
@@ -148,6 +151,9 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E · 45 unmodified lines
148151
149152 void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
150153
154+ if (! canEdit())
155+ return;
156+
151157 EntityItemID actualID = entityID;
152158
153159 // if the entity is unknown, attempt to look it up