Rename "facetexcoord" to "elemtexcoord" in mjsFlex element for consistency.

PiperOrigin-RevId: 734153759
Change-Id: Ic17d7c8a6e53fba04da511d405c815a723c5e55b
This commit is contained in:
Alessio Quaglino
2025-03-06 08:27:26 -08:00
committed by Copybara-Service
parent 37d6d7792a
commit e04e0e5c3d
12 changed files with 30 additions and 30 deletions
+2 -2
View File
@@ -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:
+1 -1
View File
@@ -485,7 +485,7 @@
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`material<deformable-flex-material>` | :ref:`rgba<deformable-flex-rgba>` | :ref:`flatskin<deformable-flex-flatskin>` | :ref:`body<deformable-flex-body>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`vertex<deformable-flex-vertex>` | :ref:`element<deformable-flex-element>` | :ref:`texcoord<deformable-flex-texcoord>` | :ref:`facetexcoord<deformable-flex-facetexcoord>` | |
| | | | :ref:`vertex<deformable-flex-vertex>` | :ref:`element<deformable-flex-element>` | :ref:`texcoord<deformable-flex-texcoord>` | :ref:`elemtexcoord<deformable-flex-elemtexcoord>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`node<deformable-flex-node>` | | | | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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',
+2 -2
View File
@@ -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
+1 -1
View File
@@ -106,7 +106,7 @@ class mjCFlexcomp {
std::vector<bool> used; // is point used by any element (false: skip)
std::vector<int> element; // flex elements
std::vector<float> texcoord; // vertex texture coordinates
std::vector<int> facetexcoord; // face texture coordinates (OBJ only)
std::vector<int> elemtexcoord; // face texture coordinates (OBJ only)
// plugin support
std::string plugin_name;
+8 -8
View File
@@ -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
+2 -2
View File
@@ -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));
+3 -3
View File
@@ -776,7 +776,7 @@ class mjCFlex_ : public mjCBase {
std::vector<double> node_; // node positions
std::vector<int> elem_; // element vertex ids
std::vector<float> texcoord_; // vertex texture coordinates
std::vector<int> facetexcoord_; // face texture coordinates (OBJ only)
std::vector<int> 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<double> spec_node_;
std::vector<int> spec_elem_;
std::vector<float> spec_texcoord_;
std::vector<int> spec_facetexcoord_;
std::vector<int> spec_elemtexcoord_;
};
class mjCFlex: public mjCFlex_, private mjsFlex {
@@ -817,7 +817,7 @@ class mjCFlex: public mjCFlex_, private mjsFlex {
const std::vector<double>& get_elemaabb() const { return elemaabb_; }
const std::vector<int>& get_elem() const { return elem_; }
const std::vector<float>& get_texcoord() const { return texcoord_; }
const std::vector<int>& get_facetexcoord() const { return facetexcoord_; }
const std::vector<int>& get_elemtexcoord() const { return elemtexcoord_; }
const std::vector<std::string>& get_nodebody() const { return nodebody_; }
bool HasTexcoord() const; // texcoord not null
+4 -4
View File
@@ -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<int>(elem, "facetexcoord");
if (facetexcoord.has_value()) {
mjs_setInt(flex->facetexcoord, facetexcoord->data(), facetexcoord->size());
auto elemtexcoord = ReadAttrVec<int>(elem, "elemtexcoord");
if (elemtexcoord.has_value()) {
mjs_setInt(flex->elemtexcoord, elemtexcoord->data(), elemtexcoord->size());
}
// contact subelement
+3 -3
View File
@@ -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());