Fix importing of PolyVox entities

PolyVox entities reference neighboring PolyVox entities in their entity
properties so that they can be stitched together. When importing, a new ID is
generated for each entity. When importing PolyVox entities, the
neighboring entity IDs were not updated to reflect the newly generated
IDs. This commit fixes that.
This commit is contained in:
Ryan Huffman 2017-01-30 13:33:42 -08:00
parent ae8d0d1948
commit f553656e36

View file

@ -1552,6 +1552,8 @@ 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
@ -1567,6 +1569,43 @@ bool EntityTree::sendEntitiesOperation(OctreeElementPointer element, void* extra
}
}
if (!properties.getXNNeighborID().isInvalidID()) {
auto neighborEntity = args->ourTree->findEntityByEntityItemID(properties.getXNNeighborID());
if (neighborEntity) {
properties.setXNNeighborID(getMapped(neighborEntity));
}
}
if (!properties.getXPNeighborID().isInvalidID()) {
auto neighborEntity = args->ourTree->findEntityByEntityItemID(properties.getXPNeighborID());
if (neighborEntity) {
properties.setXPNeighborID(getMapped(neighborEntity));
}
}
if (!properties.getYNNeighborID().isInvalidID()) {
auto neighborEntity = args->ourTree->findEntityByEntityItemID(properties.getYNNeighborID());
if (neighborEntity) {
properties.setYNNeighborID(getMapped(neighborEntity));
}
}
if (!properties.getYPNeighborID().isInvalidID()) {
auto neighborEntity = args->ourTree->findEntityByEntityItemID(properties.getYPNeighborID());
if (neighborEntity) {
properties.setYPNeighborID(getMapped(neighborEntity));
}
}
if (!properties.getZNNeighborID().isInvalidID()) {
auto neighborEntity = args->ourTree->findEntityByEntityItemID(properties.getZNNeighborID());
if (neighborEntity) {
properties.setZNNeighborID(getMapped(neighborEntity));
}
}
if (!properties.getZPNeighborID().isInvalidID()) {
auto neighborEntity = args->ourTree->findEntityByEntityItemID(properties.getZPNeighborID());
if (neighborEntity) {
properties.setZPNeighborID(getMapped(neighborEntity));
}
}
// set creation time to "now" for imported entities
properties.setCreated(usecTimestampNow());
@ -1584,7 +1623,6 @@ bool EntityTree::sendEntitiesOperation(OctreeElementPointer element, void* extra
args->otherTree->addEntity(newID, properties);
});
}
args->map->insert(oldID, newID);
return newID;
};