Fix load bone from document
parent
cfc26649f2
commit
c9aafb6a18
|
@ -1746,8 +1746,10 @@ void Document::toSnapshot(dust3d::Snapshot* snapshot, const std::set<dust3d::Uui
|
||||||
for (const auto& boneIt : boneMap) {
|
for (const auto& boneIt : boneMap) {
|
||||||
std::map<std::string, std::string> bone;
|
std::map<std::string, std::string> bone;
|
||||||
bone["id"] = boneIt.second.id.toString();
|
bone["id"] = boneIt.second.id.toString();
|
||||||
|
if (!boneIt.second.attachBoneId.isNull()) {
|
||||||
bone["attachBoneId"] = boneIt.second.attachBoneId.toString();
|
bone["attachBoneId"] = boneIt.second.attachBoneId.toString();
|
||||||
bone["attachBoneJointIndex"] = std::to_string(boneIt.second.attachBoneJointIndex);
|
bone["attachBoneJointIndex"] = std::to_string(boneIt.second.attachBoneJointIndex);
|
||||||
|
}
|
||||||
if (!boneIt.second.name.isEmpty())
|
if (!boneIt.second.name.isEmpty())
|
||||||
bone["name"] = boneIt.second.name.toUtf8().constData();
|
bone["name"] = boneIt.second.name.toUtf8().constData();
|
||||||
snapshot->bones[bone["id"]] = bone;
|
snapshot->bones[bone["id"]] = bone;
|
||||||
|
@ -1869,11 +1871,13 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo
|
||||||
}
|
}
|
||||||
for (const auto& boneKv : snapshot.bones) {
|
for (const auto& boneKv : snapshot.bones) {
|
||||||
Document::Bone bone;
|
Document::Bone bone;
|
||||||
oldNewIdMap[dust3d::Uuid(boneKv.first)] = bone.id;
|
auto boneId = bone.id;
|
||||||
|
oldNewIdMap[dust3d::Uuid(boneKv.first)] = boneId;
|
||||||
bone.name = dust3d::String::valueOrEmpty(boneKv.second, "name").c_str();
|
bone.name = dust3d::String::valueOrEmpty(boneKv.second, "name").c_str();
|
||||||
bone.attachBoneJointIndex = dust3d::String::toInt(dust3d::String::valueOrEmpty(boneKv.second, "attachBoneJointIndex").c_str());
|
bone.attachBoneJointIndex = dust3d::String::toInt(dust3d::String::valueOrEmpty(boneKv.second, "attachBoneJointIndex"));
|
||||||
boneMap.emplace(bone.id, std::move(bone));
|
boneMap.emplace(boneId, std::move(bone));
|
||||||
newAddedBoneIds.insert(bone.id);
|
boneIdList.push_back(boneId);
|
||||||
|
newAddedBoneIds.insert(boneId);
|
||||||
}
|
}
|
||||||
for (const auto& boneKv : snapshot.bones) {
|
for (const auto& boneKv : snapshot.bones) {
|
||||||
auto attachBoneId = dust3d::Uuid(dust3d::String::valueOrEmpty(boneKv.second, "attachBoneId"));
|
auto attachBoneId = dust3d::Uuid(dust3d::String::valueOrEmpty(boneKv.second, "attachBoneId"));
|
||||||
|
@ -1953,7 +1957,8 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo
|
||||||
QString linkData = dust3d::String::valueOrEmpty(componentKv.second, "linkData").c_str();
|
QString linkData = dust3d::String::valueOrEmpty(componentKv.second, "linkData").c_str();
|
||||||
QString linkDataType = dust3d::String::valueOrEmpty(componentKv.second, "linkDataType").c_str();
|
QString linkDataType = dust3d::String::valueOrEmpty(componentKv.second, "linkDataType").c_str();
|
||||||
Document::Component component(dust3d::Uuid(), linkData, linkDataType);
|
Document::Component component(dust3d::Uuid(), linkData, linkDataType);
|
||||||
oldNewIdMap[dust3d::Uuid(componentKv.first)] = component.id;
|
auto componentId = component.id;
|
||||||
|
oldNewIdMap[dust3d::Uuid(componentKv.first)] = componentId;
|
||||||
component.name = dust3d::String::valueOrEmpty(componentKv.second, "name").c_str();
|
component.name = dust3d::String::valueOrEmpty(componentKv.second, "name").c_str();
|
||||||
component.expanded = dust3d::String::isTrue(dust3d::String::valueOrEmpty(componentKv.second, "expanded"));
|
component.expanded = dust3d::String::isTrue(dust3d::String::valueOrEmpty(componentKv.second, "expanded"));
|
||||||
component.combineMode = dust3d::CombineModeFromString(dust3d::String::valueOrEmpty(componentKv.second, "combineMode").c_str());
|
component.combineMode = dust3d::CombineModeFromString(dust3d::String::valueOrEmpty(componentKv.second, "combineMode").c_str());
|
||||||
|
@ -1966,12 +1971,12 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo
|
||||||
dust3d::Uuid partId = oldNewIdMap[dust3d::Uuid(linkData.toUtf8().constData())];
|
dust3d::Uuid partId = oldNewIdMap[dust3d::Uuid(linkData.toUtf8().constData())];
|
||||||
component.linkToPartId = partId;
|
component.linkToPartId = partId;
|
||||||
//qDebug() << "Add part:" << partId << " from component:" << component.id;
|
//qDebug() << "Add part:" << partId << " from component:" << component.id;
|
||||||
partMap[partId].componentId = component.id;
|
partMap[partId].componentId = componentId;
|
||||||
if (inversePartIds.find(partId) != inversePartIds.end())
|
if (inversePartIds.find(partId) != inversePartIds.end())
|
||||||
component.combineMode = dust3d::CombineMode::Inversion;
|
component.combineMode = dust3d::CombineMode::Inversion;
|
||||||
}
|
}
|
||||||
componentMap.emplace(component.id, std::move(component));
|
componentMap.emplace(componentId, std::move(component));
|
||||||
newAddedComponentIds.insert(component.id);
|
newAddedComponentIds.insert(componentId);
|
||||||
}
|
}
|
||||||
const auto& rootComponentChildren = snapshot.rootComponent.find("children");
|
const auto& rootComponentChildren = snapshot.rootComponent.find("children");
|
||||||
if (rootComponentChildren != snapshot.rootComponent.end()) {
|
if (rootComponentChildren != snapshot.rootComponent.end()) {
|
||||||
|
@ -2018,6 +2023,7 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo
|
||||||
for (const auto& boneIt : newAddedBoneIds) {
|
for (const auto& boneIt : newAddedBoneIds) {
|
||||||
emit boneAdded(boneIt);
|
emit boneAdded(boneIt);
|
||||||
}
|
}
|
||||||
|
emit boneIdListChanged();
|
||||||
|
|
||||||
emit skeletonChanged();
|
emit skeletonChanged();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
None = 0,
|
None = 0,
|
||||||
Nodes = 0x00000001,
|
Nodes = 0x00000001,
|
||||||
Bones = 0x00000002,
|
Bones = 0x00000002,
|
||||||
Document = (Nodes | Bones)
|
Document = (SnapshotFor::Nodes | SnapshotFor::Bones)
|
||||||
};
|
};
|
||||||
|
|
||||||
class HistoryItem {
|
class HistoryItem {
|
||||||
|
|
|
@ -641,6 +641,7 @@ DocumentWindow::DocumentWindow()
|
||||||
|
|
||||||
connect(m_document, &Document::skeletonChanged, this, &DocumentWindow::documentChanged);
|
connect(m_document, &Document::skeletonChanged, this, &DocumentWindow::documentChanged);
|
||||||
connect(m_document, &Document::textureChanged, this, &DocumentWindow::documentChanged);
|
connect(m_document, &Document::textureChanged, this, &DocumentWindow::documentChanged);
|
||||||
|
connect(m_document, &Document::rigChanged, this, &DocumentWindow::documentChanged);
|
||||||
connect(m_document, &Document::turnaroundChanged, this, &DocumentWindow::documentChanged);
|
connect(m_document, &Document::turnaroundChanged, this, &DocumentWindow::documentChanged);
|
||||||
connect(m_document, &Document::optionsChanged, this, &DocumentWindow::documentChanged);
|
connect(m_document, &Document::optionsChanged, this, &DocumentWindow::documentChanged);
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,8 @@ namespace String {
|
||||||
|
|
||||||
inline int toInt(const std::string& string)
|
inline int toInt(const std::string& string)
|
||||||
{
|
{
|
||||||
|
if (string.empty())
|
||||||
|
return 0;
|
||||||
return std::stoi(string);
|
return std::stoi(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue