forked from 0ad/0ad
Ykkrosh
a265a441fd
* vsnprintf2: Made compatible between GCC and MSVC - it now always null-terminates the buffer, and returns -1 on overflow. Fixes #158. Added tests. * MeshManager: Use shared_ptr.expired() instead of checking for bad_weak_ptr exception. * Xeromyces: Added tests for GetXMBPath, because it does unusual things in sscanf which MSVC's /analyze complains about. * ConfigDB, ScriptGlue: Replaced some asserts with return-on-failure, to avoid invalid array accesses when continuing after the assert (as complained about by /analyze). * CStr: Removed "using namespace std". Added tests for handling of invalid UTF-8. This was SVN commit r4625.
42 lines
868 B
C++
42 lines
868 B
C++
#include "precompiled.h"
|
|
#include "graphics/MeshManager.h"
|
|
#include "ps/CLogger.h"
|
|
#include "ps/FileUnpacker.h" // to get access to its CError
|
|
#include "ModelDef.h"
|
|
|
|
CMeshManager::CMeshManager()
|
|
{
|
|
}
|
|
|
|
CMeshManager::~CMeshManager()
|
|
{
|
|
}
|
|
|
|
CModelDefPtr CMeshManager::GetMesh(const char *filename)
|
|
{
|
|
CStr fn(filename);
|
|
mesh_map::iterator iter = m_MeshMap.find(fn);
|
|
if (iter != m_MeshMap.end() && !iter->second.expired())
|
|
{
|
|
CModelDefPtr model (iter->second);
|
|
//LOG(MESSAGE, "mesh", "Loading mesh '%s%' (cached)...", filename);
|
|
return model;
|
|
}
|
|
|
|
try
|
|
{
|
|
CModelDefPtr model (CModelDef::Load(filename));
|
|
if (!model)
|
|
return CModelDefPtr();
|
|
|
|
//LOG(MESSAGE, "mesh", "Loading mesh '%s'...", filename);
|
|
m_MeshMap[fn] = model;
|
|
return model;
|
|
}
|
|
catch (PSERROR_File&)
|
|
{
|
|
LOG(ERROR, "mesh", "Could not load mesh '%s'!", filename);
|
|
return CModelDefPtr();
|
|
}
|
|
}
|