History

more model naming cleanup and fixing example scripts

ZappoMan committed 12 years ago

Commit 3e140101 parent 5b8be784 files · +39 −38Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+23−24
@@ -1,6 +1,6 @@
11 //
22 // EntityScriptingInterface.cpp
3−// libraries/models/src
3+// libraries/entities/src
44 //
55 // Created by Brad Hefta-Gaub on 12/6/13.
66 // Copyright 2013 High Fidelity, Inc.
@@ -19,7 +19,6 @@ EntityScriptingInterface::EntityScriptingInterface() : · 12 unmodified lines
1919 {
2020 }
2121
22−
2322 void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
2423 EntityItemID entityID, const EntityItemProperties& properties) {
2524 getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);
@@ -35,7 +34,7 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro · 9 unmodified lines
3534 // queue the packet
3635 queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
3736
38− // If we have a local model tree set, then also update it.
37+ // If we have a local entity tree set, then also update it.
3938 if (_entityTree) {
4039 _entityTree->lockForWrite();
4140 _entityTree->addEntity(id, properties);
@@ -93,20 +92,20 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID · 51 unmodified lines
9392 EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {
9493 EntityItemID actualID = entityID;
9594
96− // if the model is unknown, attempt to look it up
95+ // if the entity is unknown, attempt to look it up
9796 if (!entityID.isKnownID) {
9897 actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
9998 }
10099
101− // if at this point, we know the id, send the update to the model server
100+ // if at this point, we know the id, send the update to the entity server
102101 if (actualID.id != UNKNOWN_ENTITY_ID) {
103102 entityID.id = actualID.id;
104103 entityID.isKnownID = true;
105104 queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
106105 }
107106
108− // If we have a local model tree set, then also update it. We can do this even if we don't know
109− // the actual id, because we can edit out local models just with creatorTokenID
107+ // If we have a local entity tree set, then also update it. We can do this even if we don't know
108+ // the actual id, because we can edit out local entities just with creatorTokenID
110109 if (_entityTree) {
111110 _entityTree->lockForWrite();
112111 _entityTree->updateEntity(entityID, properties);
@@ -119,19 +118,19 @@ void EntityScriptingInterface::deleteEntity(EntityItemID entityID) { · 6 unmodified lines
119118
120119 EntityItemID actualID = entityID;
121120
122− // if the model is unknown, attempt to look it up
121+ // if the entity is unknown, attempt to look it up
123122 if (!entityID.isKnownID) {
124123 actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
125124 }
126125
127− // if at this point, we know the id, send the update to the model server
126+ // if at this point, we know the id, send the update to the entity server
128127 if (actualID.id != UNKNOWN_ENTITY_ID) {
129128 entityID.id = actualID.id;
130129 entityID.isKnownID = true;
131130 getEntityPacketSender()->queueEraseEntityMessage(entityID);
132131 }
133132
134− // If we have a local model tree set, then also update it.
133+ // If we have a local entity tree set, then also update it.
135134 if (_entityTree) {
136135 _entityTree->lockForWrite();
137136 _entityTree->deleteEntity(entityID);
@@ -167,12 +166,12 @@ QVector<EntityItemID> EntityScriptingInterface::findEntities(const glm::vec3& ce · 29 unmodified lines
167166 QVector<EntityItemID> result;
168167 if (_entityTree) {
169168 _entityTree->lockForRead();
170− QVector<const EntityItem*> models;
171− _entityTree->findEntities(center/(float)TREE_SCALE, radius/(float)TREE_SCALE, models);
169+ QVector<const EntityItem*> entities;
170+ _entityTree->findEntities(center/(float)TREE_SCALE, radius/(float)TREE_SCALE, entities);
172171 _entityTree->unlock();
173172
174− foreach (const EntityItem* model, models) {
175− EntityItemID thisEntityItemID(model->getID(), UNKNOWN_ENTITY_TOKEN, true);
173+ foreach (const EntityItem* entity, entities) {
174+ EntityItemID thisEntityItemID(entity->getID(), UNKNOWN_ENTITY_TOKEN, true);
176175 result << thisEntityItemID;
177176 }
178177 }
@@ -219,11 +218,11 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 40 unmodified lines
219218 QScriptValue obj = engine->newObject();
220219 obj.setProperty("intersects", value.intersects);
221220 obj.setProperty("accurate", value.accurate);
222− QScriptValue modelItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
223− obj.setProperty("entityID", modelItemValue);
221+ QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
222+ obj.setProperty("entityID", entityItemValue);
224223
225− QScriptValue modelPropertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties);
226− obj.setProperty("properties", modelPropertiesValue);
224+ QScriptValue propertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties);
225+ obj.setProperty("properties", propertiesValue);
227226
228227 obj.setProperty("distance", value.distance);
229228
@@ -262,13 +261,13 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 32 unmodified lines
262261 void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {
263262 value.intersects = object.property("intersects").toVariant().toBool();
264263 value.accurate = object.property("accurate").toVariant().toBool();
265− QScriptValue modelIDValue = object.property("entityID");
266− if (modelIDValue.isValid()) {
267− EntityItemIDfromScriptValue(modelIDValue, value.entityID);
264+ QScriptValue entityIDValue = object.property("entityID");
265+ if (entityIDValue.isValid()) {
266+ EntityItemIDfromScriptValue(entityIDValue, value.entityID);
268267 }
269− QScriptValue modelPropertiesValue = object.property("properties");
270− if (modelPropertiesValue.isValid()) {
271− EntityItemPropertiesFromScriptValue(modelPropertiesValue, value.properties);
268+ QScriptValue entityPropertiesValue = object.property("properties");
269+ if (entityPropertiesValue.isValid()) {
270+ EntityItemPropertiesFromScriptValue(entityPropertiesValue, value.properties);
272271 }
273272 value.distance = object.property("distance").toVariant().toFloat();
274273