More robust checking of file extensions courtesy of the SGPath. Thanks to Mathias FROHLICH.

This commit is contained in:
Stuart Buchanan 2012-02-27 21:27:27 +00:00
parent 39d45e9e0a
commit a72d858034

View File

@ -128,14 +128,6 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
tname = "unknown.rgb";
}
if ((tname.rfind(".dds") == (tname.length() - 4)) ||
(tname.rfind(".DDS") == (tname.length() - 4)) )
{
dds.push_back(true);
} else {
dds.push_back(false);
}
SGPath tpath("Textures.high");
tpath.append(tname);
string fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
@ -145,6 +137,12 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
}
if (tpath.lower_extension() == "dds") {
dds.push_back(true);
} else {
dds.push_back(false);
}
if (!fullTexPath.empty() ) {
_internal_state st( NULL, fullTexPath, false, options );
_status.push_back( st );
@ -162,17 +160,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
if (tname.empty()) {
tname = "unknown.rgb";
}
if (j == 0) {
if ((tname.rfind(".dds") == (tname.length() - 4)) ||
(tname.rfind(".DDS") == (tname.length() - 4)) )
{
dds.push_back(true);
} else {
dds.push_back(false);
}
}
SGPath tpath("Textures.high");
tpath.append(tname);
string fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
@ -182,6 +170,14 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
}
if (j == 0) {
if (tpath.lower_extension() == "dds") {
dds.push_back(true);
} else {
dds.push_back(false);
}
}
st.add_texture(fullTexPath, textures[j]->getIndex());
}
@ -219,8 +215,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
{
osg::Texture2D* object_mask = new osg::Texture2D;
bool dds_mask = ((omname.rfind(".dds") == (omname.length() - 4)) ||
(omname.rfind(".DDS") == (omname.length() - 4)) );
bool dds_mask = (ompath.lower_extension() == "dds");
if (dds[i] != dds_mask) {
// Texture format does not match mask format. This is relevant for