当前位置: 首页>>代码示例>>C++>>正文


C++ EntityTreePointer::findEntityByEntityItemID方法代码示例

本文整理汇总了C++中EntityTreePointer::findEntityByEntityItemID方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityTreePointer::findEntityByEntityItemID方法的具体用法?C++ EntityTreePointer::findEntityByEntityItemID怎么用?C++ EntityTreePointer::findEntityByEntityItemID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityTreePointer的用法示例。


在下文中一共展示了EntityTreePointer::findEntityByEntityItemID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: queueEditAvatarEntityMessage

void EntityEditPacketSender::queueEditAvatarEntityMessage(PacketType type,
        EntityTreePointer entityTree,
        EntityItemID entityItemID,
        const EntityItemProperties& properties) {
    if (!_shouldSend) {
        return; // bail early
    }

    if (properties.getOwningAvatarID() != _myAvatar->getID()) {
        return; // don't send updates for someone else's avatarEntity
    }

    assert(properties.getClientOnly());

    // this is an avatar-based entity.  update our avatar-data rather than sending to the entity-server
    assert(_myAvatar);

    if (!entityTree) {
        qCDebug(entities) << "EntityEditPacketSender::queueEditEntityMessage null entityTree.";
        return;
    }
    EntityItemPointer entity = entityTree->findEntityByEntityItemID(entityItemID);
    if (!entity) {
        qCDebug(entities) << "EntityEditPacketSender::queueEditEntityMessage can't find entity.";
        return;
    }

    // the properties that get serialized into the avatar identity packet should be the entire set
    // rather than just the ones being edited.
    EntityItemProperties entityProperties = entity->getProperties();
    entityProperties.merge(properties);

    QScriptValue scriptProperties = EntityItemNonDefaultPropertiesToScriptValue(&_scriptEngine, entityProperties);
    QVariant variantProperties = scriptProperties.toVariant();
    QJsonDocument jsonProperties = QJsonDocument::fromVariant(variantProperties);

    // the ID of the parent/avatar changes from session to session.  use a special UUID to indicate the avatar
    QJsonObject jsonObject = jsonProperties.object();
    if (QUuid(jsonObject["parentID"].toString()) == _myAvatar->getID()) {
        jsonObject["parentID"] = AVATAR_SELF_ID.toString();
    }
    jsonProperties = QJsonDocument(jsonObject);

    QByteArray binaryProperties = jsonProperties.toBinaryData();
    _myAvatar->updateAvatarEntity(entityItemID, binaryProperties);

    entity->setLastBroadcast(usecTimestampNow());
    return;
}
开发者ID:kitely,项目名称:hifiki,代码行数:49,代码来源:EntityEditPacketSender.cpp

示例2: find

SpatiallyNestableWeakPointer InterfaceParentFinder::find(QUuid parentID, bool& success, SpatialParentTree* entityTree) const {
    SpatiallyNestableWeakPointer parent;

    if (parentID.isNull()) {
        success = true;
        return parent;
    }

    // search entities
    if (entityTree) {
        parent = entityTree->findByID(parentID);
    } else {
        auto treeRenderer = qApp->getEntities();
        EntityTreePointer tree = treeRenderer ? treeRenderer->getTree() : nullptr;
        parent = tree ? tree->findEntityByEntityItemID(parentID) : nullptr;
    }
    if (!parent.expired()) {
        success = true;
        return parent;
    }

    // search avatars
    QSharedPointer<AvatarManager> avatarManager = DependencyManager::get<AvatarManager>();
    parent = avatarManager->getAvatarBySessionID(parentID);
    if (!parent.expired()) {
        success = true;
        return parent;
    }
    if (parentID == AVATAR_SELF_ID) {
        success = true;
        return avatarManager->getMyAvatar();
    }

    // search overlays
    auto& overlays = qApp->getOverlays();
    auto overlay = overlays.getOverlay(parentID);
    parent = std::dynamic_pointer_cast<SpatiallyNestable>(overlay); // this will return nullptr for non-3d overlays
    if (!parent.expired()) {
        success = true;
        return parent;
    }

    success = false;
    return parent;
}
开发者ID:Nex-Pro,项目名称:hifi,代码行数:45,代码来源:InterfaceParentFinder.cpp

