Radium Engine  1.5.20
Loading...
Searching...
No Matches
MaterialConverters.cpp
1#include <Engine/Data/MaterialConverters.hpp>
2
3#include <Core/Utils/Log.hpp>
4
5#include <map>
6
10
11namespace Ra {
12namespace Engine {
13namespace Data {
14using namespace Core::Utils; // log
15
19
20namespace EngineMaterialConverters {
24
26 auto result = MaterialConverterRegistry.insert( { name, converter } );
27 return result.second;
28}
29
31 std::size_t removed = MaterialConverterRegistry.erase( name );
32 return ( removed == 1 );
33}
34
36 auto search = MaterialConverterRegistry.find( name );
37 if ( search != MaterialConverterRegistry.end() ) { return { true, search->second }; }
38 auto result = std::make_pair( false, [name]( AssetMaterialPtr ) -> RadiumMaterialPtr {
39 LOG( logERROR ) << "Required material converter " << name << " not found!";
40 return nullptr;
41 } );
42 return result;
43}
44
45bool cleanup() {
47 return true;
48}
49
50} // namespace EngineMaterialConverters
51} // namespace Data
52} // namespace Engine
53} // namespace Ra
represent material data loaded by a file loader. Material data must be identified by a unique name....
Base class for materials.
Definition Material.hpp:24
T make_pair(T... args)
bool removeMaterialConverter(const std::string &name)
bool registerMaterialConverter(const std::string &name, ConverterFunction converter)
std::pair< bool, ConverterFunction > getMaterialConverter(const std::string &name)
static std::map< std::string, std::function< RadiumMaterialPtr(AssetMaterialPtr)> > MaterialConverterRegistry
Map that stores each conversion function.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3