本文整理汇总了C++中EntityTreePointer类的典型用法代码示例。如果您正苦于以下问题:C++ EntityTreePointer类的具体用法?C++ EntityTreePointer怎么用?C++ EntityTreePointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EntityTreePointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: usecTimestampNow
int EntityServer::sendSpecialPackets(const SharedNodePointer& node, OctreeQueryNode* queryNode, int& packetsSent) {
int totalBytes = 0;
EntityNodeData* nodeData = static_cast<EntityNodeData*>(node->getLinkedData());
if (nodeData) {
quint64 deletedEntitiesSentAt = nodeData->getLastDeletedEntitiesSentAt();
quint64 deletePacketSentAt = usecTimestampNow();
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
bool hasMoreToSend = true;
packetsSent = 0;
while (hasMoreToSend) {
auto specialPacket = tree->encodeEntitiesDeletedSince(queryNode->getSequenceNumber(), deletedEntitiesSentAt,
hasMoreToSend);
queryNode->packetSent(*specialPacket);
totalBytes += specialPacket->getDataSize();
packetsSent++;
DependencyManager::get<NodeList>()->sendPacket(std::move(specialPacket), *node);
}
nodeData->setLastDeletedEntitiesSentAt(deletePacketSentAt);
}
// TODO: caller is expecting a packetLength, what if we send more than one packet??
return totalBytes;
}
示例2: elementAddChildTests
void OctreeTests::elementAddChildTests() {
EntityTreePointer tree = std::make_shared<EntityTree>();
auto elem = tree->createNewElement();
QCOMPARE((bool)elem->getChildAtIndex(0), false);
elem->addChildAtIndex(0);
QCOMPARE((bool)elem->getChildAtIndex(0), true);
const int MAX_CHILD_INDEX = 8;
for (int i = 0; i < MAX_CHILD_INDEX; i++) {
for (int j = 0; j < MAX_CHILD_INDEX; j++) {
auto e = tree->createNewElement();
// add a single child.
auto firstChild = e->addChildAtIndex(i);
QCOMPARE(e->getChildAtIndex(i), firstChild);
if (i != j) {
// add a second child.
auto secondChild = e->addChildAtIndex(j);
QCOMPARE(e->getChildAtIndex(i), firstChild);
QCOMPARE(e->getChildAtIndex(j), secondChild);
// remove scecond child.
e->removeChildAtIndex(j);
QCOMPARE((bool)e->getChildAtIndex(j), false);
}
QCOMPARE(e->getChildAtIndex(i), firstChild);
}
}
}
示例3: removeDeadAvatarEntities
void AvatarManager::removeDeadAvatarEntities(const SetOfEntities& deadEntities) {
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
for (auto entity : deadEntities) {
QUuid entityOwnerID = entity->getOwningAvatarID();
AvatarSharedPointer avatar = getAvatarBySessionID(entityOwnerID);
const bool REQUIRES_REMOVAL_FROM_TREE = false;
if (avatar) {
avatar->clearAvatarEntity(entity->getID(), REQUIRES_REMOVAL_FROM_TREE);
}
if (entityTree && entity->isMyAvatarEntity()) {
entityTree->withWriteLock([&] {
// We only need to delete the direct children (rather than the descendants) because
// when the child is deleted, it will take care of its own children. If the child
// is also an avatar-entity, we'll end up back here. If it's not, the entity-server
// will take care of it in the usual way.
entity->forEachChild([&](SpatiallyNestablePointer child) {
EntityItemPointer childEntity = std::dynamic_pointer_cast<EntityItem>(child);
if (childEntity) {
entityTree->deleteEntity(childEntity->getID(), true, true);
if (avatar) {
avatar->clearAvatarEntity(childEntity->getID(), REQUIRES_REMOVAL_FROM_TREE);
}
}
});
});
}
}
}
示例4: update
void EntityTreeHeadlessViewer::update() {
if (_tree) {
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
tree->withTryWriteLock([&] {
tree->update();
});
}
}
示例5:
EntityServer::~EntityServer() {
if (_pruneDeletedEntitiesTimer) {
_pruneDeletedEntitiesTimer->stop();
_pruneDeletedEntitiesTimer->deleteLater();
}
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
tree->removeNewlyCreatedHook(this);
}
示例6: SimpleEntitySimulation
void EntityTreeHeadlessViewer::init() {
OctreeHeadlessViewer::init();
if (!_simulation) {
SimpleEntitySimulationPointer simpleSimulation { new SimpleEntitySimulation() };
EntityTreePointer entityTree = std::static_pointer_cast<EntityTree>(_tree);
simpleSimulation->setEntityTree(entityTree);
entityTree->setSimulation(simpleSimulation);
_simulation = simpleSimulation;
}
}
示例7: readOptionBool
bool EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectionObject) {
bool wantEditLogging = false;
readOptionBool(QString("wantEditLogging"), settingsSectionObject, wantEditLogging);
qDebug("wantEditLogging=%s", debug::valueOf(wantEditLogging));
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
tree->setWantEditLogging(wantEditLogging);
return true;
}
示例8: addAvatarEntities
void addAvatarEntities(const QVariantList& avatarEntities) {
auto nodeList = DependencyManager::get<NodeList>();
const QUuid myNodeID = nodeList->getSessionUUID();
EntityTreePointer entityTree = DependencyManager::get<EntityTreeRenderer>()->getTree();
if (!entityTree) {
return;
}
EntitySimulationPointer entitySimulation = entityTree->getSimulation();
PhysicalEntitySimulationPointer physicalEntitySimulation = std::static_pointer_cast<PhysicalEntitySimulation>(entitySimulation);
EntityEditPacketSender* entityPacketSender = physicalEntitySimulation->getPacketSender();
QScriptEngine scriptEngine;
for (int index = 0; index < avatarEntities.count(); index++) {
const QVariantMap& avatarEntityProperties = avatarEntities.at(index).toMap();
QVariant variantProperties = avatarEntityProperties["properties"];
QVariantMap asMap = variantProperties.toMap();
QScriptValue scriptProperties = variantMapToScriptValue(asMap, scriptEngine);
EntityItemProperties entityProperties;
EntityItemPropertiesFromScriptValueHonorReadOnly(scriptProperties, entityProperties);
entityProperties.setParentID(myNodeID);
entityProperties.setClientOnly(true);
entityProperties.setOwningAvatarID(myNodeID);
entityProperties.setSimulationOwner(myNodeID, AVATAR_ENTITY_SIMULATION_PRIORITY);
entityProperties.markAllChanged();
EntityItemID id = EntityItemID(QUuid::createUuid());
bool success = true;
entityTree->withWriteLock([&] {
EntityItemPointer entity = entityTree->addEntity(id, entityProperties);
if (entity) {
if (entityProperties.queryAACubeRelatedPropertyChanged()) {
// due to parenting, the server may not know where something is in world-space, so include the bounding cube.
bool success;
AACube queryAACube = entity->getQueryAACube(success);
if (success) {
entityProperties.setQueryAACube(queryAACube);
}
}
entity->setLastBroadcast(usecTimestampNow());
// since we're creating this object we will immediately volunteer to own its simulation
entity->flagForOwnershipBid(VOLUNTEER_SIMULATION_PRIORITY);
entityProperties.setLastEdited(entity->getLastEdited());
} else {
qCDebug(entities) << "AvatarEntitiesBookmark failed to add new Entity to local Octree";
success = false;
}
});
if (success) {
entityPacketSender->queueEditEntityMessage(PacketType::EntityAdd, entityTree, id, entityProperties);
}
}
}
示例9: getCompoundShapeURL
void RenderableModelEntityItem::setCompoundShapeURL(const QString& url) {
auto currentCompoundShapeURL = getCompoundShapeURL();
ModelEntityItem::setCompoundShapeURL(url);
if (getCompoundShapeURL() != currentCompoundShapeURL || !_model) {
EntityTreePointer tree = getTree();
if (tree) {
QMetaObject::invokeMethod(tree.get(), "callLoader", Qt::QueuedConnection, Q_ARG(EntityItemID, getID()));
}
}
}
示例10: getParsedModelURL
void RenderableModelEntityItem::setModelURL(const QString& url) {
auto& currentURL = getParsedModelURL();
ModelEntityItem::setModelURL(url);
if (currentURL != getParsedModelURL() || !_model) {
EntityTreePointer tree = getTree();
if (tree) {
QMetaObject::invokeMethod(tree.get(), "callLoader", Qt::QueuedConnection, Q_ARG(EntityItemID, getID()));
}
}
}
示例11: EntityTreePointer
OctreePointer EntityServer::createTree() {
EntityTreePointer tree = EntityTreePointer(new EntityTree(true));
tree->createRootElement();
tree->addNewlyCreatedHook(this);
if (!_entitySimulation) {
SimpleEntitySimulation* simpleSimulation = new SimpleEntitySimulation();
simpleSimulation->setEntityTree(tree);
tree->setSimulation(simpleSimulation);
_entitySimulation = simpleSimulation;
}
return tree;
}
示例12: withReadLock
EntityItemPointer ObjectDynamic::getEntityByID(EntityItemID entityID) const {
EntityItemPointer ownerEntity;
withReadLock([&]{
ownerEntity = _ownerEntity.lock();
});
EntityTreeElementPointer element = ownerEntity ? ownerEntity->getElement() : nullptr;
EntityTreePointer tree = element ? element->getTree() : nullptr;
if (!tree) {
return nullptr;
}
return tree->findEntityByID(entityID);
}
示例13: hasSpecialPacketsToSend
// EntityServer will use the "special packets" to send list of recently deleted entities
bool EntityServer::hasSpecialPacketsToSend(const SharedNodePointer& node) {
bool shouldSendDeletedEntities = false;
// check to see if any new entities have been added since we last sent to this node...
EntityNodeData* nodeData = static_cast<EntityNodeData*>(node->getLinkedData());
if (nodeData) {
quint64 deletedEntitiesSentAt = nodeData->getLastDeletedEntitiesSentAt();
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
shouldSendDeletedEntities = tree->hasEntitiesDeletedSince(deletedEntitiesSentAt);
}
return shouldSendDeletedEntities;
}
示例14: EntityTreePointer
OctreePointer EntityServer::createTree() {
EntityTreePointer tree = EntityTreePointer(new EntityTree(true));
tree->createRootElement();
tree->addNewlyCreatedHook(this);
if (!_entitySimulation) {
SimpleEntitySimulationPointer simpleSimulation { new SimpleEntitySimulation() };
simpleSimulation->setEntityTree(tree);
tree->setSimulation(simpleSimulation);
_entitySimulation = simpleSimulation;
}
DependencyManager::registerInheritance<SpatialParentFinder, AssignmentParentFinder>();
DependencyManager::set<AssignmentParentFinder>(tree);
return tree;
}
示例15: pruneDeletedEntities
void EntityServer::pruneDeletedEntities() {
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
if (tree->hasAnyDeletedEntities()) {
quint64 earliestLastDeletedEntitiesSent = usecTimestampNow() + 1; // in the future
DependencyManager::get<NodeList>()->eachNode([&earliestLastDeletedEntitiesSent](const SharedNodePointer& node) {
if (node->getLinkedData()) {
EntityNodeData* nodeData = static_cast<EntityNodeData*>(node->getLinkedData());
quint64 nodeLastDeletedEntitiesSentAt = nodeData->getLastDeletedEntitiesSentAt();
if (nodeLastDeletedEntitiesSentAt < earliestLastDeletedEntitiesSent) {
earliestLastDeletedEntitiesSent = nodeLastDeletedEntitiesSentAt;
}
}
});
tree->forgetEntitiesDeletedBefore(earliestLastDeletedEntitiesSent);
}
}