diff --git a/doomsday/engine/include/filesys/fs_main.h b/doomsday/engine/include/filesys/fs_main.h index 1635c49303..0d4a98c63b 100644 --- a/doomsday/engine/include/filesys/fs_main.h +++ b/doomsday/engine/include/filesys/fs_main.h @@ -49,509 +49,509 @@ * @defgroup fs File System */ -namespace de -{ - namespace internal { - template - inline bool cannotCastFileTo(File1 *file) { - return dynamic_cast(file) == NULL; - } +namespace de { + +namespace internal { + template + inline bool cannotCastFileTo(File1 *file) { + return dynamic_cast(file) == NULL; } +} + +/** + * Files with a .wad extension are archived data files with multiple 'lumps', + * other files are single lumps whose base filename will become the lump name. + * + * Internally the lump index has two parts: the Primary index (which is populated + * with lumps from loaded data files) and the Auxiliary index (used to temporarily + * open a file that is not considered part of the filesystem). + * + * Functions that don't know the absolute/logical lumpnum of file will have to + * check both indexes (e.g., FS1::lumpNumForName()). + * + * @ingroup fs + */ +class FS1 +{ +public: + /// No files found. @ingroup errors + DENG2_ERROR(NotFoundError); + + /// An unknown scheme was referenced. @ingroup errors + DENG2_ERROR(UnknownSchemeError); /** - * Files with a .wad extension are archived data files with multiple 'lumps', - * other files are single lumps whose base filename will become the lump name. - * - * Internally the lump index has two parts: the Primary index (which is populated - * with lumps from loaded data files) and the Auxiliary index (used to temporarily - * open a file that is not considered part of the filesystem). - * - * Functions that don't know the absolute/logical lumpnum of file will have to - * check both indexes (e.g., FS1::lumpNumForName()). + * (Search) path groupings in descending priority. + */ + enum PathGroup + { + /// 'Override' paths have the highest priority. These are usually + /// set according to user specified paths, e.g., via the command line. + OverridePaths, + + /// 'Extra' paths are those which are determined dynamically when some + /// runtime resources are loaded. The DED module utilizes these to add + /// new model search paths found when parsing definition files. + ExtraPaths, + + /// Default paths are those which are known a priori. These are usually + /// determined at compile time and are implicit paths relative to the + /// virtual file system. + DefaultPaths, + + /// Fallback (i.e., last-resort) paths have the lowest priority. These + /// are usually set according to user specified paths, e.g., via the + /// command line. + FallbackPaths + }; + + /** + * Scheme defines a file system subspace. * - * @ingroup fs + * @todo The symbolic name of the schme and the path mapping template + * (@ref mapPath()) should be defined externally. -ds */ - class FS1 + class Scheme { public: - /// No files found. @ingroup errors - DENG2_ERROR(NotFoundError); - - /// An unknown scheme was referenced. @ingroup errors - DENG2_ERROR(UnknownSchemeError); + /// Symbolic names must be at least this number of characters. + static int const min_name_length = URI_MINSCHEMELENGTH; - /** - * (Search) path groupings in descending priority. - */ - enum PathGroup + enum Flag { - /// 'Override' paths have the highest priority. These are usually - /// set according to user specified paths, e.g., via the command line. - OverridePaths, - - /// 'Extra' paths are those which are determined dynamically when some - /// runtime resources are loaded. The DED module utilizes these to add - /// new model search paths found when parsing definition files. - ExtraPaths, - - /// Default paths are those which are known a priori. These are usually - /// determined at compile time and are implicit paths relative to the - /// virtual file system. - DefaultPaths, - - /// Fallback (i.e., last-resort) paths have the lowest priority. These - /// are usually set according to user specified paths, e.g., via the - /// command line. - FallbackPaths + /// Packages may include virtual file mappings to the scheme with a + /// root directory which matches the symbolic name of the scheme. + /// + /// @see mapPath() + MappedInPackages = 0x01 }; + Q_DECLARE_FLAGS(Flags, Flag) - /** - * Scheme defines a file system subspace. - * - * @todo The symbolic name of the schme and the path mapping template - * (@ref mapPath()) should be defined externally. -ds - */ - class Scheme - { - public: - /// Symbolic names must be at least this number of characters. - static int const min_name_length = URI_MINSCHEMELENGTH; - - enum Flag - { - /// Packages may include virtual file mappings to the scheme with a - /// root directory which matches the symbolic name of the scheme. - /// - /// @see mapPath() - MappedInPackages = 0x01 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - /// Groups of search paths ordered by priority. - typedef QMultiMap SearchPaths; - - /// List of found file nodes. - typedef QList FoundNodes; - - public: - explicit Scheme(String symbolicName, Flags flags = 0); - ~Scheme(); - - /// @return Symbolic name of this scheme (e.g., "Models"). - String const &name() const; - - /** - * Clear this scheme back to it's "empty" state (i.e., no resources). - * The search path groups are unaffected. - */ - void clear(); - - /** - * Rebuild this scheme by re-scanning for resources on all search paths - * and re-populating the scheme's index. - * - * @note Any manually added resources will not be present after this. - */ - void rebuild(); - - /** - * Reset this scheme, returning it to an empty state and clearing any - * @ref ExtraPaths which have been registered since its construction. - */ - inline void reset() - { - clearSearchPathGroup(ExtraPaths); - clear(); - } - - /** - * Manually add a resource to this scheme. Duplicates are pruned automatically. - * - * @param resourceNode Node which represents the resource. - * - * @return @c true iff this scheme did not already contain the resource. - */ - bool add(PathTree::Node &resourceNode); - - /** - * Finds all resources in this scheme. - * - * @param name If not an empty string, only consider resources whose - * name begins with this. Case insensitive. - * @param found Set of resources which match the search. - * - * @return Number of found resources. - */ - int findAll(String name, FoundNodes &found); - - /** - * Add a new search path to this scheme. Newer paths have priority over - * previously added paths. - * - * @param path New unresolved search path to add. A copy is made. - * @param group Group to add this path to. @ref PathGroup - * - * @return @c true if @a path was well-formed and subsequently added. - */ - bool addSearchPath(SearchPath const &path, PathGroup group = DefaultPaths); - - /** - * Clear search paths in @a group from the scheme. - * - * @param group Search path group to be cleared. - */ - void clearSearchPathGroup(PathGroup group); - - /** - * Provides access to the search paths for efficient traversals. - */ - SearchPaths const &allSearchPaths() const; - - /** - * Clear all search paths in all groups in the scheme. - */ - void clearAllSearchPaths(); - - /** - * Apply mapping for this scheme to the specified path. Mapping must be - * enabled (with @ref MappedInPackages) otherwise this does nothing. - * - * For example, given the scheme name "models": - * - *
-             *     "models/mymodel.dmd" => "$(App.DataPath)/$(GamePlugin.Name)/models/mymodel.dmd"
-             * 
- * - * @param path The path to be mapped (applied in-place). - * - * @return @c true iff mapping was applied to the path. - */ - bool mapPath(String &path) const; - -#if _DEBUG - void debugPrint() const; -#endif - - private: - struct Instance; - Instance *d; - }; + /// Groups of search paths ordered by priority. + typedef QMultiMap SearchPaths; - /// File system subspace schemes. - typedef QMap Schemes; - - /** - * PathListItem represents a found path for find file search results. - */ - struct PathListItem - { - Path path; - int attrib; - - PathListItem(Path const &_path, int _attrib = 0) - : path(_path), attrib(_attrib) - {} - - bool operator < (PathListItem const &other) const - { - return path < other.path; - } - }; - - /// List of found path search results. - typedef QList PathList; - - /// List of file search results. - typedef QList FileList; + /// List of found file nodes. + typedef QList FoundNodes; public: - /** - * Constructs a new file system. - */ - FS1(); + explicit Scheme(String symbolicName, Flags flags = 0); + ~Scheme(); - virtual ~FS1(); - - /// Register the console commands, variables, etc..., of this module. - static void consoleRegister(); + /// @return Symbolic name of this scheme (e.g., "Models"). + String const &name() const; /** - * @post No more WADs will be loaded in startup mode. + * Clear this scheme back to it's "empty" state (i.e., no resources). + * The search path groups are unaffected. */ - void endStartup(); + void clear(); /** - * Find a Scheme by symbolic name. + * Rebuild this scheme by re-scanning for resources on all search paths + * and re-populating the scheme's index. * - * @param name Symbolic name of the scheme. - * @return Scheme associated with @a name. - */ - Scheme &scheme(String name); - - /** - * @param name Unique symbolic name of the new scheme. Must be at least - * @c Scheme::min_name_length characters long. - * @param flags @ref Scheme::Flag + * @note Any manually added resources will not be present after this. */ - Scheme &createScheme(String name, Scheme::Flags flags = 0); + void rebuild(); /** - * Returns @c true iff a Scheme exists with the symbolic @a name. + * Reset this scheme, returning it to an empty state and clearing any + * @ref ExtraPaths which have been registered since its construction. */ - bool knownScheme(String name); - - /** - * Returns the schemes for efficient traversal. - */ - Schemes const &allSchemes(); - - /** - * Reset all the schemes, returning their indexes to an empty state and clearing - * any @ref ExtraPaths which have been registered since creation. - */ - inline void resetAllSchemes() + inline void reset() { - Schemes schemes = allSchemes(); - DENG2_FOR_EACH(Schemes, i, schemes){ (*i)->reset(); } + clearSearchPathGroup(ExtraPaths); + clear(); } /** - * Add a new path mapping from source to destination. - * @note Paths will be transformed into absolute paths if needed. - */ - void addPathMapping(String source, String destination); - - /** - * Clears all virtual path mappings. - */ - void clearPathMappings(); - - /** - * Add a new lump mapping so that @a lumpName becomes visible at @a destination. - */ - void addPathLumpMapping(String lumpName, String destination); - - /** - * Clears all path => lump mappings. + * Manually add a resource to this scheme. Duplicates are pruned automatically. * - * @return This instance. - */ - void clearPathLumpMappings(); - - /** - * @return @c true if a file exists at @a path which can be opened for reading. - */ - bool accessFile(Uri const &path); - - /** - * Maintains a list of identifiers already seen. + * @param resourceNode Node which represents the resource. * - * @return @c true if the given file can be opened, or - * @c false if it has already been opened. + * @return @c true iff this scheme did not already contain the resource. */ - bool checkFileId(Uri const &path); + bool add(PathTree::Node &resourceNode); /** - * Reset known fileId records so that the next time checkFileId() is called for - * a filepath, it will pass. - */ - void resetFileIds(); - - /** - * @param hndl Handle to the file to be interpreted. Ownership is passed to - * the interpreted file instance. - * @param path Absolute VFS path by which the interpreted file will be known. - * @param info Prepared info metadata for the file. + * Finds all resources in this scheme. + * + * @param name If not an empty string, only consider resources whose + * name begins with this. Case insensitive. + * @param found Set of resources which match the search. * - * @return The interpreted File file instance. + * @return Number of found resources. */ - File1 &interpret(FileHandle &hndl, String path, FileInfo const &info); + int findAll(String name, FoundNodes &found); /** - * Indexes @a file (which must have been opened with this file system) into - * this file system and adds it to the list of loaded files. + * Add a new search path to this scheme. Newer paths have priority over + * previously added paths. * - * @param file The file to index. Assumed to have not yet been indexed! + * @param path New unresolved search path to add. A copy is made. + * @param group Group to add this path to. @ref PathGroup + * + * @return @c true if @a path was well-formed and subsequently added. */ - void index(File1 &file); + bool addSearchPath(SearchPath const &path, PathGroup group = DefaultPaths); /** - * Removes a file from any indexes. + * Clear search paths in @a group from the scheme. * - * @param file File to remove from the index. + * @param group Search path group to be cleared. */ - void deindex(File1 &file); - - /// Clear all references to this file. - void releaseFile(File1 &file); + void clearSearchPathGroup(PathGroup group); /** - * Lookup a lump by name. - * - * @param name Name of the lump to lookup. - * @return Logical lump number for the found lump; otherwise @c -1. - * - * @todo At this level there should be no distinction between lumps. -ds + * Provides access to the search paths for efficient traversals. */ - lumpnum_t lumpNumForName(String name); + SearchPaths const &allSearchPaths() const; /** - * Provides access to the main index of the file system. This can be - * used for efficiently looking up files based on name. + * Clear all search paths in all groups in the scheme. */ - LumpIndex const &nameIndex() const; + void clearAllSearchPaths(); /** - * Opens the given file (will be translated) for reading. + * Apply mapping for this scheme to the specified path. Mapping must be + * enabled (with @ref MappedInPackages) otherwise this does nothing. * - * @post If @a allowDuplicate = @c false a new file ID for this will have been - * added to the list of known file identifiers if this file hasn't yet been - * opened. It is the responsibility of the caller to release this identifier when done. + * For example, given the scheme name "models": * - * @param path Possibly relative or mapped path to the resource being opened. - * @param mode 'b' = binary - * 't' = text mode (with real files, lumps are always binary) + *
+         *     "models/mymodel.dmd" => "$(App.DataPath)/$(GamePlugin.Name)/models/mymodel.dmd"
+         * 
* - * 'f' = must be a real file in the local file system - * @param baseOffset Offset from the start of the file in bytes to begin. - * @param allowDuplicate @c false = open only if not already opened. + * @param path The path to be mapped (applied in-place). * - * @return Handle to the opened file. - * - * @throws NotFoundError If the requested file could not be found. + * @return @c true iff mapping was applied to the path. */ - FileHandle &openFile(String const &path, String const &mode, size_t baseOffset = 0, - bool allowDuplicate = true); + bool mapPath(String &path) const; - /** - * Try to open the specified lump for reading. - * - * @param lump The file to be opened. - * - * @return Handle to the opened file. - * - * @todo This method is no longer necessary at this level. Opening a file which - * is already present in the file system should not require calling back to a - * method of the file system itself (bad OO design). - */ - FileHandle &openLump(File1 &lump); +#if _DEBUG + void debugPrint() const; +#endif - /** - * Find a single file. - * - * @param search The search term. - * @return Found file. - */ - File1 &find(Uri const &search); + private: + struct Instance; + Instance *d; + }; - /** - * Finds all files. - * - * @param found Set of files that match the result. - * - * @return Number of files found. - */ - int findAll(FileList &found) const; + /// File system subspace schemes. + typedef QMap Schemes; - /** - * Finds all files which meet the supplied @a predicate. - * - * @param predicate If not @c NULL, this predicate evaluator callback must - * return @c true for a given file to be included in the - * @a found FileList. - * @param parameters Passed to the predicate evaluator callback. - * @param found Set of files that match the result. - * - * @return Number of files found. - */ - int findAll(bool (*predicate)(File1 &file, void *parameters), void *parameters, - FileList &found) const; + /** + * PathListItem represents a found path for find file search results. + */ + struct PathListItem + { + Path path; + int attrib; - /** - * Finds all files of a specific type which meet the supplied @a predicate. - * Only files that can be represented as @a Type are included in the results. - * - * @param predicate If not @c NULL, this predicate evaluator callback must - * return @c true for a given file to be included in the - * @a found FileList. - * @param parameters Passed to the predicate evaluator callback. - * @param found Set of files that match the result. - * - * @return Number of files found. - */ - template - int findAll(bool (*predicate)(File1 &file, void *parameters), void *parameters, - FileList &found) const + PathListItem(Path const &_path, int _attrib = 0) + : path(_path), attrib(_attrib) + {} + + bool operator < (PathListItem const &other) const { - findAll(predicate, parameters, found); - // Filter out the wrong types. - QMutableListIterator i(found); - while(i.hasNext()) - { - i.next(); - if(internal::cannotCastFileTo(&i.value()->file())) - i.remove(); - } - return found.count(); + return path < other.path; } + }; - /** - * Search the file system for a path to a file. - * - * @param search The search term. If a scheme is specified, first check - * for a similarly named Scheme with which to limit the - * search. If not found within the scheme then perform a - * wider search of the whole file system. - * @param flags @ref resourceLocationFlags - * @param rclass Class of resource being searched for. If no file is found - * which matches the search term and a non-null resource - * class is specified try alternative names for the file - * according to the list of known file extensions for each - * file type associated with this class of resource. - * - * @return The found path. - * - * @throws NotFoundError If the requested file could not be found. - * - * @todo Fold into @ref find() -ds - */ - String findPath(Uri const &search, int flags, ResourceClass &rclass); - String findPath(Uri const &search, int flags); + /// List of found path search results. + typedef QList PathList; - /** - * Finds all paths which match the search criteria. Will search the Zip - * lump index, lump => path mappings and native files in the local system. - * - * @param searchPattern Pattern which defines the scope of the search. - * @param flags @ref searchPathFlags - * @param found Set of (absolute) paths that match the result. - * - * @return Number of paths found. - */ - int findAllPaths(Path searchPattern, int flags, PathList &found); + /// List of file search results. + typedef QList FileList; - /** - * Print contents of the specified directory of the virtual file system. - */ - void printDirectory(Path path); +public: + /** + * Constructs a new file system. + */ + FS1(); - /** - * Calculate a CRC for the loaded file list. - */ - uint loadedFilesCRC(); + virtual ~FS1(); - /** - * Unload all files loaded after startup. - * @return Number of files unloaded. - */ - int unloadAllNonStartupFiles(); + /// Register the console commands, variables, etc..., of this module. + static void consoleRegister(); - private: - struct Instance; - Instance *d; - }; + /** + * @post No more WADs will be loaded in startup mode. + */ + void endStartup(); + + /** + * Find a Scheme by symbolic name. + * + * @param name Symbolic name of the scheme. + * @return Scheme associated with @a name. + */ + Scheme &scheme(String name); + + /** + * @param name Unique symbolic name of the new scheme. Must be at least + * @c Scheme::min_name_length characters long. + * @param flags @ref Scheme::Flag + */ + Scheme &createScheme(String name, Scheme::Flags flags = 0); + + /** + * Returns @c true iff a Scheme exists with the symbolic @a name. + */ + bool knownScheme(String name); + + /** + * Returns the schemes for efficient traversal. + */ + Schemes const &allSchemes(); + + /** + * Reset all the schemes, returning their indexes to an empty state and clearing + * any @ref ExtraPaths which have been registered since creation. + */ + inline void resetAllSchemes() + { + Schemes schemes = allSchemes(); + DENG2_FOR_EACH(Schemes, i, schemes){ (*i)->reset(); } + } + + /** + * Add a new path mapping from source to destination. + * @note Paths will be transformed into absolute paths if needed. + */ + void addPathMapping(String source, String destination); + + /** + * Clears all virtual path mappings. + */ + void clearPathMappings(); + + /** + * Add a new lump mapping so that @a lumpName becomes visible at @a destination. + */ + void addPathLumpMapping(String lumpName, String destination); + + /** + * Clears all path => lump mappings. + * + * @return This instance. + */ + void clearPathLumpMappings(); + + /** + * @return @c true if a file exists at @a path which can be opened for reading. + */ + bool accessFile(Uri const &path); + + /** + * Maintains a list of identifiers already seen. + * + * @return @c true if the given file can be opened, or + * @c false if it has already been opened. + */ + bool checkFileId(Uri const &path); + + /** + * Reset known fileId records so that the next time checkFileId() is called for + * a filepath, it will pass. + */ + void resetFileIds(); + + /** + * @param hndl Handle to the file to be interpreted. Ownership is passed to + * the interpreted file instance. + * @param path Absolute VFS path by which the interpreted file will be known. + * @param info Prepared info metadata for the file. + * + * @return The interpreted File file instance. + */ + File1 &interpret(FileHandle &hndl, String path, FileInfo const &info); + + /** + * Indexes @a file (which must have been opened with this file system) into + * this file system and adds it to the list of loaded files. + * + * @param file The file to index. Assumed to have not yet been indexed! + */ + void index(File1 &file); + + /** + * Removes a file from any indexes. + * + * @param file File to remove from the index. + */ + void deindex(File1 &file); + + /// Clear all references to this file. + void releaseFile(File1 &file); + + /** + * Lookup a lump by name. + * + * @param name Name of the lump to lookup. + * @return Logical lump number for the found lump; otherwise @c -1. + * + * @todo At this level there should be no distinction between lumps. -ds + */ + lumpnum_t lumpNumForName(String name); + + /** + * Provides access to the main index of the file system. This can be + * used for efficiently looking up files based on name. + */ + LumpIndex const &nameIndex() const; + + /** + * Opens the given file (will be translated) for reading. + * + * @post If @a allowDuplicate = @c false a new file ID for this will have been + * added to the list of known file identifiers if this file hasn't yet been + * opened. It is the responsibility of the caller to release this identifier when done. + * + * @param path Possibly relative or mapped path to the resource being opened. + * @param mode 'b' = binary + * 't' = text mode (with real files, lumps are always binary) + * + * 'f' = must be a real file in the local file system + * @param baseOffset Offset from the start of the file in bytes to begin. + * @param allowDuplicate @c false = open only if not already opened. + * + * @return Handle to the opened file. + * + * @throws NotFoundError If the requested file could not be found. + */ + FileHandle &openFile(String const &path, String const &mode, size_t baseOffset = 0, + bool allowDuplicate = true); + + /** + * Try to open the specified lump for reading. + * + * @param lump The file to be opened. + * + * @return Handle to the opened file. + * + * @todo This method is no longer necessary at this level. Opening a file which + * is already present in the file system should not require calling back to a + * method of the file system itself (bad OO design). + */ + FileHandle &openLump(File1 &lump); + + /** + * Find a single file. + * + * @param search The search term. + * @return Found file. + */ + File1 &find(Uri const &search); + + /** + * Finds all files. + * + * @param found Set of files that match the result. + * + * @return Number of files found. + */ + int findAll(FileList &found) const; + + /** + * Finds all files which meet the supplied @a predicate. + * + * @param predicate If not @c NULL, this predicate evaluator callback must + * return @c true for a given file to be included in the + * @a found FileList. + * @param parameters Passed to the predicate evaluator callback. + * @param found Set of files that match the result. + * + * @return Number of files found. + */ + int findAll(bool (*predicate)(File1 &file, void *parameters), void *parameters, + FileList &found) const; + + /** + * Finds all files of a specific type which meet the supplied @a predicate. + * Only files that can be represented as @a Type are included in the results. + * + * @param predicate If not @c NULL, this predicate evaluator callback must + * return @c true for a given file to be included in the + * @a found FileList. + * @param parameters Passed to the predicate evaluator callback. + * @param found Set of files that match the result. + * + * @return Number of files found. + */ + template + int findAll(bool (*predicate)(File1 &file, void *parameters), void *parameters, + FileList &found) const + { + findAll(predicate, parameters, found); + // Filter out the wrong types. + QMutableListIterator i(found); + while(i.hasNext()) + { + i.next(); + if(internal::cannotCastFileTo(&i.value()->file())) + i.remove(); + } + return found.count(); + } + + /** + * Search the file system for a path to a file. + * + * @param search The search term. If a scheme is specified, first check + * for a similarly named Scheme with which to limit the + * search. If not found within the scheme then perform a + * wider search of the whole file system. + * @param flags @ref resourceLocationFlags + * @param rclass Class of resource being searched for. If no file is found + * which matches the search term and a non-null resource + * class is specified try alternative names for the file + * according to the list of known file extensions for each + * file type associated with this class of resource. + * + * @return The found path. + * + * @throws NotFoundError If the requested file could not be found. + * + * @todo Fold into @ref find() -ds + */ + String findPath(Uri const &search, int flags, ResourceClass &rclass); + String findPath(Uri const &search, int flags); + + /** + * Finds all paths which match the search criteria. Will search the Zip + * lump index, lump => path mappings and native files in the local system. + * + * @param searchPattern Pattern which defines the scope of the search. + * @param flags @ref searchPathFlags + * @param found Set of (absolute) paths that match the result. + * + * @return Number of paths found. + */ + int findAllPaths(Path searchPattern, int flags, PathList &found); + + /** + * Print contents of the specified directory of the virtual file system. + */ + void printDirectory(Path path); + + /** + * Calculate a CRC for the loaded file list. + */ + uint loadedFilesCRC(); + + /** + * Unload all files loaded after startup. + * @return Number of files unloaded. + */ + int unloadAllNonStartupFiles(); + +private: + struct Instance; + Instance *d; +}; - Q_DECLARE_OPERATORS_FOR_FLAGS(FS1::Scheme::Flags) +Q_DECLARE_OPERATORS_FOR_FLAGS(FS1::Scheme::Flags) } // namespace de diff --git a/doomsday/engine/include/filesys/manifest.h b/doomsday/engine/include/filesys/manifest.h index 14ed4276ab..a84d341c6e 100644 --- a/doomsday/engine/include/filesys/manifest.h +++ b/doomsday/engine/include/filesys/manifest.h @@ -31,88 +31,88 @@ #include #include "api_uri.h" -namespace de +namespace de { + +/** + * Stores high-level metadata for and arbitrates/facilitates + * access to the associated "physical" resource. + * + * @ingroup core + */ +class Manifest { +public: + /** + * @param rClass Class for the associated resource. + * @param fFlags @ref fileFlags + * @param name An expected name for the associated file. + */ + Manifest(resourceclassid_t rClass, int fFlags, String* name = 0); + ~Manifest(); + + /// @return Class of the associated resource. + resourceclassid_t resourceClass() const; + + /// @return Flags for this file. + int fileFlags() const; + + /// @return List of "identity keys" used to identify the file. + QStringList const& identityKeys() const; + + /// @return List of names for the associated file. + QStringList const& names() const; + + /** + * Attempt to locate this file by systematically resolving and then + * checking each search path. + */ + Manifest& locateFile(); + + /** + * "Forget" the currently located file if one has been found. + */ + Manifest& forgetFile(); + + /** + * Attempt to resolve a path to (and maybe locate) this file. + * + * @param tryLocate @c true= Attempt to locate the file now. + * + * @return Path to the found file or an empty string. + * + * @see locateFile() + */ + String const& resolvedPath(bool tryLocate = true); + + /** + * Add a new file segment identity key to the list for this manifest. + * + * @param newIdentityKey New identity key (e.g., a lump/file name). + * @param didAdd If not @c =0, the outcome will be written here. + */ + Manifest& addIdentityKey(String newIdentityKey, bool* didAdd = 0); + + /** + * Add a new file name to the list of names for this manifest. + * + * @param newName New name for this file. Newer names have precedence. + * @param didAdd If not @c =0, the outcome will be written here. + */ + Manifest& addName(String newName, bool* didAdd = 0); + /** - * Stores high-level metadata for and arbitrates/facilitates - * access to the associated "physical" resource. + * Print information about a file to the console. * - * @ingroup core + * @param manifest Manifest for the file. + * @param showStatus @c true = print loaded/located status for the + * associated file. */ - class Manifest - { - public: - /** - * @param rClass Class for the associated resource. - * @param fFlags @ref fileFlags - * @param name An expected name for the associated file. - */ - Manifest(resourceclassid_t rClass, int fFlags, String* name = 0); - ~Manifest(); - - /// @return Class of the associated resource. - resourceclassid_t resourceClass() const; - - /// @return Flags for this file. - int fileFlags() const; - - /// @return List of "identity keys" used to identify the file. - QStringList const& identityKeys() const; - - /// @return List of names for the associated file. - QStringList const& names() const; - - /** - * Attempt to locate this file by systematically resolving and then - * checking each search path. - */ - Manifest& locateFile(); - - /** - * "Forget" the currently located file if one has been found. - */ - Manifest& forgetFile(); - - /** - * Attempt to resolve a path to (and maybe locate) this file. - * - * @param tryLocate @c true= Attempt to locate the file now. - * - * @return Path to the found file or an empty string. - * - * @see locateFile() - */ - String const& resolvedPath(bool tryLocate = true); - - /** - * Add a new file segment identity key to the list for this manifest. - * - * @param newIdentityKey New identity key (e.g., a lump/file name). - * @param didAdd If not @c =0, the outcome will be written here. - */ - Manifest& addIdentityKey(String newIdentityKey, bool* didAdd = 0); - - /** - * Add a new file name to the list of names for this manifest. - * - * @param newName New name for this file. Newer names have precedence. - * @param didAdd If not @c =0, the outcome will be written here. - */ - Manifest& addName(String newName, bool* didAdd = 0); - - /** - * Print information about a file to the console. - * - * @param manifest Manifest for the file. - * @param showStatus @c true = print loaded/located status for the - * associated file. - */ - static void consolePrint(Manifest& manifest, bool showStatus = true); - - private: - struct Instance; - Instance* d; - }; + static void consolePrint(Manifest& manifest, bool showStatus = true); + +private: + struct Instance; + Instance* d; +}; } // namespace de diff --git a/doomsday/engine/include/resource/compositetexture.h b/doomsday/engine/include/resource/compositetexture.h index 1a6d6de130..6877c6b0cb 100644 --- a/doomsday/engine/include/resource/compositetexture.h +++ b/doomsday/engine/include/resource/compositetexture.h @@ -32,175 +32,175 @@ #include #include "patchname.h" -namespace de +namespace de { + +/** + * A logical texture composite of one or more @em component images. + * + * The component images are sorted according to the order in which they + * should be composited, from bottom-most to top-most. + * + * @ingroup resource + */ +class CompositeTexture { +public: /** - * A logical texture composite of one or more @em component images. - * - * The component images are sorted according to the order in which they - * should be composited, from bottom-most to top-most. - * - * @ingroup resource + * Flags denoting usage traits. */ - class CompositeTexture + enum Flag { - public: - /** - * Flags denoting usage traits. - */ - enum Flag - { - Custom = 0x1 /**< The texture does not originate from a definition - of the current game. */ - }; - Q_DECLARE_FLAGS(Flags, Flag) - - /** - * Archived format variants. - */ - enum ArchiveFormat - { - /// Original format used by most id-tech 1 games. - DoomFormat, - - /// StrifeFormat differs only slightly from DoomFormat (ommits some unused values). - StrifeFormat - }; - - /** - * Component image. - */ - struct Component - { - protected: - explicit Component(int xOrigin = 0, int yOrigin = 0); - - public: - /// Origin of the top left corner of the component (in texture space units). - QPoint const &origin() const; - - /// X-axis origin of the top left corner of the component (in texture space units). - inline int xOrigin() const { - return origin().x(); - } - - /// Y-axis origin of the top left corner of the component (in texture space units). - inline int yOrigin() const { - return origin().y(); - } - - /// Returns the number of the lump (file) containing the associated - /// image; otherwise @c -1 (not found). - lumpnum_t lumpNum() const; - - friend class CompositeTexture; - - private: - /// Origin of the top left corner in the texture coordinate space. - QPoint origin_; - - /// Index of the lump containing the associated image. - lumpnum_t lumpNum_; - }; - typedef QList Components; + Custom = 0x1 /**< The texture does not originate from a definition + of the current game. */ + }; + Q_DECLARE_FLAGS(Flags, Flag) + + /** + * Archived format variants. + */ + enum ArchiveFormat + { + /// Original format used by most id-tech 1 games. + DoomFormat, + + /// StrifeFormat differs only slightly from DoomFormat (ommits some unused values). + StrifeFormat + }; + + /** + * Component image. + */ + struct Component + { + protected: + explicit Component(int xOrigin = 0, int yOrigin = 0); public: - /** - * Construct a default composite texture. - */ - explicit CompositeTexture(String percentEncodedName = "", int logicalWidth = 0, - int logicalHeight = 0, Flags _flags = 0); - - /** - * Construct a composite texture by deserializing an archived id-tech 1 - * format definition from the Reader. Lump numbers will be looked up using - * @a patchNames and any discrepancies or issues in the texture will be - * logged about at this time. - * - * @param reader Reader. - * @param patchNames List of component image names. - * @param format Format of the archived data. - * - * @return The deserialized composite texture. Caller gets ownership. - */ - static CompositeTexture *constructFrom(Reader &reader, QList patchNames, - ArchiveFormat format = DoomFormat); - - /// Returns the percent-endcoded symbolic name of the texture. - String percentEncodedName() const; - - /// Returns the percent-endcoded symbolic name of the texture. - String const &percentEncodedNameRef() const; - - /// Returns the logical dimensions of the texture (in map space units). - QSize const &logicalDimensions() const; - - /// Returns the logical width of the texture (in map space units). - inline int logicalWidth() const { - return logicalDimensions().width(); + /// Origin of the top left corner of the component (in texture space units). + QPoint const &origin() const; + + /// X-axis origin of the top left corner of the component (in texture space units). + inline int xOrigin() const { + return origin().x(); } - /// Returns the logical height of the texture (in map space units). - inline int logicalHeight() const { - return logicalDimensions().height(); + /// Y-axis origin of the top left corner of the component (in texture space units). + inline int yOrigin() const { + return origin().y(); } - /// Returns the pixel dimensions of the texture. - QSize const &dimensions() const; + /// Returns the number of the lump (file) containing the associated + /// image; otherwise @c -1 (not found). + lumpnum_t lumpNum() const; - /// Returns the pixel width of the texture. - inline int width() const { - return dimensions().width(); - } + friend class CompositeTexture; - /// Returns the pixel height of the texture. - inline int height() const { - return dimensions().height(); - } + private: + /// Origin of the top left corner in the texture coordinate space. + QPoint origin_; + + /// Index of the lump containing the associated image. + lumpnum_t lumpNum_; + }; + typedef QList Components; + +public: + /** + * Construct a default composite texture. + */ + explicit CompositeTexture(String percentEncodedName = "", int logicalWidth = 0, + int logicalHeight = 0, Flags _flags = 0); + + /** + * Construct a composite texture by deserializing an archived id-tech 1 + * format definition from the Reader. Lump numbers will be looked up using + * @a patchNames and any discrepancies or issues in the texture will be + * logged about at this time. + * + * @param reader Reader. + * @param patchNames List of component image names. + * @param format Format of the archived data. + * + * @return The deserialized composite texture. Caller gets ownership. + */ + static CompositeTexture *constructFrom(Reader &reader, QList patchNames, + ArchiveFormat format = DoomFormat); - /// Returns the associated "original index" for the texture. - int origIndex() const; + /// Returns the percent-endcoded symbolic name of the texture. + String percentEncodedName() const; - /// Change the "original index" value for the texture. - void setOrigIndex(int newIndex); + /// Returns the percent-endcoded symbolic name of the texture. + String const &percentEncodedNameRef() const; - /// Returns the total number of component images. - inline int componentCount() const { - return components().count(); - } + /// Returns the logical dimensions of the texture (in map space units). + QSize const &logicalDimensions() const; - /** - * Provides access to the component images of the texture for efficent traversal. - */ - Components const &components() const; + /// Returns the logical width of the texture (in map space units). + inline int logicalWidth() const { + return logicalDimensions().width(); + } - /** - * Provides access to the usage flags for the texture for efficent manipulation. - */ - Flags &flags(); + /// Returns the logical height of the texture (in map space units). + inline int logicalHeight() const { + return logicalDimensions().height(); + } - private: - /// Symbolic name of the texture (percent encoded). - String name; + /// Returns the pixel dimensions of the texture. + QSize const &dimensions() const; - /// Flags denoting usage traits. - Flags flags_; + /// Returns the pixel width of the texture. + inline int width() const { + return dimensions().width(); + } - /// Logical dimensions of the texture in map coordinate space units. - QSize logicalDimensions_; + /// Returns the pixel height of the texture. + inline int height() const { + return dimensions().height(); + } - /// Dimensions of the texture in pixels. - QSize dimensions_; + /// Returns the associated "original index" for the texture. + int origIndex() const; - /// Index of this resource determined by the logic of the indexing algorithm - /// used by the original game. - int origIndex_; + /// Change the "original index" value for the texture. + void setOrigIndex(int newIndex); - /// Set of component images to be composited. - Components components_; - }; + /// Returns the total number of component images. + inline int componentCount() const { + return components().count(); + } + + /** + * Provides access to the component images of the texture for efficent traversal. + */ + Components const &components() const; + + /** + * Provides access to the usage flags for the texture for efficent manipulation. + */ + Flags &flags(); + +private: + /// Symbolic name of the texture (percent encoded). + String name; + + /// Flags denoting usage traits. + Flags flags_; + + /// Logical dimensions of the texture in map coordinate space units. + QSize logicalDimensions_; + + /// Dimensions of the texture in pixels. + QSize dimensions_; + + /// Index of this resource determined by the logic of the indexing algorithm + /// used by the original game. + int origIndex_; + + /// Set of component images to be composited. + Components components_; +}; - Q_DECLARE_OPERATORS_FOR_FLAGS(CompositeTexture::Flags) +Q_DECLARE_OPERATORS_FOR_FLAGS(CompositeTexture::Flags) } // namespace de #endif // __cplusplus diff --git a/doomsday/engine/include/resource/material.h b/doomsday/engine/include/resource/material.h index 5ff3a41e54..505659fc9b 100644 --- a/doomsday/engine/include/resource/material.h +++ b/doomsday/engine/include/resource/material.h @@ -31,129 +31,129 @@ namespace de { +/** + * @ingroup resource + */ +class MaterialAnim +{ +public: /** - * @ingroup resource + * One frame in the animation. */ - class MaterialAnim + class Frame { public: - /** - * One frame in the animation. - */ - class Frame - { - public: - Frame(material_t &mat, ushort _tics, ushort _randomTics) - : material_(&mat), tics_(_tics), randomTics_(_randomTics) - {} - - /** - * Returns the material of the frame. - */ - material_t &material() const { - return *material_; - } - - /** - * Returns the duration of the frame in (sharp) tics. - */ - ushort tics() const { - return tics_; - } - - /** - * Returns the random part of the frame duration in (sharp) tics. - */ - ushort randomTics() const { - return randomTics_; - } - - private: - material_t *material_; - ushort tics_; - ushort randomTics_; - }; - - /// All frames in the animation. - typedef QList Frames; - - public: - /// An invalid frame reference was specified. @ingroup errors - DENG2_ERROR(InvalidFrameError); - - public: - MaterialAnim(int id, int flags); + Frame(material_t &mat, ushort _tics, ushort _randomTics) + : material_(&mat), tics_(_tics), randomTics_(_randomTics) + {} /** - * Progress the animation one frame forward. + * Returns the material of the frame. */ - void animate(); + material_t &material() const { + return *material_; + } /** - * Restart the animation over from the first frame. + * Returns the duration of the frame in (sharp) tics. */ - void reset(); + ushort tics() const { + return tics_; + } /** - * Returns the animation's unique identifier. + * Returns the random part of the frame duration in (sharp) tics. */ - int id() const; + ushort randomTics() const { + return randomTics_; + } - /** - * Returns the animation's @ref animationGroupFlags. - */ - int flags() const; + private: + material_t *material_; + ushort tics_; + ushort randomTics_; + }; - /** - * Returns the total number of frames in the animation. - */ - int frameCount() const; + /// All frames in the animation. + typedef QList Frames; - /** - * Lookup a frame in the animation by number. - * - * @param number Frame number to lookup. - * @return Found animation frame. - */ - Frame &frame(int number); +public: + /// An invalid frame reference was specified. @ingroup errors + DENG2_ERROR(InvalidFrameError); - /** - * Extend the animation by adding a new frame to the end of the sequence. - * - * @param mat Material for the frame. - * @param tics Duration of the frame in (sharp) tics. - * @param randomTics Random part of the frame duration in (sharp) tics. - */ - void addFrame(material_t &mat, int tics, int randomTics); +public: + MaterialAnim(int id, int flags); - /** - * Returns @c true iff @a mat is used by one or more frames in the animation. - * - * @param mat Material to search for. - */ - bool hasFrameForMaterial(material_t const &mat) const; + /** + * Progress the animation one frame forward. + */ + void animate(); - /** - * Provides access to the frame list for efficient traversal. - */ - Frames const &allFrames() const; + /** + * Restart the animation over from the first frame. + */ + void reset(); - private: - /// Unique identifier. - int id_; + /** + * Returns the animation's unique identifier. + */ + int id() const; - /// @ref animationGroupFlags. - int flags_; + /** + * Returns the animation's @ref animationGroupFlags. + */ + int flags() const; - /// Current frame index. - int index; + /** + * Returns the total number of frames in the animation. + */ + int frameCount() const; - int maxTimer; - int timer; + /** + * Lookup a frame in the animation by number. + * + * @param number Frame number to lookup. + * @return Found animation frame. + */ + Frame &frame(int number); - /// All animation frames. - Frames frames; - }; + /** + * Extend the animation by adding a new frame to the end of the sequence. + * + * @param mat Material for the frame. + * @param tics Duration of the frame in (sharp) tics. + * @param randomTics Random part of the frame duration in (sharp) tics. + */ + void addFrame(material_t &mat, int tics, int randomTics); + + /** + * Returns @c true iff @a mat is used by one or more frames in the animation. + * + * @param mat Material to search for. + */ + bool hasFrameForMaterial(material_t const &mat) const; + + /** + * Provides access to the frame list for efficient traversal. + */ + Frames const &allFrames() const; + +private: + /// Unique identifier. + int id_; + + /// @ref animationGroupFlags. + int flags_; + + /// Current frame index. + int index; + + int maxTimer; + int timer; + + /// All animation frames. + Frames frames; +}; } // namespace de extern "C" { diff --git a/doomsday/engine/include/resource/materialarchive.h b/doomsday/engine/include/resource/materialarchive.h index 1c53579c45..f23efd0d2b 100644 --- a/doomsday/engine/include/resource/materialarchive.h +++ b/doomsday/engine/include/resource/materialarchive.h @@ -34,68 +34,68 @@ struct material_s; namespace de { - class MaterialArchive - { - public: - /// Base class for all deserialization errors. @ingroup errors - DENG2_ERROR(ReadError); - - public: - /** - * @param useSegments If @c true, a serialized archive will be preceded by a segment id number. - */ - MaterialArchive(int useSegments, bool populate = true); - - ~MaterialArchive(); - - /** - * @return A new (unused) SerialId for the specified material. - */ - materialarchive_serialid_t findUniqueSerialId(struct material_s *mat) const; - - /** - * Finds and returns a material with the identifier @a serialId. - * - * @param serialId SerialId of a material. - * @param group Set to zero. Only used with the version 0 of MaterialArchive (now obsolete). - * - * @return Pointer to a material instance. Ownership not given. - */ - struct material_s *find(materialarchive_serialid_t serialId, int group) const; - - /** - * Returns the number of materials in the archive. - */ - int count() const; - - /** - * Returns the number of materials in the archive. - * Same as count() - */ - inline int size() const { - return count(); - } - - /** - * Serializes the state of the archive using @a writer. - * - * @param writer Writer instance. - */ - void write(writer_s &writer) const; - - /** - * Deserializes the state of the archive from @a reader. - * - * @param reader Reader instance. - * @param forcedVersion Version to interpret as, not actual format version. - * Use -1 to use whatever version is encountered. - */ - void read(reader_s &reader, int forcedVersion = -1); - - private: - struct Instance; - Instance *d; - }; +class MaterialArchive +{ +public: + /// Base class for all deserialization errors. @ingroup errors + DENG2_ERROR(ReadError); + +public: + /** + * @param useSegments If @c true, a serialized archive will be preceded by a segment id number. + */ + MaterialArchive(int useSegments, bool populate = true); + + ~MaterialArchive(); + + /** + * @return A new (unused) SerialId for the specified material. + */ + materialarchive_serialid_t findUniqueSerialId(struct material_s *mat) const; + + /** + * Finds and returns a material with the identifier @a serialId. + * + * @param serialId SerialId of a material. + * @param group Set to zero. Only used with the version 0 of MaterialArchive (now obsolete). + * + * @return Pointer to a material instance. Ownership not given. + */ + struct material_s *find(materialarchive_serialid_t serialId, int group) const; + + /** + * Returns the number of materials in the archive. + */ + int count() const; + + /** + * Returns the number of materials in the archive. + * Same as count() + */ + inline int size() const { + return count(); + } + + /** + * Serializes the state of the archive using @a writer. + * + * @param writer Writer instance. + */ + void write(writer_s &writer) const; + + /** + * Deserializes the state of the archive from @a reader. + * + * @param reader Reader instance. + * @param forcedVersion Version to interpret as, not actual format version. + * Use -1 to use whatever version is encountered. + */ + void read(reader_s &reader, int forcedVersion = -1); + +private: + struct Instance; + Instance *d; +}; } // namespace de diff --git a/doomsday/engine/include/resource/materialbind.h b/doomsday/engine/include/resource/materialbind.h index 88101998a0..b2393abe63 100644 --- a/doomsday/engine/include/resource/materialbind.h +++ b/doomsday/engine/include/resource/materialbind.h @@ -29,123 +29,123 @@ namespace de { - class Materials; - class MaterialScheme; - - class MaterialBind : public PathTree::Node +class Materials; +class MaterialScheme; + +class MaterialBind : public PathTree::Node +{ +public: + /** + * Contains extended info about a material binding. + * There are two links for each definition type, the first (index @c 0) + * for original game data and the second for external data. + */ + struct Info { - public: - /** - * Contains extended info about a material binding. - * There are two links for each definition type, the first (index @c 0) - * for original game data and the second for external data. - */ - struct Info - { - ded_decor_t *decorationDefs[2]; - ded_detailtexture_t *detailtextureDefs[2]; - ded_ptcgen_t *ptcgenDefs[2]; - ded_reflection_t *reflectionDefs[2]; - - Info(); - - /** - * Update the info with new linked definitions. Should be called: - * - * - When the bound material is changed/first-configured. - * - When said material's "custom" state changes. - * - * @param mat Material to link the definitions of. - */ - void linkDefinitions(material_t *mat); - - /** - * Zeroes all links to definitions. Should be called when the - * definition database is reset. - */ - void clearDefinitionLinks(); - }; - - public: - MaterialBind(PathTree::NodeArgs const &args); - - virtual ~MaterialBind(); - - void setId(materialid_t newId); + ded_decor_t *decorationDefs[2]; + ded_detailtexture_t *detailtextureDefs[2]; + ded_ptcgen_t *ptcgenDefs[2]; + ded_reflection_t *reflectionDefs[2]; - /** - * Returns the owning scheme of the material bind. - */ - MaterialScheme &scheme() const; - - /// Convenience method for returning the name of the owning scheme. - String const &schemeName() const; + Info(); /** - * Compose a URI of the form "scheme:path" for the material bind. + * Update the info with new linked definitions. Should be called: * - * The scheme component of the URI will contain the symbolic name of - * the scheme for the material bind. + * - When the bound material is changed/first-configured. + * - When said material's "custom" state changes. * - * The path component of the URI will contain the percent-encoded path - * of the material bind. + * @param mat Material to link the definitions of. */ - Uri composeUri(QChar sep = '/') const; - - /// @return Unique identifier associated with this. - materialid_t id() const; - - /// @return Material associated with this; otherwise @c NULL. - material_t *material() const; - - /// @return Extended info owned by this; otherwise @c NULL. - Info *info() const; - - /** - * Attach extended info data to this. If existing info is present it is replaced. - * MaterialBind is given ownership of the info. - * @param info Extended info data to attach. - */ - void attachInfo(Info &info); + void linkDefinitions(material_t *mat); /** - * Detach any extended info owned by this and relinquish ownership to the caller. - * @return Extended info or else @c NULL if not present. + * Zeroes all links to definitions. Should be called when the + * definition database is reset. */ - Info *detachInfo(); - - /** - * Change the Material associated with this binding. - * - * @note Only the relationship from MaterialBind to @a material changes! - * - * @post If @a material differs from that currently associated with this, any - * MaterialBindInfo presently owned by this will destroyed (its invalid). - * - * @param material New Material to associate with this. - */ - void setMaterial(material_t *material); - - /// @return Detail texture definition associated with this else @c NULL - ded_detailtexture_t *detailTextureDef() const; - - /// @return Decoration definition associated with this else @c NULL - ded_decor_t *decorationDef() const; - - /// @return Particle generator definition associated with this else @c NULL - ded_ptcgen_t *ptcGenDef() const; - - /// @return Reflection definition associated with this else @c NULL - ded_reflection_t *reflectionDef() const; - - /// Returns a reference to the application's material system. - static Materials &materials(); - - private: - struct Instance; - Instance *d; + void clearDefinitionLinks(); }; +public: + MaterialBind(PathTree::NodeArgs const &args); + + virtual ~MaterialBind(); + + void setId(materialid_t newId); + + /** + * Returns the owning scheme of the material bind. + */ + MaterialScheme &scheme() const; + + /// Convenience method for returning the name of the owning scheme. + String const &schemeName() const; + + /** + * Compose a URI of the form "scheme:path" for the material bind. + * + * The scheme component of the URI will contain the symbolic name of + * the scheme for the material bind. + * + * The path component of the URI will contain the percent-encoded path + * of the material bind. + */ + Uri composeUri(QChar sep = '/') const; + + /// @return Unique identifier associated with this. + materialid_t id() const; + + /// @return Material associated with this; otherwise @c NULL. + material_t *material() const; + + /// @return Extended info owned by this; otherwise @c NULL. + Info *info() const; + + /** + * Attach extended info data to this. If existing info is present it is replaced. + * MaterialBind is given ownership of the info. + * @param info Extended info data to attach. + */ + void attachInfo(Info &info); + + /** + * Detach any extended info owned by this and relinquish ownership to the caller. + * @return Extended info or else @c NULL if not present. + */ + Info *detachInfo(); + + /** + * Change the Material associated with this binding. + * + * @note Only the relationship from MaterialBind to @a material changes! + * + * @post If @a material differs from that currently associated with this, any + * MaterialBindInfo presently owned by this will destroyed (its invalid). + * + * @param material New Material to associate with this. + */ + void setMaterial(material_t *material); + + /// @return Detail texture definition associated with this else @c NULL + ded_detailtexture_t *detailTextureDef() const; + + /// @return Decoration definition associated with this else @c NULL + ded_decor_t *decorationDef() const; + + /// @return Particle generator definition associated with this else @c NULL + ded_ptcgen_t *ptcGenDef() const; + + /// @return Reflection definition associated with this else @c NULL + ded_reflection_t *reflectionDef() const; + + /// Returns a reference to the application's material system. + static Materials &materials(); + +private: + struct Instance; + Instance *d; +}; + } // namespace de #endif diff --git a/doomsday/engine/include/resource/materials.h b/doomsday/engine/include/resource/materials.h index e17f94bcc6..c330ac7f2a 100644 --- a/doomsday/engine/include/resource/materials.h +++ b/doomsday/engine/include/resource/materials.h @@ -36,323 +36,323 @@ namespace de { - class MaterialBind; +class MaterialBind; + +/** + * Specialized resource collection for a set of materials. + * + * - Pointers to Material are @em eternal, they are always valid and continue + * to reference the same logical material data even after engine reset. + * + * - Public material identifiers (materialid_t) are similarly eternal. + * + * - Material name bindings are semi-independant from the materials. There + * may be multiple name bindings for a given material (aliases). The only + * requirement is that their symbolic names must be unique among those in + * the same scheme. + * + * @ingroup resource + */ +class Materials +{ +public: + typedef class MaterialScheme Scheme; + + /** + * Flags determining URI validation logic. + * + * @see validateUri() + */ + enum UriValidationFlag + { + AnyScheme = 0x1 ///< The scheme of the URI may be of zero-length; signifying "any scheme". + }; + Q_DECLARE_FLAGS(UriValidationFlags, UriValidationFlag) + + /// Material system subspace schemes. + typedef QList Schemes; + + /// Material animation groups. + typedef QList AnimGroups; + +public: + /// The referenced texture was not found. @ingroup errors + DENG2_ERROR(NotFoundError); + + /// An unknown scheme was referenced. @ingroup errors + DENG2_ERROR(UnknownSchemeError); + + /// An unknown animation group was referenced. @ingroup errors + DENG2_ERROR(UnknownAnimGroupError); + +public: + /** + * Constructs a new material collection. + */ + Materials(); + + virtual ~Materials(); + + /// Register the console commands, variables, etc..., of this module. + static void consoleRegister(); /** - * Specialized resource collection for a set of materials. + * Returns the total number of unique materials in the collection. + */ + uint size() const; + + /** + * Returns the total number of unique materials in the collection. * - * - Pointers to Material are @em eternal, they are always valid and continue - * to reference the same logical material data even after engine reset. + * Same as size() + */ + inline uint count() const { + return size(); + } + + /// Process all outstanding tasks in the cache queue. + void processCacheQueue(); + + /// Empty the Material cache queue, cancelling all outstanding tasks. + void purgeCacheQueue(); + + /// To be called during a definition database reset to clear all links to defs. + void clearDefinitionLinks(); + + /** + * Process a tic of @a elapsed length, animating materials and anim-groups. + * @param elapsed Length of tic to be processed. + */ + void ticker(timespan_t elapsed); + + /** + * Lookup a subspace scheme by symbolic name. * - * - Public material identifiers (materialid_t) are similarly eternal. + * @param name Symbolic name of the scheme. + * @return Scheme associated with @a name. * - * - Material name bindings are semi-independant from the materials. There - * may be multiple name bindings for a given material (aliases). The only - * requirement is that their symbolic names must be unique among those in - * the same scheme. + * @throws UnknownSchemeError If @a name is unknown. + */ + Scheme &scheme(String name) const; + + /** + * Create a new subspace scheme. * - * @ingroup resource + * @param name Unique symbolic name of the new scheme. Must be at + * least @c Scheme::min_name_length characters long. + */ + Scheme &createScheme(String name); + + /** + * Returns @c true iff a Scheme exists with the symbolic @a name. + */ + bool knownScheme(String name) const; + + /** + * Returns a list of all the schemes for efficient traversal. + */ + Schemes const &allSchemes() const; + + /** + * Clear all materials in all schemes. + * @see Scheme::clear(). */ - class Materials + inline void clearAllSchemes() { - public: - typedef class MaterialScheme Scheme; - - /** - * Flags determining URI validation logic. - * - * @see validateUri() - */ - enum UriValidationFlag - { - AnyScheme = 0x1 ///< The scheme of the URI may be of zero-length; signifying "any scheme". - }; - Q_DECLARE_FLAGS(UriValidationFlags, UriValidationFlag) - - /// Material system subspace schemes. - typedef QList Schemes; - - /// Material animation groups. - typedef QList AnimGroups; - - public: - /// The referenced texture was not found. @ingroup errors - DENG2_ERROR(NotFoundError); - - /// An unknown scheme was referenced. @ingroup errors - DENG2_ERROR(UnknownSchemeError); - - /// An unknown animation group was referenced. @ingroup errors - DENG2_ERROR(UnknownAnimGroupError); - - public: - /** - * Constructs a new material collection. - */ - Materials(); - - virtual ~Materials(); - - /// Register the console commands, variables, etc..., of this module. - static void consoleRegister(); - - /** - * Returns the total number of unique materials in the collection. - */ - uint size() const; - - /** - * Returns the total number of unique materials in the collection. - * - * Same as size() - */ - inline uint count() const { - return size(); - } - - /// Process all outstanding tasks in the cache queue. - void processCacheQueue(); - - /// Empty the Material cache queue, cancelling all outstanding tasks. - void purgeCacheQueue(); - - /// To be called during a definition database reset to clear all links to defs. - void clearDefinitionLinks(); - - /** - * Process a tic of @a elapsed length, animating materials and anim-groups. - * @param elapsed Length of tic to be processed. - */ - void ticker(timespan_t elapsed); - - /** - * Lookup a subspace scheme by symbolic name. - * - * @param name Symbolic name of the scheme. - * @return Scheme associated with @a name. - * - * @throws UnknownSchemeError If @a name is unknown. - */ - Scheme &scheme(String name) const; - - /** - * Create a new subspace scheme. - * - * @param name Unique symbolic name of the new scheme. Must be at - * least @c Scheme::min_name_length characters long. - */ - Scheme &createScheme(String name); - - /** - * Returns @c true iff a Scheme exists with the symbolic @a name. - */ - bool knownScheme(String name) const; - - /** - * Returns a list of all the schemes for efficient traversal. - */ - Schemes const &allSchemes() const; - - /** - * Clear all materials in all schemes. - * @see Scheme::clear(). - */ - inline void clearAllSchemes() - { - Schemes schemes = allSchemes(); - DENG2_FOR_EACH(Schemes, i, schemes){ (*i)->clear(); } - } - - /** - * Validate @a uri to determine if it is well-formed and is usable as a - * search argument. - * - * @param uri Uri to be validated. - * @param flags Validation flags. - * @param quiet @c true= Do not output validation remarks to the log. - * - * @return @c true if @a Uri passes validation. - * - * @todo Should throw de::Error exceptions -ds - */ - bool validateUri(Uri const &uri, UriValidationFlags flags = 0, - bool quiet = false) const; - - /** - * Determines if a bind exists for a material on @a path. - * @return @c true, if a bind exists; otherwise @a false. - */ - bool has(Uri const &path) const; - - /** - * Find the material bind on @a path. - * - * @param search The search term. - * @return Found material bind. - */ - MaterialBind &find(Uri const &search) const; - - /** - * Update @a material according to the supplied definition @a def. - * To be called after an engine update/reset. - * - * @param material Material to be updated. - * @param def Material definition to update using. - */ - void rebuild(material_t &material, ded_material_t *def = 0); - - void updateTextureLinks(MaterialBind &bind); - - /// @return (Particle) Generator definition associated with @a material else @c NULL. - ded_ptcgen_t const *ptcGenDef(material_t &material); - - /// @return Decoration defintion associated with @a material else @c NULL. - ded_decor_t const *decorationDef(material_t &material); - - /// @return @c true if one or more light decorations are defined for this material. - bool hasDecorations(material_t &material); - - /** - * Create a new Material unless an existing Material is found at the path - * (and within the same scheme) as that specified in @a def, in which case - * it is returned instead. - * - * @note: May fail on invalid definitions (return= @c NULL). - * - * @param def Material definition to construct from. - * @return The newly-created/existing material; otherwise @c NULL. - */ - material_t *newFromDef(ded_material_t &def); - - MaterialBind &newBind(MaterialScheme &scheme, Path const &path, - material_t *material = 0); - - /** - * Prepare a material variant specification in accordance to the specified - * usage context. If incomplete context information is supplied, suitable - * default values will be chosen in their place. - * - * @param materialContext Material (usage) context identifier. - * @param flags @ref textureVariantSpecificationFlags - * @param border Border size in pixels (all edges). - * @param tClass Color palette translation class. - * @param tMap Color palette translation map. - * @param wrapS GL texture wrap/clamp mode on the horizontal axis (texture-space). - * @param wrapT GL texture wrap/clamp mode on the vertical axis (texture-space). - * @param minFilter Logical DGL texture minification level. - * @param magFilter Logical DGL texture magnification level. - * @param anisoFilter @c -1= User preference else a logical DGL anisotropic filter level. - * @param mipmapped @c true= use mipmapping. - * @param gammaCorrection @c true= apply gamma correction to textures. - * @param noStretch @c true= disallow stretching of textures. - * @param toAlpha @c true= convert textures to alpha data. - * - * @return Rationalized (and interned) copy of the final specification. - */ - MaterialVariantSpec const &variantSpecForContext(materialcontext_t materialContext, - int flags, byte border, int tClass, int tMap, int wrapS, int wrapT, - int minFilter, int magFilter, int anisoFilter, - bool mipmapped, bool gammaCorrection, bool noStretch, bool toAlpha); - - /** - * Add a variant of @a material to the cache queue for deferred preparation. - * - * @param material Base Material from which to derive a variant. - * @param spec Specification for the desired derivation of @a material. - * @param smooth @c true= Select the current frame if the material is group-animated. - * @param cacheGroups @c true= variants for all Materials in any applicable animation - * groups are desired, else just this specific Material. - */ - void cache(material_t &material, MaterialVariantSpec const &spec, - bool smooth, bool cacheGroups = true); - - /** - * Choose/create a variant of @a material which fulfills @a spec and then - * immediately prepare it for render (e.g., upload textures if necessary). - * - * @note A convenient shorthand of the call tree: - *
-         *    prepare( chooseVariant( @a material, @a spec, @a smooth, @c true ), @a forceSnapshotUpdate )
-         * 
- * - * @param material Base Material from which to derive a variant. - * @param spec Specification for the derivation of @a material. - * @param smooth @c true= Select the current frame if the material is group-animated. - * @param forceSnapshotUpdate @c true= Ensure to update the state snapshot. - * - * @return Snapshot for the chosen and prepared variant of Material. - */ - MaterialSnapshot const &prepare(material_t &material, MaterialVariantSpec const &spec, - bool smooth, bool forceSnapshotUpdate = false); - - /** - * Prepare variant @a material for render (e.g., upload textures if necessary). - * - * @see chooseVariant() - * - * @param material MaterialVariant to be prepared. - * @param forceSnapshotUpdate @c true= Force an update of the variant's state snapshot. - * - * @return Snapshot for the chosen and prepared variant of Material. - */ - MaterialSnapshot const &prepare(MaterialVariant &material, - bool forceSnapshotUpdate = false); - - /** - * Choose/create a variant of @a material which fulfills @a spec. - * - * @param material Material to derive the variant from. - * @param spec Specification for the derivation of @a material. - * @param smooth @c true= Select the current frame if the material is group-animated. - * @param canCreate @c true= Create a new variant if no suitable one exists. - * - * @return Chosen variant; otherwise @c NULL if none suitable and not creating. - */ - MaterialVariant *chooseVariant(material_t &material, MaterialVariantSpec const &spec, - bool smoothed, bool canCreate); - - /// @todo Refactor away -ds - MaterialBind *toMaterialBind(materialid_t materialId); - - /** - * Lookup an animation group by unique @a number. - */ - MaterialAnim &animGroup(int number) const; - - /** - * Create a new animation group. - * @return Unique identifier associated with the new group. - */ - int newAnimGroup(int flags); - - /** - * To be called to reset all animation groups back to their initial state. - */ - void resetAllAnimGroups(); - - /** - * To be called to destroy all animation groups when they are no longer needed. - */ - void clearAllAnimGroups(); - - /** - * Provides access to the list of animation groups for efficient traversal. - */ - AnimGroups const &allAnimGroups() const; - - /** - * Returns the total number of animation/precache groups in the collection. - */ - inline int animGroupCount() const { - return allAnimGroups().count(); - } - - private: - struct Instance; - Instance *d; - }; + Schemes schemes = allSchemes(); + DENG2_FOR_EACH(Schemes, i, schemes){ (*i)->clear(); } + } + + /** + * Validate @a uri to determine if it is well-formed and is usable as a + * search argument. + * + * @param uri Uri to be validated. + * @param flags Validation flags. + * @param quiet @c true= Do not output validation remarks to the log. + * + * @return @c true if @a Uri passes validation. + * + * @todo Should throw de::Error exceptions -ds + */ + bool validateUri(Uri const &uri, UriValidationFlags flags = 0, + bool quiet = false) const; + + /** + * Determines if a bind exists for a material on @a path. + * @return @c true, if a bind exists; otherwise @a false. + */ + bool has(Uri const &path) const; + + /** + * Find the material bind on @a path. + * + * @param search The search term. + * @return Found material bind. + */ + MaterialBind &find(Uri const &search) const; + + /** + * Update @a material according to the supplied definition @a def. + * To be called after an engine update/reset. + * + * @param material Material to be updated. + * @param def Material definition to update using. + */ + void rebuild(material_t &material, ded_material_t *def = 0); + + void updateTextureLinks(MaterialBind &bind); + + /// @return (Particle) Generator definition associated with @a material else @c NULL. + ded_ptcgen_t const *ptcGenDef(material_t &material); + + /// @return Decoration defintion associated with @a material else @c NULL. + ded_decor_t const *decorationDef(material_t &material); + + /// @return @c true if one or more light decorations are defined for this material. + bool hasDecorations(material_t &material); + + /** + * Create a new Material unless an existing Material is found at the path + * (and within the same scheme) as that specified in @a def, in which case + * it is returned instead. + * + * @note: May fail on invalid definitions (return= @c NULL). + * + * @param def Material definition to construct from. + * @return The newly-created/existing material; otherwise @c NULL. + */ + material_t *newFromDef(ded_material_t &def); + + MaterialBind &newBind(MaterialScheme &scheme, Path const &path, + material_t *material = 0); + + /** + * Prepare a material variant specification in accordance to the specified + * usage context. If incomplete context information is supplied, suitable + * default values will be chosen in their place. + * + * @param materialContext Material (usage) context identifier. + * @param flags @ref textureVariantSpecificationFlags + * @param border Border size in pixels (all edges). + * @param tClass Color palette translation class. + * @param tMap Color palette translation map. + * @param wrapS GL texture wrap/clamp mode on the horizontal axis (texture-space). + * @param wrapT GL texture wrap/clamp mode on the vertical axis (texture-space). + * @param minFilter Logical DGL texture minification level. + * @param magFilter Logical DGL texture magnification level. + * @param anisoFilter @c -1= User preference else a logical DGL anisotropic filter level. + * @param mipmapped @c true= use mipmapping. + * @param gammaCorrection @c true= apply gamma correction to textures. + * @param noStretch @c true= disallow stretching of textures. + * @param toAlpha @c true= convert textures to alpha data. + * + * @return Rationalized (and interned) copy of the final specification. + */ + MaterialVariantSpec const &variantSpecForContext(materialcontext_t materialContext, + int flags, byte border, int tClass, int tMap, int wrapS, int wrapT, + int minFilter, int magFilter, int anisoFilter, + bool mipmapped, bool gammaCorrection, bool noStretch, bool toAlpha); + + /** + * Add a variant of @a material to the cache queue for deferred preparation. + * + * @param material Base Material from which to derive a variant. + * @param spec Specification for the desired derivation of @a material. + * @param smooth @c true= Select the current frame if the material is group-animated. + * @param cacheGroups @c true= variants for all Materials in any applicable animation + * groups are desired, else just this specific Material. + */ + void cache(material_t &material, MaterialVariantSpec const &spec, + bool smooth, bool cacheGroups = true); + + /** + * Choose/create a variant of @a material which fulfills @a spec and then + * immediately prepare it for render (e.g., upload textures if necessary). + * + * @note A convenient shorthand of the call tree: + *
+     *    prepare( chooseVariant( @a material, @a spec, @a smooth, @c true ), @a forceSnapshotUpdate )
+     * 
+ * + * @param material Base Material from which to derive a variant. + * @param spec Specification for the derivation of @a material. + * @param smooth @c true= Select the current frame if the material is group-animated. + * @param forceSnapshotUpdate @c true= Ensure to update the state snapshot. + * + * @return Snapshot for the chosen and prepared variant of Material. + */ + MaterialSnapshot const &prepare(material_t &material, MaterialVariantSpec const &spec, + bool smooth, bool forceSnapshotUpdate = false); + + /** + * Prepare variant @a material for render (e.g., upload textures if necessary). + * + * @see chooseVariant() + * + * @param material MaterialVariant to be prepared. + * @param forceSnapshotUpdate @c true= Force an update of the variant's state snapshot. + * + * @return Snapshot for the chosen and prepared variant of Material. + */ + MaterialSnapshot const &prepare(MaterialVariant &material, + bool forceSnapshotUpdate = false); + + /** + * Choose/create a variant of @a material which fulfills @a spec. + * + * @param material Material to derive the variant from. + * @param spec Specification for the derivation of @a material. + * @param smooth @c true= Select the current frame if the material is group-animated. + * @param canCreate @c true= Create a new variant if no suitable one exists. + * + * @return Chosen variant; otherwise @c NULL if none suitable and not creating. + */ + MaterialVariant *chooseVariant(material_t &material, MaterialVariantSpec const &spec, + bool smoothed, bool canCreate); + + /// @todo Refactor away -ds + MaterialBind *toMaterialBind(materialid_t materialId); + + /** + * Lookup an animation group by unique @a number. + */ + MaterialAnim &animGroup(int number) const; + + /** + * Create a new animation group. + * @return Unique identifier associated with the new group. + */ + int newAnimGroup(int flags); + + /** + * To be called to reset all animation groups back to their initial state. + */ + void resetAllAnimGroups(); + + /** + * To be called to destroy all animation groups when they are no longer needed. + */ + void clearAllAnimGroups(); + + /** + * Provides access to the list of animation groups for efficient traversal. + */ + AnimGroups const &allAnimGroups() const; + + /** + * Returns the total number of animation/precache groups in the collection. + */ + inline int animGroupCount() const { + return allAnimGroups().count(); + } + +private: + struct Instance; + Instance *d; +}; - Q_DECLARE_OPERATORS_FOR_FLAGS(Materials::UriValidationFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(Materials::UriValidationFlags) } // namespace de diff --git a/doomsday/engine/include/resource/materialscheme.h b/doomsday/engine/include/resource/materialscheme.h index 3119188506..b0f9a88af1 100644 --- a/doomsday/engine/include/resource/materialscheme.h +++ b/doomsday/engine/include/resource/materialscheme.h @@ -26,79 +26,79 @@ namespace de { +/** + * A material system subspace. + * @ingroup resource + */ +class MaterialScheme +{ +public: + /// Minimum length of a symbolic name. + static int const min_name_length = URI_MINSCHEMELENGTH; + + /// Binds within the scheme are placed into a tree. + typedef PathTreeT Index; + +public: + /// The requested bind could not be found in the index. + DENG2_ERROR(NotFoundError); + +public: + /** + * Construct a new (empty) material subspace scheme. + * + * @param symbolicName Symbolic name of the new subspace scheme. Must + * have at least @ref min_name_length characters. + */ + explicit MaterialScheme(String symbolicName); + + ~MaterialScheme(); + + /// @return Symbolic name of this scheme (e.g., "Flats"). + String const &name() const; + + /// @return Total number of binds in the scheme. + int size() const; + + /// @return Total number of binds in the scheme. Same as @ref size(). + inline int count() const { + return size(); + } + /** - * A material system subspace. - * @ingroup resource + * Clear all binds in the scheme. */ - class MaterialScheme - { - public: - /// Minimum length of a symbolic name. - static int const min_name_length = URI_MINSCHEMELENGTH; - - /// Binds within the scheme are placed into a tree. - typedef PathTreeT Index; - - public: - /// The requested bind could not be found in the index. - DENG2_ERROR(NotFoundError); - - public: - /** - * Construct a new (empty) material subspace scheme. - * - * @param symbolicName Symbolic name of the new subspace scheme. Must - * have at least @ref min_name_length characters. - */ - explicit MaterialScheme(String symbolicName); - - ~MaterialScheme(); - - /// @return Symbolic name of this scheme (e.g., "Flats"). - String const &name() const; - - /// @return Total number of binds in the scheme. - int size() const; - - /// @return Total number of binds in the scheme. Same as @ref size(). - inline int count() const { - return size(); - } - - /** - * Clear all binds in the scheme. - */ - void clear(); - - /** - * Insert a new material bind at the given @a path into the scheme. - * If a bind already exists at this path, the existing bind is - * returned and this is a no-op. - * - * @param path Virtual path for the resultant bind. - * @return The (possibly newly created) bind at @a path. - */ - MaterialBind &insertBind(Path const &path, materialid_t id); - - /** - * Search the scheme for a bind matching @a path. - * - * @return Found bind. - */ - MaterialBind const &find(Path const &path) const; - - /// @copydoc find() - MaterialBind &find(Path const &path); - - /** - * Provides access to the bind index for efficient traversal. - */ - Index const &index() const; - - private: - struct Instance; - Instance *d; - }; + void clear(); + + /** + * Insert a new material bind at the given @a path into the scheme. + * If a bind already exists at this path, the existing bind is + * returned and this is a no-op. + * + * @param path Virtual path for the resultant bind. + * @return The (possibly newly created) bind at @a path. + */ + MaterialBind &insertBind(Path const &path, materialid_t id); + + /** + * Search the scheme for a bind matching @a path. + * + * @return Found bind. + */ + MaterialBind const &find(Path const &path) const; + + /// @copydoc find() + MaterialBind &find(Path const &path); + + /** + * Provides access to the bind index for efficient traversal. + */ + Index const &index() const; + +private: + struct Instance; + Instance *d; +}; } // namespace de diff --git a/doomsday/engine/include/resource/materialsnapshot.h b/doomsday/engine/include/resource/materialsnapshot.h index 3fdfca0132..1c2f1e9711 100644 --- a/doomsday/engine/include/resource/materialsnapshot.h +++ b/doomsday/engine/include/resource/materialsnapshot.h @@ -38,82 +38,82 @@ enum { namespace de { - class MaterialVariant; - class TextureVariant; +class MaterialVariant; +class TextureVariant; + +/** + * @ingroup resource + */ +class MaterialSnapshot +{ +public: + /// Invalid texture unit referenced. @ingroup errors + DENG2_ERROR(InvalidUnitError); + +public: + /** + * Construct a new material snapshot instance. + * @param material Material to capture to produce the snapshot. + */ + MaterialSnapshot(MaterialVariant &material); + + ~MaterialSnapshot(); + + /** + * Returns the material variant of the material snapshot. + */ + MaterialVariant &material() const; + + /** + * Returns the dimensions in the world coordinate space for the material snapshot. + */ + QSize const &dimensions() const; + + /** + * Returns @c true if the material snapshot is completely opaque. + */ + bool isOpaque() const; + + /** + * Returns the glow strength multiplier for the material snapshot. + */ + float glowStrength() const; + + /** + * Returns the minimum ambient light color for the material snapshot. + */ + vec3f_t const &reflectionMinColor() const; + + /** + * Returns @c true if a texture with @a index is set for the material snapshot. + */ + bool hasTexture(int index) const; /** - * @ingroup resource + * Lookup a material snapshot texture unit texture by index. + * + * @param index Index of the texture unit to lookup. + * @return The texture associated with the texture unit. */ - class MaterialSnapshot - { - public: - /// Invalid texture unit referenced. @ingroup errors - DENG2_ERROR(InvalidUnitError); - - public: - /** - * Construct a new material snapshot instance. - * @param material Material to capture to produce the snapshot. - */ - MaterialSnapshot(MaterialVariant &material); - - ~MaterialSnapshot(); - - /** - * Returns the material variant of the material snapshot. - */ - MaterialVariant &material() const; - - /** - * Returns the dimensions in the world coordinate space for the material snapshot. - */ - QSize const &dimensions() const; - - /** - * Returns @c true if the material snapshot is completely opaque. - */ - bool isOpaque() const; - - /** - * Returns the glow strength multiplier for the material snapshot. - */ - float glowStrength() const; - - /** - * Returns the minimum ambient light color for the material snapshot. - */ - vec3f_t const &reflectionMinColor() const; - - /** - * Returns @c true if a texture with @a index is set for the material snapshot. - */ - bool hasTexture(int index) const; - - /** - * Lookup a material snapshot texture unit texture by index. - * - * @param index Index of the texture unit to lookup. - * @return The texture associated with the texture unit. - */ - TextureVariant &texture(int index) const; - - /** - * Lookup a material snapshot texture unit by index. - * - * @param index Index of the texture unit to lookup. - * @return The associated texture unit. - */ - rtexmapunit_t const &unit(int index) const; - - /** - * Prepare all textures and update property values. - */ - void update(); - - private: - struct Instance; - Instance *d; - }; + TextureVariant &texture(int index) const; + + /** + * Lookup a material snapshot texture unit by index. + * + * @param index Index of the texture unit to lookup. + * @return The associated texture unit. + */ + rtexmapunit_t const &unit(int index) const; + + /** + * Prepare all textures and update property values. + */ + void update(); + +private: + struct Instance; + Instance *d; +}; } // namespace de diff --git a/doomsday/engine/include/resource/materialvariant.h b/doomsday/engine/include/resource/materialvariant.h index 71cffed1a8..721e3caa64 100644 --- a/doomsday/engine/include/resource/materialvariant.h +++ b/doomsday/engine/include/resource/materialvariant.h @@ -49,178 +49,178 @@ struct material_s; namespace de { +/** + * @ingroup resource + */ +struct MaterialVariantSpec +{ + /// Usage context identifier. + materialcontext_t context; + + /// Specification for the primary texture. + struct texturevariantspecification_s *primarySpec; + /** - * @ingroup resource + * Construct a default MaterialVariantSpec instance. */ - struct MaterialVariantSpec - { - /// Usage context identifier. - materialcontext_t context; - - /// Specification for the primary texture. - struct texturevariantspecification_s *primarySpec; - - /** - * Construct a default MaterialVariantSpec instance. - */ - MaterialVariantSpec() : context(MC_UNKNOWN), primarySpec(0) - {} - - /** - * Construct a MaterialVariantSpec instance by duplicating @a other. - */ - MaterialVariantSpec(MaterialVariantSpec const &other) - : context(other.context), primarySpec(other.primarySpec) - {} - - /** - * Determines whether specification @a other is equal to this specification. - * - * @param other The other specification. - * @return @c true if specifications are equal; otherwise @c false. - * - * Same as operator == - */ - bool compare(MaterialVariantSpec const &other) const; - - /** - * Determines whether specification @a other is equal to this specification. - * @see compare() - */ - bool operator == (MaterialVariantSpec const &other) const { - return compare(other); - } - - /** - * Determines whether specification @a other is NOT equal to this specification. - * @see compare() - */ - bool operator != (MaterialVariantSpec const &other) const { - return !(*this == other); - } - }; + MaterialVariantSpec() : context(MC_UNKNOWN), primarySpec(0) + {} + + /** + * Construct a MaterialVariantSpec instance by duplicating @a other. + */ + MaterialVariantSpec(MaterialVariantSpec const &other) + : context(other.context), primarySpec(other.primarySpec) + {} /** - * @ingroup resource + * Determines whether specification @a other is equal to this specification. + * + * @param other The other specification. + * @return @c true if specifications are equal; otherwise @c false. + * + * Same as operator == */ - class MaterialVariant + bool compare(MaterialVariantSpec const &other) const; + + /** + * Determines whether specification @a other is equal to this specification. + * @see compare() + */ + bool operator == (MaterialVariantSpec const &other) const { + return compare(other); + } + + /** + * Determines whether specification @a other is NOT equal to this specification. + * @see compare() + */ + bool operator != (MaterialVariantSpec const &other) const { + return !(*this == other); + } +}; + +/** + * @ingroup resource + */ +class MaterialVariant +{ +public: + /// Maximum number of layers a material supports. + static int const max_layers = DDMAX_MATERIAL_LAYERS; + + struct Layer { - public: - /// Maximum number of layers a material supports. - static int const max_layers = DDMAX_MATERIAL_LAYERS; - - struct Layer - { - /// @c -1 => layer not in use. - int stage; - - /// Texture of the layer. - Texture *texture; - - /// Origin of the layer in material-space. - float texOrigin[2]; - - /// Glow strength for the layer. - float glow; - - /// Current frame? - short tics; - }; - - public: - /// The requested layer does not exist. @ingroup errors - DENG2_ERROR(InvalidLayerError); - - public: - MaterialVariant(struct material_s &generalCase, MaterialVariantSpec const &spec, - ded_material_t const &def); - ~MaterialVariant(); - - /** - * Retrieve the general case for this variant. Allows for a variant - * reference to be used in place of a material (implicit indirection). - * - * @see generalCase() - */ - inline operator material_t &() const { - return generalCase(); - } - - /** - * Process a system tick event. - * @param time Length of the tick in seconds. - */ - void ticker(timespan_t time); - - /** - * Reset the staged animation point for this Material. - */ - void resetAnim(); - - /// @return Material from which this variant is derived. - struct material_s &generalCase() const; - - /// @return MaterialVariantSpec from which this variant is derived. - MaterialVariantSpec const &spec() const; - - /** - * Retrieve a handle for a staged animation layer for this variant. - * @param layer Index of the layer to retrieve. - * @return MaterialVariantLayer for the specified layer index. - */ - Layer const &layer(int layer); - - /** - * Attach MaterialSnapshot data to this. MaterialVariant is given ownership of @a materialSnapshot. - * @return Same as @a materialSnapshot for caller convenience. - */ - MaterialSnapshot &attachSnapshot(MaterialSnapshot &snapshot); - - /** - * Detach MaterialSnapshot data from this. Ownership of the data is relinquished to the caller. - */ - MaterialSnapshot *detachSnapshot(); - - /// @return MaterialSnapshot data associated with this; otherwise @c 0. - MaterialSnapshot *snapshot() const; - - /// @return Frame count when the snapshot was last prepared/updated. - int snapshotPrepareFrame() const; - - /** - * Change the frame when the snapshot was last prepared/updated. - * @param frame Frame to mark the snapshot with. - */ - void setSnapshotPrepareFrame(int frame); - - /// @return Translated 'next' (or target) MaterialVariant if set, else this. - MaterialVariant *translationNext(); - - /// @return Translated 'current' MaterialVariant if set, else this. - MaterialVariant *translationCurrent(); - - /// @return Translation position [0..1] - float translationPoint(); - - /** - * Change the translation target for this variant. - * - * @param current Translated 'current' MaterialVariant. - * @param next Translated 'next' (or target) MaterialVariant. - */ - void setTranslation(MaterialVariant *current, MaterialVariant *next); - - /** - * Change the translation point for this variant. - * @param inter Translation point. - */ - void setTranslationPoint(float inter); - - private: - struct Instance; - Instance *d; + /// @c -1 => layer not in use. + int stage; + + /// Texture of the layer. + Texture *texture; + + /// Origin of the layer in material-space. + float texOrigin[2]; + + /// Glow strength for the layer. + float glow; + + /// Current frame? + short tics; }; +public: + /// The requested layer does not exist. @ingroup errors + DENG2_ERROR(InvalidLayerError); + +public: + MaterialVariant(struct material_s &generalCase, MaterialVariantSpec const &spec, + ded_material_t const &def); + ~MaterialVariant(); + + /** + * Retrieve the general case for this variant. Allows for a variant + * reference to be used in place of a material (implicit indirection). + * + * @see generalCase() + */ + inline operator material_t &() const { + return generalCase(); + } + + /** + * Process a system tick event. + * @param time Length of the tick in seconds. + */ + void ticker(timespan_t time); + + /** + * Reset the staged animation point for this Material. + */ + void resetAnim(); + + /// @return Material from which this variant is derived. + struct material_s &generalCase() const; + + /// @return MaterialVariantSpec from which this variant is derived. + MaterialVariantSpec const &spec() const; + + /** + * Retrieve a handle for a staged animation layer for this variant. + * @param layer Index of the layer to retrieve. + * @return MaterialVariantLayer for the specified layer index. + */ + Layer const &layer(int layer); + + /** + * Attach MaterialSnapshot data to this. MaterialVariant is given ownership of @a materialSnapshot. + * @return Same as @a materialSnapshot for caller convenience. + */ + MaterialSnapshot &attachSnapshot(MaterialSnapshot &snapshot); + + /** + * Detach MaterialSnapshot data from this. Ownership of the data is relinquished to the caller. + */ + MaterialSnapshot *detachSnapshot(); + + /// @return MaterialSnapshot data associated with this; otherwise @c 0. + MaterialSnapshot *snapshot() const; + + /// @return Frame count when the snapshot was last prepared/updated. + int snapshotPrepareFrame() const; + + /** + * Change the frame when the snapshot was last prepared/updated. + * @param frame Frame to mark the snapshot with. + */ + void setSnapshotPrepareFrame(int frame); + + /// @return Translated 'next' (or target) MaterialVariant if set, else this. + MaterialVariant *translationNext(); + + /// @return Translated 'current' MaterialVariant if set, else this. + MaterialVariant *translationCurrent(); + + /// @return Translation position [0..1] + float translationPoint(); + + /** + * Change the translation target for this variant. + * + * @param current Translated 'current' MaterialVariant. + * @param next Translated 'next' (or target) MaterialVariant. + */ + void setTranslation(MaterialVariant *current, MaterialVariant *next); + + /** + * Change the translation point for this variant. + * @param inter Translation point. + */ + void setTranslationPoint(float inter); + +private: + struct Instance; + Instance *d; +}; + } // namespace de #endif // __cplusplus diff --git a/doomsday/engine/include/resource/patch.h b/doomsday/engine/include/resource/patch.h index c539f373b3..d76104ce73 100644 --- a/doomsday/engine/include/resource/patch.h +++ b/doomsday/engine/include/resource/patch.h @@ -30,84 +30,84 @@ namespace de { +/** + * @em Patch is a raster image in the id Tech 1 picture format (Doom). + * @ingroup resource + * + * @see http://doomwiki.org/wiki/Picture_format + * + * @note The height dimension value as declared in the patch header may + * well differ to the actual height of the composited image. This is the + * reason why map drawing in the id tech 1 software renderer can be seen + * to "overdraw" posts - the wall column drawer is working with post pixel + * ranges rather than the "logical" height declared in the header. + */ +class Patch +{ +public: /** - * @em Patch is a raster image in the id Tech 1 picture format (Doom). - * @ingroup resource - * - * @see http://doomwiki.org/wiki/Picture_format - * - * @note The height dimension value as declared in the patch header may - * well differ to the actual height of the composited image. This is the - * reason why map drawing in the id tech 1 software renderer can be seen - * to "overdraw" posts - the wall column drawer is working with post pixel - * ranges rather than the "logical" height declared in the header. + * Metadata which describes the patch. */ - class Patch + struct Metadata { - public: - /** - * Metadata which describes the patch. - */ - struct Metadata - { - /// Dimensions of the patch in pixels. - QSize dimensions; + /// Dimensions of the patch in pixels. + QSize dimensions; - /// Logical dimensions of the patch in pixels (@see Patch notes). - QSize logicalDimensions; + /// Logical dimensions of the patch in pixels (@see Patch notes). + QSize logicalDimensions; - /// Origin offset (top left) in world coordinate space units. - /// Used for various purposes depending on context. - QPoint origin; - }; + /// Origin offset (top left) in world coordinate space units. + /// Used for various purposes depending on context. + QPoint origin; + }; - /** - * Flags for @ref load() - */ - enum Flag - { - /// If the color of a pixel uses index #0 write the default color - /// (black) as the color value and set the alpha to zero. - MaskZero = 0x1, + /** + * Flags for @ref load() + */ + enum Flag + { + /// If the color of a pixel uses index #0 write the default color + /// (black) as the color value and set the alpha to zero. + MaskZero = 0x1, - /// Clip the composited image to the logical dimensions of the patch - /// ; otherwise perform no clipping (use the pixel dimensions). - ClipToLogicalDimensions = 0x2 - }; - Q_DECLARE_FLAGS(Flags, Flag) + /// Clip the composited image to the logical dimensions of the patch + /// ; otherwise perform no clipping (use the pixel dimensions). + ClipToLogicalDimensions = 0x2 + }; + Q_DECLARE_FLAGS(Flags, Flag) - public: - /** - * Attempt to read metadata from @a data. - * @param data Data to read metadata from. - */ - static Metadata loadMetadata(IByteArray const &data); +public: + /** + * Attempt to read metadata from @a data. + * @param data Data to read metadata from. + */ + static Metadata loadMetadata(IByteArray const &data); - /** - * Attempt to interpret @a data as a Patch. - * @param data Data to interpret as a Patch. - * @param flags Flags determining how the data should be interpreted. - */ - static Block load(IByteArray const &data, Flags = 0); + /** + * Attempt to interpret @a data as a Patch. + * @param data Data to interpret as a Patch. + * @param flags Flags determining how the data should be interpreted. + */ + static Block load(IByteArray const &data, Flags = 0); - /** - * @copydoc load() - * @param xlatTable If not @c NULL, use this translation table when - * compositing final color palette indices. - */ - static Block load(IByteArray const &data, IByteArray const &xlatTable, Flags = 0); + /** + * @copydoc load() + * @param xlatTable If not @c NULL, use this translation table when + * compositing final color palette indices. + */ + static Block load(IByteArray const &data, IByteArray const &xlatTable, Flags = 0); - /** - * Determines whether @a data looks like it can be interpreted as a Patch. - * - * @param data Data to check. - * - * @return @c true if the data looks like a patch; otherwise @c false. - */ - static bool recognize(IByteArray const &data); - }; + /** + * Determines whether @a data looks like it can be interpreted as a Patch. + * + * @param data Data to check. + * + * @return @c true if the data looks like a patch; otherwise @c false. + */ + static bool recognize(IByteArray const &data); +}; - Q_DECLARE_OPERATORS_FOR_FLAGS(Patch::Flags) +Q_DECLARE_OPERATORS_FOR_FLAGS(Patch::Flags) } // namespace de diff --git a/doomsday/engine/include/resource/texture.h b/doomsday/engine/include/resource/texture.h index 9de01df863..255c3a6d7c 100644 --- a/doomsday/engine/include/resource/texture.h +++ b/doomsday/engine/include/resource/texture.h @@ -58,164 +58,164 @@ typedef enum { namespace de { - class TextureManifest; +class TextureManifest; +/** + * Logical texture object. + * @ingroup resource + */ +class Texture +{ +public: /** - * Logical texture object. - * @ingroup resource + * Classification/processing flags */ - class Texture + enum Flag { - public: - /** - * Classification/processing flags - */ - enum Flag - { - /// Texture is not to be drawn. - NoDraw = 0x1, - - /// Texture is "custom" (i.e., not an original game resource). - Custom = 0x2, - - /// Apply the monochrome filter to the processed image. - Monochrome = 0x4, - - /// Apply the upscaleAndSharpen filter to the processed image. - UpscaleAndSharpen = 0x8 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - typedef std::list Variants; - - public: - /** - * @param manifest Manifest derived to yield the texture. - * @param userData User data to associate with the resultant texture. - */ - Texture(TextureManifest &manifest, void *userData = 0); - - ~Texture(); - - /// @return Provides access to the classification/processing flags. - Flags const &flags() const; - - /// @return Provides access to the classification/processing flags. - Flags &flags(); - - /** - * Returns the TextureManifest derived to yield the texture. - */ - TextureManifest &manifest() const; - - /** - * Retrieve the value of the associated user data pointer. - * @return Associated data pointer value. - */ - void *userDataPointer() const; - - /** - * Set the user data pointer value. Ownership of the data is not given to - * this instance. - * - * @note If already set the old value will be replaced (so if it points - * to some dynamically constructed data/resource it is the caller's - * responsibility to release it beforehand). - * - * @param userData User data pointer value. - */ - void setUserDataPointer(void *userData); - - /** - * Add a new prepared variant to the list of resources for this Texture. - * Texture takes ownership of the variant. - * - * @param variant Variant instance to add to the resource list. - */ - TextureVariant &addVariant(TextureVariant &variant); - - /// @return Number of variants for the texture. - uint variantCount() const; - - /// Destroy all analyses for the texture. - void clearAnalyses(); - - /// Destroy all prepared variants for the texture. - void clearVariants(); - - /** - * Retrieve the value of an identified @a analysis data pointer. - * @return Associated data pointer value. - **/ - void *analysisDataPointer(texture_analysisid_t analysis) const; - - /** - * Set the value of an identified @a analysis data pointer. Ownership of - * the data is not given to this instance. - * - * @note If already set the old value will be replaced (so if it points - * to some dynamically constructed data/resource it is the caller's - * responsibility to release it beforehand). - * - * @param analysis Identifier of the data being attached. - * @param data Data to be attached. - */ - void setAnalysisDataPointer(texture_analysisid_t analysis, void *data); - - /** - * Returns the world width of the texture in map coordinate space units. - */ - int width() const; - - /** - * Returns the world height of the texture in map coordinate space units. - */ - int height() const; - - /** - * Returns the world dimensions [width, height] of the texture in map - * coordinate space units. - */ - QSize const &dimensions() const; - - /** - * Change the world width of the texture. - * @param newWidth New width in map coordinate space units. - */ - void setWidth(int newWidth); - - /** - * Change the world height of the texture. - * @param newHeight New height in map coordinate space units. - */ - void setHeight(int newHeight); - - /** - * Change the world dimensions of the texture. - * @param newDimensions New dimensions [width, height] in map coordinate space units. - */ - void setDimensions(QSize const &newDimensions); - - /** - * Returns the world origin offset of texture in map coordinate space units. - */ - QPoint const &origin() const; - - /** - * Change the world origin offset of the texture. - * @param newOrigin New origin in map coordinate space units. - */ - void setOrigin(QPoint const &newOrigin); - - /** - * Provides access to the list of variant textures for efficent traversals. - */ - Variants const &variantList() const; - - private: - struct Instance; - Instance *d; + /// Texture is not to be drawn. + NoDraw = 0x1, + + /// Texture is "custom" (i.e., not an original game resource). + Custom = 0x2, + + /// Apply the monochrome filter to the processed image. + Monochrome = 0x4, + + /// Apply the upscaleAndSharpen filter to the processed image. + UpscaleAndSharpen = 0x8 }; + Q_DECLARE_FLAGS(Flags, Flag) + + typedef std::list Variants; + +public: + /** + * @param manifest Manifest derived to yield the texture. + * @param userData User data to associate with the resultant texture. + */ + Texture(TextureManifest &manifest, void *userData = 0); + + ~Texture(); + + /// @return Provides access to the classification/processing flags. + Flags const &flags() const; + + /// @return Provides access to the classification/processing flags. + Flags &flags(); + + /** + * Returns the TextureManifest derived to yield the texture. + */ + TextureManifest &manifest() const; + + /** + * Retrieve the value of the associated user data pointer. + * @return Associated data pointer value. + */ + void *userDataPointer() const; + + /** + * Set the user data pointer value. Ownership of the data is not given to + * this instance. + * + * @note If already set the old value will be replaced (so if it points + * to some dynamically constructed data/resource it is the caller's + * responsibility to release it beforehand). + * + * @param userData User data pointer value. + */ + void setUserDataPointer(void *userData); + + /** + * Add a new prepared variant to the list of resources for this Texture. + * Texture takes ownership of the variant. + * + * @param variant Variant instance to add to the resource list. + */ + TextureVariant &addVariant(TextureVariant &variant); + + /// @return Number of variants for the texture. + uint variantCount() const; + + /// Destroy all analyses for the texture. + void clearAnalyses(); + + /// Destroy all prepared variants for the texture. + void clearVariants(); + + /** + * Retrieve the value of an identified @a analysis data pointer. + * @return Associated data pointer value. + **/ + void *analysisDataPointer(texture_analysisid_t analysis) const; + + /** + * Set the value of an identified @a analysis data pointer. Ownership of + * the data is not given to this instance. + * + * @note If already set the old value will be replaced (so if it points + * to some dynamically constructed data/resource it is the caller's + * responsibility to release it beforehand). + * + * @param analysis Identifier of the data being attached. + * @param data Data to be attached. + */ + void setAnalysisDataPointer(texture_analysisid_t analysis, void *data); + + /** + * Returns the world width of the texture in map coordinate space units. + */ + int width() const; + + /** + * Returns the world height of the texture in map coordinate space units. + */ + int height() const; + + /** + * Returns the world dimensions [width, height] of the texture in map + * coordinate space units. + */ + QSize const &dimensions() const; + + /** + * Change the world width of the texture. + * @param newWidth New width in map coordinate space units. + */ + void setWidth(int newWidth); + + /** + * Change the world height of the texture. + * @param newHeight New height in map coordinate space units. + */ + void setHeight(int newHeight); + + /** + * Change the world dimensions of the texture. + * @param newDimensions New dimensions [width, height] in map coordinate space units. + */ + void setDimensions(QSize const &newDimensions); + + /** + * Returns the world origin offset of texture in map coordinate space units. + */ + QPoint const &origin() const; + + /** + * Change the world origin offset of the texture. + * @param newOrigin New origin in map coordinate space units. + */ + void setOrigin(QPoint const &newOrigin); + + /** + * Provides access to the list of variant textures for efficent traversals. + */ + Variants const &variantList() const; + +private: + struct Instance; + Instance *d; +}; } // namespace de diff --git a/doomsday/engine/include/resource/texturevariant.h b/doomsday/engine/include/resource/texturevariant.h index abcd7ff1e2..584d28fad0 100644 --- a/doomsday/engine/include/resource/texturevariant.h +++ b/doomsday/engine/include/resource/texturevariant.h @@ -28,84 +28,84 @@ namespace de { - class Texture; +class Texture; - /** - * @ingroup resource - */ - class TextureVariant +/** + * @ingroup resource + */ +class TextureVariant +{ +private: + enum Flag { - private: - enum Flag - { - /// Texture contains alpha. - Masked = 0x1, + /// Texture contains alpha. + Masked = 0x1, - /// Texture has been uploaded to GL. - Uploaded = 0x2 - }; - Q_DECLARE_FLAGS(Flags, Flag) + /// Texture has been uploaded to GL. + Uploaded = 0x2 + }; + Q_DECLARE_FLAGS(Flags, Flag) - public: - /** - * @param generalCase Texture from which this variant is derived. - * @param spec Specification used to derive this variant. - * Ownership is NOT given to the resultant TextureVariant - * @param source Source of this variant. - */ - TextureVariant(Texture &generalCase, texturevariantspecification_t &spec, - TexSource source = TEXS_NONE); +public: + /** + * @param generalCase Texture from which this variant is derived. + * @param spec Specification used to derive this variant. + * Ownership is NOT given to the resultant TextureVariant + * @param source Source of this variant. + */ + TextureVariant(Texture &generalCase, texturevariantspecification_t &spec, + TexSource source = TEXS_NONE); - /// @return Superior Texture of which this is a derivative. - Texture &generalCase() const { return texture; } + /// @return Superior Texture of which this is a derivative. + Texture &generalCase() const { return texture; } - /// @return Source of this variant. - TexSource source() const { return texSource; } + /// @return Source of this variant. + TexSource source() const { return texSource; } - /** - * Change the source of this variant. - * @param newSource New TextureSource. - */ - void setSource(TexSource newSource); + /** + * Change the source of this variant. + * @param newSource New TextureSource. + */ + void setSource(TexSource newSource); - /// @return TextureVariantSpecification used to derive this variant. - texturevariantspecification_t *spec() const { return varSpec; } + /// @return TextureVariantSpecification used to derive this variant. + texturevariantspecification_t *spec() const { return varSpec; } - bool isMasked() const { return !!(flags & Masked); } + bool isMasked() const { return !!(flags & Masked); } - void flagMasked(bool yes); + void flagMasked(bool yes); - bool isUploaded() const { return !!(flags & Uploaded); } + bool isUploaded() const { return !!(flags & Uploaded); } - void flagUploaded(bool yes); + void flagUploaded(bool yes); - bool isPrepared() const; + bool isPrepared() const; - void coords(float *s, float *t) const; - void setCoords(float s, float t); + void coords(float *s, float *t) const; + void setCoords(float s, float t); - uint glName() const { return glTexName; } + uint glName() const { return glTexName; } - void setGLName(uint glName); + void setGLName(uint glName); - private: - /// Superior Texture of which this is a derivative. - Texture &texture; +private: + /// Superior Texture of which this is a derivative. + Texture &texture; - /// Source of this texture. - TexSource texSource; + /// Source of this texture. + TexSource texSource; - Flags flags; + Flags flags; - /// Name of the associated GL texture object. - uint glTexName; + /// Name of the associated GL texture object. + uint glTexName; - /// Prepared coordinates for the bottom right of the texture minus border. - float s, t; + /// Prepared coordinates for the bottom right of the texture minus border. + float s, t; - /// Specification used to derive this variant. - texturevariantspecification_t *varSpec; - }; + /// Specification used to derive this variant. + texturevariantspecification_t *varSpec; +}; } // namespace de