Fix issue where mj_addConstraint was writing values into efc_J_rowadr and efc_J_rownnz that are not needed.
PiperOrigin-RevId: 512919818 Change-Id: I8ee7443a2bf2265934899673f8943a83cdd4ef69
This commit is contained in:
committed by
Copybara-Service
parent
f2413a5d55
commit
90b5dd14ca
@@ -176,8 +176,18 @@ int mj_addConstraint(const mjModel* m, mjData* d,
|
|||||||
|
|
||||||
// sparse: copy chain
|
// sparse: copy chain
|
||||||
else {
|
else {
|
||||||
|
// clamp NV (in case -1 was used in constraint construction)
|
||||||
|
NV = mjMAX(0, NV);
|
||||||
|
|
||||||
|
if (NV) {
|
||||||
|
empty = 0;
|
||||||
|
} else if (empty) {
|
||||||
|
// all rows are empty, return early
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// chain required in sparse mode
|
// chain required in sparse mode
|
||||||
if (!chain) {
|
if (NV && !chain) {
|
||||||
mju_error("Sparse mj_addConstraint called with dense arguments");
|
mju_error("Sparse mj_addConstraint called with dense arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,17 +196,9 @@ int mj_addConstraint(const mjModel* m, mjData* d,
|
|||||||
// set row address
|
// set row address
|
||||||
adr[nefc+i] = (nefc+i ? adr[nefc+i-1]+nnz[nefc+i-1] : 0);
|
adr[nefc+i] = (nefc+i ? adr[nefc+i-1]+nnz[nefc+i-1] : 0);
|
||||||
|
|
||||||
// clamp NV (in case -1 was used in constraint construction)
|
|
||||||
NV = mjMAX(0, NV);
|
|
||||||
|
|
||||||
// set row descriptor
|
// set row descriptor
|
||||||
nnz[nefc+i] = NV;
|
nnz[nefc+i] = NV;
|
||||||
|
|
||||||
// update empty flag
|
|
||||||
if (NV) {
|
|
||||||
empty = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy if not empty
|
// copy if not empty
|
||||||
if (NV) {
|
if (NV) {
|
||||||
memcpy(ind + adr[nefc+i], chain, sizeof(int)*NV);
|
memcpy(ind + adr[nefc+i], chain, sizeof(int)*NV);
|
||||||
|
|||||||
Reference in New Issue
Block a user