Rename "facetexcoord" to "elemtexcoord" in mjsFlex element for consistency.
PiperOrigin-RevId: 734153759 Change-Id: Ic17d7c8a6e53fba04da511d405c815a723c5e55b
This commit is contained in:
committed by
Copybara-Service
parent
37d6d7792a
commit
e04e0e5c3d
@@ -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
|
Texture coordinates. If omitted, texture mapping for this flex is disabled, even if a texture is specified in the
|
||||||
material.
|
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.
|
Texture indices for each face. If omitted, texture are assumed to be vertex-based.
|
||||||
|
|
||||||
.. _deformable-flex-element:
|
.. _deformable-flex-element:
|
||||||
|
|||||||
+1
-1
@@ -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:`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>` | | | | |
|
| | | | :ref:`node<deformable-flex-node>` | | | | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
|
|||||||
@@ -2014,7 +2014,7 @@ typedef struct mjsFlex_ { // flex specification
|
|||||||
mjDoubleVec* vert; // vertex positions
|
mjDoubleVec* vert; // vertex positions
|
||||||
mjIntVec* elem; // element vertex ids
|
mjIntVec* elem; // element vertex ids
|
||||||
mjFloatVec* texcoord; // vertex texture coordinates
|
mjFloatVec* texcoord; // vertex texture coordinates
|
||||||
mjIntVec* facetexcoord; // face texture coordinates
|
mjIntVec* elemtexcoord; // element texture coordinates
|
||||||
|
|
||||||
// other
|
// other
|
||||||
mjString* info; // message appended to compiler errors
|
mjString* info; // message appended to compiler errors
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ typedef struct mjsFlex_ { // flex specification
|
|||||||
mjDoubleVec* vert; // vertex positions
|
mjDoubleVec* vert; // vertex positions
|
||||||
mjIntVec* elem; // element vertex ids
|
mjIntVec* elem; // element vertex ids
|
||||||
mjFloatVec* texcoord; // vertex texture coordinates
|
mjFloatVec* texcoord; // vertex texture coordinates
|
||||||
mjIntVec* facetexcoord; // face texture coordinates
|
mjIntVec* elemtexcoord; // element texture coordinates
|
||||||
|
|
||||||
// other
|
// other
|
||||||
mjString* info; // message appended to compiler errors
|
mjString* info; // message appended to compiler errors
|
||||||
|
|||||||
@@ -10488,11 +10488,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
doc='vertex texture coordinates',
|
doc='vertex texture coordinates',
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='facetexcoord',
|
name='elemtexcoord',
|
||||||
type=PointerType(
|
type=PointerType(
|
||||||
inner_type=ValueType(name='mjIntVec'),
|
inner_type=ValueType(name='mjIntVec'),
|
||||||
),
|
),
|
||||||
doc='face texture coordinates',
|
doc='element texture coordinates',
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='info',
|
name='info',
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) {
|
|||||||
mjs_setString(pf->name, name.c_str());
|
mjs_setString(pf->name, name.c_str());
|
||||||
mjs_setInt(pf->elem, element.data(), element.size());
|
mjs_setInt(pf->elem, element.data(), element.size());
|
||||||
mjs_setFloat(pf->texcoord, texcoord.data(), texcoord.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) {
|
if (!centered) {
|
||||||
mjs_setDouble(pf->vert, point.data(), point.size());
|
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()) {
|
if (mesh.HasTexcoord()) {
|
||||||
texcoord = mesh.Texcoord();
|
texcoord = mesh.Texcoord();
|
||||||
facetexcoord = mesh.FaceTexcoord();
|
elemtexcoord = mesh.FaceTexcoord();
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy faces or create 3D mesh
|
// copy faces or create 3D mesh
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class mjCFlexcomp {
|
|||||||
std::vector<bool> used; // is point used by any element (false: skip)
|
std::vector<bool> used; // is point used by any element (false: skip)
|
||||||
std::vector<int> element; // flex elements
|
std::vector<int> element; // flex elements
|
||||||
std::vector<float> texcoord; // vertex texture coordinates
|
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
|
// plugin support
|
||||||
std::string plugin_name;
|
std::string plugin_name;
|
||||||
|
|||||||
@@ -3184,7 +3184,7 @@ void mjCFlex::PointToLocal() {
|
|||||||
spec.vert = &spec_vert_;
|
spec.vert = &spec_vert_;
|
||||||
spec.node = &spec_node_;
|
spec.node = &spec_node_;
|
||||||
spec.texcoord = &spec_texcoord_;
|
spec.texcoord = &spec_texcoord_;
|
||||||
spec.facetexcoord = &spec_facetexcoord_;
|
spec.elemtexcoord = &spec_elemtexcoord_;
|
||||||
spec.elem = &spec_elem_;
|
spec.elem = &spec_elem_;
|
||||||
spec.info = &info;
|
spec.info = &info;
|
||||||
material = nullptr;
|
material = nullptr;
|
||||||
@@ -3193,7 +3193,7 @@ void mjCFlex::PointToLocal() {
|
|||||||
vert = nullptr;
|
vert = nullptr;
|
||||||
node = nullptr;
|
node = nullptr;
|
||||||
texcoord = nullptr;
|
texcoord = nullptr;
|
||||||
facetexcoord = nullptr;
|
elemtexcoord = nullptr;
|
||||||
elem = nullptr;
|
elem = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3219,7 +3219,7 @@ void mjCFlex::CopyFromSpec() {
|
|||||||
vert_ = spec_vert_;
|
vert_ = spec_vert_;
|
||||||
node_ = spec_node_;
|
node_ = spec_node_;
|
||||||
texcoord_ = spec_texcoord_;
|
texcoord_ = spec_texcoord_;
|
||||||
facetexcoord_ = spec_facetexcoord_;
|
elemtexcoord_ = spec_elemtexcoord_;
|
||||||
elem_ = spec_elem_;
|
elem_ = spec_elem_;
|
||||||
|
|
||||||
// clear precompiled asset. TODO: use asset cache
|
// clear precompiled asset. TODO: use asset cache
|
||||||
@@ -3323,14 +3323,14 @@ void mjCFlex::Compile(const mjVFS* vfs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check texcoord
|
// 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");
|
throw mjCError(this, "two texture coordinates per vertex expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
// no facetexcoord: copy from faces
|
// no elemtexcoord: copy from faces
|
||||||
if (facetexcoord_.empty() && !texcoord_.empty()) {
|
if (elemtexcoord_.empty() && !texcoord_.empty()) {
|
||||||
facetexcoord_.assign(3*nelem, 0);
|
elemtexcoord_.assign(3*nelem, 0);
|
||||||
memcpy(facetexcoord_.data(), elem_.data(), 3*nelem*sizeof(int));
|
memcpy(elemtexcoord_.data(), elem_.data(), 3*nelem*sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve material name
|
// resolve material name
|
||||||
|
|||||||
@@ -2916,8 +2916,8 @@ void mjCModel::CopyObjects(mjModel* m) {
|
|||||||
m->flex_texcoordadr[i] = texcoord_adr;
|
m->flex_texcoordadr[i] = texcoord_adr;
|
||||||
memcpy(m->flex_texcoord + 2*texcoord_adr,
|
memcpy(m->flex_texcoord + 2*texcoord_adr,
|
||||||
pfl->texcoord_.data(), pfl->texcoord_.size()*sizeof(float));
|
pfl->texcoord_.data(), pfl->texcoord_.size()*sizeof(float));
|
||||||
memcpy(m->flex_elemtexcoord + elemdata_adr, pfl->facetexcoord_.data(),
|
memcpy(m->flex_elemtexcoord + elemdata_adr, pfl->elemtexcoord_.data(),
|
||||||
pfl->facetexcoord_.size()*sizeof(int));
|
pfl->elemtexcoord_.size()*sizeof(int));
|
||||||
}
|
}
|
||||||
m->flex_elemnum[i] = pfl->nelem;
|
m->flex_elemnum[i] = pfl->nelem;
|
||||||
memcpy(m->flex_elem + elemdata_adr, pfl->elem_.data(), pfl->elem_.size()*sizeof(int));
|
memcpy(m->flex_elem + elemdata_adr, pfl->elem_.data(), pfl->elem_.size()*sizeof(int));
|
||||||
|
|||||||
@@ -776,7 +776,7 @@ class mjCFlex_ : public mjCBase {
|
|||||||
std::vector<double> node_; // node positions
|
std::vector<double> node_; // node positions
|
||||||
std::vector<int> elem_; // element vertex ids
|
std::vector<int> elem_; // element vertex ids
|
||||||
std::vector<float> texcoord_; // vertex texture coordinates
|
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 material_; // name of material used for rendering
|
||||||
|
|
||||||
std::string spec_material_;
|
std::string spec_material_;
|
||||||
@@ -786,7 +786,7 @@ class mjCFlex_ : public mjCBase {
|
|||||||
std::vector<double> spec_node_;
|
std::vector<double> spec_node_;
|
||||||
std::vector<int> spec_elem_;
|
std::vector<int> spec_elem_;
|
||||||
std::vector<float> spec_texcoord_;
|
std::vector<float> spec_texcoord_;
|
||||||
std::vector<int> spec_facetexcoord_;
|
std::vector<int> spec_elemtexcoord_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class mjCFlex: public mjCFlex_, private mjsFlex {
|
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<double>& get_elemaabb() const { return elemaabb_; }
|
||||||
const std::vector<int>& get_elem() const { return elem_; }
|
const std::vector<int>& get_elem() const { return elem_; }
|
||||||
const std::vector<float>& get_texcoord() const { return texcoord_; }
|
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_; }
|
const std::vector<std::string>& get_nodebody() const { return nodebody_; }
|
||||||
|
|
||||||
bool HasTexcoord() const; // texcoord not null
|
bool HasTexcoord() const; // texcoord not null
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
|||||||
{"deformable", "*", "0"},
|
{"deformable", "*", "0"},
|
||||||
{"<"},
|
{"<"},
|
||||||
{"flex", "*", "13", "name", "group", "dim", "radius", "material",
|
{"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",
|
{"contact", "?", "13", "contype", "conaffinity", "condim", "priority",
|
||||||
"friction", "solmix", "solref", "solimp", "margin", "gap",
|
"friction", "solmix", "solref", "solimp", "margin", "gap",
|
||||||
@@ -1354,9 +1354,9 @@ void mjXReader::OneFlex(XMLElement* elem, mjsFlex* flex) {
|
|||||||
if (texcoord.has_value()) {
|
if (texcoord.has_value()) {
|
||||||
mjs_setFloat(flex->texcoord, texcoord->data(), texcoord->size());
|
mjs_setFloat(flex->texcoord, texcoord->data(), texcoord->size());
|
||||||
}
|
}
|
||||||
auto facetexcoord = ReadAttrVec<int>(elem, "facetexcoord");
|
auto elemtexcoord = ReadAttrVec<int>(elem, "elemtexcoord");
|
||||||
if (facetexcoord.has_value()) {
|
if (elemtexcoord.has_value()) {
|
||||||
mjs_setInt(flex->facetexcoord, facetexcoord->data(), facetexcoord->size());
|
mjs_setInt(flex->elemtexcoord, elemtexcoord->data(), elemtexcoord->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// contact subelement
|
// contact subelement
|
||||||
|
|||||||
@@ -158,9 +158,9 @@ void mjXWriter::OneFlex(XMLElement* elem, const mjCFlex* flex) {
|
|||||||
text = VectorToString(flex->get_texcoord());
|
text = VectorToString(flex->get_texcoord());
|
||||||
WriteAttrTxt(elem, "texcoord", text);
|
WriteAttrTxt(elem, "texcoord", text);
|
||||||
}
|
}
|
||||||
if (!flex->get_facetexcoord().empty()) {
|
if (!flex->get_elemtexcoord().empty()) {
|
||||||
text = VectorToString(flex->get_facetexcoord());
|
text = VectorToString(flex->get_elemtexcoord());
|
||||||
WriteAttrTxt(elem, "facetexcoord", text);
|
WriteAttrTxt(elem, "elemtexcoord", text);
|
||||||
}
|
}
|
||||||
if (!flex->get_nodebody().empty()) {
|
if (!flex->get_nodebody().empty()) {
|
||||||
text = VectorToString(flex->get_nodebody());
|
text = VectorToString(flex->get_nodebody());
|
||||||
|
|||||||
Reference in New Issue
Block a user