Add support for loading 1D flex components from OBJ line segments.
The obj_decoder plugin is updated to parse line segments ('l') from OBJ files and represent them as degenerate triangles. The user_flexcomp compiler now supports flex dimensions of 1, using these parsed line segments to define the 1D flex elements. The compile sample's error reporting is also improved.
PiperOrigin-RevId: 928566870
Change-Id: I6920729d1b1d5aeb391401c3245ebb1d4784c190
This commit is contained in:
committed by
Copybara-Service
parent
ac7f198536
commit
7a7dc7ccad
@@ -1334,8 +1334,8 @@ bool mjCFlexcomp::MakeMesh(mjCModel* model, mjsCompiler* compiler, char* error,
|
||||
}
|
||||
|
||||
// check dim
|
||||
if (def.spec.flex->dim < 2) {
|
||||
return comperr(error, "Flex dim must be at least 2 for mesh", error_sz);
|
||||
if (def.spec.flex->dim < 1) {
|
||||
return comperr(error, "Flex dim must be at least 1 for mesh", error_sz);
|
||||
}
|
||||
|
||||
// load resource
|
||||
@@ -1381,6 +1381,15 @@ bool mjCFlexcomp::MakeMesh(mjCModel* model, mjsCompiler* compiler, char* error,
|
||||
// copy faces or create 3D mesh
|
||||
if (def.spec.flex->dim == 2) {
|
||||
element = mesh.Face();
|
||||
} else if (def.spec.flex->dim == 1) {
|
||||
// extract edge pairs from degenerate triangles (i1, i2, i2)
|
||||
const std::vector<int>& face = mesh.Face();
|
||||
element.clear();
|
||||
element.reserve(face.size() * 2 / 3);
|
||||
for (size_t i = 0; i < face.size(); i += 3) {
|
||||
element.push_back(face[i]);
|
||||
element.push_back(face[i+1]);
|
||||
}
|
||||
} else {
|
||||
point.insert(point.begin() + 0, origin[0]);
|
||||
point.insert(point.begin() + 1, origin[1]);
|
||||
|
||||
Reference in New Issue
Block a user