Fix undo
Add a crc64 hash check for history keeping to avoid repeated snapshot. Besides, before, there is a logic error in the undo implementation, which recover the most recent snapshot from undo stack, so user need undo twice and at the second undo get the expected result. This incorrect behavior got fixed.master
parent
208d2a0166
commit
637356e895
|
@ -1086,3 +1086,45 @@ https://www.reddit.com/r/gamedev/comments/5iuf3h/i_am_writting_a_3d_monster_mode
|
||||||
<pre>
|
<pre>
|
||||||
https://www.gamedev.net/articles/programming/graphics/how-to-work-with-fbx-sdk-r3582
|
https://www.gamedev.net/articles/programming/graphics/how-to-work-with-fbx-sdk-r3582
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<h1>crc64</h1>
|
||||||
|
<pre>
|
||||||
|
/* Redis uses the CRC64 variant with "Jones" coefficients and init value of 0.
|
||||||
|
*
|
||||||
|
* Specification of this CRC64 variant follows:
|
||||||
|
* Name: crc-64-jones
|
||||||
|
* Width: 64 bites
|
||||||
|
* Poly: 0xad93d23594c935a9
|
||||||
|
* Reflected In: True
|
||||||
|
* Xor_In: 0xffffffffffffffff
|
||||||
|
* Reflected_Out: True
|
||||||
|
* Xor_Out: 0x0
|
||||||
|
* Check("123456789"): 0xe9c6d914c4b8d9ca
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012, Salvatore Sanfilippo <antirez at gmail dot com>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Redis nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE. */
|
||||||
|
</pre>
|
|
@ -276,6 +276,11 @@ SOURCES += src/main.cpp
|
||||||
|
|
||||||
HEADERS += src/version.h
|
HEADERS += src/version.h
|
||||||
|
|
||||||
|
INCLUDEPATH += thirdparty/crc64
|
||||||
|
|
||||||
|
SOURCES += thirdparty/crc64/crc64.c
|
||||||
|
HEADERS += thirdparty/crc64/crc64.h
|
||||||
|
|
||||||
INCLUDEPATH += thirdparty/miniz
|
INCLUDEPATH += thirdparty/miniz
|
||||||
|
|
||||||
SOURCES += thirdparty/miniz/miniz.c
|
SOURCES += thirdparty/miniz/miniz.c
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
|
#include <functional>
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "snapshotxml.h"
|
#include "snapshotxml.h"
|
||||||
|
@ -1326,7 +1327,7 @@ void Document::addFromSnapshot(const Snapshot &snapshot, bool fromPaste)
|
||||||
emit motionListChanged();
|
emit motionListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::reset()
|
void Document::silentReset()
|
||||||
{
|
{
|
||||||
originX = 0.0;
|
originX = 0.0;
|
||||||
originY = 0.0;
|
originY = 0.0;
|
||||||
|
@ -1344,6 +1345,11 @@ void Document::reset()
|
||||||
motionIdList.clear();
|
motionIdList.clear();
|
||||||
rootComponent = Component();
|
rootComponent = Component();
|
||||||
removeRigResults();
|
removeRigResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::reset()
|
||||||
|
{
|
||||||
|
silentReset();
|
||||||
emit cleanup();
|
emit cleanup();
|
||||||
emit skeletonChanged();
|
emit skeletonChanged();
|
||||||
}
|
}
|
||||||
|
@ -2285,21 +2291,27 @@ void Document::setPartColorState(QUuid partId, bool hasColor, QColor color)
|
||||||
|
|
||||||
void Document::saveSnapshot()
|
void Document::saveSnapshot()
|
||||||
{
|
{
|
||||||
if (m_undoItems.size() + 1 > m_maxSnapshot)
|
|
||||||
m_undoItems.pop_front();
|
|
||||||
HistoryItem item;
|
HistoryItem item;
|
||||||
toSnapshot(&item.snapshot);
|
toSnapshot(&item.snapshot);
|
||||||
|
item.hash = item.snapshot.hash();
|
||||||
|
if (!m_undoItems.empty() && item.hash == m_undoItems[m_undoItems.size() - 1].hash) {
|
||||||
|
qDebug() << "Snapshot has the same hash:" << item.hash << "skipped";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_undoItems.size() + 1 > m_maxSnapshot)
|
||||||
|
m_undoItems.pop_front();
|
||||||
m_undoItems.push_back(item);
|
m_undoItems.push_back(item);
|
||||||
qDebug() << "Undo items:" << m_undoItems.size();
|
qDebug() << "Snapshot saved with hash:" << item.hash << " History count:" << m_undoItems.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::undo()
|
void Document::undo()
|
||||||
{
|
{
|
||||||
if (m_undoItems.empty())
|
if (!undoable())
|
||||||
return;
|
return;
|
||||||
m_redoItems.push_back(m_undoItems.back());
|
m_redoItems.push_back(m_undoItems.back());
|
||||||
fromSnapshot(m_undoItems.back().snapshot);
|
|
||||||
m_undoItems.pop_back();
|
m_undoItems.pop_back();
|
||||||
|
const auto &item = m_undoItems.back();
|
||||||
|
fromSnapshot(item.snapshot);
|
||||||
qDebug() << "Undo/Redo items:" << m_undoItems.size() << m_redoItems.size();
|
qDebug() << "Undo/Redo items:" << m_undoItems.size() << m_redoItems.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2308,11 +2320,18 @@ void Document::redo()
|
||||||
if (m_redoItems.empty())
|
if (m_redoItems.empty())
|
||||||
return;
|
return;
|
||||||
m_undoItems.push_back(m_redoItems.back());
|
m_undoItems.push_back(m_redoItems.back());
|
||||||
fromSnapshot(m_redoItems.back().snapshot);
|
const auto &item = m_redoItems.back();
|
||||||
|
fromSnapshot(item.snapshot);
|
||||||
m_redoItems.pop_back();
|
m_redoItems.pop_back();
|
||||||
qDebug() << "Undo/Redo items:" << m_undoItems.size() << m_redoItems.size();
|
qDebug() << "Undo/Redo items:" << m_undoItems.size() << m_redoItems.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::clearHistories()
|
||||||
|
{
|
||||||
|
m_undoItems.clear();
|
||||||
|
m_redoItems.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void Document::paste()
|
void Document::paste()
|
||||||
{
|
{
|
||||||
const QClipboard *clipboard = QApplication::clipboard();
|
const QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
@ -2371,7 +2390,7 @@ bool Document::hasPastableMotionsInClipboard() const
|
||||||
|
|
||||||
bool Document::undoable() const
|
bool Document::undoable() const
|
||||||
{
|
{
|
||||||
return !m_undoItems.empty();
|
return m_undoItems.size() >= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Document::redoable() const
|
bool Document::redoable() const
|
||||||
|
|
|
@ -200,6 +200,7 @@ enum class SkeletonProfile
|
||||||
class HistoryItem
|
class HistoryItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
uint32_t hash;
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -773,6 +774,8 @@ public slots:
|
||||||
void batchChangeBegin();
|
void batchChangeBegin();
|
||||||
void batchChangeEnd();
|
void batchChangeEnd();
|
||||||
void reset();
|
void reset();
|
||||||
|
void clearHistories();
|
||||||
|
void silentReset();
|
||||||
void breakEdge(QUuid edgeId);
|
void breakEdge(QUuid edgeId);
|
||||||
void setXlockState(bool locked);
|
void setXlockState(bool locked);
|
||||||
void setYlockState(bool locked);
|
void setYlockState(bool locked);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -738,7 +738,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround);
|
connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround);
|
||||||
connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &SkeletonDocumentWindow::save);
|
connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &SkeletonDocumentWindow::save);
|
||||||
connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &SkeletonDocumentWindow::open);
|
connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &SkeletonDocumentWindow::open);
|
||||||
|
|
||||||
connect(m_document, &Document::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded);
|
connect(m_document, &Document::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded);
|
||||||
connect(m_document, &Document::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved);
|
connect(m_document, &Document::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved);
|
||||||
connect(m_document, &Document::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded);
|
connect(m_document, &Document::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded);
|
||||||
|
@ -966,7 +966,9 @@ void SkeletonDocumentWindow::newDocument()
|
||||||
if (answer != QMessageBox::Yes)
|
if (answer != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
m_document->clearHistories();
|
||||||
m_document->reset();
|
m_document->reset();
|
||||||
|
m_document->saveSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonDocumentWindow::saveAs()
|
void SkeletonDocumentWindow::saveAs()
|
||||||
|
@ -1153,6 +1155,10 @@ void SkeletonDocumentWindow::open()
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
Ds3FileReader ds3Reader(filename);
|
Ds3FileReader ds3Reader(filename);
|
||||||
|
|
||||||
|
m_document->clearHistories();
|
||||||
|
m_document->reset();
|
||||||
|
m_document->saveSnapshot();
|
||||||
|
|
||||||
for (int i = 0; i < ds3Reader.items().size(); ++i) {
|
for (int i = 0; i < ds3Reader.items().size(); ++i) {
|
||||||
Ds3ReaderItem item = ds3Reader.items().at(i);
|
Ds3ReaderItem item = ds3Reader.items().at(i);
|
||||||
if (item.type == "asset") {
|
if (item.type == "asset") {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "snapshot.h"
|
#include "snapshot.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
void Snapshot::resolveBoundingBox(QRectF *mainProfile, QRectF *sideProfile, const QString &partId)
|
void Snapshot::resolveBoundingBox(QRectF *mainProfile, QRectF *sideProfile, const QString &partId) const
|
||||||
{
|
{
|
||||||
float left = 0;
|
float left = 0;
|
||||||
bool leftFirstTime = true;
|
bool leftFirstTime = true;
|
||||||
|
@ -50,9 +50,6 @@ void Snapshot::resolveBoundingBox(QRectF *mainProfile, QRectF *sideProfile, cons
|
||||||
}
|
}
|
||||||
*mainProfile = QRectF(QPointF(left, top), QPointF(right, bottom));
|
*mainProfile = QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||||
*sideProfile = QRectF(QPointF(zLeft, top), QPointF(zRight, bottom));
|
*sideProfile = QRectF(QPointF(zLeft, top), QPointF(zRight, bottom));
|
||||||
//qDebug() << "resolveBoundingBox left:" << left << "top:" << top << "right:" << right << "bottom:" << bottom << " zLeft:" << zLeft << "zRight:" << zRight;
|
|
||||||
//qDebug() << "mainHeight:" << mainProfile->height() << "mainWidth:" << mainProfile->width();
|
|
||||||
//qDebug() << "sideHeight:" << sideProfile->height() << "sideWidth:" << sideProfile->width();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QSizeF>
|
#include <QSizeF>
|
||||||
|
extern "C" {
|
||||||
|
#include <crc64.h>
|
||||||
|
}
|
||||||
|
|
||||||
class Snapshot
|
class Snapshot
|
||||||
{
|
{
|
||||||
|
@ -18,8 +21,98 @@ public:
|
||||||
std::vector<std::pair<std::map<QString, QString>, std::map<QString, std::map<QString, QString>>>> poses; // std::pair<Pose attributes, Bone attributes>
|
std::vector<std::pair<std::map<QString, QString>, std::map<QString, std::map<QString, QString>>>> poses; // std::pair<Pose attributes, Bone attributes>
|
||||||
std::vector<std::pair<std::map<QString, QString>, std::vector<std::map<QString, QString>>>> motions; // std::pair<Motion attributes, clips>
|
std::vector<std::pair<std::map<QString, QString>, std::vector<std::map<QString, QString>>>> motions; // std::pair<Motion attributes, clips>
|
||||||
std::vector<std::pair<std::map<QString, QString>, std::vector<std::pair<std::map<QString, QString>, std::vector<std::map<QString, QString>>>>>> materials; // std::pair<Material attributes, layers> layer: std::pair<Layer attributes, maps>
|
std::vector<std::pair<std::map<QString, QString>, std::vector<std::pair<std::map<QString, QString>, std::vector<std::map<QString, QString>>>>>> materials; // std::pair<Material attributes, layers> layer: std::pair<Layer attributes, maps>
|
||||||
public:
|
|
||||||
void resolveBoundingBox(QRectF *mainProfile, QRectF *sideProfile, const QString &partId=QString());
|
uint64_t hash() const
|
||||||
|
{
|
||||||
|
std::vector<unsigned char> buffer;
|
||||||
|
auto addQStringToBuffer = [&buffer](const QString &str) {
|
||||||
|
auto byteArray = str.toUtf8();
|
||||||
|
for (const auto &byte: byteArray)
|
||||||
|
buffer.push_back(byte);
|
||||||
|
};
|
||||||
|
for (const auto &item: canvas) {
|
||||||
|
addQStringToBuffer(item.first);
|
||||||
|
addQStringToBuffer(item.second);
|
||||||
|
}
|
||||||
|
for (const auto &item: nodes) {
|
||||||
|
addQStringToBuffer(item.first);
|
||||||
|
for (const auto &subItem: item.second) {
|
||||||
|
addQStringToBuffer(subItem.first);
|
||||||
|
addQStringToBuffer(subItem.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &item: edges) {
|
||||||
|
addQStringToBuffer(item.first);
|
||||||
|
for (const auto &subItem: item.second) {
|
||||||
|
addQStringToBuffer(subItem.first);
|
||||||
|
addQStringToBuffer(subItem.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &item: parts) {
|
||||||
|
addQStringToBuffer(item.first);
|
||||||
|
for (const auto &subItem: item.second) {
|
||||||
|
addQStringToBuffer(subItem.first);
|
||||||
|
addQStringToBuffer(subItem.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &item: components) {
|
||||||
|
addQStringToBuffer(item.first);
|
||||||
|
for (const auto &subItem: item.second) {
|
||||||
|
addQStringToBuffer(subItem.first);
|
||||||
|
addQStringToBuffer(subItem.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &item: rootComponent) {
|
||||||
|
addQStringToBuffer(item.first);
|
||||||
|
addQStringToBuffer(item.second);
|
||||||
|
}
|
||||||
|
for (const auto &item: poses) {
|
||||||
|
for (const auto &subItem: item.first) {
|
||||||
|
addQStringToBuffer(subItem.first);
|
||||||
|
addQStringToBuffer(subItem.second);
|
||||||
|
}
|
||||||
|
for (const auto &subItem: item.second) {
|
||||||
|
addQStringToBuffer(subItem.first);
|
||||||
|
for (const auto &subSubItem: subItem.second) {
|
||||||
|
addQStringToBuffer(subSubItem.first);
|
||||||
|
addQStringToBuffer(subSubItem.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &item: motions) {
|
||||||
|
for (const auto &subItem: item.first) {
|
||||||
|
addQStringToBuffer(subItem.first);
|
||||||
|
addQStringToBuffer(subItem.second);
|
||||||
|
}
|
||||||
|
for (const auto &subItem: item.second) {
|
||||||
|
for (const auto &subSubItem: subItem) {
|
||||||
|
addQStringToBuffer(subSubItem.first);
|
||||||
|
addQStringToBuffer(subSubItem.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &item: materials) {
|
||||||
|
for (const auto &subItem: item.first) {
|
||||||
|
addQStringToBuffer(subItem.first);
|
||||||
|
addQStringToBuffer(subItem.second);
|
||||||
|
}
|
||||||
|
for (const auto &subItem: item.second) {
|
||||||
|
for (const auto &subSubItem: subItem.first) {
|
||||||
|
addQStringToBuffer(subSubItem.first);
|
||||||
|
addQStringToBuffer(subSubItem.second);
|
||||||
|
}
|
||||||
|
for (const auto &subSubItem: subItem.second) {
|
||||||
|
for (const auto &subSubSubItem: subSubItem) {
|
||||||
|
addQStringToBuffer(subSubSubItem.first);
|
||||||
|
addQStringToBuffer(subSubSubItem.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return crc64(0, buffer.data(), buffer.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void resolveBoundingBox(QRectF *mainProfile, QRectF *sideProfile, const QString &partId=QString()) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,12 +32,14 @@ bool ChartPacker::tryPack(float textureSize)
|
||||||
std::vector<maxRectsSize> rects;
|
std::vector<maxRectsSize> rects;
|
||||||
int width = textureSize * m_floatToIntFactor;
|
int width = textureSize * m_floatToIntFactor;
|
||||||
int height = width;
|
int height = width;
|
||||||
qDebug() << "Try the " << m_tryNum << "nth times pack with factor:" << m_textureSizeFactor << " size:" << width << "x" << height;
|
if (m_tryNum > 3) {
|
||||||
|
qDebug() << "Try the " << m_tryNum << "nth times pack with factor:" << m_textureSizeFactor << " size:" << width << "x" << height;
|
||||||
|
}
|
||||||
for (const auto &chartSize: m_chartSizes) {
|
for (const auto &chartSize: m_chartSizes) {
|
||||||
maxRectsSize r;
|
maxRectsSize r;
|
||||||
r.width = chartSize.first * m_floatToIntFactor;
|
r.width = chartSize.first * m_floatToIntFactor;
|
||||||
r.height = chartSize.second * m_floatToIntFactor;
|
r.height = chartSize.second * m_floatToIntFactor;
|
||||||
qDebug() << " :chart " << r.width << "x" << r.height;
|
//qDebug() << " :chart " << r.width << "x" << r.height;
|
||||||
rects.push_back(r);
|
rects.push_back(r);
|
||||||
}
|
}
|
||||||
const maxRectsFreeRectChoiceHeuristic methods[] = {
|
const maxRectsFreeRectChoiceHeuristic methods[] = {
|
||||||
|
@ -51,13 +53,13 @@ bool ChartPacker::tryPack(float textureSize)
|
||||||
float bestOccupancy = 0;
|
float bestOccupancy = 0;
|
||||||
std::vector<maxRectsPosition> bestResult;
|
std::vector<maxRectsPosition> bestResult;
|
||||||
for (size_t i = 0; i < sizeof(methods) / sizeof(methods[0]); ++i) {
|
for (size_t i = 0; i < sizeof(methods) / sizeof(methods[0]); ++i) {
|
||||||
qDebug() << "Test method[" << methods[i] << "]";
|
//qDebug() << "Test method[" << methods[i] << "]";
|
||||||
std::vector<maxRectsPosition> result(rects.size());
|
std::vector<maxRectsPosition> result(rects.size());
|
||||||
if (0 != maxRects(width, height, rects.size(), rects.data(), methods[i], true, result.data(), &occupancy)) {
|
if (0 != maxRects(width, height, rects.size(), rects.data(), methods[i], true, result.data(), &occupancy)) {
|
||||||
qDebug() << " method[" << methods[i] << "] failed";
|
//qDebug() << " method[" << methods[i] << "] failed";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
qDebug() << " method[" << methods[i] << "] occupancy:" << occupancy;
|
//qDebug() << " method[" << methods[i] << "] occupancy:" << occupancy;
|
||||||
if (occupancy > bestOccupancy) {
|
if (occupancy > bestOccupancy) {
|
||||||
bestResult = result;
|
bestResult = result;
|
||||||
bestOccupancy = occupancy;
|
bestOccupancy = occupancy;
|
||||||
|
|
|
@ -17,7 +17,7 @@ bool parametrize(const std::vector<Vertex> &verticies,
|
||||||
if (verticies.empty() || faces.empty())
|
if (verticies.empty() || faces.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
qDebug() << "parametrize vertices:" << verticies.size() << "faces:" << faces.size();
|
//qDebug() << "parametrize vertices:" << verticies.size() << "faces:" << faces.size();
|
||||||
|
|
||||||
Eigen::MatrixXd V(verticies.size(), 3);
|
Eigen::MatrixXd V(verticies.size(), 3);
|
||||||
Eigen::MatrixXi F(faces.size(), 3);
|
Eigen::MatrixXi F(faces.size(), 3);
|
||||||
|
|
|
@ -310,8 +310,8 @@ void UvUnwrapper::calculateSizeAndRemoveInvalidCharts()
|
||||||
item.coords[i].uv[1] -= top;
|
item.coords[i].uv[1] -= top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << "left:" << left << "top:" << top << "right:" << right << "bottom:" << bottom;
|
//qDebug() << "left:" << left << "top:" << top << "right:" << right << "bottom:" << bottom;
|
||||||
qDebug() << "width:" << size.first << "height:" << size.second;
|
//qDebug() << "width:" << size.first << "height:" << size.second;
|
||||||
m_chartSizes.push_back(size);
|
m_chartSizes.push_back(size);
|
||||||
m_charts.push_back(chart);
|
m_charts.push_back(chart);
|
||||||
}
|
}
|
||||||
|
|
|
@ -645,7 +645,7 @@ static int startLayout(maxRectsContext *ctx) {
|
||||||
loop = loop->next;
|
loop = loop->next;
|
||||||
}
|
}
|
||||||
if (!bestNode) {
|
if (!bestNode) {
|
||||||
fprintf(stderr, "%s: %s\n", __FUNCTION__, "find bestRect failed");
|
//fprintf(stderr, "%s: %s\n", __FUNCTION__, "find bestRect failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (bestNode->width != bestRect->width ||
|
if (bestNode->width != bestRect->width ||
|
||||||
|
|
Loading…
Reference in New Issue