mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:52:26 +02:00
cleanups
This commit is contained in:
parent
4a1be69be4
commit
5b28f3a3c4
1 changed files with 16 additions and 3 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "model/Geometry.h"
|
#include "model/Geometry.h"
|
||||||
#include "OBJWriter.h"
|
#include "OBJWriter.h"
|
||||||
|
#include "ModelFormatLogging.h"
|
||||||
|
|
||||||
static QString formatFloat(double n) {
|
static QString formatFloat(double n) {
|
||||||
// limit precision to 6, but don't output trailing zeros.
|
// limit precision to 6, but don't output trailing zeros.
|
||||||
|
@ -23,6 +24,18 @@ static QString formatFloat(double n) {
|
||||||
if (s.endsWith(".")) {
|
if (s.endsWith(".")) {
|
||||||
s.remove(s.size() - 1, 1);
|
s.remove(s.size() - 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for non-numbers. if we get NaN or inf or scientific notation, just return 0
|
||||||
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
auto c = s.at(i).toLatin1();
|
||||||
|
if (c != '-' &&
|
||||||
|
c != '.' &&
|
||||||
|
(c < '0' || c > '9')) {
|
||||||
|
qCDebug(modelformat) << "OBJWriter zeroing bad vertex coordinate:" << s << "because of" << c;
|
||||||
|
return QString("0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +83,7 @@ bool writeOBJToTextStream(QTextStream& out, QList<MeshPointer> meshes) {
|
||||||
out << "g part-" << nth++ << "\n";
|
out << "g part-" << nth++ << "\n";
|
||||||
|
|
||||||
// model::Mesh::TRIANGLES
|
// model::Mesh::TRIANGLES
|
||||||
// XXX handle other formats
|
// TODO -- handle other formats
|
||||||
gpu::BufferView::Iterator<const uint32_t> indexItr = indexBuffer.cbegin<uint32_t>();
|
gpu::BufferView::Iterator<const uint32_t> indexItr = indexBuffer.cbegin<uint32_t>();
|
||||||
indexItr += part._startIndex;
|
indexItr += part._startIndex;
|
||||||
|
|
||||||
|
@ -108,13 +121,13 @@ bool writeOBJToTextStream(QTextStream& out, QList<MeshPointer> meshes) {
|
||||||
|
|
||||||
bool writeOBJToFile(QString path, QList<MeshPointer> meshes) {
|
bool writeOBJToFile(QString path, QList<MeshPointer> meshes) {
|
||||||
if (QFileInfo(path).exists() && !QFile::remove(path)) {
|
if (QFileInfo(path).exists() && !QFile::remove(path)) {
|
||||||
qDebug() << "OBJ writer failed, file exists:" << path; // XXX qCDebug
|
qCDebug(modelformat) << "OBJ writer failed, file exists:" << path;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
qDebug() << "OBJ writer failed to open output file:" << path; // XXX qCDebug
|
qCDebug(modelformat) << "OBJ writer failed to open output file:" << path;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue