Ejemplo n.º 1
0
void CObjects::ValidateObjectsConsistency(void)
{
	//If this method is called from an Object - rather than a test file - the it should be wrapped with a #ifdef DEBUG
	//This is because it is still useful to have ValidateObjectsConsistency called in RELEASE from tests.

	ValidateSceneGraph();
	ValidateIndexedObjects();
	ClearValidationFlags();
}
Ejemplo n.º 2
0
  ezSharedPtr<Scene> Importer::ImportScene(const char* szFileName, ezBitflags<ImportFlags> importFlags, bool addToCache)
  {
    ezLogBlock logBlock("Scene Import", szFileName);

    ezSharedPtr<Scene> scene;
    if (m_cachedScenes.TryGetValue(szFileName, scene))
      return scene;

    ezString fileExtension = ezPathUtils::GetFileExtension(szFileName);
    if (fileExtension.IsEmpty())
    {
      ezLog::Error("Unable to choose model importer since file '{0}' has no file extension.", szFileName);
      return nullptr;
    }

    // Newer implementations have higher priority.
    for (int i = m_ImporterImplementations.GetCount() - 1; i >= 0; --i)
    {
      auto supportedFormats = m_ImporterImplementations[i]->GetSupportedFileFormats();
      if (std::any_of(cbegin(supportedFormats), cend(supportedFormats),
                      [fileExtension](const char* ext) { return ezStringUtils::IsEqual_NoCase(ext, fileExtension); }))
      {
        ezStopwatch timer;
        scene = m_ImporterImplementations[i]->ImportScene(szFileName, importFlags);

#if EZ_ENABLED(EZ_COMPILE_FOR_DEBUG)
        ValidateSceneGraph(scene);
#endif
        if (scene)
        {
          scene->RefreshRootList();
          scene->CreateUniqueNames();
        }

        ezLog::Success("Imported scene '{0}' in {1} seconds", szFileName, ezArgF(timer.GetRunningTotal().GetSeconds(), 2));
        if (addToCache)
          m_cachedScenes.Insert(szFileName, scene);

        return scene;
      }
    }

    return nullptr;
  }