Resolve default asset names while attaching a spec.

PiperOrigin-RevId: 676053538
Change-Id: I717b87be4bc18a5d9f8e5f2dc071bd93409eea81
This commit is contained in:
Alessio Quaglino
2024-09-18 10:57:16 -07:00
committed by Copybara-Service
parent 1a5536ce5b
commit aca4b3324d
5 changed files with 85 additions and 24 deletions
+22
View File
@@ -3399,11 +3399,22 @@ void mjCHField::CopyFromSpec() {
nrow = 0;
ncol = 0;
}
// use filename if name is missing
if (name.empty()) {
std::string stripped = mjuu_strippath(file_);
name = mjuu_stripext(stripped);
}
}
void mjCHField::NameSpace(const mjCModel* m) {
// use filename if name is missing
if (name.empty()) {
std::string stripped = mjuu_strippath(spec_file_);
name = mjuu_stripext(stripped);
}
mjCBase::NameSpace(m);
if (modelfiledir_.empty()) {
modelfiledir_ = FilePath(m->spec_modelfiledir_);
@@ -3648,11 +3659,22 @@ void mjCTexture::CopyFromSpec() {
// clear precompiled asset. TODO: use asset cache
data_.clear();
}
// use filename if name is missing
if (name.empty()) {
std::string stripped = mjuu_strippath(file_);
name = mjuu_stripext(stripped);
}
}
void mjCTexture::NameSpace(const mjCModel* m) {
// use filename if name is missing
if (name.empty()) {
std::string stripped = mjuu_strippath(spec_file_);
name = mjuu_stripext(stripped);
}
mjCBase::NameSpace(m);
if (modelfiledir_.empty()) {
modelfiledir_ = FilePath(m->spec_modelfiledir_);