mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
cleanup
This commit is contained in:
parent
bcb729eac2
commit
4ebf816166
3 changed files with 21 additions and 52 deletions
|
@ -2791,19 +2791,7 @@ void Application::calibrateEyeTracker5Points() {
|
|||
}
|
||||
#endif
|
||||
|
||||
bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs) {
|
||||
/* class EntityDatum { // For parent-first sorting and mapping.
|
||||
public:
|
||||
EntityItemPointer item;
|
||||
EntityItemProperties properties;
|
||||
EntityItemID originalParentID;
|
||||
EntityItemID mappedID;
|
||||
EntityDatum() {};
|
||||
EntityDatum(EntityItemPointer itemArg, EntityItemProperties propertiesArg, EntityItemID parentID) :
|
||||
item(itemArg), properties(propertiesArg), originalParentID(parentID) {
|
||||
};
|
||||
};
|
||||
QHash<EntityItemID, EntityDatum> entities;*/
|
||||
bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset) {
|
||||
QHash<EntityItemID, EntityItemPointer> entities;
|
||||
|
||||
auto entityTree = getEntities()->getTree();
|
||||
|
@ -2818,21 +2806,25 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt
|
|||
continue;
|
||||
}
|
||||
|
||||
EntityItemID parentID = entityItem->getParentID();
|
||||
if (parentID.isInvalidID() || !entityIDs.contains(parentID) || !entityTree->findEntityByEntityItemID(parentID)) {
|
||||
auto position = entityItem->getPosition(); // If parent wasn't selected, we want absolute position, which isn't in properties.
|
||||
root.x = glm::min(root.x, position.x);
|
||||
root.y = glm::min(root.y, position.y);
|
||||
root.z = glm::min(root.z, position.z);
|
||||
if (!givenOffset) {
|
||||
EntityItemID parentID = entityItem->getParentID();
|
||||
if (parentID.isInvalidID() || !entityIDs.contains(parentID) || !entityTree->findEntityByEntityItemID(parentID)) {
|
||||
auto position = entityItem->getPosition(); // If parent wasn't selected, we want absolute position, which isn't in properties.
|
||||
root.x = glm::min(root.x, position.x);
|
||||
root.y = glm::min(root.y, position.y);
|
||||
root.z = glm::min(root.z, position.z);
|
||||
}
|
||||
}
|
||||
entities[entityID] = entityItem; // EntityDatum(entityItem, entityItem->getProperties(), parentID);
|
||||
entities[entityID] = entityItem;
|
||||
}
|
||||
|
||||
if (entities.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//for (EntityDatum& entityDatum : entities) {
|
||||
if (givenOffset) {
|
||||
root = *givenOffset;
|
||||
}
|
||||
for (EntityItemPointer& entityDatum : entities) {
|
||||
auto properties = entityDatum->getProperties();
|
||||
EntityItemID parentID = properties.getParentID();
|
||||
|
@ -2852,33 +2844,14 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt
|
|||
}
|
||||
|
||||
bool Application::exportEntities(const QString& filename, float x, float y, float z, float scale) {
|
||||
glm::vec3 offset(x, y, z);
|
||||
QVector<EntityItemPointer> entities;
|
||||
getEntities()->getTree()->findEntities(AACube(glm::vec3(x, y, z), scale), entities);
|
||||
|
||||
if (entities.size() > 0) {
|
||||
glm::vec3 root(x, y, z);
|
||||
auto exportTree = std::make_shared<EntityTree>();
|
||||
exportTree->createRootElement();
|
||||
|
||||
for (int i = 0; i < entities.size(); i++) {
|
||||
EntityItemProperties properties = entities.at(i)->getProperties();
|
||||
EntityItemID id = entities.at(i)->getEntityItemID();
|
||||
properties.setPosition(properties.getPosition() - root);
|
||||
exportTree->addEntity(id, properties);
|
||||
}
|
||||
|
||||
// remap IDs on export so that we aren't publishing the IDs of entities in our domain
|
||||
exportTree->remapIDs();
|
||||
|
||||
exportTree->writeToSVOFile(filename.toLocal8Bit().constData());
|
||||
} else {
|
||||
qCDebug(interfaceapp) << "No models were selected";
|
||||
return false;
|
||||
QVector<EntityItemID> ids;
|
||||
getEntities()->getTree()->findEntities(AACube(offset, scale), entities);
|
||||
foreach(EntityItemPointer entity, entities) {
|
||||
ids << entity->getEntityItemID();
|
||||
}
|
||||
|
||||
// restore the main window's active state
|
||||
_window->activateWindow();
|
||||
return true;
|
||||
return exportEntities(filename, ids, &offset);
|
||||
}
|
||||
|
||||
void Application::loadSettings() {
|
||||
|
@ -2911,7 +2884,6 @@ bool Application::importEntities(const QString& urlOrFilename) {
|
|||
|
||||
bool success = _entityClipboard->readFromURL(urlOrFilename);
|
||||
if (success) {
|
||||
// FIXME _entityClipboard->remapIDs();
|
||||
_entityClipboard->reaverageOctreeElements();
|
||||
}
|
||||
return success;
|
||||
|
|
|
@ -233,7 +233,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset = nullptr);
|
||||
bool exportEntities(const QString& filename, float x, float y, float z, float scale);
|
||||
bool importEntities(const QString& url);
|
||||
|
||||
|
|
|
@ -1009,7 +1009,6 @@ void EntityTree::entityChanged(EntityItemPointer entity) {
|
|||
void EntityTree::fixupMissingParents() {
|
||||
MovingEntitiesOperator moveOperator(getThisPointer());
|
||||
|
||||
if (!_missingParent.empty()) qCDebug(entities) << "HRS fixme fixupMissingParents" << _missingParent.count() << "entities";
|
||||
QMutableVectorIterator<EntityItemWeakPointer> iter(_missingParent);
|
||||
while (iter.hasNext()) {
|
||||
EntityItemWeakPointer entityWP = iter.next();
|
||||
|
@ -1028,7 +1027,6 @@ void EntityTree::fixupMissingParents() {
|
|||
|
||||
bool doMove = false;
|
||||
if (entity->isParentIDValid()) {
|
||||
qCDebug(entities) << "HRS fixme valid parent" << entity->getEntityItemID() << queryAACubeSuccess;
|
||||
// this entity's parent was previously not known, and now is. Update its location in the EntityTree...
|
||||
doMove = true;
|
||||
} else if (getIsServer() && _avatarIDs.contains(entity->getParentID())) {
|
||||
|
@ -1040,7 +1038,6 @@ void EntityTree::fixupMissingParents() {
|
|||
_childrenOfAvatars[entity->getParentID()] += entity->getEntityItemID();
|
||||
doMove = true;
|
||||
}
|
||||
else qCDebug(entities) << "HRS fixme failed parent" << entity->getEntityItemID() << queryAACubeSuccess << "parent:" << entity->getParentID() << !!findEntityByID(entity->getParentID());
|
||||
|
||||
if (queryAACubeSuccess && doMove) {
|
||||
moveOperator.addEntityToMoveList(entity, newCube);
|
||||
|
@ -1342,7 +1339,6 @@ bool EntityTree::sendEntitiesOperation(OctreeElementPointer element, void* extra
|
|||
return args->map->value(oldID);
|
||||
}
|
||||
EntityItemID newID = QUuid::createUuid();
|
||||
args->map->insert(oldID, newID);
|
||||
EntityItemProperties properties = item->getProperties();
|
||||
EntityItemID oldParentID = properties.getParentID();
|
||||
if (oldParentID.isInvalidID()) { // no parent
|
||||
|
@ -1368,6 +1364,7 @@ bool EntityTree::sendEntitiesOperation(OctreeElementPointer element, void* extra
|
|||
args->otherTree->addEntity(newID, properties);
|
||||
});
|
||||
}
|
||||
args->map->insert(oldID, newID);
|
||||
return newID;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue