mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Fix use of EntityTree in import/export operations
The EntityTree needs to be references by a shared_ptr somewhere. The EntityTree does not start with a root element by default, which some operations rely on to work as expected.
This commit is contained in:
parent
2d477ad3b9
commit
dde1c8b42f
1 changed files with 8 additions and 6 deletions
|
@ -2337,7 +2337,8 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt
|
|||
QVector<EntityItemPointer> entities;
|
||||
|
||||
auto entityTree = _entities.getTree();
|
||||
EntityTree exportTree;
|
||||
auto exportTree = std::make_shared<EntityTree>();
|
||||
exportTree->createRootElement();
|
||||
|
||||
glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE);
|
||||
for (auto entityID : entityIDs) {
|
||||
|
@ -2364,10 +2365,10 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt
|
|||
auto properties = entityItem->getProperties();
|
||||
|
||||
properties.setPosition(properties.getPosition() - root);
|
||||
exportTree.addEntity(entityItem->getEntityItemID(), properties);
|
||||
exportTree->addEntity(entityItem->getEntityItemID(), properties);
|
||||
}
|
||||
|
||||
exportTree.writeToJSONFile(filename.toLocal8Bit().constData());
|
||||
exportTree->writeToJSONFile(filename.toLocal8Bit().constData());
|
||||
|
||||
// restore the main window's active state
|
||||
_window->activateWindow();
|
||||
|
@ -2380,15 +2381,16 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
|
|||
|
||||
if (entities.size() > 0) {
|
||||
glm::vec3 root(x, y, z);
|
||||
EntityTree exportTree;
|
||||
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);
|
||||
exportTree->addEntity(id, properties);
|
||||
}
|
||||
exportTree.writeToSVOFile(filename.toLocal8Bit().constData());
|
||||
exportTree->writeToSVOFile(filename.toLocal8Bit().constData());
|
||||
} else {
|
||||
qCDebug(interfaceapp) << "No models were selected";
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue