History

rather than a list of allowed editors, a list of allowed lockers/unlockers

Seth Alves committed 11 years ago

Commit 60a4f481 parent 46bf6ea12 files · +75 −86Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+31−43
@@ -27,9 +27,9 @@ void EntityScriptingInterface::queueEntityMessage(PacketType packetType, · 26 unmodified lines
2727 }
2828
2929
30−bool EntityScriptingInterface::canEdit() {
30+bool EntityScriptingInterface::canAdjustLocks() {
3131 auto nodeList = DependencyManager::get<NodeList>();
32− return nodeList->getThisNodeCanEdit();
32+ return nodeList->getThisNodeCanAdjustLocks();
3333 }
3434
3535
@@ -40,18 +40,16 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro · 4 unmodified lines
4040
4141 EntityItemID id(NEW_ENTITY, creatorTokenID, false );
4242
43− if (canEdit()) {
44− // If we have a local entity tree set, then also update it.
45− if (_entityTree) {
46− _entityTree->lockForWrite();
47− _entityTree->addEntity(id, properties);
48− _entityTree->unlock();
49− }
50−
51− // queue the packet
52− queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
43+ // If we have a local entity tree set, then also update it.
44+ if (_entityTree) {
45+ _entityTree->lockForWrite();
46+ _entityTree->addEntity(id, properties);
47+ _entityTree->unlock();
5348 }
5449
50+ // queue the packet
51+ queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
52+
5553 return id;
5654 }
5755
@@ -74,32 +72,30 @@ EntityItemID EntityScriptingInterface::identifyEntity(EntityItemID entityID) { · 16 unmodified lines
7472 EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID entityID) {
7573 EntityItemProperties results;
7674
77− if (canEdit()) {
78− EntityItemID identity = identifyEntity(entityID);
79− if (_entityTree) {
80− _entityTree->lockForRead();
81− EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(identity));
75+ EntityItemID identity = identifyEntity(entityID);
76+ if (_entityTree) {
77+ _entityTree->lockForRead();
78+ EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(identity));
8279
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− }
80+ if (entity) {
81+ results = entity->getProperties();
82+
83+ // TODO: improve sitting points and naturalDimensions in the future,
84+ // for now we've included the old sitting points model behavior for entity types that are models
85+ // we've also added this hack for setting natural dimensions of models
86+ if (entity->getType() == EntityTypes::Model) {
87+ const FBXGeometry* geometry = _entityTree->getGeometryForEntity(entity);
88+ if (geometry) {
89+ results.setSittingPoints(geometry->sittingPoints);
90+ Extents meshExtents = geometry->getUnscaledMeshExtents();
91+ results.setNaturalDimensions(meshExtents.maximum - meshExtents.minimum);
9692 }
97−
98− } else {
99− results.setIsUnknownID();
10093 }
101− _entityTree->unlock();
94+
95+ } else {
96+ results.setIsUnknownID();
10297 }
98+ _entityTree->unlock();
10399 }
104100
105101 return results;
@@ -107,10 +103,6 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID · 1 unmodified line
107103
108104 EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {
109105
110− if (!canEdit()) {
111− return entityID;
112− }
113−
114106 EntityItemID actualID = entityID;
115107 // if the entity is unknown, attempt to look it up
116108 if (!entityID.isKnownID) {
@@ -125,7 +117,7 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E · 8 unmodified lines
125117 // the actual id, because we can edit out local entities just with creatorTokenID
126118 if (_entityTree) {
127119 _entityTree->lockForWrite();
128− _entityTree->updateEntity(entityID, properties);
120+ _entityTree->updateEntity(entityID, properties, canAdjustLocks());
129121 _entityTree->unlock();
130122 }
131123
@@ -151,10 +143,6 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E · 19 unmodified lines
151143
152144 void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
153145
154− if (!canEdit()) {
155− return;
156− }
157−
158146 EntityItemID actualID = entityID;
159147
160148 // if the entity is unknown, attempt to look it up

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t