History

Merge branch 'master' of github.com:highfidelity/hifi into polyvox

Seth Alves committed 11 years ago

Commit c80f2972 parents 0f81445 857552a69 files · +318 −306Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+11−10
@@ -79,7 +79,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties · 78 unmodified lines
79 bool success = true;79 bool success = true;
80 if (_entityTree) {80 if (_entityTree) {
81 _entityTree->lockForWrite();81 _entityTree->lockForWrite();
82 EntityItem* entity = _entityTree->addEntity(id, propertiesWithSimID);82 EntityItemPointer entity = _entityTree->addEntity(id, propertiesWithSimID);
83 if (entity) {83 if (entity) {
84 entity->setLastBroadcast(usecTimestampNow());84 entity->setLastBroadcast(usecTimestampNow());
85 // This Node is creating a new object. If it's in motion, set this Node as the simulator.85 // This Node is creating a new object. If it's in motion, set this Node as the simulator.
@@ -103,7 +103,8 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit · 17 unmodified lines
103 EntityItemProperties results;103 EntityItemProperties results;
104 if (_entityTree) {104 if (_entityTree) {
105 _entityTree->lockForRead();105 _entityTree->lockForRead();
106 EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(EntityItemID(identity)));106
107 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(EntityItemID(identity));
107 108
108 if (entity) {109 if (entity) {
109 results = entity->getProperties();110 results = entity->getProperties();
@@ -138,7 +139,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 28 unmodified lines
138 139
139 // make sure the properties has a type, so that the encode can know which properties to include140 // make sure the properties has a type, so that the encode can know which properties to include
140 if (properties.getType() == EntityTypes::Unknown) {141 if (properties.getType() == EntityTypes::Unknown) {
141 EntityItem* entity = _entityTree->findEntityByEntityItemID(entityID);142 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
142 if (entity) {143 if (entity) {
143 // we need to change the outgoing properties, so we make a copy, modify, and send.144 // we need to change the outgoing properties, so we make a copy, modify, and send.
144 EntityItemProperties modifiedProperties = properties;145 EntityItemProperties modifiedProperties = properties;
@@ -162,7 +163,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 17 unmodified lines
162 if (_entityTree) {163 if (_entityTree) {
163 _entityTree->lockForWrite();164 _entityTree->lockForWrite();
164 165
165 EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(entityID));166 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
166 if (entity) {167 if (entity) {
167 if (entity->getLocked()) {168 if (entity->getLocked()) {
168 shouldDelete = false;169 shouldDelete = false;
@@ -184,7 +185,7 @@ QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float · 15 unmodified lines
184 EntityItemID result; 185 EntityItemID result;
185 if (_entityTree) {186 if (_entityTree) {
186 _entityTree->lockForRead();187 _entityTree->lockForRead();
187 const EntityItem* closestEntity = _entityTree->findClosestEntity(center, radius);188 EntityItemPointer closestEntity = _entityTree->findClosestEntity(center, radius);
188 _entityTree->unlock();189 _entityTree->unlock();
189 if (closestEntity) {190 if (closestEntity) {
190 result = closestEntity->getEntityItemID();191 result = closestEntity->getEntityItemID();
@@ -206,11 +207,11 @@ QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, f · 15 unmodified lines
206 QVector<QUuid> result;207 QVector<QUuid> result;
207 if (_entityTree) {208 if (_entityTree) {
208 _entityTree->lockForRead();209 _entityTree->lockForRead();
209 QVector<const EntityItem*> entities;210 QVector<EntityItemPointer> entities;
210 _entityTree->findEntities(center, radius, entities);211 _entityTree->findEntities(center, radius, entities);
211 _entityTree->unlock();212 _entityTree->unlock();
212 213
213 foreach (const EntityItem* entity, entities) {214 foreach (EntityItemPointer entity, entities) {
214 result << entity->getEntityItemID();215 result << entity->getEntityItemID();
215 }216 }
216 }217 }
@@ -222,11 +223,11 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corn · 5 unmodified lines
222 if (_entityTree) {223 if (_entityTree) {
223 _entityTree->lockForRead();224 _entityTree->lockForRead();
224 AABox box(corner, dimensions);225 AABox box(corner, dimensions);
225 QVector<EntityItem*> entities;226 QVector<EntityItemPointer> entities;
226 _entityTree->findEntities(box, entities);227 _entityTree->findEntities(box, entities);
227 _entityTree->unlock();228 _entityTree->unlock();
228 229
229 foreach (const EntityItem* entity, entities) {230 foreach (EntityItemPointer entity, entities) {
230 result << entity->getEntityItemID();231 result << entity->getEntityItemID();
231 }232 }
232 }233 }
@@ -249,7 +250,7 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke · 16 unmodified lines
249 RayToEntityIntersectionResult result;250 RayToEntityIntersectionResult result;
250 if (_entityTree) {251 if (_entityTree) {
251 OctreeElement* element;252 OctreeElement* element;
252 EntityItem* intersectedEntity = NULL;253 EntityItemPointer intersectedEntity = NULL;
253 result.intersects = _entityTree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face, 254 result.intersects = _entityTree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face,
254 (void**)&intersectedEntity, lockType, &result.accurate, 255 (void**)&intersectedEntity, lockType, &result.accurate,
255 precisionPicking);256 precisionPicking);