Skip to content

Commit

Permalink
Fix paste disorder
Browse files Browse the repository at this point in the history
  • Loading branch information
huxingyi committed Feb 25, 2023
1 parent 7ffeeea commit 2c95374
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOGS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Feb 21, 2023:

- Add support to select two images and auto combine as background image
- Simplify shaders
Expand Down
6 changes: 3 additions & 3 deletions application/application.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ QT += core gui opengl widgets svg
TARGET = dust3d
TEMPLATE = app

HUMAN_VERSION = "1.0.0-rc.7"
VERSION = 1.0.0.37
HUMAN_VERSION = "1.0.0-rc.8"
VERSION = 1.0.0.38

QMAKE_TARGET_COMPANY = Dust3D
QMAKE_TARGET_PRODUCT = Dust3D
QMAKE_TARGET_DESCRIPTION = "Dust3D is a cross-platform open-source 3D modeling software"
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2018-2021 Dust3D Project. All Rights Reserved."
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2018-2023 Dust3D Project. All Rights Reserved."

HOMEPAGE_URL = "https://dust3d.org/"
REPOSITORY_URL = "https://github.com/huxingyi/dust3d"
Expand Down
37 changes: 35 additions & 2 deletions application/sources/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,6 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo
std::set<dust3d::Uuid> newAddedNodeIds;
std::set<dust3d::Uuid> newAddedEdgeIds;
std::set<dust3d::Uuid> newAddedPartIds;
std::set<dust3d::Uuid> newAddedComponentIds;

std::set<dust3d::Uuid> inversePartIds;

Expand Down Expand Up @@ -2015,6 +2014,27 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo
continue;
partMap[nodeIt.second.partId].nodeIds.push_back(nodeIt.first);
}
std::map<dust3d::Uuid, std::vector<dust3d::Uuid>> snapshotComponentChildMap;
if (SnapshotSource::Paste == source) {
for (const auto& componentKv : snapshot.components) {
auto componentId = dust3d::Uuid(componentKv.first);
for (const auto& childId : dust3d::String::split(dust3d::String::valueOrEmpty(componentKv.second, "children"), ',')) {
if (childId.empty())
continue;
dust3d::Uuid childComponentId = dust3d::Uuid(childId);
snapshotComponentChildMap[componentId].push_back(childComponentId);
}
}
const auto& rootComponentChildren = snapshot.rootComponent.find("children");
if (rootComponentChildren != snapshot.rootComponent.end()) {
for (const auto& childId : dust3d::String::split(rootComponentChildren->second, ',')) {
if (childId.empty())
continue;
dust3d::Uuid childComponentId = dust3d::Uuid(childId);
snapshotComponentChildMap[dust3d::Uuid()].push_back(childComponentId);
}
}
}
for (const auto& componentKv : snapshot.components) {
QString linkData = dust3d::String::valueOrEmpty(componentKv.second, "linkData").c_str();
QString linkDataType = dust3d::String::valueOrEmpty(componentKv.second, "linkDataType").c_str();
Expand Down Expand Up @@ -2060,9 +2080,22 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo
component.combineMode = dust3d::CombineMode::Inversion;
}
componentMap.emplace(componentId, std::move(component));
newAddedComponentIds.insert(componentId);
}
if (SnapshotSource::Paste == source) {
std::vector<dust3d::Uuid> newAddedComponentIds;
auto addChild = [&](const dust3d::Uuid& parentId) {
auto childIt = snapshotComponentChildMap.find(parentId);
if (childIt == snapshotComponentChildMap.end())
return;
for (const auto& it : childIt->second) {
auto newId = oldNewIdMap.find(it);
if (newId == oldNewIdMap.end())
continue;
newAddedComponentIds.push_back(newId->second);
}
};
for (const auto& it : snapshotComponentChildMap)
addChild(it.first);
if (m_currentCanvasComponentId.isNull()) {
for (const auto& childComponentId : newAddedComponentIds)
rootComponent.addChild(childComponentId);
Expand Down

0 comments on commit 2c95374

Please sign in to comment.