Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // |
| 2 | 2 | // EntityScriptingInterface.cpp |
| 3 | −// libraries/models/src | |
| 3 | +// libraries/entities/src | |
| 4 | 4 | // |
| 5 | 5 | // Created by Brad Hefta-Gaub on 12/6/13. |
| 6 | 6 | // Copyright 2013 High Fidelity, Inc. |
| @@ -19,7 +19,6 @@ EntityScriptingInterface::EntityScriptingInterface() : · 12 unmodified lines | ||
| 19 | 19 | { |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | − | |
| 23 | 22 | void EntityScriptingInterface::queueEntityMessage(PacketType packetType, |
| 24 | 23 | EntityItemID entityID, const EntityItemProperties& properties) { |
| 25 | 24 | getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties); |
| @@ -35,7 +34,7 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro · 9 unmodified lines | ||
| 35 | 34 | // queue the packet |
| 36 | 35 | queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties); |
| 37 | 36 | |
| 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. | |
| 39 | 38 | if (_entityTree) { |
| 40 | 39 | _entityTree->lockForWrite(); |
| 41 | 40 | _entityTree->addEntity(id, properties); |
| @@ -93,20 +92,20 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID · 51 unmodified lines | ||
| 93 | 92 | EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) { |
| 94 | 93 | EntityItemID actualID = entityID; |
| 95 | 94 | |
| 96 | − // if the model is unknown, attempt to look it up | |
| 95 | + // if the entity is unknown, attempt to look it up | |
| 97 | 96 | if (!entityID.isKnownID) { |
| 98 | 97 | actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID); |
| 99 | 98 | } |
| 100 | 99 | |
| 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 | |
| 102 | 101 | if (actualID.id != UNKNOWN_ENTITY_ID) { |
| 103 | 102 | entityID.id = actualID.id; |
| 104 | 103 | entityID.isKnownID = true; |
| 105 | 104 | queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties); |
| 106 | 105 | } |
| 107 | 106 | |
| 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 | |
| 110 | 109 | if (_entityTree) { |
| 111 | 110 | _entityTree->lockForWrite(); |
| 112 | 111 | _entityTree->updateEntity(entityID, properties); |
| @@ -119,19 +118,19 @@ void EntityScriptingInterface::deleteEntity(EntityItemID entityID) { · 6 unmodified lines | ||
| 119 | 118 | |
| 120 | 119 | EntityItemID actualID = entityID; |
| 121 | 120 | |
| 122 | − // if the model is unknown, attempt to look it up | |
| 121 | + // if the entity is unknown, attempt to look it up | |
| 123 | 122 | if (!entityID.isKnownID) { |
| 124 | 123 | actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID); |
| 125 | 124 | } |
| 126 | 125 | |
| 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 | |
| 128 | 127 | if (actualID.id != UNKNOWN_ENTITY_ID) { |
| 129 | 128 | entityID.id = actualID.id; |
| 130 | 129 | entityID.isKnownID = true; |
| 131 | 130 | getEntityPacketSender()->queueEraseEntityMessage(entityID); |
| 132 | 131 | } |
| 133 | 132 | |
| 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. | |
| 135 | 134 | if (_entityTree) { |
| 136 | 135 | _entityTree->lockForWrite(); |
| 137 | 136 | _entityTree->deleteEntity(entityID); |
| @@ -167,12 +166,12 @@ QVector<EntityItemID> EntityScriptingInterface::findEntities(const glm::vec3& ce · 29 unmodified lines | ||
| 167 | 166 | QVector<EntityItemID> result; |
| 168 | 167 | if (_entityTree) { |
| 169 | 168 | _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); | |
| 172 | 171 | _entityTree->unlock(); |
| 173 | 172 | |
| 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); | |
| 176 | 175 | result << thisEntityItemID; |
| 177 | 176 | } |
| 178 | 177 | } |
| @@ -219,11 +218,11 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 40 unmodified lines | ||
| 219 | 218 | QScriptValue obj = engine->newObject(); |
| 220 | 219 | obj.setProperty("intersects", value.intersects); |
| 221 | 220 | 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); | |
| 224 | 223 | |
| 225 | − QScriptValue modelPropertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties); | |
| 226 | − obj.setProperty("properties", modelPropertiesValue); | |
| 224 | + QScriptValue propertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties); | |
| 225 | + obj.setProperty("properties", propertiesValue); | |
| 227 | 226 | |
| 228 | 227 | obj.setProperty("distance", value.distance); |
| 229 | 228 | |
| @@ -262,13 +261,13 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 32 unmodified lines | ||
| 262 | 261 | void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) { |
| 263 | 262 | value.intersects = object.property("intersects").toVariant().toBool(); |
| 264 | 263 | 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); | |
| 268 | 267 | } |
| 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); | |
| 272 | 271 | } |
| 273 | 272 | value.distance = object.property("distance").toVariant().toFloat(); |
| 274 | 273 | |