18 #include "precompiled.h"
22 #include <boost/algorithm/string.hpp>
40 void ColladaLog(
void* cb_data,
int severity,
const char* text)
52 void ColladaOutput(
void* cb_data,
const char* data,
unsigned int length)
55 writeBuffer->
Append(data, (
size_t)length);
86 if (!boost::algorithm::starts_with(path.
string(), L
"art/skeletons/"))
102 LOGMESSAGE(L
"Hotloading skeleton definitions from '%ls'", path.
string().c_str());
109 LOGERROR(L
"Failed to read skeleton defintions from '%ls'", path.
string().c_str());
116 LOGERROR(L
"Failed to load skeleton definitions from '%ls'", path.
string().c_str());
179 if (writeBuffer.
Size())
185 return (result == 0);
192 LOGERROR(L
"Failed to load COLLADA conversion DLL");
205 LOGERROR(L
"Failed to load symbols from COLLADA conversion DLL");
217 LOGERROR(L
"No skeleton definition files present");
222 for (VfsPaths::const_iterator it = pathnames.begin(); it != pathnames.end(); ++it)
224 LOGMESSAGE(L
"Loading skeleton definitions from '%ls'", it->string().c_str());
231 LOGERROR(L
"Failed to read skeleton defintions from '%ls'", it->string().c_str());
238 LOGERROR(L
"Failed to load skeleton definitions from '%ls'", it->string().c_str());
246 LOGERROR(L
"Failed to load any skeleton definitions");
270 LOGWARNING(L
"Failed to load skeleton definitions");
276 std::sort(paths.begin(), paths.end());
283 for (VfsPaths::const_iterator it = paths.begin(); it != paths.end(); ++it)
290 LOGERROR(L
"Failed to stat '%ls' for DAE caching", it->string().c_str());
301 LOGERROR(L
"Failed to stat any skeleton definitions for DAE caching");
308 hash.
Update((
const u8*)&(*it),
sizeof(*it));
332 case PMD: extn = L
".pmd";
break;
333 case PSA: extn = L
".psa";
break;
408 if (!
m->
Convert(sourcePath, cachePath, type))
423 case PMD: extn = L
".pmd";
break;
424 case PSA: extn = L
".psa";
break;
432 return m->
Convert(sourcePath,
VfsPath(
"cache") / archiveCachePath, type);
VfsPath GetLoadablePath(const VfsPath &pathnameNoExtension, FileType type)
Returns the VFS path to a PMD/PSA file for the given source file.
Path VfsPath
VFS path of the form "(dir/)*file?".
void Append(const void *data, size_t size)
void(* set_logger)(Collada::LogFn logger, void *cb_data)
bool m_skeletonHashInvalidated
const PSRETURN PSRETURN_OK
Reads a file, then gives read-only access to the contents.
void PrepareCacheKey(MD5 &hash, u32 &version)
Creates MD5 hash key from skeletons.xml info and COLLADA converter version, used to invalidate cached...
static Status ReloadChangedFileCB(void *param, const VfsPath &path)
void Unload()
Unload the library, if it has been loaded already.
CColladaManagerImpl(const PIVFS &vfs)
int(* convert_dae_to_psa)(const char *dae, Collada::OutputFn psa_writer, void *cb_data)
void ColladaLog(void *cb_data, int severity, const char *text)
Status ReloadChangedFile(const VfsPath &path)
void ColladaOutput(void *cb_data, const char *data, unsigned int length)
CStr GetAsString() const
Returns contents of file as a string.
bool IsLoaded() const
Check whether the library has been loaded successfully.
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
void Update(const u8 *data, size_t len)
void UnregisterFileReloadFunc(FileReloadFunc func, void *obj)
delete a callback function registered with RegisterFileReloadFunc (removes any with the same func and...
void RegisterFileReloadFunc(FileReloadFunc func, void *obj)
register a callback function to be called by ReloadChangedFiles
VfsPath ArchiveCachePath(const VfsPath &sourcePath)
Return the path of the archive cache for the given source file.
bool GenerateCachedFile(const VfsPath &sourcePath, FileType type, VfsPath &archiveCachePath)
Converts DAE to archive cached .pmd/psa and outputs the resulting path (used by archive builder) ...
shared_ptr< u8 > Data() const
const String & string() const
const u8 * GetBuffer() const
Returns buffer of this file as a stream of bytes.
CColladaManager(const PIVFS &vfs)
bool LoadSkeletonDefinitions()
i64 Status
Error handling system.
#define COLLADA_CONVERTER_VERSION
bool LoadDLL()
Attempt to load and initialise the library, if not already.
void LoadSymbol(const char *name, T &fptr) const
Attempt to load a named symbol from the library.
Path ChangeExtension(Path extension) const
std::vector< u64 > m_skeletonHashes
PSRETURN Load(const PIVFS &vfs, const VfsPath &filename)
Returns either PSRETURN_OK or PSRETURN_CVFSFile_LoadFailed.
int(* set_skeleton_definitions)(const char *xml, int length)
bool VfsFileExists(const VfsPath &pathname)
size_t GetBufferSize() const
std::vector< VfsPath > VfsPaths
bool Convert(const VfsPath &daeFilename, const VfsPath &pmdFilename, CColladaManager::FileType type)
void(* OutputFn)(void *cb_data, const char *data, unsigned int length)
Status TryLoadingCached(const VfsPath &sourcePath, const MD5 &initialHash, u32 version, VfsPath &loadPath)
Attempts to find a valid cached which can be loaded.
void(* LogFn)(void *cb_data, int severity, const char *text)
Helper class for systems that have an expensive cacheable conversion process when loading files...
Status GetPathnames(const PIVFS &fs, const VfsPath &path, const wchar_t *filter, VfsPaths &pathnames)
int(* convert_dae_to_pmd)(const char *dae, Collada::OutputFn pmd_writer, void *cb_data)