Move computation of flex_vert0 to user_mesh.cc.

This removes the dependency of flex_vert0 from mj_flex and mjData.

PiperOrigin-RevId: 700382297
Change-Id: I0b6d023c2e1ba14fa92417b65bfc288f37c223ae
This commit is contained in:
Alessio Quaglino
2024-11-26 10:16:16 -08:00
committed by Copybara-Service
parent b716837395
commit 203602b01f
4 changed files with 15 additions and 12 deletions
+10
View File
@@ -2944,6 +2944,16 @@ void mjCFlex::Compile(const mjVFS* vfs) {
// create bounding volume hierarchy
CreateBVH();
// compute bounding box coordinates
vert0_.assign(3*nvert, 0);
const mjtNum* bvh = tree.Bvh().data();
for (int j=0; j < nvert; j++) {
for (int k=0; k < 3; k++) {
double size = 2*(bvh[k+3] - radius);
vert0_[3*j+k] = (vertxpos[3*j+k] - bvh[k]) / size + 0.5;
}
}
}
+3
View File
@@ -2825,6 +2825,9 @@ void mjCModel::CopyObjects(mjModel* m) {
mjuu_copyvec(m->flex_vert + 3*vert_adr, pfl->vert_.data(), 3*pfl->nvert);
}
// copy vert0
mjuu_copyvec(m->flex_vert0 + 3*vert_adr, pfl->vert0_.data(), 3*pfl->nvert);
// copy or set vertbodyid
if (pfl->rigid) {
for (int k=0; k<pfl->nvert; k++) {
+2
View File
@@ -774,6 +774,8 @@ class mjCFlex: public mjCFlex_, private mjsFlex {
void Compile(const mjVFS* vfs); // compiler
void CreateBVH(void); // create flex BVH
void CreateShellPair(void); // create shells and evpairs
std::vector<double> vert0_; // vertex positions in [0, 1]^d in the bounding box
};