示例3: find

    SpatiallyNestableWeakPointer find(QUuid parentID, bool& success, SpatialParentTree* entityTree = nullptr) const override {
        SpatiallyNestableWeakPointer parent;

        if (parentID.isNull()) {
            success = true;
            return parent;
        }

        // search entities
        if (entityTree) {
            parent = entityTree->findByID(parentID);
        } else {
            parent = _tree ? _tree->findEntityByEntityItemID(parentID) : nullptr;
        }

        if (!parent.expired()) {
            success = true;
            return parent;
        }

        success = false;
        return parent;
    }
开发者ID:imgntn,项目名称:hifi,代码行数:23,代码来源:main.cpp

示例4: startDynamicDomainVerification

void EntityServer::startDynamicDomainVerification() {
    qCDebug(entities) << "Starting Dynamic Domain Verification...";

    QString thisDomainID = DependencyManager::get<AddressManager>()->getDomainID().remove(QRegExp("\\{|\\}"));

    EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
    QHash<QString, EntityItemID> localMap(tree->getEntityCertificateIDMap());

    QHashIterator<QString, EntityItemID> i(localMap);
    qCDebug(entities) << localMap.size() << "entities in _entityCertificateIDMap";
    while (i.hasNext()) {
        i.next();

        EntityItemPointer entity = tree->findEntityByEntityItemID(i.value());

        if (entity) {
            if (!entity->getProperties().verifyStaticCertificateProperties()) {
                qCDebug(entities) << "During Dynamic Domain Verification, a certified entity with ID" << i.value() << "failed"
                    << "static certificate verification.";
                // Delete the entity if it doesn't pass static certificate verification
                tree->deleteEntity(i.value(), true);
            } else {

                QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
                QNetworkRequest networkRequest;
                networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
                networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
                QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL();
                requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/location");
                QJsonObject request;
                request["certificate_id"] = i.key();
                networkRequest.setUrl(requestURL);

                QNetworkReply* networkReply = NULL;
                networkReply = networkAccessManager.put(networkRequest, QJsonDocument(request).toJson());

                connect(networkReply, &QNetworkReply::finished, [=]() {
                    QJsonObject jsonObject = QJsonDocument::fromJson(networkReply->readAll()).object();
                    jsonObject = jsonObject["data"].toObject();

                    if (networkReply->error() == QNetworkReply::NoError) {
                        if (jsonObject["domain_id"].toString() != thisDomainID) {
                            qCDebug(entities) << "Entity's cert's domain ID" << jsonObject["domain_id"].toString()
                                << "doesn't match the current Domain ID" << thisDomainID << "; deleting entity" << i.value();
                            tree->deleteEntity(i.value(), true);
                        } else {
                            qCDebug(entities) << "Entity passed dynamic domain verification:" << i.value();
                        }
                    } else {
                        qCDebug(entities) << "Call to" << networkReply->url() << "failed with error" << networkReply->error() << "; deleting entity" << i.value()
                            << "More info:" << jsonObject;
                        tree->deleteEntity(i.value(), true);
                    }

                    networkReply->deleteLater();
                });
            }
        } else {
            qCWarning(entities) << "During DDV, an entity with ID" << i.value() << "was NOT found in the Entity Tree!";
        }
    }

    int nextInterval = qrand() % ((_MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS + 1) - _MINIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS) + _MINIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS;
    qCDebug(entities) << "Restarting Dynamic Domain Verification timer for" << nextInterval / 1000 << "seconds";
    _dynamicDomainVerificationTimer.start(nextInterval);
}
开发者ID:gcalero,项目名称:hifi,代码行数:66,代码来源:EntityServer.cpp


注:本文中的EntityTreePointer::findEntityByEntityItemID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。