mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 14:47:19 +02:00
Merge pull request #12051 from dback2/polyobjimportfixes
Poly obj import fixes
This commit is contained in:
commit
6a3609093d
3 changed files with 23 additions and 3 deletions
|
@ -457,13 +457,33 @@ bool OBJReader::parseOBJGroup(OBJTokenizer& tokenizer, const QVariantHash& mappi
|
|||
// vertex-index/texture-index
|
||||
// vertex-index/texture-index/surface-normal-index
|
||||
QByteArray token = tokenizer.getDatum();
|
||||
if (!isdigit(token[0])) { // Tokenizer treats line endings as whitespace. Non-digit indicates done;
|
||||
auto firstChar = token[0];
|
||||
// Tokenizer treats line endings as whitespace. Non-digit and non-negative sign indicates done;
|
||||
if (!isdigit(firstChar) && firstChar != '-') {
|
||||
tokenizer.pushBackToken(OBJTokenizer::DATUM_TOKEN);
|
||||
break;
|
||||
}
|
||||
QList<QByteArray> parts = token.split('/');
|
||||
assert(parts.count() >= 1);
|
||||
assert(parts.count() <= 3);
|
||||
// If indices are negative relative indices then adjust them to absolute indices based on current vector sizes
|
||||
// Also add 1 to each index as 1 will be subtracted later on from each index in OBJFace::add
|
||||
for (int i = 0; i < parts.count(); ++i) {
|
||||
int part = parts[i].toInt();
|
||||
if (part < 0) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
parts[i].setNum(vertices.size() + part + 1);
|
||||
break;
|
||||
case 1:
|
||||
parts[i].setNum(textureUVs.size() + part + 1);
|
||||
break;
|
||||
case 2:
|
||||
parts[i].setNum(normals.size() + part + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const QByteArray noData {};
|
||||
face.add(parts[0], (parts.count() > 1) ? parts[1] : noData, (parts.count() > 2) ? parts[2] : noData,
|
||||
vertices, vertexColors);
|
||||
|
|
|
@ -163,7 +163,7 @@ void Model::setScale(const glm::vec3& scale) {
|
|||
_scaledToFit = false;
|
||||
}
|
||||
|
||||
const float SCALE_CHANGE_EPSILON = 0.001f;
|
||||
const float SCALE_CHANGE_EPSILON = 0.0000001f;
|
||||
|
||||
void Model::setScaleInternal(const glm::vec3& scale) {
|
||||
if (glm::distance(_scale, scale) > SCALE_CHANGE_EPSILON) {
|
||||
|
|
|
@ -49,7 +49,7 @@ void Transform::evalRotationScale(Quat& rotation, Vec3& scale, const Mat3& rotat
|
|||
// extract scale of the matrix as the length of each axis
|
||||
Mat3 scaleMat = glm::inverse(rotationMat) * rotationScaleMatrix;
|
||||
|
||||
scale = glm::max(Vec3(ACCURACY_THREASHOLD), Vec3(scaleMat[0][0], scaleMat[1][1], scaleMat[2][2]));
|
||||
scale = Vec3(scaleMat[0][0], scaleMat[1][1], scaleMat[2][2]);
|
||||
|
||||
// Let's work on a local matrix containing rotation only
|
||||
Mat3 matRot(
|
||||
|
|
Loading…
Reference in a new issue