Fix zipped dts loading

This commit is contained in:
Alex Piola 2016-03-04 10:45:55 +01:00
parent 61bae52c89
commit d2d5b8d834

View file

@ -529,6 +529,16 @@ bool ColladaShapeLoader::canLoadCachedDTS(const Torque::Path& path)
} }
} }
//assume the dts is good since it was zipped on purpose
Torque::FS::FileSystemRef ref = Torque::FS::GetFileSystem(cachedPath);
if (ref && !dStrcmp("Zip", ref->getTypeStr()))
{
bool forceLoadDAE = Con::getBoolVariable("$collada::forceLoadDAE", false);
if (!forceLoadDAE && Torque::FS::IsFile(cachedPath))
return true;
}
return false; return false;
} }
@ -709,11 +719,17 @@ TSShape* loadColladaShape(const Torque::Path &path)
#ifndef DAE2DTS_TOOL #ifndef DAE2DTS_TOOL
// Cache the Collada model to a DTS file for faster loading next time. // Cache the Collada model to a DTS file for faster loading next time.
FileStream dtsStream; FileStream dtsStream;
if (dtsStream.open(cachedPath.getFullPath(), Torque::FS::File::Write)) if (dtsStream.open(cachedPath.getFullPath(), Torque::FS::File::Write))
{ {
Torque::FS::FileSystemRef ref = Torque::FS::GetFileSystem(daePath);
if (ref && !dStrcmp("Zip", ref->getTypeStr()))
Con::errorf("No cached dts file found in archive for %s. Forcing cache to disk.", daePath.getFullFileName().c_str());
Con::printf("Writing cached COLLADA shape to %s", cachedPath.getFullPath().c_str()); Con::printf("Writing cached COLLADA shape to %s", cachedPath.getFullPath().c_str());
tss->write(&dtsStream); tss->write(&dtsStream);
} }
#endif // DAE2DTS_TOOL #endif // DAE2DTS_TOOL
// Add collada materials to materials.cs // Add collada materials to materials.cs