History

Merge branch 'master' into NOverlays3

Sam Gondelman committed 7 years ago

Commit 2291c7e2 parents d30dd4c da296cf27 files · +205 −98Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+27−12
@@ -470,7 +470,7 @@ void synchronizeEditedGrabProperties(EntityItemProperties& properties, const QSt · 469 unmodified lines
470470 }
471471
472472
473−QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties, bool clientOnly) {
473+QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties, const QString& entityHostTypeString) {
474474 PROFILE_RANGE(script_entities, __FUNCTION__);
475475
476476 _activityTracking.addedEntityCount++;
@@ -479,9 +479,13 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties · 2 unmodified lines
479479 const auto sessionID = nodeList->getSessionUUID();
480480
481481 EntityItemProperties propertiesWithSimID = properties;
482− if (clientOnly) {
483− propertiesWithSimID.setClientOnly(clientOnly);
482+ propertiesWithSimID.setEntityHostTypeFromString(entityHostTypeString);
483+ if (propertiesWithSimID.getEntityHostType() == entity::HostType::AVATAR) {
484484 propertiesWithSimID.setOwningAvatarID(sessionID);
485+ } else if (propertiesWithSimID.getEntityHostType() == entity::HostType::LOCAL) {
486+ // For now, local entities are always collisionless
487+ // TODO: create a separate, local physics simulation that just handles local entities (and MyAvatar?)
488+ propertiesWithSimID.setCollisionless(true);
485489 }
486490
487491 propertiesWithSimID.setLastEditedBy(sessionID);
@@ -570,8 +574,11 @@ QUuid EntityScriptingInterface::cloneEntity(QUuid entityIDToClone) { · 82 unmodified lines
570574 bool cloneAvatarEntity = properties.getCloneAvatarEntity();
571575 properties.convertToCloneProperties(entityIDToClone);
572576
573− if (cloneAvatarEntity) {
574− return addEntity(properties, true);
577+ if (properties.getEntityHostType() == entity::HostType::LOCAL) {
578+ // Local entities are only cloned locally
579+ return addEntity(properties, "local");
580+ } else if (cloneAvatarEntity) {
581+ return addEntity(properties, "avatar");
575582 } else {
576583 // setLastEdited timestamp to 0 to ensure this entity gets updated with the properties
577584 // from the server-created entity, don't change this unless you know what you are doing
@@ -683,6 +690,10 @@ QScriptValue EntityScriptingInterface::getMultipleEntityPropertiesInternal(QScri · 105 unmodified lines
683690 psuedoPropertyFlags.set(EntityPsuedoPropertyFlag::ClientOnly);
684691 } else if (extendedPropertyString == "owningAvatarID") {
685692 psuedoPropertyFlags.set(EntityPsuedoPropertyFlag::OwningAvatarID);
693+ } else if (extendedPropertyString == "avatarEntity") {
694+ psuedoPropertyFlags.set(EntityPsuedoPropertyFlag::AvatarEntity);
695+ } else if (extendedPropertyString == "localEntity") {
696+ psuedoPropertyFlags.set(EntityPsuedoPropertyFlag::LocalEntity);
686697 } else if (extendedPropertyString == "faceCamera") {
687698 psuedoPropertyFlags.set(EntityPsuedoPropertyFlag::FaceCamera);
688699 } else if (extendedPropertyString == "isFacingAvatar") {
@@ -790,7 +801,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 101 unmodified lines
790801 return;
791802 }
792803
793− if (entity->getClientOnly() && entity->getOwningAvatarID() != sessionID) {
804+ if (entity->isAvatarEntity() && entity->getOwningAvatarID() != sessionID) {
794805 // don't edit other avatar's avatarEntities
795806 properties = EntityItemProperties();
796807 return;
@@ -833,7 +844,11 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 36 unmodified lines
833844 }
834845
835846 // set these to make EntityItemProperties::getScalesWithParent() work correctly
836− properties.setClientOnly(entity->getClientOnly());
847+ entity::HostType entityHostType = entity->getEntityHostType();
848+ properties.setEntityHostType(entityHostType);
849+ if (entityHostType == entity::HostType::LOCAL) {
850+ properties.setCollisionless(true);
851+ }
837852 properties.setOwningAvatarID(entity->getOwningAvatarID());
838853
839854 properties.setActionData(entity->getDynamicData());
@@ -960,7 +975,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 120 unmodified lines
960975
961976 auto nodeList = DependencyManager::get<NodeList>();
962977 const QUuid myNodeID = nodeList->getSessionUUID();
963− if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) {
978+ if (entity->isAvatarEntity() && entity->getOwningAvatarID() != myNodeID) {
964979 // don't delete other avatar's avatarEntities
965980 shouldSendDeleteToServer = false;
966981 return;
@@ -970,11 +985,11 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 3 unmodified lines
970985 shouldSendDeleteToServer = false;
971986 } else {
972987 // only delete local entities, server entities will round trip through the server filters
973− if (entity->getClientOnly() || _entityTree->isServerlessMode()) {
988+ if (entity->isAvatarEntity() || _entityTree->isServerlessMode()) {
974989 shouldSendDeleteToServer = false;
975990 _entityTree->deleteEntity(entityID);
976991
977− if (entity->getClientOnly() && getEntityPacketSender()->getMyAvatar()) {
992+ if (entity->isAvatarEntity() && getEntityPacketSender()->getMyAvatar()) {
978993 getEntityPacketSender()->getMyAvatar()->clearAvatarEntity(entityID, false);
979994 }
980995 }
@@ -1641,14 +1656,14 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID, · 660 unmodified lines
16411656 return;
16421657 }
16431658
1644− if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) {
1659+ if (entity->isAvatarEntity() && entity->getOwningAvatarID() != myNodeID) {
16451660 return;
16461661 }
16471662
16481663 doTransmit = actor(simulation, entity);
16491664 _entityTree->entityChanged(entity);
16501665 if (doTransmit) {
1651− properties.setClientOnly(entity->getClientOnly());
1666+ properties.setEntityHostType(entity->getEntityHostType());
16521667 properties.setOwningAvatarID(entity->getOwningAvatarID());
16531668 }
16541669 });

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