Add engine internal error macro mjERROR to prepend calling function to error function.

PiperOrigin-RevId: 541584847
Change-Id: I57447e64375413ee07aa96372a402e1ced59ff4a
This commit is contained in:
Kyle Bayes
2023-06-19 03:28:44 -07:00
committed by Copybara-Service
parent c9e9cd8b35
commit ac1f41160d
28 changed files with 218 additions and 162 deletions
+19 -10
View File
@@ -274,7 +274,9 @@ void mj_collideTree(const mjModel* m, mjData* d, int b1, int b2,
if (!isleaf1 && isleaf2) {
for (int i=0; i < 2; i++) {
if (child1[2*node1+i] != -1) {
if (nstack >= max_stack) mju_error("BVH stack depth exceeded."); // SHOULD NOT OCCUR
if (nstack >= max_stack) {
mjERROR("BVH stack depth exceeded."); // SHOULD NOT OCCUR
}
stack[nstack].node1 = child1[2*node1+i];
stack[nstack].node2 = node2;
nstack++;
@@ -283,7 +285,9 @@ void mj_collideTree(const mjModel* m, mjData* d, int b1, int b2,
} else if (isleaf1 && !isleaf2) {
for (int i=0; i < 2; i++) {
if (child2[2*node2+i] != -1) {
if (nstack >= max_stack) mju_error("BVH stack depth exceeded."); // SHOULD NOT OCCUR
if (nstack >= max_stack) {
mjERROR("BVH stack depth exceeded."); // SHOULD NOT OCCUR
}
stack[nstack].node1 = node1;
stack[nstack].node2 = child2[2*node2+i];
nstack++;
@@ -304,7 +308,9 @@ void mj_collideTree(const mjModel* m, mjData* d, int b1, int b2,
if (surface1 > surface2) {
for (int i = 0; i < 2; i++) {
if (child1[2 * node1 + i] != -1) {
if (nstack >= max_stack) mju_error("BVH stack depth exceeded."); // SHOULD NOT OCCUR
if (nstack >= max_stack) {
mjERROR("BVH stack depth exceeded."); // SHOULD NOT OCCUR
}
stack[nstack].node1 = child1[2 * node1 + i];
stack[nstack].node2 = node2;
nstack++;
@@ -313,7 +319,9 @@ void mj_collideTree(const mjModel* m, mjData* d, int b1, int b2,
} else {
for (int i = 0; i < 2; i++) {
if (child2[2 * node2 + i] != -1) {
if (nstack >= max_stack) mju_error("BVH stack depth exceeded."); // SHOULD NOT OCCUR
if (nstack >= max_stack) {
mjERROR("BVH stack depth exceeded."); // SHOULD NOT OCCUR
}
stack[nstack].node1 = node1;
stack[nstack].node2 = child2[2*node2+i];
nstack++;
@@ -590,7 +598,7 @@ static void add_pair(const mjModel* m, int b1, int b2, int* npair, int* pair, in
(*npair)++;
} else {
mju_error("Broadphase buffer full");
mjERROR("broadphase buffer full");
}
}
@@ -767,7 +775,7 @@ int mj_broadphase(const mjModel* m, mjData* d, int* pair, int maxpair) {
// sanity check; SHOULD NOT OCCUR
if (k != bufcnt) {
mju_error("Internal error in broadphase: unexpected bufcnt");
mjERROR("internal error: unexpected bufcnt");
}
// sort along axis0
@@ -939,7 +947,7 @@ void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2, int flg_user,
// check number of contacts, SHOULD NOT OCCUR
if (num > mjMAXCONPAIR) {
mju_error("Too many contacts returned by collision function");
mjERROR("too many contacts returned by collision function");
}
// remove repeated contacts in box-box
@@ -1065,10 +1073,11 @@ void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2, int flg_user,
// add contact returned by collision detector
for (int i=0; i < num; i++) {
// set contact data
if (condim > 6 || condim < 1) { // SHOULD NOT OCCUR
mju_error("Invalid condim value: %d", i);
if (condim > 6 || condim < 1) {
mjERROR("invalid condim value: %d", i); // SHOULD NOT OCCUR
}
// set contact data
con[i].dim = condim;
con[i].geom1 = g1;
con[i].geom2 = g2;