From e04e0e5c3dcd3cc92f22d8f732a353768c8b00c5 Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Thu, 6 Mar 2025 08:27:26 -0800 Subject: [PATCH] Rename "facetexcoord" to "elemtexcoord" in mjsFlex element for consistency. PiperOrigin-RevId: 734153759 Change-Id: Ic17d7c8a6e53fba04da511d405c815a723c5e55b --- doc/XMLreference.rst | 4 ++-- doc/XMLschema.rst | 2 +- doc/includes/references.h | 2 +- include/mujoco/mjspec.h | 2 +- python/mujoco/introspect/structs.py | 4 ++-- src/user/user_flexcomp.cc | 4 ++-- src/user/user_flexcomp.h | 2 +- src/user/user_mesh.cc | 16 ++++++++-------- src/user/user_model.cc | 4 ++-- src/user/user_objects.h | 6 +++--- src/xml/xml_native_reader.cc | 8 ++++---- src/xml/xml_native_writer.cc | 6 +++--- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/doc/XMLreference.rst b/doc/XMLreference.rst index 64a03444..f733d08c 100644 --- a/doc/XMLreference.rst +++ b/doc/XMLreference.rst @@ -3920,9 +3920,9 @@ cases, the user will specify a :el:`flexcomp` which will then automatically cons Texture coordinates. If omitted, texture mapping for this flex is disabled, even if a texture is specified in the material. -.. _deformable-flex-facetexcoord: +.. _deformable-flex-elemtexcoord: -:at:`facetexcoord`: :at-val:`int((dim+1)*nelem), optional` +:at:`elemtexcoord`: :at-val:`int((dim+1)*nelem), optional` Texture indices for each face. If omitted, texture are assumed to be vertex-based. .. _deformable-flex-element: diff --git a/doc/XMLschema.rst b/doc/XMLschema.rst index 1d2d31e0..0f71f6a3 100644 --- a/doc/XMLschema.rst +++ b/doc/XMLschema.rst @@ -485,7 +485,7 @@ | | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ | | | | | :ref:`material` | :ref:`rgba` | :ref:`flatskin` | :ref:`body` | | | | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ | -| | | | :ref:`vertex` | :ref:`element` | :ref:`texcoord` | :ref:`facetexcoord` | | +| | | | :ref:`vertex` | :ref:`element` | :ref:`texcoord` | :ref:`elemtexcoord` | | | | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ | | | | | :ref:`node` | | | | | | | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ | diff --git a/doc/includes/references.h b/doc/includes/references.h index 8eb37d4d..17b08604 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -2014,7 +2014,7 @@ typedef struct mjsFlex_ { // flex specification mjDoubleVec* vert; // vertex positions mjIntVec* elem; // element vertex ids mjFloatVec* texcoord; // vertex texture coordinates - mjIntVec* facetexcoord; // face texture coordinates + mjIntVec* elemtexcoord; // element texture coordinates // other mjString* info; // message appended to compiler errors diff --git a/include/mujoco/mjspec.h b/include/mujoco/mjspec.h index 77ce5ddc..52e96f41 100644 --- a/include/mujoco/mjspec.h +++ b/include/mujoco/mjspec.h @@ -446,7 +446,7 @@ typedef struct mjsFlex_ { // flex specification mjDoubleVec* vert; // vertex positions mjIntVec* elem; // element vertex ids mjFloatVec* texcoord; // vertex texture coordinates - mjIntVec* facetexcoord; // face texture coordinates + mjIntVec* elemtexcoord; // element texture coordinates // other mjString* info; // message appended to compiler errors diff --git a/python/mujoco/introspect/structs.py b/python/mujoco/introspect/structs.py index c0f605b6..fc75c798 100644 --- a/python/mujoco/introspect/structs.py +++ b/python/mujoco/introspect/structs.py @@ -10488,11 +10488,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([ doc='vertex texture coordinates', ), StructFieldDecl( - name='facetexcoord', + name='elemtexcoord', type=PointerType( inner_type=ValueType(name='mjIntVec'), ), - doc='face texture coordinates', + doc='element texture coordinates', ), StructFieldDecl( name='info', diff --git a/src/user/user_flexcomp.cc b/src/user/user_flexcomp.cc index fb2d7fba..6cf4c13e 100644 --- a/src/user/user_flexcomp.cc +++ b/src/user/user_flexcomp.cc @@ -413,7 +413,7 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) { mjs_setString(pf->name, name.c_str()); mjs_setInt(pf->elem, element.data(), element.size()); mjs_setFloat(pf->texcoord, texcoord.data(), texcoord.size()); - mjs_setInt(pf->facetexcoord, facetexcoord.data(), facetexcoord.size()); + mjs_setInt(pf->elemtexcoord, elemtexcoord.data(), elemtexcoord.size()); if (!centered) { mjs_setDouble(pf->vert, point.data(), point.size()); } @@ -1058,7 +1058,7 @@ bool mjCFlexcomp::MakeMesh(mjCModel* model, char* error, int error_sz) { if (mesh.HasTexcoord()) { texcoord = mesh.Texcoord(); - facetexcoord = mesh.FaceTexcoord(); + elemtexcoord = mesh.FaceTexcoord(); } // copy faces or create 3D mesh diff --git a/src/user/user_flexcomp.h b/src/user/user_flexcomp.h index de25d0d8..ff3e3706 100644 --- a/src/user/user_flexcomp.h +++ b/src/user/user_flexcomp.h @@ -106,7 +106,7 @@ class mjCFlexcomp { std::vector used; // is point used by any element (false: skip) std::vector element; // flex elements std::vector texcoord; // vertex texture coordinates - std::vector facetexcoord; // face texture coordinates (OBJ only) + std::vector elemtexcoord; // face texture coordinates (OBJ only) // plugin support std::string plugin_name; diff --git a/src/user/user_mesh.cc b/src/user/user_mesh.cc index 0132c60e..e86c60bc 100644 --- a/src/user/user_mesh.cc +++ b/src/user/user_mesh.cc @@ -3184,7 +3184,7 @@ void mjCFlex::PointToLocal() { spec.vert = &spec_vert_; spec.node = &spec_node_; spec.texcoord = &spec_texcoord_; - spec.facetexcoord = &spec_facetexcoord_; + spec.elemtexcoord = &spec_elemtexcoord_; spec.elem = &spec_elem_; spec.info = &info; material = nullptr; @@ -3193,7 +3193,7 @@ void mjCFlex::PointToLocal() { vert = nullptr; node = nullptr; texcoord = nullptr; - facetexcoord = nullptr; + elemtexcoord = nullptr; elem = nullptr; } @@ -3219,7 +3219,7 @@ void mjCFlex::CopyFromSpec() { vert_ = spec_vert_; node_ = spec_node_; texcoord_ = spec_texcoord_; - facetexcoord_ = spec_facetexcoord_; + elemtexcoord_ = spec_elemtexcoord_; elem_ = spec_elem_; // clear precompiled asset. TODO: use asset cache @@ -3323,14 +3323,14 @@ void mjCFlex::Compile(const mjVFS* vfs) { } // check texcoord - if (!texcoord_.empty() && texcoord_.size()!=2*nvert && facetexcoord_.empty()) { + if (!texcoord_.empty() && texcoord_.size()!=2*nvert && elemtexcoord_.empty()) { throw mjCError(this, "two texture coordinates per vertex expected"); } - // no facetexcoord: copy from faces - if (facetexcoord_.empty() && !texcoord_.empty()) { - facetexcoord_.assign(3*nelem, 0); - memcpy(facetexcoord_.data(), elem_.data(), 3*nelem*sizeof(int)); + // no elemtexcoord: copy from faces + if (elemtexcoord_.empty() && !texcoord_.empty()) { + elemtexcoord_.assign(3*nelem, 0); + memcpy(elemtexcoord_.data(), elem_.data(), 3*nelem*sizeof(int)); } // resolve material name diff --git a/src/user/user_model.cc b/src/user/user_model.cc index 1bdbc701..c0efcd9c 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -2916,8 +2916,8 @@ void mjCModel::CopyObjects(mjModel* m) { m->flex_texcoordadr[i] = texcoord_adr; memcpy(m->flex_texcoord + 2*texcoord_adr, pfl->texcoord_.data(), pfl->texcoord_.size()*sizeof(float)); - memcpy(m->flex_elemtexcoord + elemdata_adr, pfl->facetexcoord_.data(), - pfl->facetexcoord_.size()*sizeof(int)); + memcpy(m->flex_elemtexcoord + elemdata_adr, pfl->elemtexcoord_.data(), + pfl->elemtexcoord_.size()*sizeof(int)); } m->flex_elemnum[i] = pfl->nelem; memcpy(m->flex_elem + elemdata_adr, pfl->elem_.data(), pfl->elem_.size()*sizeof(int)); diff --git a/src/user/user_objects.h b/src/user/user_objects.h index 8b233a20..7b367f7f 100644 --- a/src/user/user_objects.h +++ b/src/user/user_objects.h @@ -776,7 +776,7 @@ class mjCFlex_ : public mjCBase { std::vector node_; // node positions std::vector elem_; // element vertex ids std::vector texcoord_; // vertex texture coordinates - std::vector facetexcoord_; // face texture coordinates (OBJ only) + std::vector elemtexcoord_; // face texture coordinates (OBJ only) std::string material_; // name of material used for rendering std::string spec_material_; @@ -786,7 +786,7 @@ class mjCFlex_ : public mjCBase { std::vector spec_node_; std::vector spec_elem_; std::vector spec_texcoord_; - std::vector spec_facetexcoord_; + std::vector spec_elemtexcoord_; }; class mjCFlex: public mjCFlex_, private mjsFlex { @@ -817,7 +817,7 @@ class mjCFlex: public mjCFlex_, private mjsFlex { const std::vector& get_elemaabb() const { return elemaabb_; } const std::vector& get_elem() const { return elem_; } const std::vector& get_texcoord() const { return texcoord_; } - const std::vector& get_facetexcoord() const { return facetexcoord_; } + const std::vector& get_elemtexcoord() const { return elemtexcoord_; } const std::vector& get_nodebody() const { return nodebody_; } bool HasTexcoord() const; // texcoord not null diff --git a/src/xml/xml_native_reader.cc b/src/xml/xml_native_reader.cc index 7b6e8eaa..c726a9fb 100644 --- a/src/xml/xml_native_reader.cc +++ b/src/xml/xml_native_reader.cc @@ -325,7 +325,7 @@ const char* MJCF[nMJCF][mjXATTRNUM] = { {"deformable", "*", "0"}, {"<"}, {"flex", "*", "13", "name", "group", "dim", "radius", "material", - "rgba", "flatskin", "body", "vertex", "element", "texcoord", "facetexcoord", "node"}, + "rgba", "flatskin", "body", "vertex", "element", "texcoord", "elemtexcoord", "node"}, {"<"}, {"contact", "?", "13", "contype", "conaffinity", "condim", "priority", "friction", "solmix", "solref", "solimp", "margin", "gap", @@ -1354,9 +1354,9 @@ void mjXReader::OneFlex(XMLElement* elem, mjsFlex* flex) { if (texcoord.has_value()) { mjs_setFloat(flex->texcoord, texcoord->data(), texcoord->size()); } - auto facetexcoord = ReadAttrVec(elem, "facetexcoord"); - if (facetexcoord.has_value()) { - mjs_setInt(flex->facetexcoord, facetexcoord->data(), facetexcoord->size()); + auto elemtexcoord = ReadAttrVec(elem, "elemtexcoord"); + if (elemtexcoord.has_value()) { + mjs_setInt(flex->elemtexcoord, elemtexcoord->data(), elemtexcoord->size()); } // contact subelement diff --git a/src/xml/xml_native_writer.cc b/src/xml/xml_native_writer.cc index 1889e3fd..b34eb2e5 100644 --- a/src/xml/xml_native_writer.cc +++ b/src/xml/xml_native_writer.cc @@ -158,9 +158,9 @@ void mjXWriter::OneFlex(XMLElement* elem, const mjCFlex* flex) { text = VectorToString(flex->get_texcoord()); WriteAttrTxt(elem, "texcoord", text); } - if (!flex->get_facetexcoord().empty()) { - text = VectorToString(flex->get_facetexcoord()); - WriteAttrTxt(elem, "facetexcoord", text); + if (!flex->get_elemtexcoord().empty()) { + text = VectorToString(flex->get_elemtexcoord()); + WriteAttrTxt(elem, "elemtexcoord", text); } if (!flex->get_nodebody().empty()) { text = VectorToString(flex->get_nodebody());