Improve CRB code:

- remove mj_crbSkip since this was only utilized during compile time to compute m->dof_m0, replaced with mj_crbDiag to compute only the diagonals for dof_m0,
- change row backward pass to forward pass to optimize processing diagonal blocks,
- and various code refactoring.

PiperOrigin-RevId: 556799924
Change-Id: I0a18d7a45862860fdddd7150540ddc8d64b01b29
This commit is contained in:
Kyle Bayes
2023-08-14 08:31:35 -07:00
committed by Copybara-Service
parent 8ddef7007f
commit 7e1c65b10e
4 changed files with 67 additions and 55 deletions
+6 -11
View File
@@ -1667,19 +1667,14 @@ void mjCModel::CopyTree(mjModel* m) {
m->nB = nB;
// set dof_simplenum
int scnt = 0;
for (int i=nv-1; i>=0; i--) {
// dof in simple body
int count = 0;
for (int i=nv-1; i >= 0; i--) {
if (m->body_simple[m->dof_bodyid[i]]) {
scnt++;
m->dof_simplenum[i] = scnt;
}
// dof in regular body
else {
scnt = 0;
m->dof_simplenum[i] = 0;
count++; // increment counter
} else {
count = 0; // reset
}
m->dof_simplenum[i] = count;
}
}