Some mip map / OBJ file loader improvements for an issue reported by Yoran Bosman

metadata
Wenzel Jakob 2014-02-25 08:19:25 -08:00
parent 1ca04133d9
commit c466c70738
2 changed files with 16 additions and 5 deletions

View File

@ -196,8 +196,15 @@ public:
/* Potentially create a MIP map cache file */
uint8_t *mmapData = NULL, *mmapPtr = NULL;
if (!cacheFilename.empty()) {
Log(EInfo, "Generating MIP map cache file \"%s\" ..", cacheFilename.c_str());
m_mmap = new MemoryMappedFile(cacheFilename, cacheSize);
Log(EInfo, "Generating MIP map cache file \"%s\" ..", cacheFilename.string().c_str());
try {
m_mmap = new MemoryMappedFile(cacheFilename, cacheSize);
} catch (std::runtime_error &e) {
Log(EWarn, "Unable to create MIP map cache file \"%s\" -- "
"retrying with a temporary file. Error message was: %s",
cacheFilename.string().c_str(), e.what());
m_mmap = MemoryMappedFile::createTemporary(cacheSize);
}
mmapData = mmapPtr = (uint8_t *) m_mmap->getData();
}
@ -313,7 +320,7 @@ public:
: m_weightLut(NULL), m_maxAnisotropy(maxAnisotropy) {
m_mmap = new MemoryMappedFile(cacheFilename);
uint8_t *mmapPtr = (uint8_t *) m_mmap->getData();
Log(EInfo, "Mapped MIP map cache file \"%s\" into memory (%s).", cacheFilename.c_str(),
Log(EInfo, "Mapped MIP map cache file \"%s\" into memory (%s).", cacheFilename.string().c_str(),
memString(m_mmap->getSize()).c_str());
stats::mipStorage += m_mmap->getSize();

View File

@ -557,7 +557,7 @@ public:
}
bsdf->setID(name);
addChild(name, bsdf);
addChild(name, bsdf, false);
}
struct Vertex {
@ -716,6 +716,10 @@ public:
}
void addChild(const std::string &name, ConfigurableObject *child) {
addChild(name, child, true);
}
void addChild(const std::string &name, ConfigurableObject *child, bool warn) {
const Class *cClass = child->getClass();
if (cClass->derivesFrom(MTS_CLASS(BSDF))) {
Shape::addChild(name, child);
@ -731,7 +735,7 @@ public:
m_meshes[i]->addChild(name, child);
}
}
if (!found)
if (!found && warn)
Log(EWarn, "Attempted to register the material named "
"'%s', which does not occur in the OBJ file!", name.c_str());
}