Skip to content

Commit

Permalink
Ogre assets: Make threaded loading work in tundra2. Restore the old o…
Browse files Browse the repository at this point in the history
…gre sanitise asset refs, for some reason the code was changed and did not anymore correspond with assetapi sanitise ref code. This resulted into threaded loading to fail to find sanitised texture refs inside material files.
  • Loading branch information
Jonne Nauha committed Jul 27, 2011
1 parent 5e6e4f1 commit 3730ae1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
22 changes: 17 additions & 5 deletions src/Core/OgreRenderingModule/OgreConversionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,24 @@ float3 ToCoreVector(const Ogre::Vector3 &vector)

std::string SanitateAssetIdForOgre(const QString& input)
{
/// \bug Why is this new $1 $2 logic needed? It breaks asynch asset loads
/// as the filename wont match the cache file entry!
QString ret = input;
if (ret.contains('$'))
return ret.toStdString();

ret.replace(':', "$1");
ret.replace('/', "$2");
//if (ret.contains('$'))
// return ret.toStdString();

//ret.replace(':', "$1");
//ret.replace('/', "$2");
ret.replace("/", "_");
ret.replace("\\", "_");
ret.replace(":", "_");
ret.replace("*", "_");
ret.replace("?", "_");
ret.replace("\"", "_");
ret.replace("'", "_");
ret.replace("<", "_");
ret.replace(">", "_");
ret.replace("|", "_");
return ret.toStdString();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/OgreRenderingModule/OgreMeshAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool OgreMeshAsset::DeserializeFromData(const u8 *data_, size_t numBytes, const
if (!cacheDiskSource.isEmpty())
{
QFileInfo fileInfo(cacheDiskSource);
std::string sanitatedAssetRef = fileInfo.fileName().toStdString();
std::string sanitatedAssetRef = fileInfo.fileName().toStdString();
loadTicket_ = Ogre::ResourceBackgroundQueue::getSingleton().load(Ogre::MeshManager::getSingleton().getResourceType(),
sanitatedAssetRef, OgreRenderer::OgreRenderingModule::CACHE_RESOURCE_GROUP, false, 0, 0, this);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/OgreRenderingModule/OgreSkeletonAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void OgreSkeletonAsset::operationCompleted(Ogre::BackgroundProcessTicket ticket,
return;

const QString assetRef = Name();
internal_name_ = SanitateAssetIdForOgre(assetRef);
internal_name_ = OgreRenderer::SanitateAssetIdForOgre(assetRef);
if (!result.error)
{
ogreSkeleton = Ogre::SkeletonManager::getSingleton().getByName(internal_name_, OgreRenderer::OgreRenderingModule::CACHE_RESOURCE_GROUP);
Expand Down
4 changes: 4 additions & 0 deletions src/Core/OgreRenderingModule/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ namespace OgreRenderer
overriddenLogManager->createLog("", true, false, true);
Ogre::LogManager::getSingleton().getDefaultLog()->setDebugOutputEnabled(false); // Disable Ogre from outputting to std::cerr by itself.
Ogre::LogManager::getSingleton().getDefaultLog()->addListener(logListener); // Make all Ogre log output to come to our log listener.
#ifdef _DEBUG
Ogre::LogManager::getSingleton().getDefaultLog()->setLogDetail(Ogre::LL_NORMAL); // This is probably the default level anyway, but be explicit.
#else
Ogre::LogManager::getSingleton().getDefaultLog()->setLogDetail(Ogre::LL_LOW);
#endif

root_ = OgreRootPtr(new Ogre::Root("", config_filename_, logfilepath));

Expand Down
2 changes: 1 addition & 1 deletion src/Core/OgreRenderingModule/TextureAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void TextureAsset::operationCompleted(Ogre::BackgroundProcessTicket ticket, cons
return;

const QString assetRef = Name();
ogreAssetName = OgreRenderer::SanitateAssetIdForOgre(assetRef).c_str();
ogreAssetName = QString::fromStdString(OgreRenderer::SanitateAssetIdForOgre(assetRef));
if (!result.error)
{
ogreTexture = Ogre::TextureManager::getSingleton().getByName(ogreAssetName.toStdString(), OgreRenderer::OgreRenderingModule::CACHE_RESOURCE_GROUP);
Expand Down

0 comments on commit 3730ae1

Please sign in to comment.