Add material namespacing to sites.

Fixes #2243.

PiperOrigin-RevId: 699713625
Change-Id: I1b45e43f2a6ccfa64c46489c9426fcc2acdc94c3
This commit is contained in:
Alessio Quaglino
2024-11-24 08:38:41 -08:00
committed by Copybara-Service
parent f909d63cdf
commit 13b6055098
3 changed files with 15 additions and 5 deletions
+9
View File
@@ -3102,6 +3102,15 @@ void mjCSite::CopyFromSpec() {
void mjCSite::NameSpace(const mjCModel* m) {
mjCBase::NameSpace(m);
if (!spec_material_.empty() && model != m) {
spec_material_ = m->prefix + spec_material_ + m->suffix;
}
}
// compiler
void mjCSite::Compile(void) {
CopyFromSpec();
+1
View File
@@ -615,6 +615,7 @@ class mjCSite : public mjCSite_, private mjsSite {
void Compile(void); // compiler
void CopyFromSpec(); // copy spec into attributes
void PointToLocal(void);
void NameSpace(const mjCModel* m);
};
+5 -5
View File
@@ -731,7 +731,7 @@ static constexpr char xml_child[] = R"(
<joint type="hinge" name="hinge"/>
<geom class="cylinder" material="material"/>
<light mode="targetbody" target="targetbody"/>
<site name="site"/>
<site name="site" material="material"/>
<body name="targetbody"/>
<body/>
</body>
@@ -798,7 +798,7 @@ TEST_F(MujocoTest, AttachSame) {
<joint type="hinge" name="hinge"/>
<geom class="cylinder" material="material"/>
<light mode="targetbody" target="targetbody"/>
<site name="site"/>
<site name="site" material="material"/>
<body name="targetbody"/>
<body/>
</body>
@@ -811,7 +811,7 @@ TEST_F(MujocoTest, AttachSame) {
<joint type="hinge" name="attached-hinge-1"/>
<geom class="cylinder" material="material"/>
<light mode="targetbody" target="attached-targetbody-1"/>
<site name="attached-site-1"/>
<site name="attached-site-1" material="material"/>
<body name="attached-targetbody-1"/>
<body/>
</body>
@@ -952,7 +952,7 @@ TEST_F(MujocoTest, AttachDifferent) {
<joint type="hinge" name="attached-hinge-1"/>
<geom class="attached-cylinder-1" material="attached-material-1"/>
<light mode="targetbody" target="attached-targetbody-1"/>
<site name="attached-site-1"/>
<site name="attached-site-1" material="attached-material-1"/>
<body name="attached-targetbody-1"/>
<body/>
</body>
@@ -1087,7 +1087,7 @@ TEST_F(MujocoTest, AttachFrame) {
<joint type="hinge" name="attached-hinge-1"/>
<geom class="attached-cylinder-1" material="attached-material-1"/>
<light mode="targetbody" target="attached-targetbody-1"/>
<site name="attached-site-1"/>
<site name="attached-site-1" material="attached-material-1"/>
<body name="attached-targetbody-1"/>
<body/>
</body>