had to dumb this down a bit so that it compiles with GCC 4.2.1/OSX

metadata
Wenzel Jakob 2013-01-31 01:03:40 -05:00
parent 4895aeef7b
commit 38002c8450
3 changed files with 21 additions and 13 deletions

View File

@ -68,6 +68,9 @@ private:
# pragma warning( pop )
#endif
/// Push a cleanup handler to be executed after loading the scene is done
extern MTS_EXPORT_RENDER void pushSceneCleanupHandler(void (*cleanup)());
/**
* \brief XML parser for Mitsuba scene files. To be used with the
* SAX interface of Xerces-C++.
@ -101,9 +104,6 @@ public:
/// Free the memory taken up by staticInitialization()
static void staticShutdown();
/// Push a cleanup handler to be executed after loading the scene is done
static void pushCleanupHandler(void (*cleanup)());
// -----------------------------------------------------------------------
// Implementation of the SAX DocumentHandler interface
// -----------------------------------------------------------------------
@ -136,8 +136,7 @@ protected:
private:
struct ParseContext {
inline ParseContext(ParseContext *_parent)
: parent(_parent) {
}
: parent(_parent) { }
ParseContext *parent;
Properties properties;

View File

@ -274,7 +274,7 @@ void SceneHandler::startElement(const XMLCh* const xmlName,
m_context.push(context);
}
void SceneHandler::pushCleanupHandler(void (*cleanup)()) {
void pushSceneCleanupHandler(void (*cleanup)()) {
__cleanup_tls.get().insert(cleanup);
}

View File

@ -17,7 +17,6 @@
*/
#include <mitsuba/render/trimesh.h>
#include <mitsuba/render/scenehandler.h>
#include <mitsuba/core/properties.h>
#include <mitsuba/core/fstream.h>
#include <mitsuba/core/fresolver.h>
@ -31,6 +30,9 @@
MTS_NAMESPACE_BEGIN
/* Avoid having to include scenehandler.h */
extern MTS_EXPORT_RENDER void pushSceneCleanupHandler(void (*cleanup)());
/*!\plugin{serialized}{Serialized mesh loader}
* \order{7}
* \parameters{
@ -251,16 +253,23 @@ private:
ref<FileStream> m_fstream;
};
struct FileStreamCache : LRUCache<fs::path, std::less<fs::path>,
boost::shared_ptr<MeshLoader> > {
typedef LRUCache<fs::path, std::less<fs::path>,
boost::shared_ptr<MeshLoader> > MeshLoaderCache;
class FileStreamCache : MeshLoaderCache {
public:
inline boost::shared_ptr<MeshLoader> get(const fs::path& path) {
bool dummy;
return LRUCache::get(path, dummy);
return MeshLoaderCache::get(path, dummy);
}
FileStreamCache() : LRUCache(MTS_SERIALIZED_CACHE_SIZE,
&boost::make_shared<MeshLoader, const fs::path&>) {}
FileStreamCache() : MeshLoaderCache(MTS_SERIALIZED_CACHE_SIZE,
&FileStreamCache::create) { }
private:
inline static boost::shared_ptr<MeshLoader> create(const fs::path &path) {
return boost::make_shared<MeshLoader>(path);
}
};
/// Release all currently held offset caches / file streams
@ -280,7 +289,7 @@ private:
if (EXPECT_NOT_TAKEN(cache == NULL)) {
cache = new FileStreamCache();
m_cache.set(cache);
SceneHandler::pushCleanupHandler(&SerializedMesh::flushCache);
mitsuba::pushSceneCleanupHandler(&SerializedMesh::flushCache);
}
boost::shared_ptr<MeshLoader> meshLoader = cache->get(filePath);