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
+21
View File
@@ -220,6 +220,10 @@ void mjCMesh::PointToLocal() {
void mjCMesh::NameSpace(const mjCModel* m) {
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_);
@@ -252,6 +256,12 @@ void mjCMesh::CopyFromSpec() {
szgraph_ = 0;
center_ = NULL;
graph_ = NULL;
// use filename if name is missing
if (name.empty()) {
std::string stripped = mjuu_strippath(file_);
name = mjuu_stripext(stripped);
}
}
@@ -2034,6 +2044,11 @@ void mjCSkin::PointToLocal() {
void mjCSkin::NameSpace(const mjCModel* m) {
// use filename if name is missing
if (name.empty()) {
std::string stripped = mjuu_strippath(spec_file_);
name = mjuu_stripext(stripped);
}
for (auto& name : spec_bodyname_) {
name = m->prefix + name + m->suffix;
}
@@ -2059,6 +2074,12 @@ void mjCSkin::CopyFromSpec() {
bindquat_ = spec_bindquat_;
vertid_ = spec_vertid_;
vertweight_ = spec_vertweight_;
// use filename if name is missing
if (name.empty()) {
std::string stripped = mjuu_strippath(file_);
name = mjuu_stripext(stripped);
}
}