1515 *
1616*/
1717
18+ #include < filesystem>
1819#include < vector>
1920
2021#include " Utils.hh"
@@ -133,9 +134,15 @@ Errors HeightmapTexture::Load(ElementPtr _sdf, const ParserConfig &_config)
133134
134135 if (_sdf->HasElement (" diffuse" ))
135136 {
137+ std::unordered_set<std::string> paths;
138+ if (!this ->dataPtr ->sdf ->FilePath ().empty ())
139+ {
140+ paths.insert (std::filesystem::path (
141+ this ->dataPtr ->sdf ->FilePath ()).parent_path ().string ());
142+ }
136143 this ->dataPtr ->diffuse = resolveURI (
137144 _sdf->Get <std::string>(errors, " diffuse" , this ->dataPtr ->diffuse ).first ,
138- _config, errors);
145+ _config, errors, paths );
139146 }
140147 else
141148 {
@@ -145,9 +152,15 @@ Errors HeightmapTexture::Load(ElementPtr _sdf, const ParserConfig &_config)
145152
146153 if (_sdf->HasElement (" normal" ))
147154 {
155+ std::unordered_set<std::string> paths;
156+ if (!this ->dataPtr ->sdf ->FilePath ().empty ())
157+ {
158+ paths.insert (std::filesystem::path (
159+ this ->dataPtr ->sdf ->FilePath ()).parent_path ().string ());
160+ }
148161 this ->dataPtr ->normal = resolveURI (
149162 _sdf->Get <std::string>(errors, " normal" , this ->dataPtr ->normal ).first ,
150- _config, errors);
163+ _config, errors, paths );
151164 }
152165 else
153166 {
@@ -326,9 +339,15 @@ Errors Heightmap::Load(ElementPtr _sdf, const ParserConfig &_config)
326339
327340 if (_sdf->HasElement (" uri" ))
328341 {
342+ std::unordered_set<std::string> paths;
343+ if (!this ->dataPtr ->filePath .empty ())
344+ {
345+ paths.insert (std::filesystem::path (
346+ this ->dataPtr ->filePath ).parent_path ().string ());
347+ }
329348 this ->dataPtr ->uri = resolveURI (
330349 _sdf->Get <std::string>(errors, " uri" , " " ).first ,
331- _config, errors);
350+ _config, errors, paths );
332351 }
333352 else
334353 {
0 commit comments