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
27}27}
28 28
29 29
30bool EntityScriptingInterface::canEdit() {30bool EntityScriptingInterface::canAdjustLocks() {
31 auto nodeList = DependencyManager::get<NodeList>();31 auto nodeList = DependencyManager::get<NodeList>();
32 return nodeList->getThisNodeCanEdit();32 return nodeList->getThisNodeCanAdjustLocks();
33}33}
34 34
35 35
@@ -40,18 +40,16 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro · 4 unmodified lines
40 40
41 EntityItemID id(NEW_ENTITY, creatorTokenID, false );41 EntityItemID id(NEW_ENTITY, creatorTokenID, false );
42 42
43 if (canEdit()) {43 // If we have a local entity tree set, then also update it.
44 // If we have a local entity tree set, then also update it.44 if (_entityTree) {
45 if (_entityTree) {45 _entityTree->lockForWrite();
46 _entityTree->lockForWrite();46 _entityTree->addEntity(id, properties);
47 _entityTree->addEntity(id, properties);47 _entityTree->unlock();
48 _entityTree->unlock();
49 }
50
51 // queue the packet
52 queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
53 }48 }
54 49
50 // queue the packet
51 queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
52
55 return id;53 return id;
56}54}
57 55
@@ -74,32 +72,30 @@ EntityItemID EntityScriptingInterface::identifyEntity(EntityItemID entityID) { · 16 unmodified lines
74EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID entityID) {72EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID entityID) {
75 EntityItemProperties results;73 EntityItemProperties results;
76 74
77 if (canEdit()) {75 EntityItemID identity = identifyEntity(entityID);
78 EntityItemID identity = identifyEntity(entityID);76 if (_entityTree) {
79 if (_entityTree) {77 _entityTree->lockForRead();
80 _entityTree->lockForRead();78 EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(identity));
81 EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(identity));
82 79
83 if (entity) {80 if (entity) {
84 results = entity->getProperties();81 results = entity->getProperties();
85 82
86 // TODO: improve sitting points and naturalDimensions in the future, 83 // 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 models84 // 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 models85 // we've also added this hack for setting natural dimensions of models
89 if (entity->getType() == EntityTypes::Model) {86 if (entity->getType() == EntityTypes::Model) {
90 const FBXGeometry* geometry = _entityTree->getGeometryForEntity(entity);87 const FBXGeometry* geometry = _entityTree->getGeometryForEntity(entity);
91 if (geometry) {88 if (geometry) {
92 results.setSittingPoints(geometry->sittingPoints);89 results.setSittingPoints(geometry->sittingPoints);
93 Extents meshExtents = geometry->getUnscaledMeshExtents();90 Extents meshExtents = geometry->getUnscaledMeshExtents();
94 results.setNaturalDimensions(meshExtents.maximum - meshExtents.minimum);91 results.setNaturalDimensions(meshExtents.maximum - meshExtents.minimum);
95 }
96 }92 }
97
98 } else {
99 results.setIsUnknownID();
100 }93 }
101 _entityTree->unlock();94
95 } else {
96 results.setIsUnknownID();
102 }97 }
98 _entityTree->unlock();
103 }99 }
104 100
105 return results;101 return results;
@@ -107,10 +103,6 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID · 1 unmodified line
107 103
108EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {104EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {
109 105
110 if (!canEdit()) {
111 return entityID;
112 }
113
114 EntityItemID actualID = entityID;106 EntityItemID actualID = entityID;
115 // if the entity is unknown, attempt to look it up107 // if the entity is unknown, attempt to look it up
116 if (!entityID.isKnownID) {108 if (!entityID.isKnownID) {
@@ -125,7 +117,7 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E · 8 unmodified lines
125 // the actual id, because we can edit out local entities just with creatorTokenID117 // the actual id, because we can edit out local entities just with creatorTokenID
126 if (_entityTree) {118 if (_entityTree) {
127 _entityTree->lockForWrite();119 _entityTree->lockForWrite();
128 _entityTree->updateEntity(entityID, properties);120 _entityTree->updateEntity(entityID, properties, canAdjustLocks());
129 _entityTree->unlock();121 _entityTree->unlock();
130 }122 }
131 123
@@ -151,10 +143,6 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E · 19 unmodified lines
151 143
152void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {144void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
153 145
154 if (!canEdit()) {
155 return;
156 }
157
158 EntityItemID actualID = entityID;146 EntityItemID actualID = entityID;
159 147
160 // if the entity is unknown, attempt to look it up148 // 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