gazebosim / gazebosim/sdformat

Material DOM Lighting() is always the default value regardless of XML

Open
#384 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
216
Forks
125
Avg merge
1d 14h
Merged PRs (30d)
14

Description

Using libsdformat 9.3.0

It looks like `material->Lighting()` is always `true`, even when the XML has `false`. It seems `Material::Load` doesn't read the `lighting` tag at all.

https://github.com/osrf/sdformat/blob/113bf26308f7354f446cc4dcd4746196d493bfde/src/Material.cc#L115-L217

To reproduce save this as `material_lighting.cpp`

```c++
#include
#include

const auto xml = std::string{
""
""
" "
" "
" "
" "
" "
" 0.1 0.1 0.4"
" "
" "
" "
" false"
" "
" "
" "
" "
" "
" 0.2 0.2 0.2"
" "
" "
" "
" "
" "
" "
" 0.1 0.1 0.4"
" "
" "
" "
" "
" 1.23"
" "
" 0.0205"
" 0"
" 0"
" 0.017425"
" 0"
" 0.005125"
" "
" "
" "
" "
""};

int main()
{
sdf::Root sdf_dom;
sdf::Errors errors = sdf_dom.LoadSdfString(xml);
if (!errors.empty()) {
std::cerr << "Unexpected errors while parsing\n";
return 1;
}
if (sdf_dom.ModelByIndex(0)->LinkByIndex(0)->VisualByIndex(0)->Material()->Lighting()) {
std::cerr << "DOM incorrectly thinks dynamic lighting is enabled\n";
return 1;
}
std::cout << "Lighting is correctly disabled in DOM\n";
return 0;
}
```

Build and run:

``` console
$ clang++ $(pkg-config sdformat9 --cflags --libs) material_lighting.cpp -o test-sdf-lighting
$ ./test-sdf-lighting
DOM incorrectly thinks dynamic lighting is enabled
```

Contributor guide

Open the contributing guide

Research direction

Start in src/Material.cc at the Material::Load implementation linked in the issue, then build and run the provided material_lighting.cpp reproduction with the shown pkg-config command. Done means the same XML with false no longer makes Material::Lighting() report true.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.