2022-10-18 09:35:04 +00:00
|
|
|
#include "document.h"
|
|
|
|
#include "image_forever.h"
|
|
|
|
#include "material_previews_generator.h"
|
|
|
|
#include "mesh_generator.h"
|
|
|
|
#include "mesh_result_post_processor.h"
|
|
|
|
#include "texture_generator.h"
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QClipboard>
|
2018-04-07 08:44:39 +00:00
|
|
|
#include <QDebug>
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <QElapsedTimer>
|
|
|
|
#include <QFileDialog>
|
2018-04-07 08:44:39 +00:00
|
|
|
#include <QGuiApplication>
|
2018-04-09 08:46:06 +00:00
|
|
|
#include <QMimeData>
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <QThread>
|
2018-04-12 12:27:21 +00:00
|
|
|
#include <QVector3D>
|
2020-03-18 14:17:09 +00:00
|
|
|
#include <QtCore/qbuffer.h>
|
2021-11-18 14:58:01 +00:00
|
|
|
#include <dust3d/base/snapshot_xml.h>
|
|
|
|
#include <dust3d/base/texture_type.h>
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <queue>
|
2018-04-07 08:44:39 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
unsigned long Document::m_maxSnapshot = 1000;
|
2018-04-08 23:34:46 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
Document::Document()
|
|
|
|
: SkeletonDocument()
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
2020-12-07 10:17:25 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
Document::~Document()
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
delete (dust3d::MeshGenerator::GeneratedCacheContext*)m_generatedCacheContext;
|
2018-04-07 08:44:39 +00:00
|
|
|
delete m_resultMesh;
|
2020-11-17 14:31:51 +00:00
|
|
|
delete m_postProcessedObject;
|
2018-05-07 16:08:19 +00:00
|
|
|
delete textureImage;
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureImageByteArray;
|
2018-11-15 22:56:24 +00:00
|
|
|
delete textureNormalImage;
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureNormalImageByteArray;
|
2018-11-28 03:00:03 +00:00
|
|
|
delete textureMetalnessImage;
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureMetalnessImageByteArray;
|
2018-11-28 03:00:03 +00:00
|
|
|
delete textureRoughnessImage;
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureRoughnessImageByteArray;
|
2018-11-28 03:00:03 +00:00
|
|
|
delete textureAmbientOcclusionImage;
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureAmbientOcclusionImageByteArray;
|
2018-05-10 09:16:22 +00:00
|
|
|
delete m_resultTextureMesh;
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::uiReady()
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
2018-04-10 07:59:20 +00:00
|
|
|
qDebug() << "uiReady";
|
2018-04-07 08:44:39 +00:00
|
|
|
emit editModeChanged();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
bool Document::originSettled() const
|
2018-04-15 12:11:51 +00:00
|
|
|
{
|
2019-10-19 13:14:36 +00:00
|
|
|
return !qFuzzyIsNull(getOriginX()) && !qFuzzyIsNull(getOriginY()) && !qFuzzyIsNull(getOriginZ());
|
2018-04-15 12:11:51 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
const Material* Document::findMaterial(dust3d::Uuid materialId) const
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
auto it = materialMap.find(materialId);
|
|
|
|
if (it == materialMap.end())
|
|
|
|
return nullptr;
|
|
|
|
return &it->second;
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setNodeCutRotation(dust3d::Uuid nodeId, float cutRotation)
|
2019-07-08 22:36:07 +00:00
|
|
|
{
|
|
|
|
auto node = nodeMap.find(nodeId);
|
|
|
|
if (node == nodeMap.end()) {
|
|
|
|
qDebug() << "Node not found:" << nodeId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (qFuzzyCompare(cutRotation, node->second.cutRotation))
|
|
|
|
return;
|
|
|
|
node->second.setCutRotation(cutRotation);
|
|
|
|
auto part = partMap.find(node->second.partId);
|
|
|
|
if (part != partMap.end())
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit nodeCutRotationChanged(nodeId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setNodeCutFace(dust3d::Uuid nodeId, dust3d::CutFace cutFace)
|
2019-07-08 22:36:07 +00:00
|
|
|
{
|
|
|
|
auto node = nodeMap.find(nodeId);
|
|
|
|
if (node == nodeMap.end()) {
|
|
|
|
qDebug() << "Node not found:" << nodeId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (node->second.cutFace == cutFace)
|
|
|
|
return;
|
|
|
|
node->second.setCutFace(cutFace);
|
|
|
|
auto part = partMap.find(node->second.partId);
|
|
|
|
if (part != partMap.end())
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit nodeCutFaceChanged(nodeId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setNodeCutFaceLinkedId(dust3d::Uuid nodeId, dust3d::Uuid linkedId)
|
2019-07-08 22:36:07 +00:00
|
|
|
{
|
|
|
|
auto node = nodeMap.find(nodeId);
|
|
|
|
if (node == nodeMap.end()) {
|
|
|
|
qDebug() << "Node not found:" << nodeId;
|
|
|
|
return;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
if (node->second.cutFace == dust3d::CutFace::UserDefined && node->second.cutFaceLinkedId == linkedId)
|
2019-07-08 22:36:07 +00:00
|
|
|
return;
|
|
|
|
node->second.setCutFaceLinkedId(linkedId);
|
|
|
|
auto part = partMap.find(node->second.partId);
|
|
|
|
if (part != partMap.end())
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit nodeCutFaceChanged(nodeId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::clearNodeCutFaceSettings(dust3d::Uuid nodeId)
|
2019-07-08 22:36:07 +00:00
|
|
|
{
|
|
|
|
auto node = nodeMap.find(nodeId);
|
|
|
|
if (node == nodeMap.end()) {
|
|
|
|
qDebug() << "Node not found:" << nodeId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!node->second.hasCutFaceSettings)
|
|
|
|
return;
|
|
|
|
node->second.clearCutFaceSettings();
|
|
|
|
auto part = partMap.find(node->second.partId);
|
|
|
|
if (part != partMap.end())
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit nodeCutFaceChanged(nodeId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::updateTurnaround(const QImage& image)
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
|
|
|
turnaround = image;
|
2018-11-11 13:08:13 +00:00
|
|
|
turnaroundPngByteArray.clear();
|
|
|
|
QBuffer pngBuffer(&turnaroundPngByteArray);
|
|
|
|
pngBuffer.open(QIODevice::WriteOnly);
|
|
|
|
turnaround.save(&pngBuffer, "PNG");
|
2018-04-07 08:44:39 +00:00
|
|
|
emit turnaroundChanged();
|
|
|
|
}
|
|
|
|
|
2020-12-07 22:57:37 +00:00
|
|
|
void Document::clearTurnaround()
|
|
|
|
{
|
|
|
|
turnaround = QImage();
|
|
|
|
turnaroundPngByteArray.clear();
|
|
|
|
emit turnaroundChanged();
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::updateTextureImage(QImage* image)
|
2020-11-17 14:31:51 +00:00
|
|
|
{
|
|
|
|
delete textureImageByteArray;
|
|
|
|
textureImageByteArray = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureImage;
|
|
|
|
textureImage = image;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::updateTextureNormalImage(QImage* image)
|
2020-11-17 14:31:51 +00:00
|
|
|
{
|
|
|
|
delete textureNormalImageByteArray;
|
|
|
|
textureNormalImageByteArray = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureNormalImage;
|
|
|
|
textureNormalImage = image;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::updateTextureMetalnessImage(QImage* image)
|
2020-11-17 14:31:51 +00:00
|
|
|
{
|
|
|
|
delete textureMetalnessImageByteArray;
|
|
|
|
textureMetalnessImageByteArray = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureMetalnessImage;
|
|
|
|
textureMetalnessImage = image;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::updateTextureRoughnessImage(QImage* image)
|
2020-11-17 14:31:51 +00:00
|
|
|
{
|
|
|
|
delete textureRoughnessImageByteArray;
|
|
|
|
textureRoughnessImageByteArray = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureRoughnessImage;
|
|
|
|
textureRoughnessImage = image;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::updateTextureAmbientOcclusionImage(QImage* image)
|
2020-11-17 14:31:51 +00:00
|
|
|
{
|
|
|
|
delete textureAmbientOcclusionImageByteArray;
|
|
|
|
textureAmbientOcclusionImageByteArray = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-11-17 14:31:51 +00:00
|
|
|
delete textureAmbientOcclusionImage;
|
|
|
|
textureAmbientOcclusionImage = image;
|
|
|
|
}
|
|
|
|
|
2018-11-03 08:09:42 +00:00
|
|
|
void Document::setEditMode(SkeletonDocumentEditMode mode)
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
|
|
|
if (editMode == mode)
|
|
|
|
return;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
editMode = mode;
|
|
|
|
emit editModeChanged();
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::toSnapshot(dust3d::Snapshot* snapshot, const std::set<dust3d::Uuid>& limitNodeIds,
|
2020-12-19 05:37:44 +00:00
|
|
|
DocumentToSnapshotFor forWhat,
|
2022-10-18 09:35:04 +00:00
|
|
|
const std::set<dust3d::Uuid>& limitMaterialIds) const
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
if (DocumentToSnapshotFor::Document == forWhat || DocumentToSnapshotFor::Nodes == forWhat) {
|
2021-11-18 14:58:01 +00:00
|
|
|
std::set<dust3d::Uuid> limitPartIds;
|
|
|
|
std::set<dust3d::Uuid> limitComponentIds;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& nodeId : limitNodeIds) {
|
|
|
|
const SkeletonNode* node = findNode(nodeId);
|
2018-09-21 07:10:18 +00:00
|
|
|
if (!node)
|
|
|
|
continue;
|
2022-10-18 09:35:04 +00:00
|
|
|
const SkeletonPart* part = findPart(node->partId);
|
2018-09-21 07:10:18 +00:00
|
|
|
if (!part)
|
|
|
|
continue;
|
|
|
|
limitPartIds.insert(node->partId);
|
2022-10-18 09:35:04 +00:00
|
|
|
const SkeletonComponent* component = findComponent(part->componentId);
|
2018-09-21 07:10:18 +00:00
|
|
|
while (component) {
|
|
|
|
limitComponentIds.insert(component->id);
|
|
|
|
if (component->id.isNull())
|
|
|
|
break;
|
|
|
|
component = findComponent(component->parentId);
|
|
|
|
}
|
2018-08-27 08:50:40 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& partIt : partMap) {
|
2018-09-21 07:10:18 +00:00
|
|
|
if (!limitPartIds.empty() && limitPartIds.find(partIt.first) == limitPartIds.end())
|
|
|
|
continue;
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<std::string, std::string> part;
|
2018-09-21 07:10:18 +00:00
|
|
|
part["id"] = partIt.second.id.toString();
|
|
|
|
part["visible"] = partIt.second.visible ? "true" : "false";
|
|
|
|
part["locked"] = partIt.second.locked ? "true" : "false";
|
|
|
|
part["subdived"] = partIt.second.subdived ? "true" : "false";
|
|
|
|
part["disabled"] = partIt.second.disabled ? "true" : "false";
|
|
|
|
part["xMirrored"] = partIt.second.xMirrored ? "true" : "false";
|
2021-11-18 14:58:01 +00:00
|
|
|
if (partIt.second.base != dust3d::PartBase::XYZ)
|
2019-05-20 13:38:01 +00:00
|
|
|
part["base"] = PartBaseToString(partIt.second.base);
|
2018-09-21 07:10:18 +00:00
|
|
|
part["rounded"] = partIt.second.rounded ? "true" : "false";
|
2019-03-09 22:10:39 +00:00
|
|
|
part["chamfered"] = partIt.second.chamfered ? "true" : "false";
|
2021-11-18 14:58:01 +00:00
|
|
|
if (dust3d::PartTarget::Model != partIt.second.target)
|
2019-05-19 03:21:38 +00:00
|
|
|
part["target"] = PartTargetToString(partIt.second.target);
|
2019-02-21 22:48:15 +00:00
|
|
|
if (partIt.second.cutRotationAdjusted())
|
2021-11-18 14:58:01 +00:00
|
|
|
part["cutRotation"] = std::to_string(partIt.second.cutRotation);
|
2019-05-19 03:21:38 +00:00
|
|
|
if (partIt.second.cutFaceAdjusted()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
if (dust3d::CutFace::UserDefined == partIt.second.cutFace) {
|
2019-05-19 03:21:38 +00:00
|
|
|
if (!partIt.second.cutFaceLinkedId.isNull()) {
|
|
|
|
part["cutFace"] = partIt.second.cutFaceLinkedId.toString();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
part["cutFace"] = CutFaceToString(partIt.second.cutFace);
|
|
|
|
}
|
|
|
|
}
|
2020-10-16 09:06:54 +00:00
|
|
|
part["__dirty"] = partIt.second.dirty ? "true" : "false";
|
2019-06-08 07:57:13 +00:00
|
|
|
if (partIt.second.hasColor)
|
2021-11-18 14:58:01 +00:00
|
|
|
part["color"] = partIt.second.color.name(QColor::HexArgb).toUtf8().constData();
|
2019-05-25 23:24:24 +00:00
|
|
|
if (partIt.second.colorSolubilityAdjusted())
|
2021-11-18 14:58:01 +00:00
|
|
|
part["colorSolubility"] = std::to_string(partIt.second.colorSolubility);
|
2020-10-18 05:03:15 +00:00
|
|
|
if (partIt.second.metalnessAdjusted())
|
2021-11-18 14:58:01 +00:00
|
|
|
part["metallic"] = std::to_string(partIt.second.metalness);
|
2020-10-18 05:03:15 +00:00
|
|
|
if (partIt.second.roughnessAdjusted())
|
2021-11-18 14:58:01 +00:00
|
|
|
part["roughness"] = std::to_string(partIt.second.roughness);
|
2018-09-21 07:10:18 +00:00
|
|
|
if (partIt.second.deformThicknessAdjusted())
|
2021-11-18 14:58:01 +00:00
|
|
|
part["deformThickness"] = std::to_string(partIt.second.deformThickness);
|
2018-09-21 07:10:18 +00:00
|
|
|
if (partIt.second.deformWidthAdjusted())
|
2021-11-18 14:58:01 +00:00
|
|
|
part["deformWidth"] = std::to_string(partIt.second.deformWidth);
|
2020-10-18 10:31:40 +00:00
|
|
|
if (partIt.second.deformUnified)
|
|
|
|
part["deformUnified"] = "true";
|
2019-08-18 12:02:39 +00:00
|
|
|
if (partIt.second.hollowThicknessAdjusted())
|
2021-11-18 14:58:01 +00:00
|
|
|
part["hollowThickness"] = std::to_string(partIt.second.hollowThickness);
|
2018-09-21 07:10:18 +00:00
|
|
|
if (!partIt.second.name.isEmpty())
|
2021-11-18 14:58:01 +00:00
|
|
|
part["name"] = partIt.second.name.toUtf8().constData();
|
2018-10-09 02:19:12 +00:00
|
|
|
if (partIt.second.materialAdjusted())
|
|
|
|
part["materialId"] = partIt.second.materialId.toString();
|
2019-11-07 12:08:47 +00:00
|
|
|
if (partIt.second.countershaded)
|
|
|
|
part["countershaded"] = "true";
|
2020-10-20 11:18:08 +00:00
|
|
|
if (partIt.second.smooth)
|
|
|
|
part["smooth"] = "true";
|
2018-09-21 07:10:18 +00:00
|
|
|
snapshot->parts[part["id"]] = part;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& nodeIt : nodeMap) {
|
2018-09-21 07:10:18 +00:00
|
|
|
if (!limitNodeIds.empty() && limitNodeIds.find(nodeIt.first) == limitNodeIds.end())
|
|
|
|
continue;
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<std::string, std::string> node;
|
2018-09-21 07:10:18 +00:00
|
|
|
node["id"] = nodeIt.second.id.toString();
|
2021-11-18 14:58:01 +00:00
|
|
|
node["radius"] = std::to_string(nodeIt.second.radius);
|
|
|
|
node["x"] = std::to_string(nodeIt.second.getX());
|
|
|
|
node["y"] = std::to_string(nodeIt.second.getY());
|
|
|
|
node["z"] = std::to_string(nodeIt.second.getZ());
|
2018-09-21 07:10:18 +00:00
|
|
|
node["partId"] = nodeIt.second.partId.toString();
|
2019-07-08 22:36:07 +00:00
|
|
|
if (nodeIt.second.hasCutFaceSettings) {
|
2021-11-18 14:58:01 +00:00
|
|
|
node["cutRotation"] = std::to_string(nodeIt.second.cutRotation);
|
|
|
|
if (dust3d::CutFace::UserDefined == nodeIt.second.cutFace) {
|
2019-07-08 22:36:07 +00:00
|
|
|
if (!nodeIt.second.cutFaceLinkedId.isNull()) {
|
|
|
|
node["cutFace"] = nodeIt.second.cutFaceLinkedId.toString();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
node["cutFace"] = CutFaceToString(nodeIt.second.cutFace);
|
|
|
|
}
|
|
|
|
}
|
2018-09-21 07:10:18 +00:00
|
|
|
if (!nodeIt.second.name.isEmpty())
|
2021-11-18 14:58:01 +00:00
|
|
|
node["name"] = nodeIt.second.name.toUtf8().constData();
|
2018-09-21 07:10:18 +00:00
|
|
|
snapshot->nodes[node["id"]] = node;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& edgeIt : edgeMap) {
|
2018-09-21 07:10:18 +00:00
|
|
|
if (edgeIt.second.nodeIds.size() != 2)
|
|
|
|
continue;
|
2022-10-18 09:35:04 +00:00
|
|
|
if (!limitNodeIds.empty() && (limitNodeIds.find(edgeIt.second.nodeIds[0]) == limitNodeIds.end() || limitNodeIds.find(edgeIt.second.nodeIds[1]) == limitNodeIds.end()))
|
2018-09-21 07:10:18 +00:00
|
|
|
continue;
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<std::string, std::string> edge;
|
2018-09-21 07:10:18 +00:00
|
|
|
edge["id"] = edgeIt.second.id.toString();
|
|
|
|
edge["from"] = edgeIt.second.nodeIds[0].toString();
|
|
|
|
edge["to"] = edgeIt.second.nodeIds[1].toString();
|
|
|
|
edge["partId"] = edgeIt.second.partId.toString();
|
|
|
|
if (!edgeIt.second.name.isEmpty())
|
2021-11-18 14:58:01 +00:00
|
|
|
edge["name"] = edgeIt.second.name.toUtf8().constData();
|
2018-09-21 07:10:18 +00:00
|
|
|
snapshot->edges[edge["id"]] = edge;
|
2018-08-27 08:50:40 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& componentIt : componentMap) {
|
2018-09-21 07:10:18 +00:00
|
|
|
if (!limitComponentIds.empty() && limitComponentIds.find(componentIt.first) == limitComponentIds.end())
|
|
|
|
continue;
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<std::string, std::string> component;
|
2018-09-21 07:10:18 +00:00
|
|
|
component["id"] = componentIt.second.id.toString();
|
|
|
|
if (!componentIt.second.name.isEmpty())
|
2021-11-18 14:58:01 +00:00
|
|
|
component["name"] = componentIt.second.name.toUtf8().constData();
|
2018-09-21 07:10:18 +00:00
|
|
|
component["expanded"] = componentIt.second.expanded ? "true" : "false";
|
2018-11-14 13:21:45 +00:00
|
|
|
component["combineMode"] = CombineModeToString(componentIt.second.combineMode);
|
2020-10-16 09:06:54 +00:00
|
|
|
component["__dirty"] = componentIt.second.dirty ? "true" : "false";
|
2021-11-18 14:58:01 +00:00
|
|
|
std::vector<std::string> childIdList;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& childId : componentIt.second.childrenIds) {
|
2021-11-18 14:58:01 +00:00
|
|
|
childIdList.push_back(childId.toString());
|
2018-09-21 07:10:18 +00:00
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
std::string children = dust3d::String::join(childIdList, ",");
|
|
|
|
if (!children.empty())
|
2018-09-21 07:10:18 +00:00
|
|
|
component["children"] = children;
|
2021-11-18 14:58:01 +00:00
|
|
|
std::string linkData = componentIt.second.linkData().toUtf8().constData();
|
|
|
|
if (!linkData.empty()) {
|
2018-09-21 07:10:18 +00:00
|
|
|
component["linkData"] = linkData;
|
2021-11-18 14:58:01 +00:00
|
|
|
component["linkDataType"] = componentIt.second.linkDataType().toUtf8().constData();
|
2018-09-21 07:10:18 +00:00
|
|
|
}
|
|
|
|
if (!componentIt.second.name.isEmpty())
|
2021-11-18 14:58:01 +00:00
|
|
|
component["name"] = componentIt.second.name.toUtf8().constData();
|
2018-09-21 07:10:18 +00:00
|
|
|
snapshot->components[component["id"]] = component;
|
2018-08-27 08:50:40 +00:00
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
if (limitComponentIds.empty() || limitComponentIds.find(dust3d::Uuid()) != limitComponentIds.end()) {
|
|
|
|
std::vector<std::string> childIdList;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& childId : rootComponent.childrenIds) {
|
2021-11-18 14:58:01 +00:00
|
|
|
childIdList.push_back(childId.toString());
|
2018-09-21 07:10:18 +00:00
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
std::string children = dust3d::String::join(childIdList, ",");
|
|
|
|
if (!children.empty())
|
2018-09-21 07:10:18 +00:00
|
|
|
snapshot->rootComponent["children"] = children;
|
2018-08-27 08:50:40 +00:00
|
|
|
}
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
if (DocumentToSnapshotFor::Document == forWhat || DocumentToSnapshotFor::Materials == forWhat) {
|
|
|
|
for (const auto& materialId : materialIdList) {
|
2018-10-09 02:19:12 +00:00
|
|
|
if (!limitMaterialIds.empty() && limitMaterialIds.find(materialId) == limitMaterialIds.end())
|
|
|
|
continue;
|
|
|
|
auto findMaterialResult = materialMap.find(materialId);
|
|
|
|
if (findMaterialResult == materialMap.end()) {
|
|
|
|
qDebug() << "Find material failed:" << materialId;
|
|
|
|
continue;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
auto& materialIt = *findMaterialResult;
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<std::string, std::string> material;
|
2018-10-09 02:19:12 +00:00
|
|
|
material["id"] = materialIt.second.id.toString();
|
|
|
|
material["type"] = "MetalRoughness";
|
|
|
|
if (!materialIt.second.name.isEmpty())
|
2021-11-18 14:58:01 +00:00
|
|
|
material["name"] = materialIt.second.name.toUtf8().constData();
|
|
|
|
std::vector<std::pair<std::map<std::string, std::string>, std::vector<std::map<std::string, std::string>>>> layers;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& layer : materialIt.second.layers) {
|
2021-11-18 14:58:01 +00:00
|
|
|
std::vector<std::map<std::string, std::string>> maps;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& mapItem : layer.maps) {
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<std::string, std::string> textureMap;
|
2018-10-09 02:19:12 +00:00
|
|
|
textureMap["for"] = TextureTypeToString(mapItem.forWhat);
|
|
|
|
textureMap["linkDataType"] = "imageId";
|
|
|
|
textureMap["linkData"] = mapItem.imageId.toString();
|
|
|
|
maps.push_back(textureMap);
|
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<std::string, std::string> layerAttributes;
|
2019-11-03 00:15:20 +00:00
|
|
|
if (!qFuzzyCompare((float)layer.tileScale, (float)1.0))
|
2021-11-18 14:58:01 +00:00
|
|
|
layerAttributes["tileScale"] = std::to_string(layer.tileScale);
|
2022-10-18 09:35:04 +00:00
|
|
|
layers.push_back({ layerAttributes, maps });
|
2018-10-09 02:19:12 +00:00
|
|
|
}
|
|
|
|
snapshot->materials.push_back(std::make_pair(material, layers));
|
|
|
|
}
|
|
|
|
}
|
2018-10-25 00:19:38 +00:00
|
|
|
if (DocumentToSnapshotFor::Document == forWhat) {
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<std::string, std::string> canvas;
|
|
|
|
canvas["originX"] = std::to_string(getOriginX());
|
|
|
|
canvas["originY"] = std::to_string(getOriginY());
|
|
|
|
canvas["originZ"] = std::to_string(getOriginZ());
|
2018-09-21 07:10:18 +00:00
|
|
|
snapshot->canvas = canvas;
|
|
|
|
}
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSource source)
|
2018-09-14 09:45:05 +00:00
|
|
|
{
|
|
|
|
bool isOriginChanged = false;
|
2022-10-18 09:35:04 +00:00
|
|
|
if (SnapshotSource::Paste != source && SnapshotSource::Import != source) {
|
|
|
|
const auto& originXit = snapshot.canvas.find("originX");
|
|
|
|
const auto& originYit = snapshot.canvas.find("originY");
|
|
|
|
const auto& originZit = snapshot.canvas.find("originZ");
|
|
|
|
if (originXit != snapshot.canvas.end() && originYit != snapshot.canvas.end() && originZit != snapshot.canvas.end()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
setOriginX(dust3d::String::toFloat(originXit->second));
|
|
|
|
setOriginY(dust3d::String::toFloat(originYit->second));
|
|
|
|
setOriginZ(dust3d::String::toFloat(originZit->second));
|
2018-09-14 09:45:05 +00:00
|
|
|
isOriginChanged = true;
|
|
|
|
}
|
2018-04-15 12:11:51 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
std::set<dust3d::Uuid> newAddedNodeIds;
|
|
|
|
std::set<dust3d::Uuid> newAddedEdgeIds;
|
|
|
|
std::set<dust3d::Uuid> newAddedPartIds;
|
|
|
|
std::set<dust3d::Uuid> newAddedComponentIds;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
std::set<dust3d::Uuid> inversePartIds;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<dust3d::Uuid, dust3d::Uuid> oldNewIdMap;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& materialIt : snapshot.materials) {
|
|
|
|
const auto& materialAttributes = materialIt.first;
|
2021-11-18 14:58:01 +00:00
|
|
|
auto materialType = dust3d::String::valueOrEmpty(materialAttributes, "type");
|
2018-10-09 02:19:12 +00:00
|
|
|
if ("MetalRoughness" != materialType) {
|
|
|
|
qDebug() << "Unsupported material type:" << materialType;
|
|
|
|
continue;
|
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid oldMaterialId = dust3d::Uuid(dust3d::String::valueOrEmpty(materialAttributes, "id"));
|
|
|
|
dust3d::Uuid newMaterialId = SnapshotSource::Import == source ? oldMaterialId : dust3d::Uuid::createUuid();
|
2020-04-07 23:15:20 +00:00
|
|
|
oldNewIdMap[oldMaterialId] = newMaterialId;
|
|
|
|
if (materialMap.end() == materialMap.find(newMaterialId)) {
|
2022-10-18 09:35:04 +00:00
|
|
|
auto& newMaterial = materialMap[newMaterialId];
|
2020-04-07 23:15:20 +00:00
|
|
|
newMaterial.id = newMaterialId;
|
2021-11-18 14:58:01 +00:00
|
|
|
newMaterial.name = dust3d::String::valueOrEmpty(materialAttributes, "name").c_str();
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& layerIt : materialIt.second) {
|
2020-04-07 23:15:20 +00:00
|
|
|
MaterialLayer layer;
|
|
|
|
auto findTileScale = layerIt.first.find("tileScale");
|
|
|
|
if (findTileScale != layerIt.first.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
layer.tileScale = dust3d::String::toFloat(findTileScale->second);
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& mapItem : layerIt.second) {
|
2021-11-18 14:58:01 +00:00
|
|
|
auto textureTypeString = dust3d::String::valueOrEmpty(mapItem, "for");
|
|
|
|
auto textureType = dust3d::TextureTypeFromString(textureTypeString.c_str());
|
|
|
|
if (dust3d::TextureType::None == textureType) {
|
2020-04-07 23:15:20 +00:00
|
|
|
qDebug() << "Unsupported texture type:" << textureTypeString;
|
|
|
|
continue;
|
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
auto linkTypeString = dust3d::String::valueOrEmpty(mapItem, "linkDataType");
|
2020-04-07 23:15:20 +00:00
|
|
|
if ("imageId" != linkTypeString) {
|
|
|
|
qDebug() << "Unsupported link data type:" << linkTypeString;
|
|
|
|
continue;
|
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
auto imageId = dust3d::Uuid(dust3d::String::valueOrEmpty(mapItem, "linkData"));
|
2020-04-07 23:15:20 +00:00
|
|
|
MaterialMap materialMap;
|
|
|
|
materialMap.imageId = imageId;
|
|
|
|
materialMap.forWhat = textureType;
|
|
|
|
layer.maps.push_back(materialMap);
|
2018-10-09 02:19:12 +00:00
|
|
|
}
|
2020-04-07 23:15:20 +00:00
|
|
|
newMaterial.layers.push_back(layer);
|
2018-10-09 02:19:12 +00:00
|
|
|
}
|
2020-04-07 23:15:20 +00:00
|
|
|
materialIdList.push_back(newMaterialId);
|
|
|
|
emit materialAdded(newMaterialId);
|
2018-10-09 02:19:12 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<dust3d::Uuid, dust3d::Uuid> cutFaceLinkedIdModifyMap;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& partKv : snapshot.parts) {
|
2021-11-18 14:58:01 +00:00
|
|
|
const auto newUuid = dust3d::Uuid::createUuid();
|
2022-10-18 09:35:04 +00:00
|
|
|
SkeletonPart& part = partMap[newUuid];
|
2018-09-18 06:22:29 +00:00
|
|
|
part.id = newUuid;
|
2021-11-18 14:58:01 +00:00
|
|
|
oldNewIdMap[dust3d::Uuid(partKv.first)] = part.id;
|
|
|
|
part.name = dust3d::String::valueOrEmpty(partKv.second, "name").c_str();
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& visibleIt = partKv.second.find("visible");
|
2019-12-24 23:24:49 +00:00
|
|
|
if (visibleIt != partKv.second.end()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
part.visible = dust3d::String::isTrue(visibleIt->second);
|
2019-12-24 23:24:49 +00:00
|
|
|
} else {
|
|
|
|
part.visible = true;
|
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
part.locked = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "locked"));
|
|
|
|
part.subdived = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "subdived"));
|
|
|
|
part.disabled = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "disabled"));
|
|
|
|
part.xMirrored = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "xMirrored"));
|
|
|
|
part.base = dust3d::PartBaseFromString(dust3d::String::valueOrEmpty(partKv.second, "base").c_str());
|
|
|
|
part.rounded = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "rounded"));
|
|
|
|
part.chamfered = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "chamfered"));
|
|
|
|
part.target = dust3d::PartTargetFromString(dust3d::String::valueOrEmpty(partKv.second, "target").c_str());
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& cutRotationIt = partKv.second.find("cutRotation");
|
2019-02-21 22:48:15 +00:00
|
|
|
if (cutRotationIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.setCutRotation(dust3d::String::toFloat(cutRotationIt->second));
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& cutFaceIt = partKv.second.find("cutFace");
|
2019-05-19 03:21:38 +00:00
|
|
|
if (cutFaceIt != partKv.second.end()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid cutFaceLinkedId = dust3d::Uuid(cutFaceIt->second);
|
2019-05-19 03:21:38 +00:00
|
|
|
if (cutFaceLinkedId.isNull()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
part.setCutFace(dust3d::CutFaceFromString(cutFaceIt->second.c_str()));
|
2019-05-19 03:21:38 +00:00
|
|
|
} else {
|
|
|
|
part.setCutFaceLinkedId(cutFaceLinkedId);
|
2022-10-18 09:35:04 +00:00
|
|
|
cutFaceLinkedIdModifyMap.insert({ part.id, cutFaceLinkedId });
|
2019-05-19 03:21:38 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
if (dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "inverse")))
|
2018-08-27 08:50:40 +00:00
|
|
|
inversePartIds.insert(part.id);
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& colorIt = partKv.second.find("color");
|
2018-04-26 02:23:22 +00:00
|
|
|
if (colorIt != partKv.second.end()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
part.color = QColor(colorIt->second.c_str());
|
2018-04-26 02:23:22 +00:00
|
|
|
part.hasColor = true;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& colorSolubilityIt = partKv.second.find("colorSolubility");
|
2019-05-25 23:24:24 +00:00
|
|
|
if (colorSolubilityIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.colorSolubility = dust3d::String::toFloat(colorSolubilityIt->second);
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& metalnessIt = partKv.second.find("metallic");
|
2020-10-18 05:03:15 +00:00
|
|
|
if (metalnessIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.metalness = dust3d::String::toFloat(metalnessIt->second);
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& roughnessIt = partKv.second.find("roughness");
|
2020-10-18 05:03:15 +00:00
|
|
|
if (roughnessIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.roughness = dust3d::String::toFloat(roughnessIt->second);
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& deformThicknessIt = partKv.second.find("deformThickness");
|
2018-04-17 16:14:31 +00:00
|
|
|
if (deformThicknessIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.setDeformThickness(dust3d::String::toFloat(deformThicknessIt->second));
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& deformWidthIt = partKv.second.find("deformWidth");
|
2018-04-17 16:14:31 +00:00
|
|
|
if (deformWidthIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.setDeformWidth(dust3d::String::toFloat(deformWidthIt->second));
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& deformUnifiedIt = partKv.second.find("deformUnified");
|
2020-10-18 10:31:40 +00:00
|
|
|
if (deformUnifiedIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.deformUnified = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "deformUnified"));
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& hollowThicknessIt = partKv.second.find("hollowThickness");
|
2019-08-18 12:02:39 +00:00
|
|
|
if (hollowThicknessIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.hollowThickness = dust3d::String::toFloat(hollowThicknessIt->second);
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& materialIdIt = partKv.second.find("materialId");
|
2018-10-09 02:19:12 +00:00
|
|
|
if (materialIdIt != partKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
part.materialId = oldNewIdMap[dust3d::Uuid(materialIdIt->second)];
|
|
|
|
part.countershaded = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "countershaded"));
|
|
|
|
part.smooth = dust3d::String::isTrue(dust3d::String::valueOrEmpty(partKv.second, "smooth"));
|
2018-05-12 10:07:46 +00:00
|
|
|
newAddedPartIds.insert(part.id);
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& it : cutFaceLinkedIdModifyMap) {
|
|
|
|
SkeletonPart& part = partMap[it.first];
|
2019-05-19 03:21:38 +00:00
|
|
|
auto findNewLinkedId = oldNewIdMap.find(it.second);
|
2019-07-08 22:36:07 +00:00
|
|
|
if (findNewLinkedId == oldNewIdMap.end()) {
|
2019-07-07 10:55:42 +00:00
|
|
|
if (partMap.find(it.second) == partMap.end()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
part.setCutFaceLinkedId(dust3d::Uuid());
|
2019-07-07 10:55:42 +00:00
|
|
|
}
|
|
|
|
} else {
|
2019-05-19 03:21:38 +00:00
|
|
|
part.setCutFaceLinkedId(findNewLinkedId->second);
|
2019-07-07 10:55:42 +00:00
|
|
|
}
|
2019-05-19 03:21:38 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& nodeKv : snapshot.nodes) {
|
|
|
|
if (nodeKv.second.find("radius") == nodeKv.second.end() || nodeKv.second.find("x") == nodeKv.second.end() || nodeKv.second.find("y") == nodeKv.second.end() || nodeKv.second.find("z") == nodeKv.second.end() || nodeKv.second.find("partId") == nodeKv.second.end())
|
2018-04-09 08:46:06 +00:00
|
|
|
continue;
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid oldNodeId = dust3d::Uuid(nodeKv.first);
|
|
|
|
SkeletonNode node(nodeMap.find(oldNodeId) == nodeMap.end() ? oldNodeId : dust3d::Uuid::createUuid());
|
2019-06-25 11:37:17 +00:00
|
|
|
oldNewIdMap[oldNodeId] = node.id;
|
2021-11-18 14:58:01 +00:00
|
|
|
node.name = dust3d::String::valueOrEmpty(nodeKv.second, "name").c_str();
|
|
|
|
node.radius = dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeKv.second, "radius"));
|
|
|
|
node.setX(dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeKv.second, "x")));
|
|
|
|
node.setY(dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeKv.second, "y")));
|
|
|
|
node.setZ(dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeKv.second, "z")));
|
|
|
|
node.partId = oldNewIdMap[dust3d::Uuid(dust3d::String::valueOrEmpty(nodeKv.second, "partId"))];
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& cutRotationIt = nodeKv.second.find("cutRotation");
|
2019-07-08 22:36:07 +00:00
|
|
|
if (cutRotationIt != nodeKv.second.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
node.setCutRotation(dust3d::String::toFloat(cutRotationIt->second));
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& cutFaceIt = nodeKv.second.find("cutFace");
|
2019-07-08 22:36:07 +00:00
|
|
|
if (cutFaceIt != nodeKv.second.end()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid cutFaceLinkedId = dust3d::Uuid(cutFaceIt->second);
|
2019-07-08 22:36:07 +00:00
|
|
|
if (cutFaceLinkedId.isNull()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
node.setCutFace(dust3d::CutFaceFromString(cutFaceIt->second.c_str()));
|
2019-07-08 22:36:07 +00:00
|
|
|
} else {
|
|
|
|
node.setCutFaceLinkedId(cutFaceLinkedId);
|
|
|
|
auto findNewLinkedId = oldNewIdMap.find(cutFaceLinkedId);
|
|
|
|
if (findNewLinkedId == oldNewIdMap.end()) {
|
|
|
|
if (partMap.find(cutFaceLinkedId) == partMap.end()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
node.setCutFaceLinkedId(dust3d::Uuid());
|
2019-07-08 22:36:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
node.setCutFaceLinkedId(findNewLinkedId->second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-07 08:44:39 +00:00
|
|
|
nodeMap[node.id] = node;
|
2018-05-12 10:07:46 +00:00
|
|
|
newAddedNodeIds.insert(node.id);
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& edgeKv : snapshot.edges) {
|
|
|
|
if (edgeKv.second.find("from") == edgeKv.second.end() || edgeKv.second.find("to") == edgeKv.second.end() || edgeKv.second.find("partId") == edgeKv.second.end())
|
2018-04-09 08:46:06 +00:00
|
|
|
continue;
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid oldEdgeId = dust3d::Uuid(edgeKv.first);
|
|
|
|
SkeletonEdge edge(edgeMap.find(oldEdgeId) == edgeMap.end() ? oldEdgeId : dust3d::Uuid::createUuid());
|
2019-06-25 11:37:17 +00:00
|
|
|
oldNewIdMap[oldEdgeId] = edge.id;
|
2021-11-18 14:58:01 +00:00
|
|
|
edge.name = dust3d::String::valueOrEmpty(edgeKv.second, "name").c_str();
|
|
|
|
edge.partId = oldNewIdMap[dust3d::Uuid(dust3d::String::valueOrEmpty(edgeKv.second, "partId"))];
|
|
|
|
std::string fromNodeId = dust3d::String::valueOrEmpty(edgeKv.second, "from");
|
|
|
|
if (!fromNodeId.empty()) {
|
|
|
|
dust3d::Uuid fromId = oldNewIdMap[dust3d::Uuid(fromNodeId)];
|
2018-04-09 08:46:06 +00:00
|
|
|
edge.nodeIds.push_back(fromId);
|
|
|
|
nodeMap[fromId].edgeIds.push_back(edge.id);
|
2018-04-08 23:42:59 +00:00
|
|
|
}
|
2021-11-18 14:58:01 +00:00
|
|
|
std::string toNodeId = dust3d::String::valueOrEmpty(edgeKv.second, "to");
|
|
|
|
if (!toNodeId.empty()) {
|
|
|
|
dust3d::Uuid toId = oldNewIdMap[dust3d::Uuid(toNodeId)];
|
2018-04-09 08:46:06 +00:00
|
|
|
edge.nodeIds.push_back(toId);
|
|
|
|
nodeMap[toId].edgeIds.push_back(edge.id);
|
2018-04-08 23:42:59 +00:00
|
|
|
}
|
2018-04-07 08:44:39 +00:00
|
|
|
edgeMap[edge.id] = edge;
|
2018-05-12 10:07:46 +00:00
|
|
|
newAddedEdgeIds.insert(edge.id);
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& nodeIt : nodeMap) {
|
2018-05-12 10:07:46 +00:00
|
|
|
if (newAddedNodeIds.find(nodeIt.first) == newAddedNodeIds.end())
|
|
|
|
continue;
|
2018-04-09 05:22:25 +00:00
|
|
|
partMap[nodeIt.second.partId].nodeIds.push_back(nodeIt.first);
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& componentKv : snapshot.components) {
|
2021-11-18 14:58:01 +00:00
|
|
|
QString linkData = dust3d::String::valueOrEmpty(componentKv.second, "linkData").c_str();
|
|
|
|
QString linkDataType = dust3d::String::valueOrEmpty(componentKv.second, "linkDataType").c_str();
|
|
|
|
SkeletonComponent component(dust3d::Uuid(), linkData, linkDataType);
|
|
|
|
oldNewIdMap[dust3d::Uuid(componentKv.first)] = component.id;
|
|
|
|
component.name = dust3d::String::valueOrEmpty(componentKv.second, "name").c_str();
|
|
|
|
component.expanded = dust3d::String::isTrue(dust3d::String::valueOrEmpty(componentKv.second, "expanded"));
|
|
|
|
component.combineMode = dust3d::CombineModeFromString(dust3d::String::valueOrEmpty(componentKv.second, "combineMode").c_str());
|
|
|
|
if (component.combineMode == dust3d::CombineMode::Normal) {
|
|
|
|
if (dust3d::String::isTrue(dust3d::String::valueOrEmpty(componentKv.second, "inverse")))
|
|
|
|
component.combineMode = dust3d::CombineMode::Inversion;
|
2018-11-14 13:21:45 +00:00
|
|
|
}
|
2018-09-21 07:10:18 +00:00
|
|
|
//qDebug() << "Add component:" << component.id << " old:" << componentKv.first << "name:" << component.name;
|
2018-08-27 08:50:40 +00:00
|
|
|
if ("partId" == linkDataType) {
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid partId = oldNewIdMap[dust3d::Uuid(linkData.toUtf8().constData())];
|
2018-08-27 08:50:40 +00:00
|
|
|
component.linkToPartId = partId;
|
2018-09-21 07:10:18 +00:00
|
|
|
//qDebug() << "Add part:" << partId << " from component:" << component.id;
|
2018-08-27 08:50:40 +00:00
|
|
|
partMap[partId].componentId = component.id;
|
|
|
|
if (inversePartIds.find(partId) != inversePartIds.end())
|
2021-11-18 14:58:01 +00:00
|
|
|
component.combineMode = dust3d::CombineMode::Inversion;
|
2018-08-27 08:50:40 +00:00
|
|
|
}
|
2022-10-02 19:45:46 +00:00
|
|
|
componentMap.emplace(component.id, std::move(component));
|
2018-08-27 08:50:40 +00:00
|
|
|
newAddedComponentIds.insert(component.id);
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& rootComponentChildren = snapshot.rootComponent.find("children");
|
2018-08-27 08:50:40 +00:00
|
|
|
if (rootComponentChildren != snapshot.rootComponent.end()) {
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& childId : dust3d::String::split(rootComponentChildren->second, ',')) {
|
2021-11-18 14:58:01 +00:00
|
|
|
if (childId.empty())
|
2018-08-27 08:50:40 +00:00
|
|
|
continue;
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid componentId = oldNewIdMap[dust3d::Uuid(childId)];
|
2018-08-27 08:50:40 +00:00
|
|
|
if (componentMap.find(componentId) == componentMap.end())
|
|
|
|
continue;
|
2018-09-21 07:10:18 +00:00
|
|
|
//qDebug() << "Add root component:" << componentId;
|
2018-08-27 08:50:40 +00:00
|
|
|
rootComponent.addChild(componentId);
|
|
|
|
}
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& componentKv : snapshot.components) {
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid componentId = oldNewIdMap[dust3d::Uuid(componentKv.first)];
|
2018-08-27 08:50:40 +00:00
|
|
|
if (componentMap.find(componentId) == componentMap.end())
|
2018-05-12 10:07:46 +00:00
|
|
|
continue;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& childId : dust3d::String::split(dust3d::String::valueOrEmpty(componentKv.second, "children"), ',')) {
|
2021-11-18 14:58:01 +00:00
|
|
|
if (childId.empty())
|
2018-08-27 08:50:40 +00:00
|
|
|
continue;
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid childComponentId = oldNewIdMap[dust3d::Uuid(childId)];
|
2018-08-27 08:50:40 +00:00
|
|
|
if (componentMap.find(childComponentId) == componentMap.end())
|
|
|
|
continue;
|
2018-09-21 07:10:18 +00:00
|
|
|
//qDebug() << "Add child component:" << childComponentId << "to" << componentId;
|
2018-08-27 08:50:40 +00:00
|
|
|
componentMap[componentId].addChild(childComponentId);
|
|
|
|
componentMap[childComponentId].parentId = componentId;
|
|
|
|
}
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
for (const auto& nodeIt : newAddedNodeIds) {
|
2018-05-12 10:07:46 +00:00
|
|
|
emit nodeAdded(nodeIt);
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& edgeIt : newAddedEdgeIds) {
|
2018-05-12 10:07:46 +00:00
|
|
|
emit edgeAdded(edgeIt);
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& partIt : newAddedPartIds) {
|
2018-05-12 10:07:46 +00:00
|
|
|
emit partAdded(partIt);
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
emit componentChildrenChanged(dust3d::Uuid());
|
2018-09-14 09:45:05 +00:00
|
|
|
if (isOriginChanged)
|
|
|
|
emit originChanged();
|
2018-04-08 23:34:46 +00:00
|
|
|
emit skeletonChanged();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
for (const auto& partIt : newAddedPartIds) {
|
2018-05-12 10:07:46 +00:00
|
|
|
emit partVisibleStateChanged(partIt);
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-05-12 10:07:46 +00:00
|
|
|
emit uncheckAll();
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& nodeIt : newAddedNodeIds) {
|
2018-05-12 10:07:46 +00:00
|
|
|
emit checkNode(nodeIt);
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& edgeIt : newAddedEdgeIds) {
|
2018-05-12 10:07:46 +00:00
|
|
|
emit checkEdge(edgeIt);
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
if (!snapshot.materials.empty())
|
|
|
|
emit materialListChanged();
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 06:27:59 +00:00
|
|
|
void Document::silentReset()
|
2018-04-09 08:46:06 +00:00
|
|
|
{
|
2019-10-19 13:14:36 +00:00
|
|
|
setOriginX(0.0);
|
|
|
|
setOriginY(0.0);
|
|
|
|
setOriginZ(0.0);
|
2018-04-09 08:46:06 +00:00
|
|
|
nodeMap.clear();
|
|
|
|
edgeMap.clear();
|
|
|
|
partMap.clear();
|
2018-08-27 08:50:40 +00:00
|
|
|
componentMap.clear();
|
2018-10-09 02:19:12 +00:00
|
|
|
materialMap.clear();
|
|
|
|
materialIdList.clear();
|
2020-12-19 05:37:44 +00:00
|
|
|
rootComponent = SkeletonComponent();
|
2020-01-16 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 06:27:59 +00:00
|
|
|
void Document::reset()
|
|
|
|
{
|
|
|
|
silentReset();
|
2018-04-10 07:59:20 +00:00
|
|
|
emit cleanup();
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::fromSnapshot(const dust3d::Snapshot& snapshot)
|
2018-04-10 07:59:20 +00:00
|
|
|
{
|
|
|
|
reset();
|
2020-04-07 23:15:20 +00:00
|
|
|
addFromSnapshot(snapshot, SnapshotSource::Unknown);
|
2018-05-12 10:07:46 +00:00
|
|
|
emit uncheckAll();
|
2018-04-09 08:46:06 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh* Document::takeResultMesh()
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
2018-06-11 14:24:25 +00:00
|
|
|
if (nullptr == m_resultMesh)
|
|
|
|
return nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh* resultMesh = new ModelMesh(*m_resultMesh);
|
2018-04-07 08:44:39 +00:00
|
|
|
return resultMesh;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
MonochromeMesh* Document::takeWireframeMesh()
|
2022-09-23 15:54:49 +00:00
|
|
|
{
|
|
|
|
if (nullptr == m_wireframeMesh)
|
|
|
|
return nullptr;
|
|
|
|
return new MonochromeMesh(*m_wireframeMesh);
|
|
|
|
}
|
|
|
|
|
2019-01-07 13:03:42 +00:00
|
|
|
bool Document::isMeshGenerationSucceed()
|
|
|
|
{
|
|
|
|
return m_isMeshGenerationSucceed;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh* Document::takeResultTextureMesh()
|
2018-05-10 09:16:22 +00:00
|
|
|
{
|
2018-10-09 02:19:12 +00:00
|
|
|
if (nullptr == m_resultTextureMesh)
|
|
|
|
return nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh* resultTextureMesh = new ModelMesh(*m_resultTextureMesh);
|
2018-05-10 09:16:22 +00:00
|
|
|
return resultTextureMesh;
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::meshReady()
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh* resultMesh = m_meshGenerator->takeResultMesh();
|
2022-09-23 15:54:49 +00:00
|
|
|
m_wireframeMesh.reset(m_meshGenerator->takeWireframeMesh());
|
2022-10-18 09:35:04 +00:00
|
|
|
dust3d::Object* object = m_meshGenerator->takeObject();
|
2020-04-07 23:15:20 +00:00
|
|
|
bool isSuccessful = m_meshGenerator->isSuccessful();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2022-10-02 19:45:46 +00:00
|
|
|
std::unique_ptr<std::map<dust3d::Uuid, std::unique_ptr<ModelMesh>>> componentPreviewMeshes;
|
|
|
|
componentPreviewMeshes.reset(m_meshGenerator->takeComponentPreviewMeshes());
|
|
|
|
bool componentPreviewsChanged = componentPreviewMeshes && !componentPreviewMeshes->empty();
|
|
|
|
if (componentPreviewsChanged) {
|
2022-10-18 09:35:04 +00:00
|
|
|
for (auto& it : *componentPreviewMeshes) {
|
2022-10-02 19:45:46 +00:00
|
|
|
setComponentPreviewMesh(it.first, std::move(it.second));
|
2020-12-15 14:28:20 +00:00
|
|
|
}
|
2022-10-02 19:45:46 +00:00
|
|
|
emit resultComponentPreviewMeshesChanged();
|
2020-12-15 14:28:20 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
delete m_resultMesh;
|
|
|
|
m_resultMesh = resultMesh;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-04-07 23:15:20 +00:00
|
|
|
m_isMeshGenerationSucceed = isSuccessful;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-11-17 14:31:51 +00:00
|
|
|
delete m_currentObject;
|
|
|
|
m_currentObject = object;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
if (nullptr == m_resultMesh) {
|
|
|
|
qDebug() << "Result mesh is null";
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
delete m_meshGenerator;
|
|
|
|
m_meshGenerator = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2019-06-12 11:33:38 +00:00
|
|
|
qDebug() << "Mesh generation done";
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
m_isPostProcessResultObsolete = true;
|
2018-04-07 08:44:39 +00:00
|
|
|
emit resultMeshChanged();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
if (m_isResultMeshObsolete) {
|
2018-04-07 08:44:39 +00:00
|
|
|
generateMesh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
bool Document::isPostProcessResultObsolete() const
|
2018-06-15 05:34:41 +00:00
|
|
|
{
|
2018-08-27 08:50:40 +00:00
|
|
|
return m_isPostProcessResultObsolete;
|
2018-06-15 05:34:41 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::batchChangeBegin()
|
2018-04-09 14:24:30 +00:00
|
|
|
{
|
|
|
|
m_batchChangeRefCount++;
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::batchChangeEnd()
|
2018-04-09 14:24:30 +00:00
|
|
|
{
|
|
|
|
m_batchChangeRefCount--;
|
|
|
|
if (0 == m_batchChangeRefCount) {
|
2018-08-27 08:50:40 +00:00
|
|
|
if (m_isResultMeshObsolete) {
|
2018-04-09 14:24:30 +00:00
|
|
|
generateMesh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::regenerateMesh()
|
2018-08-27 08:50:40 +00:00
|
|
|
{
|
|
|
|
markAllDirty();
|
|
|
|
generateMesh();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::toggleSmoothNormal()
|
2018-09-07 12:51:33 +00:00
|
|
|
{
|
|
|
|
m_smoothNormal = !m_smoothNormal;
|
|
|
|
regenerateMesh();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::enableWeld(bool enabled)
|
2018-09-22 10:31:02 +00:00
|
|
|
{
|
|
|
|
weldEnabled = enabled;
|
|
|
|
regenerateMesh();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::generateMesh()
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
2018-04-09 14:24:30 +00:00
|
|
|
if (nullptr != m_meshGenerator || m_batchChangeRefCount > 0) {
|
2018-08-27 08:50:40 +00:00
|
|
|
m_isResultMeshObsolete = true;
|
2018-04-07 08:44:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-01-02 12:36:43 +00:00
|
|
|
emit meshGenerating();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2019-06-12 11:33:38 +00:00
|
|
|
qDebug() << "Mesh generating..";
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
settleOrigin();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
m_isResultMeshObsolete = false;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
QThread* thread = new QThread;
|
|
|
|
|
|
|
|
dust3d::Snapshot* snapshot = new dust3d::Snapshot;
|
2018-04-07 08:44:39 +00:00
|
|
|
toSnapshot(snapshot);
|
2018-08-27 08:50:40 +00:00
|
|
|
resetDirtyFlags();
|
2018-10-09 02:19:12 +00:00
|
|
|
m_meshGenerator = new MeshGenerator(snapshot);
|
2019-07-10 12:09:46 +00:00
|
|
|
m_meshGenerator->setId(m_nextMeshGenerationId++);
|
2021-11-18 14:58:01 +00:00
|
|
|
m_meshGenerator->setDefaultPartColor(dust3d::Color::createWhite());
|
2020-10-18 14:34:43 +00:00
|
|
|
if (nullptr == m_generatedCacheContext)
|
2021-11-18 14:58:01 +00:00
|
|
|
m_generatedCacheContext = new MeshGenerator::GeneratedCacheContext;
|
2022-10-18 09:35:04 +00:00
|
|
|
m_meshGenerator->setGeneratedCacheContext((dust3d::MeshGenerator::GeneratedCacheContext*)m_generatedCacheContext);
|
2019-05-30 10:28:55 +00:00
|
|
|
if (!m_smoothNormal) {
|
|
|
|
m_meshGenerator->setSmoothShadingThresholdAngleDegrees(0);
|
|
|
|
}
|
2018-10-09 02:19:12 +00:00
|
|
|
m_meshGenerator->moveToThread(thread);
|
2018-04-07 08:44:39 +00:00
|
|
|
connect(thread, &QThread::started, m_meshGenerator, &MeshGenerator::process);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_meshGenerator, &MeshGenerator::finished, this, &Document::meshReady);
|
2018-04-07 08:44:39 +00:00
|
|
|
connect(m_meshGenerator, &MeshGenerator::finished, thread, &QThread::quit);
|
|
|
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
|
|
|
thread->start();
|
|
|
|
}
|
2018-04-08 01:30:55 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::generateTexture()
|
2018-05-07 16:08:19 +00:00
|
|
|
{
|
|
|
|
if (nullptr != m_textureGenerator) {
|
2018-08-27 08:50:40 +00:00
|
|
|
m_isTextureObsolete = true;
|
2018-05-07 16:08:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-05-07 16:08:19 +00:00
|
|
|
qDebug() << "Texture guide generating..";
|
2020-01-02 12:36:43 +00:00
|
|
|
emit textureGenerating();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
m_isTextureObsolete = false;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
dust3d::Snapshot* snapshot = new dust3d::Snapshot;
|
2018-10-09 09:17:44 +00:00
|
|
|
toSnapshot(snapshot);
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
QThread* thread = new QThread;
|
2020-11-17 14:31:51 +00:00
|
|
|
m_textureGenerator = new TextureGenerator(*m_postProcessedObject, snapshot);
|
2018-05-07 16:08:19 +00:00
|
|
|
m_textureGenerator->moveToThread(thread);
|
|
|
|
connect(thread, &QThread::started, m_textureGenerator, &TextureGenerator::process);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_textureGenerator, &TextureGenerator::finished, this, &Document::textureReady);
|
2018-05-07 16:08:19 +00:00
|
|
|
connect(m_textureGenerator, &TextureGenerator::finished, thread, &QThread::quit);
|
|
|
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
|
|
|
thread->start();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::textureReady()
|
2018-05-07 16:08:19 +00:00
|
|
|
{
|
2020-11-17 14:31:51 +00:00
|
|
|
updateTextureImage(m_textureGenerator->takeResultTextureColorImage());
|
|
|
|
updateTextureNormalImage(m_textureGenerator->takeResultTextureNormalImage());
|
|
|
|
updateTextureMetalnessImage(m_textureGenerator->takeResultTextureMetalnessImage());
|
|
|
|
updateTextureRoughnessImage(m_textureGenerator->takeResultTextureRoughnessImage());
|
|
|
|
updateTextureAmbientOcclusionImage(m_textureGenerator->takeResultTextureAmbientOcclusionImage());
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-05-10 09:16:22 +00:00
|
|
|
delete m_resultTextureMesh;
|
|
|
|
m_resultTextureMesh = m_textureGenerator->takeResultMesh();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-11-18 10:26:46 +00:00
|
|
|
m_postProcessedObject->alphaEnabled = m_textureGenerator->hasTransparencySettings();
|
2020-11-17 14:31:51 +00:00
|
|
|
|
2018-05-11 05:27:29 +00:00
|
|
|
m_textureImageUpdateVersion++;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-05-07 16:08:19 +00:00
|
|
|
delete m_textureGenerator;
|
|
|
|
m_textureGenerator = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-05-07 16:08:19 +00:00
|
|
|
qDebug() << "Texture guide generation done";
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-05-07 16:08:19 +00:00
|
|
|
emit resultTextureChanged();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
if (m_isTextureObsolete) {
|
2018-05-07 16:08:19 +00:00
|
|
|
generateTexture();
|
|
|
|
} else {
|
|
|
|
checkExportReadyState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::postProcess()
|
2018-04-30 11:31:09 +00:00
|
|
|
{
|
2018-05-07 16:08:19 +00:00
|
|
|
if (nullptr != m_postProcessor) {
|
2018-08-27 08:50:40 +00:00
|
|
|
m_isPostProcessResultObsolete = true;
|
2018-05-07 16:08:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-19 05:37:44 +00:00
|
|
|
m_isPostProcessResultObsolete = false;
|
|
|
|
|
|
|
|
if (!m_currentObject) {
|
|
|
|
qDebug() << "Model is null";
|
2018-08-27 08:50:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-12-19 05:37:44 +00:00
|
|
|
|
|
|
|
qDebug() << "Post processing..";
|
|
|
|
emit postProcessing();
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
QThread* thread = new QThread;
|
2020-12-19 05:37:44 +00:00
|
|
|
m_postProcessor = new MeshResultPostProcessor(*m_currentObject);
|
|
|
|
m_postProcessor->moveToThread(thread);
|
|
|
|
connect(thread, &QThread::started, m_postProcessor, &MeshResultPostProcessor::process);
|
|
|
|
connect(m_postProcessor, &MeshResultPostProcessor::finished, this, &Document::postProcessedMeshResultReady);
|
|
|
|
connect(m_postProcessor, &MeshResultPostProcessor::finished, thread, &QThread::quit);
|
|
|
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
|
|
|
thread->start();
|
2018-08-27 08:50:40 +00:00
|
|
|
}
|
|
|
|
|
2020-12-19 05:37:44 +00:00
|
|
|
void Document::postProcessedMeshResultReady()
|
2018-09-07 10:13:55 +00:00
|
|
|
{
|
2020-12-19 05:37:44 +00:00
|
|
|
delete m_postProcessedObject;
|
|
|
|
m_postProcessedObject = m_postProcessor->takePostProcessedObject();
|
|
|
|
|
|
|
|
delete m_postProcessor;
|
|
|
|
m_postProcessor = nullptr;
|
|
|
|
|
|
|
|
qDebug() << "Post process done";
|
|
|
|
|
|
|
|
emit postProcessedResultChanged();
|
|
|
|
|
|
|
|
if (m_isPostProcessResultObsolete) {
|
|
|
|
postProcess();
|
2018-09-07 10:13:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
const dust3d::Object& Document::currentPostProcessedObject() const
|
2018-08-27 08:50:40 +00:00
|
|
|
{
|
2020-12-19 05:37:44 +00:00
|
|
|
return *m_postProcessedObject;
|
2018-08-27 08:50:40 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setComponentCombineMode(dust3d::Uuid componentId, dust3d::CombineMode combineMode)
|
2018-08-27 08:50:40 +00:00
|
|
|
{
|
|
|
|
auto component = componentMap.find(componentId);
|
|
|
|
if (component == componentMap.end()) {
|
2020-12-19 05:37:44 +00:00
|
|
|
qDebug() << "SkeletonComponent not found:" << componentId;
|
2018-08-27 08:50:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-12-19 05:37:44 +00:00
|
|
|
if (component->second.combineMode == combineMode)
|
2018-08-27 08:50:40 +00:00
|
|
|
return;
|
2020-12-19 05:37:44 +00:00
|
|
|
component->second.combineMode = combineMode;
|
|
|
|
component->second.dirty = true;
|
|
|
|
emit componentCombineModeChanged(componentId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartSubdivState(dust3d::Uuid partId, bool subdived)
|
2020-12-19 05:37:44 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
2018-08-27 08:50:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-12-19 05:37:44 +00:00
|
|
|
if (part->second.subdived == subdived)
|
|
|
|
return;
|
|
|
|
part->second.subdived = subdived;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partSubdivStateChanged(partId);
|
2018-06-16 06:41:52 +00:00
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::resolveSnapshotBoundingBox(const dust3d::Snapshot& snapshot, QRectF* mainProfile, QRectF* sideProfile)
|
2021-11-18 14:58:01 +00:00
|
|
|
{
|
|
|
|
float left = 0;
|
|
|
|
bool leftFirstTime = true;
|
|
|
|
float right = 0;
|
|
|
|
bool rightFirstTime = true;
|
|
|
|
float top = 0;
|
|
|
|
bool topFirstTime = true;
|
|
|
|
float bottom = 0;
|
|
|
|
bool bottomFirstTime = true;
|
|
|
|
float zLeft = 0;
|
|
|
|
bool zLeftFirstTime = true;
|
|
|
|
float zRight = 0;
|
|
|
|
bool zRightFirstTime = true;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& nodeIt : snapshot.nodes) {
|
2021-11-18 14:58:01 +00:00
|
|
|
float radius = dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeIt.second, "radius"));
|
|
|
|
float x = dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeIt.second, "x"));
|
|
|
|
float y = dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeIt.second, "y"));
|
|
|
|
float z = dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeIt.second, "z"));
|
|
|
|
if (leftFirstTime || x - radius < left) {
|
|
|
|
left = x - radius;
|
|
|
|
leftFirstTime = false;
|
|
|
|
}
|
|
|
|
if (topFirstTime || y - radius < top) {
|
|
|
|
top = y - radius;
|
|
|
|
topFirstTime = false;
|
|
|
|
}
|
|
|
|
if (rightFirstTime || x + radius > right) {
|
|
|
|
right = x + radius;
|
|
|
|
rightFirstTime = false;
|
|
|
|
}
|
|
|
|
if (bottomFirstTime || y + radius > bottom) {
|
|
|
|
bottom = y + radius;
|
|
|
|
bottomFirstTime = false;
|
|
|
|
}
|
|
|
|
if (zLeftFirstTime || z - radius < zLeft) {
|
|
|
|
zLeft = z - radius;
|
|
|
|
zLeftFirstTime = false;
|
|
|
|
}
|
|
|
|
if (zRightFirstTime || z + radius > zRight) {
|
|
|
|
zRight = z + radius;
|
|
|
|
zRightFirstTime = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*mainProfile = QRectF(QPointF(left, top), QPointF(right, bottom));
|
|
|
|
*sideProfile = QRectF(QPointF(zLeft, top), QPointF(zRight, bottom));
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::settleOrigin()
|
2018-04-15 12:11:51 +00:00
|
|
|
{
|
|
|
|
if (originSettled())
|
|
|
|
return;
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Snapshot snapshot;
|
2018-04-15 12:11:51 +00:00
|
|
|
toSnapshot(&snapshot);
|
|
|
|
QRectF mainProfile;
|
|
|
|
QRectF sideProfile;
|
2021-11-18 14:58:01 +00:00
|
|
|
resolveSnapshotBoundingBox(snapshot, &mainProfile, &sideProfile);
|
2019-10-19 13:14:36 +00:00
|
|
|
setOriginX(mainProfile.x() + mainProfile.width() / 2);
|
|
|
|
setOriginY(mainProfile.y() + mainProfile.height() / 2);
|
|
|
|
setOriginZ(sideProfile.x() + sideProfile.width() / 2);
|
2018-08-27 08:50:40 +00:00
|
|
|
markAllDirty();
|
2018-04-15 12:11:51 +00:00
|
|
|
emit originChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartXmirrorState(dust3d::Uuid partId, bool mirrored)
|
2018-04-15 12:11:51 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.xMirrored == mirrored)
|
|
|
|
return;
|
|
|
|
part->second.xMirrored = mirrored;
|
2018-08-27 08:50:40 +00:00
|
|
|
part->second.dirty = true;
|
2018-04-15 12:11:51 +00:00
|
|
|
settleOrigin();
|
|
|
|
emit partXmirrorStateChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartDeformThickness(dust3d::Uuid partId, float thickness)
|
2018-04-17 13:13:32 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
2018-04-17 16:14:31 +00:00
|
|
|
part->second.setDeformThickness(thickness);
|
2018-08-27 08:50:40 +00:00
|
|
|
part->second.dirty = true;
|
2018-04-17 16:14:31 +00:00
|
|
|
emit partDeformThicknessChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartBase(dust3d::Uuid partId, dust3d::PartBase base)
|
2019-05-20 13:38:01 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.base == base)
|
|
|
|
return;
|
|
|
|
part->second.base = base;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partBaseChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartDeformWidth(dust3d::Uuid partId, float width)
|
2018-04-17 16:14:31 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
part->second.setDeformWidth(width);
|
2018-08-27 08:50:40 +00:00
|
|
|
part->second.dirty = true;
|
2018-04-17 16:14:31 +00:00
|
|
|
emit partDeformWidthChanged(partId);
|
2018-04-17 13:13:32 +00:00
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartDeformUnified(dust3d::Uuid partId, bool unified)
|
2020-10-18 10:31:40 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.deformUnified == unified)
|
|
|
|
return;
|
|
|
|
part->second.deformUnified = unified;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partDeformUnifyStateChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartMaterialId(dust3d::Uuid partId, dust3d::Uuid materialId)
|
2018-10-04 12:51:01 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
2018-10-09 02:19:12 +00:00
|
|
|
if (part->second.materialId == materialId)
|
2018-10-04 12:51:01 +00:00
|
|
|
return;
|
2018-10-09 02:19:12 +00:00
|
|
|
part->second.materialId = materialId;
|
2018-10-04 12:51:01 +00:00
|
|
|
part->second.dirty = true;
|
2018-10-09 02:19:12 +00:00
|
|
|
emit partMaterialIdChanged(partId);
|
2018-10-09 09:17:44 +00:00
|
|
|
emit textureChanged();
|
2018-10-04 12:51:01 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartRoundState(dust3d::Uuid partId, bool rounded)
|
2018-04-26 02:23:22 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.rounded == rounded)
|
|
|
|
return;
|
|
|
|
part->second.rounded = rounded;
|
2018-08-27 08:50:40 +00:00
|
|
|
part->second.dirty = true;
|
2018-04-26 02:23:22 +00:00
|
|
|
emit partRoundStateChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartChamferState(dust3d::Uuid partId, bool chamfered)
|
2019-03-09 22:10:39 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.chamfered == chamfered)
|
|
|
|
return;
|
|
|
|
part->second.chamfered = chamfered;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partChamferStateChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartTarget(dust3d::Uuid partId, dust3d::PartTarget target)
|
2019-05-19 03:21:38 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.target == target)
|
|
|
|
return;
|
|
|
|
part->second.target = target;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partTargetChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartColorSolubility(dust3d::Uuid partId, float solubility)
|
2019-05-25 23:24:24 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (qFuzzyCompare(part->second.colorSolubility, solubility))
|
|
|
|
return;
|
|
|
|
part->second.colorSolubility = solubility;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partColorSolubilityChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartMetalness(dust3d::Uuid partId, float metalness)
|
2020-10-18 05:03:15 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (qFuzzyCompare(part->second.metalness, metalness))
|
|
|
|
return;
|
|
|
|
part->second.metalness = metalness;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partMetalnessChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartRoughness(dust3d::Uuid partId, float roughness)
|
2020-10-18 05:03:15 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (qFuzzyCompare(part->second.roughness, roughness))
|
|
|
|
return;
|
|
|
|
part->second.roughness = roughness;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partRoughnessChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartHollowThickness(dust3d::Uuid partId, float hollowThickness)
|
2019-08-18 12:02:39 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (qFuzzyCompare(part->second.hollowThickness, hollowThickness))
|
|
|
|
return;
|
|
|
|
part->second.hollowThickness = hollowThickness;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partHollowThicknessChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartCountershaded(dust3d::Uuid partId, bool countershaded)
|
2019-11-07 12:08:47 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.countershaded == countershaded)
|
|
|
|
return;
|
|
|
|
part->second.countershaded = countershaded;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partCountershadeStateChanged(partId);
|
|
|
|
emit textureChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartSmoothState(dust3d::Uuid partId, bool smooth)
|
2020-10-20 11:18:08 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.smooth == smooth)
|
|
|
|
return;
|
|
|
|
part->second.smooth = smooth;
|
|
|
|
part->second.dirty = true;
|
|
|
|
emit partSmoothStateChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartCutRotation(dust3d::Uuid partId, float cutRotation)
|
2018-08-31 04:54:32 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
2019-02-24 13:42:23 +00:00
|
|
|
if (qFuzzyCompare(cutRotation, part->second.cutRotation))
|
|
|
|
return;
|
2019-02-21 22:48:15 +00:00
|
|
|
part->second.setCutRotation(cutRotation);
|
2018-08-31 04:54:32 +00:00
|
|
|
part->second.dirty = true;
|
2019-02-21 22:48:15 +00:00
|
|
|
emit partCutRotationChanged(partId);
|
2018-08-31 04:54:32 +00:00
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartCutFace(dust3d::Uuid partId, dust3d::CutFace cutFace)
|
2019-02-24 13:42:23 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
2019-05-05 12:49:26 +00:00
|
|
|
if (part->second.cutFace == cutFace)
|
2019-02-24 13:42:23 +00:00
|
|
|
return;
|
2019-05-05 12:49:26 +00:00
|
|
|
part->second.setCutFace(cutFace);
|
2019-02-24 13:42:23 +00:00
|
|
|
part->second.dirty = true;
|
2019-05-19 03:21:38 +00:00
|
|
|
emit partCutFaceChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartCutFaceLinkedId(dust3d::Uuid partId, dust3d::Uuid linkedId)
|
2019-05-19 03:21:38 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
if (part->second.cutFace == dust3d::CutFace::UserDefined && part->second.cutFaceLinkedId == linkedId)
|
2019-05-19 03:21:38 +00:00
|
|
|
return;
|
|
|
|
part->second.setCutFaceLinkedId(linkedId);
|
|
|
|
part->second.dirty = true;
|
2019-05-05 12:49:26 +00:00
|
|
|
emit partCutFaceChanged(partId);
|
2019-02-24 13:42:23 +00:00
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setPartColorState(dust3d::Uuid partId, bool hasColor, QColor color)
|
2018-04-26 02:23:22 +00:00
|
|
|
{
|
|
|
|
auto part = partMap.find(partId);
|
|
|
|
if (part == partMap.end()) {
|
|
|
|
qDebug() << "Part not found:" << partId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (part->second.hasColor == hasColor && part->second.color == color)
|
|
|
|
return;
|
|
|
|
part->second.hasColor = hasColor;
|
|
|
|
part->second.color = color;
|
2018-08-27 08:50:40 +00:00
|
|
|
part->second.dirty = true;
|
2018-04-26 02:23:22 +00:00
|
|
|
emit partColorStateChanged(partId);
|
|
|
|
emit skeletonChanged();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::saveSnapshot()
|
2018-04-08 23:34:46 +00:00
|
|
|
{
|
2018-10-25 00:19:38 +00:00
|
|
|
HistoryItem item;
|
2018-04-08 23:34:46 +00:00
|
|
|
toSnapshot(&item.snapshot);
|
2018-10-25 06:27:59 +00:00
|
|
|
if (m_undoItems.size() + 1 > m_maxSnapshot)
|
|
|
|
m_undoItems.pop_front();
|
2018-04-08 23:34:46 +00:00
|
|
|
m_undoItems.push_back(item);
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::undo()
|
2018-04-08 23:34:46 +00:00
|
|
|
{
|
2018-10-25 06:27:59 +00:00
|
|
|
if (!undoable())
|
2018-04-08 23:34:46 +00:00
|
|
|
return;
|
|
|
|
m_redoItems.push_back(m_undoItems.back());
|
|
|
|
m_undoItems.pop_back();
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& item = m_undoItems.back();
|
2018-10-25 06:27:59 +00:00
|
|
|
fromSnapshot(item.snapshot);
|
2018-04-08 23:34:46 +00:00
|
|
|
qDebug() << "Undo/Redo items:" << m_undoItems.size() << m_redoItems.size();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::redo()
|
2018-04-08 23:34:46 +00:00
|
|
|
{
|
|
|
|
if (m_redoItems.empty())
|
|
|
|
return;
|
|
|
|
m_undoItems.push_back(m_redoItems.back());
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& item = m_redoItems.back();
|
2018-10-25 06:27:59 +00:00
|
|
|
fromSnapshot(item.snapshot);
|
2018-04-08 23:34:46 +00:00
|
|
|
m_redoItems.pop_back();
|
|
|
|
qDebug() << "Undo/Redo items:" << m_undoItems.size() << m_redoItems.size();
|
|
|
|
}
|
|
|
|
|
2018-10-25 06:27:59 +00:00
|
|
|
void Document::clearHistories()
|
|
|
|
{
|
|
|
|
m_undoItems.clear();
|
|
|
|
m_redoItems.clear();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::paste()
|
2018-04-09 08:46:06 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
const QClipboard* clipboard = QApplication::clipboard();
|
|
|
|
const QMimeData* mimeData = clipboard->mimeData();
|
2018-04-09 08:46:06 +00:00
|
|
|
if (mimeData->hasText()) {
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Snapshot snapshot;
|
|
|
|
std::string text = mimeData->text().toUtf8().constData();
|
2022-10-18 09:35:04 +00:00
|
|
|
loadSnapshotFromXmlString(&snapshot, (char*)text.c_str());
|
2020-04-07 23:15:20 +00:00
|
|
|
addFromSnapshot(snapshot, SnapshotSource::Paste);
|
2020-04-12 06:48:24 +00:00
|
|
|
saveSnapshot();
|
2018-04-09 08:46:06 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-09 14:24:30 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
bool Document::hasPastableNodesInClipboard() const
|
2018-04-09 14:24:30 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
const QClipboard* clipboard = QApplication::clipboard();
|
|
|
|
const QMimeData* mimeData = clipboard->mimeData();
|
2018-04-09 14:24:30 +00:00
|
|
|
if (mimeData->hasText()) {
|
2018-10-02 04:59:30 +00:00
|
|
|
if (-1 != mimeData->text().indexOf("<node "))
|
2018-09-21 07:10:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
bool Document::hasPastableMaterialsInClipboard() const
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
const QClipboard* clipboard = QApplication::clipboard();
|
|
|
|
const QMimeData* mimeData = clipboard->mimeData();
|
2018-10-09 02:19:12 +00:00
|
|
|
if (mimeData->hasText()) {
|
|
|
|
if (-1 != mimeData->text().indexOf("<material "))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
bool Document::undoable() const
|
2018-04-09 15:10:23 +00:00
|
|
|
{
|
2018-10-25 06:27:59 +00:00
|
|
|
return m_undoItems.size() >= 2;
|
2018-04-09 15:10:23 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
bool Document::redoable() const
|
2018-04-09 15:10:23 +00:00
|
|
|
{
|
|
|
|
return !m_redoItems.empty();
|
|
|
|
}
|
2018-04-13 00:19:31 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
bool Document::isNodeEditable(dust3d::Uuid nodeId) const
|
2018-04-13 00:19:31 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
const SkeletonNode* node = findNode(nodeId);
|
2018-04-13 00:19:31 +00:00
|
|
|
if (!node) {
|
|
|
|
qDebug() << "Node id not found:" << nodeId;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !isPartReadonly(node->partId);
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
bool Document::isEdgeEditable(dust3d::Uuid edgeId) const
|
2018-04-13 00:19:31 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
const SkeletonEdge* edge = findEdge(edgeId);
|
2018-04-13 00:19:31 +00:00
|
|
|
if (!edge) {
|
|
|
|
qDebug() << "Edge id not found:" << edgeId;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !isPartReadonly(edge->partId);
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
bool Document::isExportReady() const
|
2018-05-07 16:08:19 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
if (m_meshGenerator || m_textureGenerator || m_postProcessor)
|
2018-05-07 16:08:19 +00:00
|
|
|
return false;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
if (m_isResultMeshObsolete || m_isTextureObsolete || m_isPostProcessResultObsolete)
|
2020-11-18 11:01:11 +00:00
|
|
|
return false;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-05-07 16:08:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::checkExportReadyState()
|
2018-05-07 16:08:19 +00:00
|
|
|
{
|
|
|
|
if (isExportReady())
|
|
|
|
emit exportReady();
|
|
|
|
}
|
2018-06-15 05:34:41 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::addMaterial(dust3d::Uuid materialId, QString name, std::vector<MaterialLayer> layers)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
2020-04-07 23:15:20 +00:00
|
|
|
auto findMaterialResult = materialMap.find(materialId);
|
|
|
|
if (findMaterialResult != materialMap.end()) {
|
|
|
|
qDebug() << "Material already exist:" << materialId;
|
|
|
|
return;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid newMaterialId = materialId;
|
2022-10-18 09:35:04 +00:00
|
|
|
auto& material = materialMap[newMaterialId];
|
2018-10-09 02:19:12 +00:00
|
|
|
material.id = newMaterialId;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
material.name = name;
|
|
|
|
material.layers = layers;
|
|
|
|
material.dirty = true;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
materialIdList.push_back(newMaterialId);
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
emit materialAdded(newMaterialId);
|
|
|
|
emit materialListChanged();
|
|
|
|
emit optionsChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::removeMaterial(dust3d::Uuid materialId)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
auto findMaterialResult = materialMap.find(materialId);
|
|
|
|
if (findMaterialResult == materialMap.end()) {
|
|
|
|
qDebug() << "Remove a none exist material:" << materialId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
materialIdList.erase(std::remove(materialIdList.begin(), materialIdList.end(), materialId), materialIdList.end());
|
|
|
|
materialMap.erase(findMaterialResult);
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
emit materialListChanged();
|
|
|
|
emit materialRemoved(materialId);
|
|
|
|
emit optionsChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::setMaterialLayers(dust3d::Uuid materialId, std::vector<MaterialLayer> layers)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
auto findMaterialResult = materialMap.find(materialId);
|
|
|
|
if (findMaterialResult == materialMap.end()) {
|
|
|
|
qDebug() << "Find material failed:" << materialId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
findMaterialResult->second.layers = layers;
|
|
|
|
findMaterialResult->second.dirty = true;
|
|
|
|
emit materialLayersChanged(materialId);
|
2018-10-09 09:17:44 +00:00
|
|
|
emit textureChanged();
|
2018-10-09 02:19:12 +00:00
|
|
|
emit optionsChanged();
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::renameMaterial(dust3d::Uuid materialId, QString name)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
auto findMaterialResult = materialMap.find(materialId);
|
|
|
|
if (findMaterialResult == materialMap.end()) {
|
|
|
|
qDebug() << "Find material failed:" << materialId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (findMaterialResult->second.name == name)
|
|
|
|
return;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
findMaterialResult->second.name = name;
|
|
|
|
emit materialNameChanged(materialId);
|
2019-06-25 21:54:22 +00:00
|
|
|
emit materialListChanged();
|
2018-10-09 02:19:12 +00:00
|
|
|
emit optionsChanged();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::generateMaterialPreviews()
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
if (nullptr != m_materialPreviewsGenerator) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
QThread* thread = new QThread;
|
2018-10-09 02:19:12 +00:00
|
|
|
m_materialPreviewsGenerator = new MaterialPreviewsGenerator();
|
|
|
|
bool hasDirtyMaterial = false;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (auto& materialIt : materialMap) {
|
2018-10-09 02:19:12 +00:00
|
|
|
if (!materialIt.second.dirty)
|
|
|
|
continue;
|
|
|
|
m_materialPreviewsGenerator->addMaterial(materialIt.first, materialIt.second.layers);
|
|
|
|
materialIt.second.dirty = false;
|
|
|
|
hasDirtyMaterial = true;
|
|
|
|
}
|
|
|
|
if (!hasDirtyMaterial) {
|
|
|
|
delete m_materialPreviewsGenerator;
|
|
|
|
m_materialPreviewsGenerator = nullptr;
|
|
|
|
delete thread;
|
|
|
|
return;
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
qDebug() << "Material previews generating..";
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
m_materialPreviewsGenerator->moveToThread(thread);
|
|
|
|
connect(thread, &QThread::started, m_materialPreviewsGenerator, &MaterialPreviewsGenerator::process);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_materialPreviewsGenerator, &MaterialPreviewsGenerator::finished, this, &Document::materialPreviewsReady);
|
2018-10-09 02:19:12 +00:00
|
|
|
connect(m_materialPreviewsGenerator, &MaterialPreviewsGenerator::finished, thread, &QThread::quit);
|
|
|
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
|
|
|
thread->start();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void Document::materialPreviewsReady()
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& materialId : m_materialPreviewsGenerator->generatedPreviewMaterialIds()) {
|
2018-10-09 02:19:12 +00:00
|
|
|
auto material = materialMap.find(materialId);
|
|
|
|
if (material != materialMap.end()) {
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh* resultPartPreviewMesh = m_materialPreviewsGenerator->takePreview(materialId);
|
2018-10-09 02:19:12 +00:00
|
|
|
material->second.updatePreviewMesh(resultPartPreviewMesh);
|
|
|
|
emit materialPreviewChanged(materialId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m_materialPreviewsGenerator;
|
|
|
|
m_materialPreviewsGenerator = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
qDebug() << "Material previews generation done";
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
generateMaterialPreviews();
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
bool Document::isMeshGenerating() const
|
2018-10-09 13:01:04 +00:00
|
|
|
{
|
|
|
|
return nullptr != m_meshGenerator;
|
|
|
|
}
|
|
|
|
|
2020-01-02 12:36:43 +00:00
|
|
|
bool Document::isPostProcessing() const
|
|
|
|
{
|
|
|
|
return nullptr != m_postProcessor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Document::isTextureGenerating() const
|
|
|
|
{
|
|
|
|
return nullptr != m_textureGenerator;
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
void Document::copyNodes(std::set<dust3d::Uuid> nodeIdSet) const
|
2018-11-03 08:09:42 +00:00
|
|
|
{
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Snapshot snapshot;
|
2018-11-03 08:09:42 +00:00
|
|
|
toSnapshot(&snapshot, nodeIdSet, DocumentToSnapshotFor::Nodes);
|
2021-11-18 14:58:01 +00:00
|
|
|
std::string snapshotXml;
|
|
|
|
dust3d::saveSnapshotToXmlString(snapshot, snapshotXml);
|
2022-10-18 09:35:04 +00:00
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
2021-11-18 14:58:01 +00:00
|
|
|
clipboard->setText(snapshotXml.c_str());
|
2019-08-17 10:13:11 +00:00
|
|
|
}
|
2020-12-15 14:28:20 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void Document::collectCutFaceList(std::vector<QString>& cutFaces) const
|
2020-12-15 14:28:20 +00:00
|
|
|
{
|
|
|
|
cutFaces.clear();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
std::vector<dust3d::Uuid> cutFacePartIdList;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
std::set<dust3d::Uuid> cutFacePartIds;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& it : partMap) {
|
2021-11-18 14:58:01 +00:00
|
|
|
if (dust3d::PartTarget::CutFace == it.second.target) {
|
2020-12-15 14:28:20 +00:00
|
|
|
if (cutFacePartIds.find(it.first) != cutFacePartIds.end())
|
|
|
|
continue;
|
|
|
|
cutFacePartIds.insert(it.first);
|
|
|
|
cutFacePartIdList.push_back(it.first);
|
|
|
|
}
|
|
|
|
if (!it.second.cutFaceLinkedId.isNull()) {
|
|
|
|
if (cutFacePartIds.find(it.second.cutFaceLinkedId) != cutFacePartIds.end())
|
|
|
|
continue;
|
|
|
|
cutFacePartIds.insert(it.second.cutFaceLinkedId);
|
|
|
|
cutFacePartIdList.push_back(it.second.cutFaceLinkedId);
|
|
|
|
}
|
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-12-15 14:28:20 +00:00
|
|
|
// Sort cut face by center.x of front view
|
2021-11-18 14:58:01 +00:00
|
|
|
std::map<dust3d::Uuid, float> centerOffsetMap;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& partId : cutFacePartIdList) {
|
|
|
|
const SkeletonPart* part = findPart(partId);
|
2020-12-15 14:28:20 +00:00
|
|
|
if (nullptr == part)
|
|
|
|
continue;
|
|
|
|
float offsetSum = 0;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (const auto& nodeId : part->nodeIds) {
|
|
|
|
const SkeletonNode* node = findNode(nodeId);
|
2020-12-15 14:28:20 +00:00
|
|
|
if (nullptr == node)
|
|
|
|
continue;
|
|
|
|
offsetSum += node->getX();
|
|
|
|
}
|
|
|
|
if (qFuzzyIsNull(offsetSum))
|
|
|
|
continue;
|
|
|
|
centerOffsetMap[partId] = offsetSum / part->nodeIds.size();
|
|
|
|
}
|
|
|
|
std::sort(cutFacePartIdList.begin(), cutFacePartIdList.end(),
|
2022-10-18 09:35:04 +00:00
|
|
|
[&](const dust3d::Uuid& firstPartId, const dust3d::Uuid& secondPartId) {
|
|
|
|
return centerOffsetMap[firstPartId] < centerOffsetMap[secondPartId];
|
|
|
|
});
|
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
size_t cutFaceTypeCount = (size_t)dust3d::CutFace::UserDefined;
|
2020-12-15 14:28:20 +00:00
|
|
|
for (size_t i = 0; i < (size_t)cutFaceTypeCount; ++i) {
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::CutFace cutFace = (dust3d::CutFace)i;
|
|
|
|
cutFaces.push_back(QString(dust3d::CutFaceToString(cutFace).c_str()));
|
2020-12-15 14:28:20 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
for (const auto& it : cutFacePartIdList)
|
2021-11-18 14:58:01 +00:00
|
|
|
cutFaces.push_back(QString(it.toString().c_str()));
|
2020-12-15 14:28:20 +00:00
|
|
|
}
|