Save object in document only when locked for painting
parent
484f6aaaba
commit
f6ea8bd206
|
@ -85,8 +85,6 @@ void AutoSaver::check()
|
||||||
Snapshot *snapshot = new Snapshot;
|
Snapshot *snapshot = new Snapshot;
|
||||||
m_document->toSnapshot(snapshot);
|
m_document->toSnapshot(snapshot);
|
||||||
|
|
||||||
Object *object = new Object(m_document->currentPostProcessedObject());
|
|
||||||
|
|
||||||
QByteArray *turnaroundPngByteArray = nullptr;
|
QByteArray *turnaroundPngByteArray = nullptr;
|
||||||
if (!m_document->turnaround.isNull() && m_document->turnaroundPngByteArray.size() > 0) {
|
if (!m_document->turnaround.isNull() && m_document->turnaroundPngByteArray.size() > 0) {
|
||||||
turnaroundPngByteArray = new QByteArray(m_document->turnaroundPngByteArray);
|
turnaroundPngByteArray = new QByteArray(m_document->turnaroundPngByteArray);
|
||||||
|
@ -103,24 +101,29 @@ void AutoSaver::check()
|
||||||
scriptVariables = new std::map<QString, std::map<QString, QString>>(variables);
|
scriptVariables = new std::map<QString, std::map<QString, QString>>(variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentSaver::Textures *textures = new DocumentSaver::Textures;
|
Object *object = nullptr;
|
||||||
if (nullptr != m_document->textureImage) {
|
DocumentSaver::Textures *textures = nullptr;
|
||||||
textures->textureImage = new QImage(*m_document->textureImage);
|
|
||||||
}
|
|
||||||
if (nullptr != m_document->textureNormalImage) {
|
|
||||||
textures->textureNormalImage = new QImage(*m_document->textureNormalImage);
|
|
||||||
}
|
|
||||||
if (nullptr != m_document->textureMetalnessImage) {
|
|
||||||
textures->textureMetalnessImage = new QImage(*m_document->textureMetalnessImage);
|
|
||||||
}
|
|
||||||
if (nullptr != m_document->textureRoughnessImage) {
|
|
||||||
textures->textureRoughnessImage = new QImage(*m_document->textureRoughnessImage);
|
|
||||||
}
|
|
||||||
if (nullptr != m_document->textureAmbientOcclusionImage) {
|
|
||||||
textures->textureAmbientOcclusionImage = new QImage(*m_document->textureAmbientOcclusionImage);
|
|
||||||
}
|
|
||||||
textures->textureHasTransparencySettings = m_document->textureHasTransparencySettings;
|
|
||||||
|
|
||||||
|
if (m_document->objectLocked) {
|
||||||
|
object = new Object(m_document->currentPostProcessedObject());
|
||||||
|
textures = new DocumentSaver::Textures;
|
||||||
|
if (nullptr != m_document->textureImage) {
|
||||||
|
textures->textureImage = new QImage(*m_document->textureImage);
|
||||||
|
}
|
||||||
|
if (nullptr != m_document->textureNormalImage) {
|
||||||
|
textures->textureNormalImage = new QImage(*m_document->textureNormalImage);
|
||||||
|
}
|
||||||
|
if (nullptr != m_document->textureMetalnessImage) {
|
||||||
|
textures->textureMetalnessImage = new QImage(*m_document->textureMetalnessImage);
|
||||||
|
}
|
||||||
|
if (nullptr != m_document->textureRoughnessImage) {
|
||||||
|
textures->textureRoughnessImage = new QImage(*m_document->textureRoughnessImage);
|
||||||
|
}
|
||||||
|
if (nullptr != m_document->textureAmbientOcclusionImage) {
|
||||||
|
textures->textureAmbientOcclusionImage = new QImage(*m_document->textureAmbientOcclusionImage);
|
||||||
|
}
|
||||||
|
textures->textureHasTransparencySettings = m_document->textureHasTransparencySettings;
|
||||||
|
}
|
||||||
QThread *thread = new QThread;
|
QThread *thread = new QThread;
|
||||||
m_documentSaver = new DocumentSaver(&m_filename,
|
m_documentSaver = new DocumentSaver(&m_filename,
|
||||||
snapshot,
|
snapshot,
|
||||||
|
|
|
@ -109,7 +109,7 @@ bool DocumentSaver::save(const QString *filename,
|
||||||
ds3Writer.add("model.xml", "model", &modelXml);
|
ds3Writer.add("model.xml", "model", &modelXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (nullptr != object) {
|
||||||
QByteArray objectXml;
|
QByteArray objectXml;
|
||||||
QXmlStreamWriter stream(&objectXml);
|
QXmlStreamWriter stream(&objectXml);
|
||||||
saveObjectToXmlStream(object, &stream);
|
saveObjectToXmlStream(object, &stream);
|
||||||
|
@ -117,7 +117,7 @@ bool DocumentSaver::save(const QString *filename,
|
||||||
ds3Writer.add("object.xml", "object", &objectXml);
|
ds3Writer.add("object.xml", "object", &objectXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullptr != textures) {
|
if (nullptr != object && nullptr != textures) {
|
||||||
if (nullptr != textures->textureImage && !textures->textureImage->isNull()) {
|
if (nullptr != textures->textureImage && !textures->textureImage->isNull()) {
|
||||||
if (nullptr == textures->textureImageByteArray) {
|
if (nullptr == textures->textureImageByteArray) {
|
||||||
textures->textureImageByteArray = new QByteArray;
|
textures->textureImageByteArray = new QByteArray;
|
||||||
|
|
|
@ -1584,59 +1584,63 @@ void DocumentWindow::saveTo(const QString &saveAsFilename)
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
m_document->toSnapshot(&snapshot);
|
m_document->toSnapshot(&snapshot);
|
||||||
|
bool saveObject = m_document->objectLocked;
|
||||||
DocumentSaver::Textures textures;
|
DocumentSaver::Textures textures;
|
||||||
textures.textureImage = m_document->textureImage;
|
if (saveObject) {
|
||||||
textures.textureImageByteArray = m_document->textureImageByteArray;
|
textures.textureImage = m_document->textureImage;
|
||||||
textures.textureNormalImage = m_document->textureNormalImage;
|
textures.textureImageByteArray = m_document->textureImageByteArray;
|
||||||
textures.textureNormalImageByteArray = m_document->textureNormalImageByteArray;
|
textures.textureNormalImage = m_document->textureNormalImage;
|
||||||
textures.textureMetalnessImage = m_document->textureMetalnessImage;
|
textures.textureNormalImageByteArray = m_document->textureNormalImageByteArray;
|
||||||
textures.textureMetalnessImageByteArray = m_document->textureMetalnessImageByteArray;
|
textures.textureMetalnessImage = m_document->textureMetalnessImage;
|
||||||
textures.textureRoughnessImage = m_document->textureRoughnessImage;
|
textures.textureMetalnessImageByteArray = m_document->textureMetalnessImageByteArray;
|
||||||
textures.textureRoughnessImageByteArray = m_document->textureRoughnessImageByteArray;
|
textures.textureRoughnessImage = m_document->textureRoughnessImage;
|
||||||
textures.textureAmbientOcclusionImage = m_document->textureAmbientOcclusionImage;
|
textures.textureRoughnessImageByteArray = m_document->textureRoughnessImageByteArray;
|
||||||
textures.textureAmbientOcclusionImageByteArray = m_document->textureAmbientOcclusionImageByteArray;
|
textures.textureAmbientOcclusionImage = m_document->textureAmbientOcclusionImage;
|
||||||
textures.textureHasTransparencySettings = m_document->textureHasTransparencySettings;
|
textures.textureAmbientOcclusionImageByteArray = m_document->textureAmbientOcclusionImageByteArray;
|
||||||
|
textures.textureHasTransparencySettings = m_document->textureHasTransparencySettings;
|
||||||
|
}
|
||||||
if (DocumentSaver::save(&filename,
|
if (DocumentSaver::save(&filename,
|
||||||
&snapshot,
|
&snapshot,
|
||||||
&m_document->currentPostProcessedObject(),
|
saveObject ? &m_document->currentPostProcessedObject() : nullptr,
|
||||||
&textures,
|
saveObject ? &textures : nullptr,
|
||||||
(!m_document->turnaround.isNull() && m_document->turnaroundPngByteArray.size() > 0) ?
|
(!m_document->turnaround.isNull() && m_document->turnaroundPngByteArray.size() > 0) ?
|
||||||
&m_document->turnaroundPngByteArray : nullptr,
|
&m_document->turnaroundPngByteArray : nullptr,
|
||||||
(!m_document->script().isEmpty()) ? &m_document->script() : nullptr,
|
(!m_document->script().isEmpty()) ? &m_document->script() : nullptr,
|
||||||
(!m_document->variables().empty()) ? &m_document->variables() : nullptr)) {
|
(!m_document->variables().empty()) ? &m_document->variables() : nullptr)) {
|
||||||
setCurrentFilename(filename);
|
setCurrentFilename(filename);
|
||||||
}
|
}
|
||||||
textures.textureImage = nullptr;
|
if (saveObject) {
|
||||||
textures.textureNormalImage = nullptr;
|
textures.textureImage = nullptr;
|
||||||
textures.textureMetalnessImage = nullptr;
|
textures.textureNormalImage = nullptr;
|
||||||
textures.textureRoughnessImage = nullptr;
|
textures.textureMetalnessImage = nullptr;
|
||||||
textures.textureAmbientOcclusionImage = nullptr;
|
textures.textureRoughnessImage = nullptr;
|
||||||
|
textures.textureAmbientOcclusionImage = nullptr;
|
||||||
|
|
||||||
if (textures.textureImageByteArray != m_document->textureImageByteArray)
|
if (textures.textureImageByteArray != m_document->textureImageByteArray)
|
||||||
std::swap(textures.textureImageByteArray, m_document->textureImageByteArray);
|
std::swap(textures.textureImageByteArray, m_document->textureImageByteArray);
|
||||||
else
|
else
|
||||||
textures.textureImageByteArray = nullptr;
|
textures.textureImageByteArray = nullptr;
|
||||||
|
|
||||||
if (textures.textureNormalImageByteArray != m_document->textureNormalImageByteArray)
|
if (textures.textureNormalImageByteArray != m_document->textureNormalImageByteArray)
|
||||||
std::swap(textures.textureNormalImageByteArray, m_document->textureNormalImageByteArray);
|
std::swap(textures.textureNormalImageByteArray, m_document->textureNormalImageByteArray);
|
||||||
else
|
else
|
||||||
textures.textureNormalImageByteArray = nullptr;
|
textures.textureNormalImageByteArray = nullptr;
|
||||||
|
|
||||||
if (textures.textureMetalnessImageByteArray != m_document->textureMetalnessImageByteArray)
|
if (textures.textureMetalnessImageByteArray != m_document->textureMetalnessImageByteArray)
|
||||||
std::swap(textures.textureMetalnessImageByteArray, m_document->textureMetalnessImageByteArray);
|
std::swap(textures.textureMetalnessImageByteArray, m_document->textureMetalnessImageByteArray);
|
||||||
else
|
else
|
||||||
textures.textureMetalnessImageByteArray = nullptr;
|
textures.textureMetalnessImageByteArray = nullptr;
|
||||||
|
|
||||||
if (textures.textureRoughnessImageByteArray != m_document->textureRoughnessImageByteArray)
|
if (textures.textureRoughnessImageByteArray != m_document->textureRoughnessImageByteArray)
|
||||||
std::swap(textures.textureRoughnessImageByteArray, m_document->textureRoughnessImageByteArray);
|
std::swap(textures.textureRoughnessImageByteArray, m_document->textureRoughnessImageByteArray);
|
||||||
else
|
else
|
||||||
textures.textureRoughnessImageByteArray = nullptr;
|
textures.textureRoughnessImageByteArray = nullptr;
|
||||||
|
|
||||||
if (textures.textureAmbientOcclusionImageByteArray != m_document->textureAmbientOcclusionImageByteArray)
|
|
||||||
std::swap(textures.textureAmbientOcclusionImageByteArray, m_document->textureAmbientOcclusionImageByteArray);
|
|
||||||
else
|
|
||||||
textures.textureAmbientOcclusionImageByteArray = nullptr;
|
|
||||||
|
|
||||||
|
if (textures.textureAmbientOcclusionImageByteArray != m_document->textureAmbientOcclusionImageByteArray)
|
||||||
|
std::swap(textures.textureAmbientOcclusionImageByteArray, m_document->textureAmbientOcclusionImageByteArray);
|
||||||
|
else
|
||||||
|
textures.textureAmbientOcclusionImageByteArray = nullptr;
|
||||||
|
}
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue