Add spaces around comparison operators.
PiperOrigin-RevId: 573620198 Change-Id: Icf295cc0dd381a4a7f0e2c94f2e12b499193e862
This commit is contained in:
committed by
Copybara-Service
parent
a1b6026b8c
commit
a9ee497e33
@@ -226,19 +226,19 @@ int mj_isElemActive(const mjModel* m, int f, int e) {
|
|||||||
// compare contact pairs by their geom/elem/vert IDs
|
// compare contact pairs by their geom/elem/vert IDs
|
||||||
quicksortfunc(contactcompare, context, el1, el2) {
|
quicksortfunc(contactcompare, context, el1, el2) {
|
||||||
const mjModel* m = (const mjModel*) context;
|
const mjModel* m = (const mjModel*) context;
|
||||||
mjContact* con1 = (mjContact*)el1;
|
mjContact* c1 = (mjContact*)el1;
|
||||||
mjContact* con2 = (mjContact*)el2;
|
mjContact* c2 = (mjContact*)el2;
|
||||||
|
|
||||||
// get colliding object ids
|
// get colliding object ids
|
||||||
int con1_obj1 = con1->geom[0]>=0 ? con1->geom[0] : (con1->elem[0]>=0 ? con1->elem[0] : con1->vert[0]);
|
int con1_obj1 = c1->geom[0] >= 0 ? c1->geom[0] : (c1->elem[0] >= 0 ? c1->elem[0] : c1->vert[0]);
|
||||||
int con1_obj2 = con1->geom[1]>=0 ? con1->geom[1] : (con1->elem[1]>=0 ? con1->elem[1] : con1->vert[1]);
|
int con1_obj2 = c1->geom[1] >= 0 ? c1->geom[1] : (c1->elem[1] >= 0 ? c1->elem[1] : c1->vert[1]);
|
||||||
int con2_obj1 = con2->geom[0]>=0 ? con2->geom[0] : (con2->elem[0]>=0 ? con2->elem[0] : con2->vert[0]);
|
int con2_obj1 = c2->geom[0] >= 0 ? c2->geom[0] : (c2->elem[0] >= 0 ? c2->elem[0] : c2->vert[0]);
|
||||||
int con2_obj2 = con2->geom[1]>=0 ? con2->geom[1] : (con2->elem[1]>=0 ? con2->elem[1] : con2->vert[1]);
|
int con2_obj2 = c2->geom[1] >= 0 ? c2->geom[1] : (c2->elem[1] >= 0 ? c2->elem[1] : c2->vert[1]);
|
||||||
|
|
||||||
// for geom:geom, reproduce the order of contacts without mj_collideTree
|
// for geom:geom, reproduce the order of contacts without mj_collideTree
|
||||||
// normally sorted by (g1, g2), but in mj_collideGeoms, g1 and g2 are swapped based on geom_type
|
// normally sorted by (g1, g2), but in mj_collideGeoms, g1 and g2 are swapped based on geom_type
|
||||||
// here we undo this swapping for the purpose of sorting - needs to be done for each mjContact
|
// here we undo this swapping for the purpose of sorting - needs to be done for each mjContact
|
||||||
if (con1->geom[0]>=0 && con1->geom[1] && con2->geom[0]>=0 && con2->geom[1]) {
|
if (c1->geom[0] >= 0 && c1->geom[1] && c2->geom[0] >= 0 && c2->geom[1]) {
|
||||||
if (m->geom_type[con1_obj1] > m->geom_type[con1_obj2]) {
|
if (m->geom_type[con1_obj1] > m->geom_type[con1_obj2]) {
|
||||||
int tmp = con1_obj1;
|
int tmp = con1_obj1;
|
||||||
con1_obj1 = con1_obj2;
|
con1_obj1 = con1_obj2;
|
||||||
@@ -349,11 +349,12 @@ void mj_collision(const mjModel* m, mjData* d) {
|
|||||||
int isbody2 = (bf2 < nbody);
|
int isbody2 = (bf2 < nbody);
|
||||||
int bvh1 = (isbody1 ? m->body_bvhadr[bf1] : m->flex_bvhadr[bf1-nbody]);
|
int bvh1 = (isbody1 ? m->body_bvhadr[bf1] : m->flex_bvhadr[bf1-nbody]);
|
||||||
int bvh2 = (isbody2 ? m->body_bvhadr[bf2] : m->flex_bvhadr[bf2-nbody]);
|
int bvh2 = (isbody2 ? m->body_bvhadr[bf2] : m->flex_bvhadr[bf2-nbody]);
|
||||||
|
int geomadr1 = (isbody1 ? m->body_geomadr[bf1] : -1);
|
||||||
|
int geomadr2 = (isbody2 ? m->body_geomadr[bf2] : -1);
|
||||||
|
|
||||||
// process bodyflex pair: two single-geom bodies
|
// process bodyflex pair: two single-geom bodies
|
||||||
if (isbody1 && isbody2 && m->body_geomnum[bf1] == 1 && m->body_geomnum[bf2] == 1) {
|
if (isbody1 && isbody2 && m->body_geomnum[bf1] == 1 && m->body_geomnum[bf2] == 1) {
|
||||||
mj_collideGeomPair(m, d, m->body_geomadr[bf1], m->body_geomadr[bf2],
|
mj_collideGeomPair(m, d, geomadr1, geomadr2, merged, startadr, pairadr);
|
||||||
merged, startadr, pairadr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// process bodyflex pair: midphase
|
// process bodyflex pair: midphase
|
||||||
@@ -369,13 +370,13 @@ void mj_collision(const mjModel* m, mjData* d) {
|
|||||||
|
|
||||||
// process bodyflex pair: all-to-all
|
// process bodyflex pair: all-to-all
|
||||||
else {
|
else {
|
||||||
int geomadr_end1 = m->body_geomadr[bf1] + m->body_geomnum[bf1];
|
int geomadr_end1 = geomadr1 + m->body_geomnum[bf1];
|
||||||
int geomadr_end2 = m->body_geomadr[bf2] + m->body_geomnum[bf2];
|
int geomadr_end2 = geomadr2 + m->body_geomnum[bf2];
|
||||||
|
|
||||||
// body : body
|
// body : body
|
||||||
if (isbody1 && isbody2) {
|
if (isbody1 && isbody2) {
|
||||||
for (int g1=m->body_geomadr[bf1]; g1<geomadr_end1; g1++) {
|
for (int g1=geomadr1; g1 < geomadr_end1; g1++) {
|
||||||
for (int g2=m->body_geomadr[bf2]; g2<geomadr_end2; g2++) {
|
for (int g2=geomadr2; g2 < geomadr_end2; g2++) {
|
||||||
mj_collideGeomPair(m, d, g1, g2, merged, startadr, pairadr);
|
mj_collideGeomPair(m, d, g1, g2, merged, startadr, pairadr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -400,7 +401,8 @@ void mj_collision(const mjModel* m, mjData* d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// collide geom with flex elements
|
// collide geom with flex elements
|
||||||
for (int e=0; e<m->flex_elemnum[f]; e++) {
|
int elemnum = m->flex_elemnum[f];
|
||||||
|
for (int e=0; e < elemnum; e++) {
|
||||||
mj_collideGeomElem(m, d, g, f, e);
|
mj_collideGeomElem(m, d, g, f, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -702,8 +704,8 @@ void mj_collideTree(const mjModel* m, mjData* d, int bf1, int bf2,
|
|||||||
if (isbody1 && isbody2) {
|
if (isbody1 && isbody2) {
|
||||||
// both are leaves
|
// both are leaves
|
||||||
if (isleaf1 && isleaf2) {
|
if (isleaf1 && isleaf2) {
|
||||||
mjtNum margin = mj_assignMargin(m,
|
mjtNum maxmargin = mju_max(m->geom_margin[nodeid1], m->geom_margin[nodeid2]);
|
||||||
mju_max(m->geom_margin[nodeid1], m->geom_margin[nodeid2]));
|
mjtNum margin = mj_assignMargin(m, maxmargin);
|
||||||
|
|
||||||
if (!mj_filterSphere(m, d, nodeid1, nodeid2, margin)) {
|
if (!mj_filterSphere(m, d, nodeid1, nodeid2, margin)) {
|
||||||
if (mj_collideOBB(m->geom_aabb + 6*nodeid1, m->geom_aabb + 6*nodeid2,
|
if (mj_collideOBB(m->geom_aabb + 6*nodeid1, m->geom_aabb + 6*nodeid2,
|
||||||
@@ -719,8 +721,8 @@ void mj_collideTree(const mjModel* m, mjData* d, int bf1, int bf2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if no intersection at intermediate levels, stop
|
// if no intersection at intermediate levels, stop
|
||||||
mjtNum margin = mj_assignMargin(m,
|
mjtNum maxmargin = mju_max(m->body_margin[bf1], m->body_margin[bf2]);
|
||||||
mju_max(m->body_margin[bf1], m->body_margin[bf2]));
|
mjtNum margin = mj_assignMargin(m, maxmargin);
|
||||||
if (!mj_collideOBB(bvh1 + 6*node1, bvh2 + 6*node2,
|
if (!mj_collideOBB(bvh1 + 6*node1, bvh2 + 6*node2,
|
||||||
d->xipos + 3*bf1, d->ximat + 9*bf1,
|
d->xipos + 3*bf1, d->ximat + 9*bf1,
|
||||||
d->xipos + 3*bf2, d->ximat + 9*bf2,
|
d->xipos + 3*bf2, d->ximat + 9*bf2,
|
||||||
@@ -733,8 +735,8 @@ void mj_collideTree(const mjModel* m, mjData* d, int bf1, int bf2,
|
|||||||
else if (isbody1 && !isbody2) {
|
else if (isbody1 && !isbody2) {
|
||||||
// both are leaves
|
// both are leaves
|
||||||
if (isleaf1 && isleaf2) {
|
if (isleaf1 && isleaf2) {
|
||||||
mjtNum margin = mj_assignMargin(m,
|
mjtNum maxmargin = mju_max(m->geom_margin[nodeid1], m->flex_margin[f2]);
|
||||||
mju_max(m->geom_margin[nodeid1], m->flex_margin[f2]));
|
mjtNum margin = mj_assignMargin(m, maxmargin);
|
||||||
|
|
||||||
if (!filterBitmask(m->geom_contype[nodeid1], m->geom_conaffinity[nodeid1],
|
if (!filterBitmask(m->geom_contype[nodeid1], m->geom_conaffinity[nodeid1],
|
||||||
m->flex_contype[f2], m->flex_conaffinity[f2]) &&
|
m->flex_contype[f2], m->flex_conaffinity[f2]) &&
|
||||||
@@ -756,8 +758,8 @@ void mj_collideTree(const mjModel* m, mjData* d, int bf1, int bf2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if no intersection at intermediate levels, stop
|
// if no intersection at intermediate levels, stop
|
||||||
mjtNum margin = mj_assignMargin(m,
|
mjtNum maxmargin = mju_max(m->body_margin[bf1], m->flex_margin[f2]);
|
||||||
mju_max(m->body_margin[bf1], m->flex_margin[f2]));
|
mjtNum margin = mj_assignMargin(m, maxmargin);
|
||||||
if (!mj_collideOBB(bvh1 + 6*node1, bvh2 + 6*node2,
|
if (!mj_collideOBB(bvh1 + 6*node1, bvh2 + 6*node2,
|
||||||
d->xipos + 3*bf1, d->ximat + 9*bf1,
|
d->xipos + 3*bf1, d->ximat + 9*bf1,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
@@ -783,8 +785,8 @@ void mj_collideTree(const mjModel* m, mjData* d, int bf1, int bf2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if no intersection at intermediate levels, stop
|
// if no intersection at intermediate levels, stop
|
||||||
mjtNum margin = mj_assignMargin(m,
|
mjtNum maxmargin = mju_max(m->flex_margin[f1], m->flex_margin[f2]);
|
||||||
mju_max(m->flex_margin[f1], m->flex_margin[f2]));
|
mjtNum margin = mj_assignMargin(m, maxmargin);
|
||||||
if (filterBox(bvh1 + 6*node1, bvh2 + 6*node2, margin)) {
|
if (filterBox(bvh1 + 6*node1, bvh2 + 6*node2, margin)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -723,7 +723,9 @@ int mjc_SDF(const mjModel* m, const mjData* d, mjContact* con, int g1, int g2, m
|
|||||||
cnt = addContact(contacts, con, x, pos2true, squat2, dist, cnt, m, &sdf, (mjData*)d);
|
cnt = addContact(contacts, con, x, pos2true, squat2, dist, cnt, m, &sdf, (mjData*)d);
|
||||||
|
|
||||||
// SHOULD NOT OCCUR
|
// SHOULD NOT OCCUR
|
||||||
if (cnt>mjMAXCONPAIR) mjERROR("too many contact points");
|
if (cnt > mjMAXCONPAIR) {
|
||||||
|
mjERROR("too many contact points");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cnt;
|
return cnt;
|
||||||
|
|||||||
@@ -1149,15 +1149,17 @@ void mj_diagApprox(const mjModel* m, mjData* d) {
|
|||||||
bid[0] = m->geom_bodyid[con->geom[side]];
|
bid[0] = m->geom_bodyid[con->geom[side]];
|
||||||
bweight[0] = 1;
|
bweight[0] = 1;
|
||||||
nb = 1;
|
nb = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// flex vert
|
// flex vert
|
||||||
} else if (con->vert[side]>=0) {
|
else if (con->vert[side] >= 0) {
|
||||||
bid[0] = m->flex_vertbodyid[m->flex_vertadr[con->flex[side]] + con->vert[side]];
|
bid[0] = m->flex_vertbodyid[m->flex_vertadr[con->flex[side]] + con->vert[side]];
|
||||||
bweight[0] = 1;
|
bweight[0] = 1;
|
||||||
nb = 1;
|
nb = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// flex elem
|
// flex elem
|
||||||
} else {
|
else {
|
||||||
nb = mj_elemBodyWeight(m, d, con->flex[side], con->elem[side],
|
nb = mj_elemBodyWeight(m, d, con->flex[side], con->elem[side],
|
||||||
con->vert[1-side], con->pos, bid, bweight);
|
con->vert[1-side], con->pos, bid, bweight);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-13
@@ -444,19 +444,16 @@ static int safeAddToBufferSize(intptr_t* offset, size_t* nbuffer,
|
|||||||
|
|
||||||
// allocate and initialize mjModel structure
|
// allocate and initialize mjModel structure
|
||||||
mjModel* mj_makeModel(
|
mjModel* mj_makeModel(
|
||||||
int nq, int nv, int nu, int na, int nbody, int nbvh, int nbvhstatic,
|
int nq, int nv, int nu, int na, int nbody, int nbvh, int nbvhstatic, int nbvhdynamic, int njnt,
|
||||||
int nbvhdynamic, int njnt, int ngeom, int nsite, int ncam, int nlight,
|
int ngeom, int nsite, int ncam, int nlight, int nflex, int nflexvert, int nflexedge,
|
||||||
int nflex, int nflexvert, int nflexedge, int nflexelem, int nflexelemdata,
|
int nflexelem, int nflexelemdata, int nflexshelldata, int nflexevpair, int nflextexcoord,
|
||||||
int nflexshelldata, int nflexevpair, int nflextexcoord, int nmesh,
|
int nmesh, int nmeshvert, int nmeshnormal, int nmeshtexcoord, int nmeshface, int nmeshgraph,
|
||||||
int nmeshvert, int nmeshnormal, int nmeshtexcoord, int nmeshface,
|
int nskin, int nskinvert, int nskintexvert, int nskinface, int nskinbone, int nskinbonevert,
|
||||||
int nmeshgraph, int nskin, int nskinvert, int nskintexvert, int nskinface,
|
int nhfield, int nhfielddata, int ntex, int ntexdata, int nmat, int npair, int nexclude, int neq,
|
||||||
int nskinbone, int nskinbonevert, int nhfield, int nhfielddata, int ntex,
|
int ntendon, int nwrap, int nsensor, int nnumeric, int nnumericdata, int ntext, int ntextdata,
|
||||||
int ntexdata, int nmat, int npair, int nexclude, int neq, int ntendon,
|
int ntuple, int ntupledata, int nkey, int nmocap, int nplugin, int npluginattr, int nuser_body,
|
||||||
int nwrap, int nsensor, int nnumeric, int nnumericdata, int ntext,
|
int nuser_jnt, int nuser_geom, int nuser_site, int nuser_cam, int nuser_tendon,
|
||||||
int ntextdata, int ntuple, int ntupledata, int nkey, int nmocap,
|
int nuser_actuator, int nuser_sensor, int nnames, int npaths) {
|
||||||
int nplugin, int npluginattr, int nuser_body, int nuser_jnt, int nuser_geom,
|
|
||||||
int nuser_site, int nuser_cam, int nuser_tendon, int nuser_actuator,
|
|
||||||
int nuser_sensor, int nnames, int npaths) {
|
|
||||||
intptr_t offset = 0;
|
intptr_t offset = 0;
|
||||||
|
|
||||||
// allocate mjModel
|
// allocate mjModel
|
||||||
|
|||||||
@@ -896,8 +896,8 @@ mjtNum mju_rayFlex(const mjModel* m, const mjData* d, int flex_layer, mjtByte fl
|
|||||||
|
|
||||||
// check edges if rendered, or if skin
|
// check edges if rendered, or if skin
|
||||||
if (flg_edge || (dim > 1 && flg_skin)) {
|
if (flg_edge || (dim > 1 && flg_skin)) {
|
||||||
for (int e=m->flex_edgeadr[flexid];
|
int edge_end = m->flex_edgeadr[flexid]+m->flex_edgenum[flexid];
|
||||||
e<m->flex_edgeadr[flexid]+m->flex_edgenum[flexid]; e++) {
|
for (int e=m->flex_edgeadr[flexid]; e < edge_end; e++) {
|
||||||
// get vertices for this edge
|
// get vertices for this edge
|
||||||
mjtNum* v1 = d->flexvert_xpos + 3*(m->flex_vertadr[flexid]+m->flex_edge[2*e]);
|
mjtNum* v1 = d->flexvert_xpos + 3*(m->flex_vertadr[flexid]+m->flex_edge[2*e]);
|
||||||
mjtNum* v2 = d->flexvert_xpos + 3*(m->flex_vertadr[flexid]+m->flex_edge[2*e+1]);
|
mjtNum* v2 = d->flexvert_xpos + 3*(m->flex_vertadr[flexid]+m->flex_edge[2*e+1]);
|
||||||
|
|||||||
@@ -2665,7 +2665,7 @@ void mjv_updateActiveSkin(const mjModel* m, mjData* d, mjvScene* scn, const mjvO
|
|||||||
// normalize normals
|
// normalize normals
|
||||||
for (int k=vertadr; k < vertadr+vertnum; k++) {
|
for (int k=vertadr; k < vertadr+vertnum; k++) {
|
||||||
float s = sqrtf(
|
float s = sqrtf(
|
||||||
scn->skinnormal[3*k]*scn->skinnormal[3*k] +
|
scn->skinnormal[3*k+0]*scn->skinnormal[3*k+0] +
|
||||||
scn->skinnormal[3*k+1]*scn->skinnormal[3*k+1] +
|
scn->skinnormal[3*k+1]*scn->skinnormal[3*k+1] +
|
||||||
scn->skinnormal[3*k+2]*scn->skinnormal[3*k+2]
|
scn->skinnormal[3*k+2]*scn->skinnormal[3*k+2]
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user