diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 91f7495794..5439f95aba 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -189,7 +189,7 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// PT(PandaNode) Loader:: load_file(const Filename &filename, const LoaderOptions &options) const { - if (options.allow_ram_cache()) { + if (options.get_allow_ram_cache()) { // If we're allowing a RAM cache (and we don't have any other // funny options), use the ModelPool to load the file. PT(PandaNode) node = ModelPool::load_model(filename, options); @@ -261,7 +261,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { PT(BamCacheRecord) record; - if (cache->get_active() && options.allow_disk_cache()) { + if (cache->get_active() && options.get_allow_disk_cache()) { // See if the texture can be found in the on-disk cache, if it is // active. record = cache->lookup(path, "bam"); diff --git a/panda/src/pgraph/loaderOptions.I b/panda/src/pgraph/loaderOptions.I index ced9c95a84..1fc1dbacab 100644 --- a/panda/src/pgraph/loaderOptions.I +++ b/panda/src/pgraph/loaderOptions.I @@ -70,26 +70,26 @@ get_flags() const { } //////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::allow_disk_cache +// Function: LoaderOptions::get_allow_disk_cache // Access: Published // Description: Returns true if the loader flags allow retrieving the // model from the on-disk bam cache (if it is enabled), // false otherwise. //////////////////////////////////////////////////////////////////// INLINE bool LoaderOptions:: -allow_disk_cache() const { +get_allow_disk_cache() const { return (_flags & LF_no_disk_cache) == 0; } //////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::allow_ram_cache +// Function: LoaderOptions::get_allow_ram_cache // Access: Published // Description: Returns true if the loader flags allow retrieving the // model from the in-memory ModelPool cache, false // otherwise. //////////////////////////////////////////////////////////////////// INLINE bool LoaderOptions:: -allow_ram_cache() const { +get_allow_ram_cache() const { return ((_flags & (LF_no_ram_cache | LF_convert_anim)) == 0 && (_flags & LF_search) != 0); } diff --git a/panda/src/pgraph/loaderOptions.cxx b/panda/src/pgraph/loaderOptions.cxx index 66756dc09d..8c62ab3235 100644 --- a/panda/src/pgraph/loaderOptions.cxx +++ b/panda/src/pgraph/loaderOptions.cxx @@ -17,3 +17,47 @@ //////////////////////////////////////////////////////////////////// #include "loaderOptions.h" +#include "indent.h" + +//////////////////////////////////////////////////////////////////// +// Function: LoaderOptions::output +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +void LoaderOptions:: +output(ostream &out) const { + out << "LoaderOptions("; + string sep = ""; + write_flag(out, sep, "LF_search", LF_search); + write_flag(out, sep, "LF_report_errors", LF_report_errors); + if ((_flags & LF_convert_anim) == LF_convert_anim) { + write_flag(out, sep, "LF_convert_anim", LF_convert_anim); + } else { + write_flag(out, sep, "LF_convert_skeleton", LF_convert_skeleton); + write_flag(out, sep, "LF_convert_channels", LF_convert_channels); + } + if ((_flags & LF_no_cache) == LF_no_cache) { + write_flag(out, sep, "LF_no_cache", LF_no_cache); + } else { + write_flag(out, sep, "LF_no_disk_cache", LF_no_disk_cache); + write_flag(out, sep, "LF_no_ram_cache", LF_no_ram_cache); + } + if (sep.empty()) { + out << "0"; + } + out << ")"; +} + +//////////////////////////////////////////////////////////////////// +// Function: LoaderOptions::write_flag +// Access: Private +// Description: Used to implement output(). +//////////////////////////////////////////////////////////////////// +void LoaderOptions:: +write_flag(ostream &out, string &sep, + const string &flag_name, int flag) const { + if ((_flags & flag) == flag) { + out << sep << flag_name; + sep = " | "; + } +} diff --git a/panda/src/pgraph/loaderOptions.h b/panda/src/pgraph/loaderOptions.h index d376c99c71..f08d803446 100644 --- a/panda/src/pgraph/loaderOptions.h +++ b/panda/src/pgraph/loaderOptions.h @@ -48,13 +48,22 @@ PUBLISHED: INLINE void set_flags(int flags); INLINE int get_flags() const; - INLINE bool allow_disk_cache() const; - INLINE bool allow_ram_cache() const; + INLINE bool get_allow_disk_cache() const; + INLINE bool get_allow_ram_cache() const; -private: + void output(ostream &out) const; + +private: + void write_flag(ostream &out, string &sep, + const string &flag_name, int flag) const; int _flags; }; +INLINE ostream &operator << (ostream &out, const LoaderOptions &opts) { + opts.output(out); + return out; +} + #include "loaderOptions.I" #endif