Remove redundant checks for exhausted geoms.

PiperOrigin-RevId: 813284297
Change-Id: I565c517bef782ba07ff323e206b75f6f905e5809
This commit is contained in:
Haroon Qureshi
2025-09-30 08:43:21 -07:00
committed by Copybara-Service
parent 2dc533b63b
commit 59d0676dcc
+7 -12
View File
@@ -852,7 +852,6 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
if (vopt->flags[mjVIS_BODYBVH]) { if (vopt->flags[mjVIS_BODYBVH]) {
for (int i = 0; i < m->nbvhstatic; i++) { for (int i = 0; i < m->nbvhstatic; i++) {
int isleaf = m->bvh_child[2*i] == -1 && m->bvh_child[2*i+1] == -1; int isleaf = m->bvh_child[2*i] == -1 && m->bvh_child[2*i+1] == -1;
if (scn->ngeom >= scn->maxgeom) break;
if (m->bvh_depth[i] != vopt->bvh_depth) { if (m->bvh_depth[i] != vopt->bvh_depth) {
if (!isleaf || m->bvh_depth[i] > vopt->bvh_depth) { if (!isleaf || m->bvh_depth[i] > vopt->bvh_depth) {
continue; continue;
@@ -909,7 +908,6 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
if (m->flex_bvhnum[f] && vopt->flexgroup[mjMAX(0, mjMIN(mjNGROUP-1, m->flex_group[f]))]) { if (m->flex_bvhnum[f] && vopt->flexgroup[mjMAX(0, mjMIN(mjNGROUP-1, m->flex_group[f]))]) {
for (int i=m->flex_bvhadr[f]; i < m->flex_bvhadr[f]+m->flex_bvhnum[f]; i++) { for (int i=m->flex_bvhadr[f]; i < m->flex_bvhadr[f]+m->flex_bvhnum[f]; i++) {
int isleaf = m->bvh_child[2*i] == -1 && m->bvh_child[2*i+1] == -1; int isleaf = m->bvh_child[2*i] == -1 && m->bvh_child[2*i+1] == -1;
if (scn->ngeom >= scn->maxgeom) break;
if (m->bvh_depth[i] != vopt->bvh_depth) { if (m->bvh_depth[i] != vopt->bvh_depth) {
if (!isleaf || m->bvh_depth[i] > vopt->bvh_depth) { if (!isleaf || m->bvh_depth[i] > vopt->bvh_depth) {
continue; continue;
@@ -956,7 +954,6 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
for (int i=0; i < 2; i++) { for (int i=0; i < 2; i++) {
for (int j=0; j < 2; j++) { for (int j=0; j < 2; j++) {
for (int k=0; k < 2; k++) { for (int k=0; k < 2; k++) {
if (scn->ngeom >= scn->maxgeom) break;
if (i == 0) { if (i == 0) {
if (geomsExhausted(scn)) { if (geomsExhausted(scn)) {
return; return;
@@ -1004,7 +1001,6 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
for (int b = 0; b < m->mesh_bvhnum[meshid]; b++) { for (int b = 0; b < m->mesh_bvhnum[meshid]; b++) {
int i = b + m->mesh_bvhadr[meshid]; int i = b + m->mesh_bvhadr[meshid];
int isleaf = m->bvh_child[2*i] == -1 && m->bvh_child[2*i+1] == -1; int isleaf = m->bvh_child[2*i] == -1 && m->bvh_child[2*i+1] == -1;
if (scn->ngeom >= scn->maxgeom) break;
if (m->bvh_depth[i] != vopt->bvh_depth) { if (m->bvh_depth[i] != vopt->bvh_depth) {
if (!isleaf || m->bvh_depth[i] > vopt->bvh_depth) { if (!isleaf || m->bvh_depth[i] > vopt->bvh_depth) {
continue; continue;
@@ -1120,7 +1116,8 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
for (int i=0; i < m->mesh_facenum[mesh_id]; i++) { for (int i=0; i < m->mesh_facenum[mesh_id]; i++) {
if (geomsExhausted(scn)) { if (geomsExhausted(scn)) {
return; return;
} else { }
// triangle in global frame // triangle in global frame
mjtNum pos[3][3]; mjtNum pos[3][3];
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
@@ -1160,7 +1157,6 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
} }
} }
} }
}
// inertia // inertia
objtype = mjOBJ_BODY; objtype = mjOBJ_BODY;
@@ -2044,37 +2040,36 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
if (geomsExhausted(scn)) { if (geomsExhausted(scn)) {
return; return;
} }
thisgeom = acquireGeom(scn, i, category, objtype); thisgeom = acquireGeom(scn, i, category, objtype);
makeTriangle(thisgeom, vnear[e], vfar[e], vnear[(e+1)%4], rgba); makeTriangle(thisgeom, vnear[e], vfar[e], vnear[(e+1)%4], rgba);
releaseGeom(&thisgeom, scn); releaseGeom(&thisgeom, scn);
if (geomsExhausted(scn)) { if (geomsExhausted(scn)) {
return; return;
} }
thisgeom = acquireGeom(scn, i, category, objtype); thisgeom = acquireGeom(scn, i, category, objtype);
makeTriangle(thisgeom, vfar[e], vfar[(e+1)%4], vnear[(e+1)%4], rgba); makeTriangle(thisgeom, vfar[e], vfar[(e+1)%4], vnear[(e+1)%4], rgba);
releaseGeom(&thisgeom, scn); releaseGeom(&thisgeom, scn);
if (geomsExhausted(scn)) { if (geomsExhausted(scn)) {
return; return;
} }
thisgeom = acquireGeom(scn, i, category, objtype); thisgeom = acquireGeom(scn, i, category, objtype);
mjv_connector(thisgeom, mjGEOM_LINE, 3, vnear[e], vnear[(e+1)%4]); mjv_connector(thisgeom, mjGEOM_LINE, 3, vnear[e], vnear[(e+1)%4]);
f2f(thisgeom->rgba, rgba, 4); f2f(thisgeom->rgba, rgba, 4);
releaseGeom(&thisgeom, scn); releaseGeom(&thisgeom, scn);
if (geomsExhausted(scn)) { if (geomsExhausted(scn)) {
return; return;
} }
thisgeom = acquireGeom(scn, i, category, objtype); thisgeom = acquireGeom(scn, i, category, objtype);
mjv_connector(thisgeom, mjGEOM_LINE, 3, vfar[e], vfar[(e+1)%4]); mjv_connector(thisgeom, mjGEOM_LINE, 3, vfar[e], vfar[(e+1)%4]);
f2f(thisgeom->rgba, rgba, 4); f2f(thisgeom->rgba, rgba, 4);
releaseGeom(&thisgeom, scn); releaseGeom(&thisgeom, scn);
if (geomsExhausted(scn)) { if (geomsExhausted(scn)) {
return; return;
} }
thisgeom = acquireGeom(scn, i, category, objtype); thisgeom = acquireGeom(scn, i, category, objtype);
mjv_connector(thisgeom, mjGEOM_LINE, 3, vnear[e], vfar[e]); mjv_connector(thisgeom, mjGEOM_LINE, 3, vnear[e], vfar[e]);
f2f(thisgeom->rgba, rgba, 4); f2f(thisgeom->rgba, rgba, 4);
@@ -3364,7 +3359,7 @@ static const mjtNum tolerance = 1e-9;
// solve trancendental catenary equation using change of variables proposed in // solve transcendental catenary equation using change of variables proposed in
// https://math.stackexchange.com/a/1002996 // https://math.stackexchange.com/a/1002996
static inline mjtNum solve_catenary(mjtNum v, mjtNum h, mjtNum length) { static inline mjtNum solve_catenary(mjtNum v, mjtNum h, mjtNum length) {
mjtNum intercept = catenary_intercept(v, h, length); mjtNum intercept = catenary_intercept(v, h, length);