Avoid setting metallic/roughness/sheen/clearcoat properties when they are not found on mtl file.

This commit is contained in:
Sergio Acereda
2022-03-11 22:29:59 +01:00
parent a305d14b8f
commit 51e248909f
6 changed files with 72 additions and 17 deletions

View File

@@ -205,7 +205,7 @@ void ObjFileMtlImporter::load() {
break;
case 's':
++m_DataIt;
getColorRGBA(&m_pModel->m_pCurrentMaterial->sheen);
getColorRGBA(m_pModel->m_pCurrentMaterial->sheen);
break;
case 'c':
++m_DataIt;
@@ -267,6 +267,12 @@ void ObjFileMtlImporter::getColorRGBA(aiColor3D *pColor) {
pColor->b = b;
}
void ObjFileMtlImporter::getColorRGBA(Maybe<aiColor3D> &value) {
aiColor3D v;
getColorRGBA(&v);
value = Maybe<aiColor3D>(v);
}
// -------------------------------------------------------------------
// Loads the kind of illumination model.
void ObjFileMtlImporter::getIlluminationModel(int &illum_model) {
@@ -274,6 +280,7 @@ void ObjFileMtlImporter::getIlluminationModel(int &illum_model) {
illum_model = atoi(&m_buffer[0]);
}
// -------------------------------------------------------------------
// Loads a single float value.
void ObjFileMtlImporter::getFloatValue(ai_real &value) {
@@ -283,10 +290,19 @@ void ObjFileMtlImporter::getFloatValue(ai_real &value) {
value = 0.0f;
return;
}
value = (ai_real)fast_atof(&m_buffer[0]);
}
void ObjFileMtlImporter::getFloatValue(Maybe<ai_real> &value) {
m_DataIt = CopyNextWord<DataArrayIt>(m_DataIt, m_DataItEnd, &m_buffer[0], BUFFERSIZE);
size_t len = std::strlen(&m_buffer[0]);
if (len)
value = Maybe<ai_real>(fast_atof(&m_buffer[0]));
else
value = Maybe<ai_real>();
}
// -------------------------------------------------------------------
// Creates a material from loaded data.
void ObjFileMtlImporter::createMaterial() {