MCPcopy Create free account
hub / github.com/RenderKit/embree / loadMap

Method loadMap

tutorials/common/scenegraph/corona_loader.cpp:136–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134 }
135
136 std::shared_ptr<Texture> CoronaLoader::loadMap(const Ref<XML>& xml)
137 {
138 /* process map node */
139 if (xml->name == "map")
140 {
141 std::string mapClass = xml->parm("class");
142
143 /* load textures */
144 if (mapClass == "Texture")
145 {
146 const FileName src = load<FileName>(xml->child("image"));
147
148 /* load images only once */
149 if (textureFileMap.find(src) != textureFileMap.end())
150 return textureFileMap[src];
151
152 try {
153 return Texture::load(path+src);
154 } catch (const std::runtime_error& e) {
155 std::cerr << "failed to load " << path+src << ": " << e.what() << std::endl;
156 }
157 }
158 else if (mapClass == "Reference") {
159 const std::string name = load<std::string>(xml);
160 return textureMap[name];
161 }
162 }
163
164 /* recurse into every unknown node to find some texture */
165 for (auto& child : xml->children) {
166 std::shared_ptr<Texture> texture = loadMap(child);
167 if (texture) return texture;
168 }
169 return std::shared_ptr<Texture>();
170 }
171
172 void CoronaLoader::loadMapDefinition(const Ref<XML>& xml)
173 {

Callers

nothing calls this directly

Calls 6

parmMethod · 0.80
loadFunction · 0.50
childMethod · 0.45
findMethod · 0.45
endMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected