This commit is contained in:
SamGondelman 2018-11-26 01:15:07 -05:00
parent 8dbb2d806b
commit e282d51883
18 changed files with 92 additions and 86 deletions

View file

@ -58,7 +58,7 @@ void addAvatarEntities(const QVariantList& avatarEntities) {
EntityItemPropertiesFromScriptValueHonorReadOnly(scriptProperties, entityProperties);
entityProperties.setParentID(myNodeID);
entityProperties.setEntityHost(EntityHost::AVATAR_ENTITY);
entityProperties.setEntityHostType(entity::HostType::AVATAR);
entityProperties.setOwningAvatarID(myNodeID);
entityProperties.setSimulationOwner(myNodeID, AVATAR_ENTITY_SIMULATION_PRIORITY);
entityProperties.markAllChanged();

View file

@ -35,7 +35,7 @@ void WalletScriptingInterface::proveAvatarEntityOwnershipVerification(const QUui
QSharedPointer<ContextOverlayInterface> contextOverlayInterface = DependencyManager::get<ContextOverlayInterface>();
EntityItemProperties entityProperties = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(entityID,
contextOverlayInterface->getEntityPropertyFlags());
if (entityProperties.getEntityHost() == EntityHost::AVATAR_ENTITY) {
if (entityProperties.getEntityHostType() == entity::HostType::AVATAR) {
if (!entityID.isNull() && entityProperties.getCertificateID().length() > 0) {
contextOverlayInterface->requestOwnershipVerification(entityID);
} else {

View file

@ -46,7 +46,7 @@ ContextOverlayInterface::ContextOverlayInterface() {
_entityPropertyFlags += PROP_DIMENSIONS;
_entityPropertyFlags += PROP_REGISTRATION_POINT;
_entityPropertyFlags += PROP_CERTIFICATE_ID;
_entityPropertyFlags += PROP_ENTITY_HOST;
_entityPropertyFlags += PROP_ENTITY_HOST_TYPE;
_entityPropertyFlags += PROP_OWNING_AVATAR_ID;
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>().data();
@ -296,7 +296,7 @@ void ContextOverlayInterface::requestOwnershipVerification(const QUuid& entityID
auto nodeList = DependencyManager::get<NodeList>();
if (entityProperties.verifyStaticCertificateProperties()) {
if (entityProperties.getEntityHost() == EntityHost::AVATAR_ENTITY) {
if (entityProperties.getEntityHostType() == entity::HostType::AVATAR) {
SharedNodePointer entityServer = nodeList->soloNodeOfType(NodeType::EntityServer);
if (entityServer) {

View file

@ -389,7 +389,7 @@ void Avatar::updateAvatarEntities() {
QScriptValue scriptProperties = variantMapToScriptValue(asMap, scriptEngine);
EntityItemProperties properties;
EntityItemPropertiesFromScriptValueHonorReadOnly(scriptProperties, properties);
properties.setEntityHost(EntityHost::AVATAR_ENTITY);
properties.setEntityHostType(entity::HostType::AVATAR);
properties.setOwningAvatarID(getID());
// there's no entity-server to tell us we're the simulation owner, so always set the

View file

@ -39,7 +39,7 @@ enum class RenderItemStatusIcon {
SIMULATION_OWNER = 3,
HAS_ACTIONS = 4,
OTHER_SIMULATION_OWNER = 5,
ENTITY_HOST = 6,
ENTITY_HOST_TYPE = 6,
NONE = 255
};
@ -118,17 +118,17 @@ void EntityRenderer::makeStatusGetters(const EntityItemPointer& entity, Item::St
if (entity->isAvatarEntity()) {
if (entity->getOwningAvatarID() == myNodeID) {
return render::Item::Status::Value(1.0f, render::Item::Status::Value::GREEN,
(unsigned char)RenderItemStatusIcon::ENTITY_HOST);
(unsigned char)RenderItemStatusIcon::ENTITY_HOST_TYPE);
} else {
return render::Item::Status::Value(1.0f, render::Item::Status::Value::RED,
(unsigned char)RenderItemStatusIcon::ENTITY_HOST);
(unsigned char)RenderItemStatusIcon::ENTITY_HOST_TYPE);
}
} else if (entity->isLocalEntity()) {
return render::Item::Status::Value(1.0f, render::Item::Status::Value::BLUE,
(unsigned char)RenderItemStatusIcon::ENTITY_HOST);
(unsigned char)RenderItemStatusIcon::ENTITY_HOST_TYPE);
}
return render::Item::Status::Value(0.0f, render::Item::Status::Value::GREEN,
(unsigned char)RenderItemStatusIcon::ENTITY_HOST);
(unsigned char)RenderItemStatusIcon::ENTITY_HOST_TYPE);
});
}

View file

@ -84,7 +84,7 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
EntityTreePointer entityTree,
EntityItemID entityItemID,
const EntityItemProperties& properties) {
if (properties.getEntityHost() == EntityHost::AVATAR_ENTITY) {
if (properties.getEntityHostType() == entity::HostType::AVATAR) {
if (!_myAvatar) {
qCWarning(entities) << "Suppressing entity edit message: cannot send avatar entity edit with no myAvatar";
} else if (properties.getOwningAvatarID() == _myAvatar->getID()) {
@ -94,7 +94,7 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
qCWarning(entities) << "Suppressing entity edit message: cannot send avatar entity edit for another avatar";
}
return;
} else if (properties.getEntityHost() == EntityHost::LOCAL_ENTITY) {
} else if (properties.getEntityHostType() == entity::HostType::LOCAL) {
// Don't send edits for local entities
return;
}

View file

@ -119,7 +119,7 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
requestedProperties += PROP_PARENT_JOINT_INDEX;
requestedProperties += PROP_QUERY_AA_CUBE;
requestedProperties += PROP_ENTITY_HOST;
requestedProperties += PROP_ENTITY_HOST_TYPE;
requestedProperties += PROP_OWNING_AVATAR_ID;
requestedProperties += PROP_LAST_EDITED_BY;
@ -172,7 +172,7 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
EntityPropertyFlags propertyFlags(PROP_LAST_ITEM);
EntityPropertyFlags requestedProperties = getEntityProperties(params);
requestedProperties -= PROP_ENTITY_HOST;
requestedProperties -= PROP_ENTITY_HOST_TYPE;
requestedProperties -= PROP_OWNING_AVATAR_ID;
// If we are being called for a subsequent pass at appendEntityData() that failed to completely encode this item,
@ -1334,7 +1334,7 @@ EntityItemProperties EntityItem::getProperties(const EntityPropertyFlags& desire
COPY_ENTITY_PROPERTY_TO_PROPERTIES(localPosition, getLocalPosition);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(localRotation, getLocalOrientation);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(entityHost, getEntityHost);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(entityHostType, getEntityHostType);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(owningAvatarID, getOwningAvatarID);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(lastEditedBy, getLastEditedBy);
@ -1476,7 +1476,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(parentJointIndex, setParentJointIndex);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(queryAACube, setQueryAACube);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(entityHost, setEntityHost);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(entityHostType, setEntityHostType);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(owningAvatarID, setOwningAvatarID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lastEditedBy, setLastEditedBy);
@ -3274,7 +3274,7 @@ void EntityItem::prepareForSimulationOwnershipBid(EntityItemProperties& properti
properties.setSimulationOwner(Physics::getSessionUUID(), priority);
setPendingOwnershipPriority(priority);
properties.setEntityHost(getEntityHost());
properties.setEntityHostType(getEntityHostType());
properties.setOwningAvatarID(getOwningAvatarID());
setLastBroadcast(now); // for debug/physics status icons
}

View file

@ -64,11 +64,17 @@ const uint64_t MAX_INCOMING_SIMULATION_UPDATE_PERIOD = MAX_OUTGOING_SIMULATION_U
class MeshProxyList;
enum class EntityHost {
DOMAIN_ENTITY = 0,
AVATAR_ENTITY,
LOCAL_ENTITY
#ifdef DOMAIN
#undef DOMAIN
#endif
namespace entity {
enum class HostType {
DOMAIN = 0,
AVATAR,
LOCAL
};
}
/// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available
/// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate
@ -484,11 +490,11 @@ public:
void setScriptHasFinishedPreload(bool value);
bool isScriptPreloadFinished();
bool isDomainEntity() const { return _entityHost == EntityHost::DOMAIN_ENTITY; }
bool isAvatarEntity() const { return _entityHost == EntityHost::AVATAR_ENTITY; }
bool isLocalEntity() const { return _entityHost == EntityHost::LOCAL_ENTITY; }
EntityHost getEntityHost() const { return _entityHost; }
virtual void setEntityHost(EntityHost entityHost) { _entityHost = entityHost; }
bool isDomainEntity() const { return _hostType == entity::HostType::DOMAIN; }
bool isAvatarEntity() const { return _hostType == entity::HostType::AVATAR; }
bool isLocalEntity() const { return _hostType == entity::HostType::LOCAL; }
entity::HostType getEntityHostType() const { return _hostType; }
virtual void setEntityHostType(entity::HostType hostType) { _hostType = hostType; }
// if this entity is an avatar entity, which avatar is it associated with?
QUuid getOwningAvatarID() const { return _owningAvatarID; }
@ -683,7 +689,7 @@ protected:
QUuid _sourceUUID; /// the server node UUID we came from
EntityHost _entityHost { EntityHost::DOMAIN_ENTITY };
entity::HostType _hostType { entity::HostType::DOMAIN };
bool _transitingWithAvatar{ false };
QUuid _owningAvatarID;

View file

@ -306,26 +306,26 @@ void EntityItemProperties::setMaterialMappingModeFromString(const QString& mater
}
}
QString EntityItemProperties::getEntityHostAsString() const {
switch (_entityHost) {
case EntityHost::DOMAIN_ENTITY:
QString EntityItemProperties::getEntityHostTypeAsString() const {
switch (_entityHostType) {
case entity::HostType::DOMAIN:
return "domain";
case EntityHost::AVATAR_ENTITY:
case entity::HostType::AVATAR:
return "avatar";
case EntityHost::LOCAL_ENTITY:
case entity::HostType::LOCAL:
return "local";
default:
return "";
}
}
void EntityItemProperties::setEntityHostFromString(const QString& entityHost) {
if (entityHost == "domain") {
_entityHost = EntityHost::DOMAIN_ENTITY;
} else if (entityHost == "avatar") {
_entityHost = EntityHost::AVATAR_ENTITY;
} else if (entityHost == "local") {
_entityHost = EntityHost::LOCAL_ENTITY;
void EntityItemProperties::setEntityHostTypeFromString(const QString& entityHostType) {
if (entityHostType == "domain") {
_entityHostType = entity::HostType::DOMAIN;
} else if (entityHostType == "avatar") {
_entityHostType = entity::HostType::AVATAR;
} else if (entityHostType == "local") {
_entityHostType = entity::HostType::LOCAL;
}
}
@ -476,7 +476,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_GHOSTING_ALLOWED, ghostingAllowed);
CHECK_PROPERTY_CHANGE(PROP_FILTER_URL, filterURL);
CHECK_PROPERTY_CHANGE(PROP_ENTITY_HOST, entityHost);
CHECK_PROPERTY_CHANGE(PROP_ENTITY_HOST_TYPE, entityHostType);
CHECK_PROPERTY_CHANGE(PROP_OWNING_AVATAR_ID, owningAvatarID);
CHECK_PROPERTY_CHANGE(PROP_SHAPE, shape);
@ -512,16 +512,16 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
* @property {Entities.EntityType} type - The entity type. You cannot change the type of an entity after it's created. (Though
* its value may switch among <code>"Box"</code>, <code>"Shape"</code>, and <code>"Sphere"</code> depending on changes to
* the <code>shape</code> property set for entities of these types.) <em>Read-only.</em>
* @property {EntityHost} entityHost="domain" - How this entity will behave, including if and how it is sent to other people.
* The value can only be set at entity creation by using the <code>entityHost</code> parameter in
* @property {EntityHostType} entityHostType="domain" - How this entity will behave, including if and how it is sent to other people.
* The value can only be set at entity creation by using the <code>entityHostType</code> parameter in
* {@link Entities.addEntity}.
* @property {boolean} avatarEntity=false - If <code>true</code> then the entity is an avatar entity; An avatar entity follows you to each domain you visit,
* rendering at the same world coordinates unless it's parented to your avatar. <em>Value cannot be changed after the entity is created.</em><br />
* The value can only be set at entity creation by using the <code>entityHost</code> parameter in
* The value can only be set at entity creation by using the <code>entityHostType</code> parameter in
* {@link Entities.addEntity}. <code>clientOnly</code> is an alias.
* @property {boolean} localEntity=false - If <code>true</code> then the entity is a local entity; Local entities only render for you and are not sent over the wire.
* <em>Value cannot be changed after the entity is created.</em><br />
* The value can only be set at entity creation by using the <code>entityHost</code> parameter in
* The value can only be set at entity creation by using the <code>entityHostType</code> parameter in
* {@link Entities.addEntity}.
* @property {Uuid} owningAvatarID=Uuid.NULL - The session ID of the owning avatar if <code>avatarEntity</code> is
* <code>true</code>, otherwise {@link Uuid|Uuid.NULL}. <em>Read-only.</em>
@ -768,7 +768,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
* overlay's ID.
* To apply a material to an avatar, set the material entity's <code>parentID</code> property to the avatar's session UUID.
* To apply a material to your avatar such that it persists across domains and log-ins, create the material as an avatar entity
* by setting the <code>entityHost</code> parameter in {@link Entities.addEntity} to <code>"avatar"</code>.
* by setting the <code>entityHostType</code> parameter in {@link Entities.addEntity} to <code>"avatar"</code>.
* Material entities render as non-scalable spheres if they don't have their parent set.
* @typedef {object} Entities.EntityProperties-Material
* @property {string} materialURL="" - URL to a {@link MaterialResource}. If you append <code>?name</code> to the URL, the
@ -1556,8 +1556,8 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LOCAL_ANGULAR_VELOCITY, localAngularVelocity);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LOCAL_DIMENSIONS, localDimensions);
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ENTITY_HOST, entityHost, getEntityHostAsString()); // Gettable but not settable except at entity creation
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID); // Gettable but not settable
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ENTITY_HOST_TYPE, entityHostType, getEntityHostTypeAsString()); // Gettable but not settable except at entity creation
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID); // Gettable but not settable
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CLONEABLE, cloneable);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CLONE_LIFETIME, cloneLifetime);
@ -1597,13 +1597,13 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
}
if (!psuedoPropertyFlagsActive || psueudoPropertyFlags.test(EntityPsuedoPropertyFlag::ClientOnly)) {
properties.setProperty("clientOnly", convertScriptValue(engine, getEntityHost() == EntityHost::AVATAR_ENTITY));
properties.setProperty("clientOnly", convertScriptValue(engine, getEntityHostType() == entity::HostType::AVATAR));
}
if (!psuedoPropertyFlagsActive || psueudoPropertyFlags.test(EntityPsuedoPropertyFlag::AvatarEntity)) {
properties.setProperty("avatarEntity", convertScriptValue(engine, getEntityHost() == EntityHost::AVATAR_ENTITY));
properties.setProperty("avatarEntity", convertScriptValue(engine, getEntityHostType() == entity::HostType::AVATAR));
}
if (!psuedoPropertyFlagsActive || psueudoPropertyFlags.test(EntityPsuedoPropertyFlag::LocalEntity)) {
properties.setProperty("localEntity", convertScriptValue(engine, getEntityHost() == EntityHost::LOCAL_ENTITY));
properties.setProperty("localEntity", convertScriptValue(engine, getEntityHostType() == entity::HostType::LOCAL));
}
// FIXME - I don't think these properties are supported any more
@ -1792,7 +1792,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
COPY_PROPERTY_FROM_QSCRIPTVALUE(ghostingAllowed, bool, setGhostingAllowed);
COPY_PROPERTY_FROM_QSCRIPTVALUE(filterURL, QString, setFilterURL);
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(entityHost, EntityHost);
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(entityHostType, EntityHostType);
COPY_PROPERTY_FROM_QSCRIPTVALUE(owningAvatarID, QUuid, setOwningAvatarID);
COPY_PROPERTY_FROM_QSCRIPTVALUE(dpi, uint16_t, setDPI);
@ -1958,7 +1958,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
COPY_PROPERTY_IF_CHANGED(ghostingAllowed);
COPY_PROPERTY_IF_CHANGED(filterURL);
COPY_PROPERTY_IF_CHANGED(entityHost);
COPY_PROPERTY_IF_CHANGED(entityHostType);
COPY_PROPERTY_IF_CHANGED(owningAvatarID);
COPY_PROPERTY_IF_CHANGED(dpi);
@ -3244,7 +3244,7 @@ void EntityItemProperties::markAllChanged() {
_ghostingAllowedChanged = true;
_filterURLChanged = true;
_entityHostChanged = true;
_entityHostTypeChanged = true;
_owningAvatarIDChanged = true;
_dpiChanged = true;
@ -3743,8 +3743,8 @@ QList<QString> EntityItemProperties::listChangedProperties() {
out += "queryAACube";
}
if (entityHostChanged()) {
out += "entityHost";
if (entityHostTypeChanged()) {
out += "entityHostType";
}
if (owningAvatarIDChanged()) {
out += "owningAvatarID";
@ -3819,7 +3819,7 @@ bool EntityItemProperties::getScalesWithParent() const {
if (success && parent) {
bool avatarAncestor = (parent->getNestableType() == NestableType::Avatar ||
parent->hasAncestorOfType(NestableType::Avatar));
scalesWithParent = getEntityHost() == EntityHost::AVATAR_ENTITY && avatarAncestor;
scalesWithParent = getEntityHostType() == entity::HostType::AVATAR && avatarAncestor;
}
}
return scalesWithParent;
@ -3977,11 +3977,11 @@ void EntityItemProperties::convertToCloneProperties(const EntityItemID& entityID
setParentJointIndex(-1);
setLifetime(getCloneLifetime());
setDynamic(getCloneDynamic());
if (getEntityHost() != EntityHost::LOCAL_ENTITY) {
setEntityHost(getCloneAvatarEntity() ? EntityHost::AVATAR_ENTITY : EntityHost::DOMAIN_ENTITY);
if (getEntityHostType() != entity::HostType::LOCAL) {
setEntityHostType(getCloneAvatarEntity() ? entity::HostType::AVATAR : entity::HostType::DOMAIN);
} else {
// Local Entities clone as local entities
setEntityHost(EntityHost::LOCAL_ENTITY);
setEntityHostType(entity::HostType::LOCAL);
setCollisionless(true);
}
setCreated(usecTimestampNow());

View file

@ -279,7 +279,7 @@ public:
DEFINE_PROPERTY(PROP_GHOSTING_ALLOWED, GhostingAllowed, ghostingAllowed, bool, ZoneEntityItem::DEFAULT_GHOSTING_ALLOWED);
DEFINE_PROPERTY(PROP_FILTER_URL, FilterURL, filterURL, QString, ZoneEntityItem::DEFAULT_FILTER_URL);
DEFINE_PROPERTY_REF_ENUM(PROP_ENTITY_HOST, EntityHost, entityHost, EntityHost, EntityHost::DOMAIN_ENTITY);
DEFINE_PROPERTY_REF_ENUM(PROP_ENTITY_HOST_TYPE, EntityHostType, entityHostType, entity::HostType, entity::HostType::DOMAIN);
DEFINE_PROPERTY_REF(PROP_OWNING_AVATAR_ID, OwningAvatarID, owningAvatarID, QUuid, UNKNOWN_ENTITY_ID);
DEFINE_PROPERTY_REF(PROP_DPI, DPI, dpi, uint16_t, ENTITY_ITEM_DEFAULT_DPI);
@ -589,7 +589,7 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
DEBUG_PROPERTY_IF_CHANGED(debug, properties, GhostingAllowed, ghostingAllowed, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, FilterURL, filterURL, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, EntityHostAsString, entityHost, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, EntityHostTypeAsString, entityHostType, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, OwningAvatarID, owningAvatarID, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, LastEditedBy, lastEditedBy, "");

View file

@ -121,7 +121,7 @@ QDebug& operator<<(QDebug& dbg, const EntityPropertyFlags& f) {
result = f.getHasProperty(PROP_FALLOFF_RADIUS) ? result + "falloffRadius " : result;
result = f.getHasProperty(PROP_FLYING_ALLOWED) ? result + "flyingAllowed " : result;
result = f.getHasProperty(PROP_GHOSTING_ALLOWED) ? result + "ghostingAllowed " : result;
result = f.getHasProperty(PROP_ENTITY_HOST) ? result + "entityHost " : result;
result = f.getHasProperty(PROP_ENTITY_HOST_TYPE) ? result + "entityHostType " : result;
result = f.getHasProperty(PROP_OWNING_AVATAR_ID) ? result + "owningAvatarID " : result;
result = f.getHasProperty(PROP_SHAPE) ? result + "shape " : result;
result = f.getHasProperty(PROP_DPI) ? result + "dpi " : result;

View file

@ -176,7 +176,7 @@ enum EntityPropertyList {
PROP_FLYING_ALLOWED, // can avatars in a zone fly?
PROP_GHOSTING_ALLOWED, // can avatars in a zone turn off physics?
PROP_ENTITY_HOST, // doesn't go over wire
PROP_ENTITY_HOST_TYPE, // doesn't go over wire
PROP_OWNING_AVATAR_ID, // doesn't go over wire
PROP_SHAPE,

View file

@ -470,7 +470,7 @@ void synchronizeEditedGrabProperties(EntityItemProperties& properties, const QSt
}
QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties, const QString& entityHostString) {
QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties, const QString& entityHostTypeString) {
PROFILE_RANGE(script_entities, __FUNCTION__);
_activityTracking.addedEntityCount++;
@ -479,10 +479,10 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
const auto sessionID = nodeList->getSessionUUID();
EntityItemProperties propertiesWithSimID = properties;
propertiesWithSimID.setEntityHostFromString(entityHostString);
if (propertiesWithSimID.getEntityHost() == EntityHost::AVATAR_ENTITY) {
propertiesWithSimID.setEntityHostTypeFromString(entityHostTypeString);
if (propertiesWithSimID.getEntityHostType() == entity::HostType::AVATAR) {
propertiesWithSimID.setOwningAvatarID(sessionID);
} else if (propertiesWithSimID.getEntityHost() == EntityHost::LOCAL_ENTITY) {
} else if (propertiesWithSimID.getEntityHostType() == entity::HostType::LOCAL) {
// For now, local entities are always collisionless
// TODO: create a separate, local physics simulation that just handles local entities (and MyAvatar?)
propertiesWithSimID.setCollisionless(true);
@ -572,7 +572,7 @@ QUuid EntityScriptingInterface::cloneEntity(QUuid entityIDToClone) {
bool cloneAvatarEntity = properties.getCloneAvatarEntity();
properties.convertToCloneProperties(entityIDToClone);
if (properties.getEntityHost() == EntityHost::LOCAL_ENTITY) {
if (properties.getEntityHostType() == entity::HostType::LOCAL) {
// Local entities are only cloned locally
return addEntity(properties, "local");
} else if (cloneAvatarEntity) {
@ -838,9 +838,9 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
}
// set these to make EntityItemProperties::getScalesWithParent() work correctly
EntityHost entityHost = entity->getEntityHost();
properties.setEntityHost(entityHost);
if (entityHost == EntityHost::LOCAL_ENTITY) {
entity::HostType entityHostType = entity->getEntityHostType();
properties.setEntityHostType(entityHostType);
if (entityHostType == entity::HostType::LOCAL) {
properties.setCollisionless(true);
}
properties.setOwningAvatarID(entity->getOwningAvatarID());
@ -1660,7 +1660,7 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID,
doTransmit = actor(simulation, entity);
_entityTree->entityChanged(entity);
if (doTransmit) {
properties.setEntityHost(entity->getEntityHost());
properties.setEntityHostType(entity->getEntityHostType());
properties.setOwningAvatarID(entity->getOwningAvatarID());
}
});

View file

@ -245,14 +245,14 @@ public slots:
* <tr><td><code>local</code></td><td>Local entities are not sent over the wire and will only render for you, locally</td></tr>
* </tbody>
* </table>
* @typedef {string} EntityHost
* @typedef {string} EntityHostType
*/
/**jsdoc
* Add a new entity with specified properties.
* @function Entities.addEntity
* @param {Entities.EntityProperties} properties - The properties of the entity to create.
* @param {EntityHost} [entityHost="domain"] - If <code>"avatar"</code> the entity is created as an avatar entity. An avatar entity
* @param {EntityHostType} [entityHostType="domain"] - If <code>"avatar"</code> the entity is created as an avatar entity. An avatar entity
* follows you to each domain you visit, rendering at the same world coordinates unless it's parented to your avatar.
* If <code>"local"</code>, the entity is created as a local entity, which will only render for you and isn't sent over the wire.
* Otherwise it is created as a normal entity and sent over the entity server.
@ -266,7 +266,7 @@ public slots:
* });
* print("Entity created: " + entityID);
*/
Q_INVOKABLE QUuid addEntity(const EntityItemProperties& properties, const QString& entityHostString);
Q_INVOKABLE QUuid addEntity(const EntityItemProperties& properties, const QString& entityHostTypeString);
/**jsdoc
* Add a new entity with specified properties.
@ -276,8 +276,8 @@ public slots:
* @returns {Uuid} The ID of the entity if successfully created, otherwise {@link Uuid|Uuid.NULL}.
*/
Q_INVOKABLE QUuid addEntity(const EntityItemProperties& properties, bool avatarEntity = false) {
QString entityHost = avatarEntity ? "avatar" : "domain";
return addEntity(properties, entityHost);
QString entityHostType = avatarEntity ? "avatar" : "domain";
return addEntity(properties, entityHostType);
}
/// temporary method until addEntity can be used from QJSEngine

View file

@ -541,7 +541,7 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
return nullptr;
}
if (properties.getEntityHost() == EntityHost::DOMAIN_ENTITY && getIsClient() &&
if (properties.getEntityHostType() == entity::HostType::DOMAIN && getIsClient() &&
!nodeList->getThisNodeCanRez() && !nodeList->getThisNodeCanRezTmp() &&
!nodeList->getThisNodeCanRezCertified() && !nodeList->getThisNodeCanRezTmpCertified() && !_serverlessDomain && !isClone) {
return nullptr;
@ -2668,15 +2668,15 @@ bool EntityTree::readFromMap(QVariantMap& map) {
entityItemID = EntityItemID(QUuid::createUuid());
}
// Convert old clientOnly bool to new entityHost enum
// Convert old clientOnly bool to new entityHostType enum
// (must happen before setOwningAvatarID below)
if (contentVersion < (int)EntityVersion::EntityHosts) {
if (contentVersion < (int)EntityVersion::EntityHostTypes) {
if (entityMap.contains("clientOnly")) {
properties.setEntityHost(entityMap["clientOnly"].toBool() ? EntityHost::AVATAR_ENTITY : EntityHost::DOMAIN_ENTITY);
properties.setEntityHostType(entityMap["clientOnly"].toBool() ? entity::HostType::AVATAR : entity::HostType::DOMAIN);
}
}
if (properties.getEntityHost() == EntityHost::AVATAR_ENTITY) {
if (properties.getEntityHostType() == entity::HostType::AVATAR) {
auto nodeList = DependencyManager::get<NodeList>();
const QUuid myNodeID = nodeList->getSessionUUID();
properties.setOwningAvatarID(myNodeID);

View file

@ -33,7 +33,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
case PacketType::EntityEdit:
case PacketType::EntityData:
case PacketType::EntityPhysics:
return static_cast<PacketVersion>(EntityVersion::EntityHosts);
return static_cast<PacketVersion>(EntityVersion::EntityHostTypes);
case PacketType::EntityQuery:
return static_cast<PacketVersion>(EntityQueryPacketVersion::ConicalFrustums);
case PacketType::AvatarIdentity:

View file

@ -246,7 +246,7 @@ enum class EntityVersion : PacketVersion {
GrabProperties,
ScriptGlmVectors,
FixedLightSerialization,
EntityHosts
EntityHostTypes
};
enum class EntityScriptCallMethodVersion : PacketVersion {

View file

@ -595,7 +595,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
EntityTreeElementPointer element = _entity->getElement();
EntityTreePointer tree = element ? element->getTree() : nullptr;
properties.setEntityHost(_entity->getEntityHost());
properties.setEntityHostType(_entity->getEntityHostType());
properties.setOwningAvatarID(_entity->getOwningAvatarID());
entityPacketSender->queueEditEntityMessage(PacketType::EntityPhysics, tree, id, properties);
@ -610,7 +610,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
EntityItemProperties newQueryCubeProperties;
newQueryCubeProperties.setQueryAACube(descendant->getQueryAACube());
newQueryCubeProperties.setLastEdited(properties.getLastEdited());
newQueryCubeProperties.setEntityHost(entityDescendant->getEntityHost());
newQueryCubeProperties.setEntityHostType(entityDescendant->getEntityHostType());
newQueryCubeProperties.setOwningAvatarID(entityDescendant->getOwningAvatarID());
entityPacketSender->queueEditEntityMessage(PacketType::EntityPhysics, tree,