OBJ loader robustness improvements
parent
b8d4aeb524
commit
0fff79af57
|
@ -255,12 +255,11 @@ public:
|
||||||
if (triangles.size() > 0) {
|
if (triangles.size() > 0) {
|
||||||
/// make sure that we have unique names
|
/// make sure that we have unique names
|
||||||
if (geomNames.find(targetName) != geomNames.end())
|
if (geomNames.find(targetName) != geomNames.end())
|
||||||
name = formatString("%s_%i", targetName.c_str(), geomIdx);
|
targetName = formatString("%s_%i", targetName.c_str(), geomIdx++);
|
||||||
|
geomNames.insert(targetName);
|
||||||
createMesh(targetName, vertices, normals, texcoords,
|
createMesh(targetName, vertices, normals, texcoords,
|
||||||
triangles, materialName, objectToWorld, vertexBuffer);
|
triangles, materialName, objectToWorld, vertexBuffer);
|
||||||
triangles.clear();
|
triangles.clear();
|
||||||
geomNames.insert(name);
|
|
||||||
geomIdx++;
|
|
||||||
} else {
|
} else {
|
||||||
nameBeforeGeometry = true;
|
nameBeforeGeometry = true;
|
||||||
}
|
}
|
||||||
|
@ -270,12 +269,11 @@ public:
|
||||||
if (triangles.size() > 0) {
|
if (triangles.size() > 0) {
|
||||||
/// make sure that we have unique names
|
/// make sure that we have unique names
|
||||||
if (geomNames.find(name) != geomNames.end())
|
if (geomNames.find(name) != geomNames.end())
|
||||||
name = formatString("%s_%i", name.c_str(), geomIdx);
|
name = formatString("%s_%i", name.c_str(), geomIdx++);
|
||||||
|
geomNames.insert(name);
|
||||||
createMesh(name, vertices, normals, texcoords,
|
createMesh(name, vertices, normals, texcoords,
|
||||||
triangles, materialName, objectToWorld, vertexBuffer);
|
triangles, materialName, objectToWorld, vertexBuffer);
|
||||||
triangles.clear();
|
triangles.clear();
|
||||||
geomNames.insert(name);
|
|
||||||
geomIdx++;
|
|
||||||
name = m_name;
|
name = m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +470,7 @@ public:
|
||||||
std::string filename;
|
std::string filename;
|
||||||
iss >> filename;
|
iss >> filename;
|
||||||
mask = loadTexture(fileResolver, cache, mtlPath, filename);
|
mask = loadTexture(fileResolver, cache, mtlPath, filename);
|
||||||
} else if (buf == "d" || buf == "Tr") {
|
} else if (buf == "d" /* || buf == "Tr" */) {
|
||||||
Float value;
|
Float value;
|
||||||
iss >> value;
|
iss >> value;
|
||||||
if (value == 1)
|
if (value == 1)
|
||||||
|
@ -501,7 +499,6 @@ public:
|
||||||
Texture *exponent, Texture *bump, Texture *mask, int model) {
|
Texture *exponent, Texture *bump, Texture *mask, int model) {
|
||||||
ref<BSDF> bsdf;
|
ref<BSDF> bsdf;
|
||||||
Properties props;
|
Properties props;
|
||||||
props.setID(name);
|
|
||||||
|
|
||||||
if (model == 2 && (specular->getMaximum().isZero() || exponent->getMaximum().isZero()))
|
if (model == 2 && (specular->getMaximum().isZero() || exponent->getMaximum().isZero()))
|
||||||
model = 1;
|
model = 1;
|
||||||
|
@ -554,6 +551,7 @@ public:
|
||||||
bsdf = maskedBSDF;
|
bsdf = maskedBSDF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bsdf->setID(name);
|
||||||
addChild(name, bsdf);
|
addChild(name, bsdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue