Copy texture coordinates from OBJ into flex. Fixes #2464.
PiperOrigin-RevId: 732109960 Change-Id: I506b3540ab5d489ce8f10d0c473919611ccb654a
This commit is contained in:
committed by
Copybara-Service
parent
06e217df7e
commit
7651cb1b33
+10
-1
@@ -3184,6 +3184,7 @@ void mjCFlex::PointToLocal() {
|
||||
spec.vert = &spec_vert_;
|
||||
spec.node = &spec_node_;
|
||||
spec.texcoord = &spec_texcoord_;
|
||||
spec.facetexcoord = &spec_facetexcoord_;
|
||||
spec.elem = &spec_elem_;
|
||||
spec.info = &info;
|
||||
material = nullptr;
|
||||
@@ -3192,6 +3193,7 @@ void mjCFlex::PointToLocal() {
|
||||
vert = nullptr;
|
||||
node = nullptr;
|
||||
texcoord = nullptr;
|
||||
facetexcoord = nullptr;
|
||||
elem = nullptr;
|
||||
}
|
||||
|
||||
@@ -3217,6 +3219,7 @@ void mjCFlex::CopyFromSpec() {
|
||||
vert_ = spec_vert_;
|
||||
node_ = spec_node_;
|
||||
texcoord_ = spec_texcoord_;
|
||||
facetexcoord_ = spec_facetexcoord_;
|
||||
elem_ = spec_elem_;
|
||||
|
||||
// clear precompiled asset. TODO: use asset cache
|
||||
@@ -3320,10 +3323,16 @@ void mjCFlex::Compile(const mjVFS* vfs) {
|
||||
}
|
||||
|
||||
// check texcoord
|
||||
if (!texcoord_.empty() && texcoord_.size()!=2*nvert) {
|
||||
if (!texcoord_.empty() && texcoord_.size()!=2*nvert && facetexcoord_.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));
|
||||
}
|
||||
|
||||
// resolve material name
|
||||
mjCBase* pmat = model->FindObject(mjOBJ_MATERIAL, material_);
|
||||
if (pmat) {
|
||||
|
||||
Reference in New Issue
Block a user