BVB Source Codes

CRYENGINE Show MFXLibrary.cpp Source code

Return Download CRYENGINE: download MFXLibrary.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "MFXLibrary.h"
  5.  
  6. namespace MaterialEffectsUtils
  7. {
  8. CMFXContainer* CreateContainer()
  9. {
  10.         if (gEnv->IsDedicated())
  11.         {
  12.                 return new CMFXDummyContainer();
  13.         }
  14.         else
  15.         {
  16.                 return new CMFXContainer();
  17.         }
  18. }
  19. }
  20.  
  21. void CMFXLibrary::LoadFromXml(SLoadingEnvironment& loadingEnvironment)
  22. {
  23.         CryLogAlways("[MFX] Loading FXLib '%s' ...", loadingEnvironment.libraryName.c_str());
  24.  
  25.         INDENT_LOG_DURING_SCOPE();
  26.  
  27.         for (int i = 0; i < loadingEnvironment.libraryParamsNode->getChildCount(); ++i)
  28.         {
  29.                 XmlNodeRef currentEffectNode = loadingEnvironment.libraryParamsNode->getChild(i);
  30.                 if (!currentEffectNode)
  31.                         continue;
  32.  
  33.                 TMFXContainerPtr pContainer = MaterialEffectsUtils::CreateContainer();
  34.                 pContainer->BuildFromXML(currentEffectNode);
  35.  
  36.                 const TMFXNameId& effectName = pContainer->GetParams().name;
  37.                 const bool effectAdded = AddContainer(effectName, pContainer);
  38.                 if (effectAdded)
  39.                 {
  40.                         loadingEnvironment.AddLibraryContainer(loadingEnvironment.libraryName, pContainer);
  41.                 }
  42.                 else
  43.                 {
  44.                         GameWarning("[MFX] Effect (at line %d) '%s:%s' already present, skipping redefinition!", currentEffectNode->getLine(), loadingEnvironment.libraryName.c_str(), effectName.c_str());
  45.                 }
  46.         }
  47. }
  48.  
  49. bool CMFXLibrary::AddContainer(const TMFXNameId& effectName, TMFXContainerPtr pContainer)
  50. {
  51.         TEffectContainersMap::const_iterator it = m_effectContainers.find(effectName);
  52.         if (it != m_effectContainers.end())
  53.                 return false;
  54.  
  55.         m_effectContainers.insert(TEffectContainersMap::value_type(effectName, pContainer));
  56.         return true;
  57. }
  58.  
  59. TMFXContainerPtr CMFXLibrary::FindEffectContainer(const char* effectName) const
  60. {
  61.         TEffectContainersMap::const_iterator it = m_effectContainers.find(CONST_TEMP_STRING(effectName));
  62.  
  63.         return (it != m_effectContainers.end()) ? it->second : TMFXContainerPtr(NULL);
  64. }
  65.  
  66. void CMFXLibrary::GetEffectNames(TEffectNames& nameList) const
  67. {
  68.         for (const auto& curEffect : m_effectContainers)
  69.         {
  70.                 nameList.push_back(curEffect.first.c_str());
  71.         }
  72. }
  73.  
  74. void CMFXLibrary::GetMemoryUsage(ICrySizer* pSizer) const
  75. {
  76.         pSizer->AddObject(this, sizeof(*this));
  77.         pSizer->AddObject(m_effectContainers);
  78. }
  79.  
downloadMFXLibrary.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top