Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 15 files). Show all
Unified · Split
| @@ -62,7 +62,7 @@ void EntityScriptingInterface::setEntityTree(EntityTree* modelTree) { · 61 unmodified lines | ||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | void bidForSimulationOwnership(EntityItemProperties& properties) { |
| 65 | − // We make a bid for simulation ownership by declaring our sessionID as simulation owner | |
| 65 | + // We make a bid for simulation ownership by declaring our sessionID as simulation owner | |
| 66 | 66 | // in the outgoing properties. The EntityServer may accept the bid or might not. |
| 67 | 67 | auto nodeList = DependencyManager::get<NodeList>(); |
| 68 | 68 | const QUuid myNodeID = nodeList->getSessionUUID(); |
| @@ -113,7 +113,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit · 44 unmodified lines | ||
| 113 | 113 | if (entity) { |
| 114 | 114 | results = entity->getProperties(); |
| 115 | 115 | |
| 116 | − // TODO: improve sitting points and naturalDimensions in the future, | |
| 116 | + // TODO: improve sitting points and naturalDimensions in the future, | |
| 117 | 117 | // for now we've included the old sitting points model behavior for entity types that are models |
| 118 | 118 | // we've also added this hack for setting natural dimensions of models |
| 119 | 119 | if (entity->getType() == EntityTypes::Model) { |
| @@ -149,15 +149,15 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties proper · 29 unmodified lines | ||
| 149 | 149 | if (properties.hasTerseUpdateChanges()) { |
| 150 | 150 | auto nodeList = DependencyManager::get<NodeList>(); |
| 151 | 151 | const QUuid myNodeID = nodeList->getSessionUUID(); |
| 152 | − | |
| 152 | + | |
| 153 | 153 | if (entity->getSimulatorID() == myNodeID) { |
| 154 | 154 | // we think we already own the simulation, so make sure to send ALL TerseUpdate properties |
| 155 | 155 | entity->getAllTerseUpdateProperties(properties); |
| 156 | − // TODO: if we knew that ONLY TerseUpdate properties have changed in properties AND the object | |
| 157 | − // is dynamic AND it is active in the physics simulation then we could chose to NOT queue an update | |
| 156 | + // TODO: if we knew that ONLY TerseUpdate properties have changed in properties AND the object | |
| 157 | + // is dynamic AND it is active in the physics simulation then we could chose to NOT queue an update | |
| 158 | 158 | // and instead let the physics simulation decide when to send a terse update. This would remove |
| 159 | 159 | // the "slide-no-rotate" glitch (and typical a double-update) that we see during the "poke rolling |
| 160 | − // balls" test. However, even if we solve this problem we still need to provide a "slerp the visible | |
| 160 | + // balls" test. However, even if we solve this problem we still need to provide a "slerp the visible | |
| 161 | 161 | // proxy toward the true physical position" feature to hide the final glitches in the remote watcher's |
| 162 | 162 | // simulation. |
| 163 | 163 | } |
| @@ -204,7 +204,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 40 unmodified lines | ||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const { |
| 207 | − EntityItemID result; | |
| 207 | + EntityItemID result; | |
| 208 | 208 | if (_entityTree) { |
| 209 | 209 | _entityTree->lockForRead(); |
| 210 | 210 | EntityItemPointer closestEntity = _entityTree->findClosestEntity(center, radius); |
| @@ -264,8 +264,8 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionBlock · 53 unmodified lines | ||
| 264 | 264 | return findRayIntersectionWorker(ray, Octree::Lock, precisionPicking); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | −RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorker(const PickRay& ray, | |
| 268 | − Octree::lockType lockType, | |
| 267 | +RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorker(const PickRay& ray, | |
| 268 | + Octree::lockType lockType, | |
| 269 | 269 | bool precisionPicking) { |
| 270 | 270 | |
| 271 | 271 | |
| @@ -273,8 +273,8 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke · 1 unmodified line | ||
| 273 | 273 | if (_entityTree) { |
| 274 | 274 | OctreeElement* element; |
| 275 | 275 | EntityItemPointer intersectedEntity = NULL; |
| 276 | − result.intersects = _entityTree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face, | |
| 277 | − (void**)&intersectedEntity, lockType, &result.accurate, | |
| 276 | + result.intersects = _entityTree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face, | |
| 277 | + (void**)&intersectedEntity, lockType, &result.accurate, | |
| 278 | 278 | precisionPicking); |
| 279 | 279 | if (result.intersects && intersectedEntity) { |
| 280 | 280 | result.entityID = intersectedEntity->getEntityItemID(); |
| @@ -318,15 +318,15 @@ bool EntityScriptingInterface::getSendPhysicsUpdates() const { · 37 unmodified lines | ||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | |
| 321 | −RayToEntityIntersectionResult::RayToEntityIntersectionResult() : | |
| 322 | − intersects(false), | |
| 321 | +RayToEntityIntersectionResult::RayToEntityIntersectionResult() : | |
| 322 | + intersects(false), | |
| 323 | 323 | accurate(true), // assume it's accurate |
| 324 | 324 | entityID(), |
| 325 | 325 | properties(), |
| 326 | 326 | distance(0), |
| 327 | 327 | face(), |
| 328 | 328 | entity(NULL) |
| 329 | −{ | |
| 329 | +{ | |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) { |
| @@ -341,7 +341,7 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 8 unmodified lines | ||
| 341 | 341 | |
| 342 | 342 | obj.setProperty("distance", value.distance); |
| 343 | 343 | |
| 344 | − QString faceName = ""; | |
| 344 | + QString faceName = ""; | |
| 345 | 345 | // handle BoxFace |
| 346 | 346 | switch (value.face) { |
| 347 | 347 | case MIN_X_FACE: |
| @@ -446,35 +446,35 @@ bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(Line · 98 unmodified lines | ||
| 446 | 446 | if (!_entityTree) { |
| 447 | 447 | return false; |
| 448 | 448 | } |
| 449 | − | |
| 449 | + | |
| 450 | 450 | EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID)); |
| 451 | 451 | if (!entity) { |
| 452 | 452 | qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID; |
| 453 | 453 | } |
| 454 | − | |
| 454 | + | |
| 455 | 455 | EntityTypes::EntityType entityType = entity->getType(); |
| 456 | − | |
| 456 | + | |
| 457 | 457 | if (entityType != EntityTypes::Line) { |
| 458 | 458 | return false; |
| 459 | 459 | } |
| 460 | − | |
| 460 | + | |
| 461 | 461 | auto now = usecTimestampNow(); |
| 462 | − | |
| 462 | + | |
| 463 | 463 | LineEntityItem* lineEntity = static_cast<LineEntityItem*>(entity.get()); |
| 464 | 464 | _entityTree->lockForWrite(); |
| 465 | 465 | bool success = actor(*lineEntity); |
| 466 | 466 | entity->setLastEdited(now); |
| 467 | 467 | entity->setLastBroadcast(now); |
| 468 | 468 | _entityTree->unlock(); |
| 469 | − | |
| 469 | + | |
| 470 | 470 | _entityTree->lockForRead(); |
| 471 | 471 | EntityItemProperties properties = entity->getProperties(); |
| 472 | 472 | _entityTree->unlock(); |
| 473 | − | |
| 473 | + | |
| 474 | 474 | properties.setLinePointsDirty(); |
| 475 | 475 | properties.setLastEdited(now); |
| 476 | − | |
| 477 | − | |
| 476 | + | |
| 477 | + | |
| 478 | 478 | queueEntityMessage(PacketTypeEntityEdit, entityID, properties); |
| 479 | 479 | return success; |
| 480 | 480 | } |
| @@ -509,7 +509,6 @@ bool EntityScriptingInterface::appendPoint(QUuid entityID, const glm::vec3& poin · 28 unmodified lines | ||
| 509 | 509 | { |
| 510 | 510 | return lineEntity.appendPoint(point); |
| 511 | 511 | }); |
| 512 | − | |
| 513 | 512 | } |
| 514 | 513 | |
| 515 | 514 | |
| @@ -585,9 +584,27 @@ bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& · 69 unmodified lines | ||
| 585 | 584 | }); |
| 586 | 585 | } |
| 587 | 586 | |
| 588 | − | |
| 589 | 587 | bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) { |
| 590 | 588 | return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { |
| 591 | 589 | return entity->removeAction(simulation, actionID); |
| 592 | 590 | }); |
| 593 | 591 | } |
| 592 | + | |
| 593 | +QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) { | |
| 594 | + QVector<QUuid> result; | |
| 595 | + actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | |
| 596 | + QList<QUuid> actionIDs = entity->getActionIDs(); | |
| 597 | + result = QVector<QUuid>::fromList(actionIDs); | |
| 598 | + return true; | |
| 599 | + }); | |
| 600 | + return result; | |
| 601 | +} | |
| 602 | + | |
| 603 | +QVariantMap EntityScriptingInterface::getActionArguments(const QUuid& entityID, const QUuid& actionID) { | |
| 604 | + QVariantMap result; | |
| 605 | + actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { | |
| 606 | + result = entity->getActionArguments(actionID); | |
| 607 | + return true; | |
| 608 | + }); | |
| 609 | + return result; | |
| 610 | +} | |