Add UV island padding
parent
877ef1ff4c
commit
471a324bb3
|
@ -34,10 +34,12 @@ bool ChartPacker::tryPack(float textureSize)
|
|||
if (m_tryNum > 50) {
|
||||
//qDebug() << "Try the " << m_tryNum << "nth times pack with factor:" << m_textureSizeFactor << " size:" << width << "x" << height;
|
||||
}
|
||||
float paddingSize = m_paddingSize * width;
|
||||
float paddingSize2 = paddingSize + paddingSize;
|
||||
for (const auto &chartSize: m_chartSizes) {
|
||||
maxRectsSize r;
|
||||
r.width = chartSize.first * m_floatToIntFactor;
|
||||
r.height = chartSize.second * m_floatToIntFactor;
|
||||
r.width = chartSize.first * m_floatToIntFactor + paddingSize2;
|
||||
r.height = chartSize.second * m_floatToIntFactor + paddingSize2;
|
||||
//qDebug() << " :chart " << r.width << "x" << r.height;
|
||||
rects.push_back(r);
|
||||
}
|
||||
|
@ -71,10 +73,10 @@ bool ChartPacker::tryPack(float textureSize)
|
|||
const auto &result = bestResult[i];
|
||||
const auto &rect = rects[i];
|
||||
auto &dest = m_result[i];
|
||||
std::get<0>(dest) = (float)result.left / width;
|
||||
std::get<1>(dest) = (float)result.top / height;
|
||||
std::get<2>(dest) = (float)rect.width / width;
|
||||
std::get<3>(dest) = (float)rect.height / height;
|
||||
std::get<0>(dest) = (float)(result.left + paddingSize) / width;
|
||||
std::get<1>(dest) = (float)(result.top + paddingSize) / height;
|
||||
std::get<2>(dest) = (float)(rect.width - paddingSize2) / width;
|
||||
std::get<3>(dest) = (float)(rect.height - paddingSize2) / height;
|
||||
std::get<4>(dest) = result.rotated;
|
||||
//qDebug() << "result[" << i << "]:" << std::get<0>(dest) << std::get<1>(dest) << std::get<2>(dest) << std::get<3>(dest) << std::get<4>(dest);
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@ private:
|
|||
|
||||
std::vector<std::pair<float, float>> m_chartSizes;
|
||||
std::vector<std::tuple<float, float, float, float, bool>> m_result;
|
||||
float m_initialAreaGuessFactor = 1.05;
|
||||
float m_initialAreaGuessFactor = 1.1;
|
||||
float m_textureSizeGrowFactor = 0.01;
|
||||
float m_floatToIntFactor = 10000;
|
||||
size_t m_tryNum = 0;
|
||||
float m_textureSizeFactor = 1.0;
|
||||
float m_paddingSize = 0.001;
|
||||
size_t m_maxTryNum = 100;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue