Moved setting of isftream locale to Model::readOBJ(..) and Model::readMTL(..).

This commit is contained in:
Robert Osfield 2020-01-17 09:07:58 +00:00
parent 396cfca1ae
commit b063f510c1
2 changed files with 4 additions and 5 deletions

View File

@ -948,12 +948,9 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fil
std::string fileName = osgDB::findDataFile( file, options );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osgDB::ifstream fin(fileName.c_str());
if (fin)
{
fin.imbue(std::locale::classic());
// code for setting up the database path so that internally referenced file are searched for on relative paths.
osg::ref_ptr<Options> local_opt = options ? static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName));
@ -975,8 +972,6 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(std::istream& fin, con
{
if (fin)
{
fin.imbue(std::locale::classic());
obj::Model model;
model.readOBJ(fin, options);

View File

@ -225,6 +225,8 @@ bool Model::readMTL(std::istream& fin)
{
OSG_INFO<<"Reading MTL file"<<std::endl;
fin.imbue(std::locale::classic());
const int LINE_SIZE = 4096;
char line[LINE_SIZE];
float r = 1.0f, g = 1.0f, b = 1.0f, a = 1.0f;
@ -567,6 +569,8 @@ bool Model::readOBJ(std::istream& fin, const osgDB::ReaderWriter::Options* optio
{
OSG_INFO<<"Reading OBJ file"<<std::endl;
fin.imbue(std::locale::classic());
const int LINE_SIZE = 4096;
char line[LINE_SIZE];
float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;