Add spaces around comparison operators in render/ and ui/ source files.
PiperOrigin-RevId: 536001297 Change-Id: Ia0d97bf9f886aea03b8363e4d97e18301520909f
This commit is contained in:
committed by
Copybara-Service
parent
455b1cd2e2
commit
d1c6561f1c
+79
-78
@@ -44,9 +44,9 @@ static int isBehind(const float* headpos, const float* pos, const float* mat) {
|
||||
|
||||
// check if geom is reflective
|
||||
static int isReflective(const mjvGeom* geom) {
|
||||
return ((geom->type==mjGEOM_PLANE || geom->type==mjGEOM_BOX) &&
|
||||
return ((geom->type == mjGEOM_PLANE || geom->type == mjGEOM_BOX) &&
|
||||
!geom->transparent &&
|
||||
(geom->reflectance>0));
|
||||
(geom->reflectance > 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ static void settexture(int type, int state, const mjrContext* con, const mjvGeom
|
||||
float plane[4], scl[2];
|
||||
|
||||
// shadow
|
||||
if (type==mjtexSHADOW) {
|
||||
if (type == mjtexSHADOW) {
|
||||
// enable
|
||||
if (state) {
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
@@ -88,7 +88,7 @@ static void settexture(int type, int state, const mjrContext* con, const mjvGeom
|
||||
}
|
||||
|
||||
// explicit texture coordinates
|
||||
else if (type==mjtexREGULAR && geom->texcoord) {
|
||||
else if (type == mjtexREGULAR && geom->texcoord) {
|
||||
// enable
|
||||
if (state) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
@@ -104,7 +104,7 @@ static void settexture(int type, int state, const mjrContext* con, const mjvGeom
|
||||
}
|
||||
|
||||
// 2D
|
||||
else if (type==mjtexREGULAR && con->textureType[geom->texid]==mjTEXTURE_2D) {
|
||||
else if (type == mjtexREGULAR && con->textureType[geom->texid] == mjTEXTURE_2D) {
|
||||
// enable
|
||||
if (state) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
@@ -116,23 +116,23 @@ static void settexture(int type, int state, const mjrContext* con, const mjvGeom
|
||||
// determine scaling, adjust for pre-scaled geoms
|
||||
scl[0] = geom->texrepeat[0];
|
||||
scl[1] = geom->texrepeat[1];
|
||||
if (geom->dataid>=0) {
|
||||
if (geom->size[0]>0) {
|
||||
if (geom->dataid >= 0) {
|
||||
if (geom->size[0] > 0) {
|
||||
scl[0] = scl[0] / mju_max(mjMINVAL, geom->size[0]);
|
||||
}
|
||||
|
||||
if (geom->size[1]>0) {
|
||||
if (geom->size[1] > 0) {
|
||||
scl[1] = scl[1] / mju_max(mjMINVAL, geom->size[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// uniform: repeat relative to spatial units rather than object
|
||||
if (geom->texuniform) {
|
||||
if (geom->size[0]>0) {
|
||||
if (geom->size[0] > 0) {
|
||||
scl[0] = scl[0] * geom->size[0];
|
||||
}
|
||||
|
||||
if (geom->size[1]>0) {
|
||||
if (geom->size[1] > 0) {
|
||||
scl[1] = scl[1] * geom->size[1];
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ static void settexture(int type, int state, const mjrContext* con, const mjvGeom
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, con->texture[geom->texid]);
|
||||
|
||||
// set mapping : cube
|
||||
if (type==mjtexREGULAR) {
|
||||
if (type == mjtexREGULAR) {
|
||||
mjr_setf4(plane, geom->texuniform ? geom->size[0] : 1, 0, 0, 0);
|
||||
glTexGenfv(GL_S, GL_OBJECT_PLANE, plane);
|
||||
mjr_setf4(plane, 0, geom->texuniform ? geom->size[1] : 1, 0, 0);
|
||||
@@ -217,7 +217,7 @@ static void renderGeom(const mjvGeom* geom, int mode, const float* headpos,
|
||||
int behind, whichface, lighting;
|
||||
|
||||
// lines to do not cast shadows
|
||||
if (mode==mjrRND_SHADOWCAST && geom->type==mjGEOM_LINE) {
|
||||
if (mode == mjrRND_SHADOWCAST && geom->type == mjGEOM_LINE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -233,18 +233,18 @@ static void renderGeom(const mjvGeom* geom, int mode, const float* headpos,
|
||||
behind = isBehind(headpos, geom->pos, geom->mat);
|
||||
|
||||
// enable texture in normal and shadowmap mode
|
||||
if (geom->texid>=0 && con->ntexture>0 &&
|
||||
(mode==mjrRND_NORMAL || mode==mjrRND_SHADOWMAP)) {
|
||||
if (geom->texid >= 0 && con->ntexture > 0 &&
|
||||
(mode == mjrRND_NORMAL || mode == mjrRND_SHADOWMAP)) {
|
||||
settexture(mjtexREGULAR, 1, con, geom);
|
||||
}
|
||||
|
||||
// make plane more transparent from the back
|
||||
if (geom->type==mjGEOM_PLANE && behind && mode==mjrRND_NORMAL) {
|
||||
if (geom->type == mjGEOM_PLANE && behind && mode == mjrRND_NORMAL) {
|
||||
rgba[3] *= 0.3;
|
||||
}
|
||||
|
||||
// set material emission: none in shadow mode
|
||||
if (mode==mjrRND_NORMAL) {
|
||||
if (mode == mjrRND_NORMAL) {
|
||||
mjr_setf4(temp,
|
||||
geom->emission*rgba[0],
|
||||
geom->emission*rgba[1],
|
||||
@@ -261,9 +261,9 @@ static void renderGeom(const mjvGeom* geom, int mode, const float* headpos,
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, temp);
|
||||
|
||||
// set color for segmentation mode
|
||||
if (mode>=mjrRND_SEGMENT) {
|
||||
if (mode >= mjrRND_SEGMENT) {
|
||||
// segid color
|
||||
if (mode==mjrRND_IDCOLOR) {
|
||||
if (mode == mjrRND_IDCOLOR) {
|
||||
unsigned char seg[4] = {
|
||||
(geom->segid+1) & 0xFF,
|
||||
((geom->segid+1)>>8) & 0xFF,
|
||||
@@ -287,7 +287,7 @@ static void renderGeom(const mjvGeom* geom, int mode, const float* headpos,
|
||||
|
||||
// apply coordinate transformation, except for skin which is global
|
||||
glPushMatrix();
|
||||
if (geom->type!=mjGEOM_SKIN) {
|
||||
if (geom->type != mjGEOM_SKIN) {
|
||||
glTranslatef(geom->pos[0], geom->pos[1], geom->pos[2]);
|
||||
glMultMatrixf(mat);
|
||||
}
|
||||
@@ -297,13 +297,13 @@ static void renderGeom(const mjvGeom* geom, int mode, const float* headpos,
|
||||
case mjGEOM_PLANE: // plane
|
||||
if (behind) {
|
||||
glGetIntegerv(GL_CULL_FACE_MODE, &whichface);
|
||||
if (whichface==GL_BACK) {
|
||||
if (whichface == GL_BACK) {
|
||||
glCullFace(GL_FRONT);
|
||||
}
|
||||
}
|
||||
|
||||
// use plane-specific displaylist if available
|
||||
if (geom->dataid>=0) {
|
||||
if (geom->dataid >= 0) {
|
||||
glCallList(con->basePlane + geom->dataid+1);
|
||||
}
|
||||
|
||||
@@ -313,13 +313,13 @@ static void renderGeom(const mjvGeom* geom, int mode, const float* headpos,
|
||||
glCallList(con->basePlane);
|
||||
}
|
||||
|
||||
if (behind && whichface==GL_BACK) {
|
||||
if (behind && whichface == GL_BACK) {
|
||||
glCullFace(GL_BACK);
|
||||
}
|
||||
break;
|
||||
|
||||
case mjGEOM_HFIELD: // height field
|
||||
if (geom->dataid>=0) {
|
||||
if (geom->dataid >= 0) {
|
||||
glCallList(con->baseHField + geom->dataid);
|
||||
}
|
||||
break;
|
||||
@@ -356,7 +356,7 @@ static void renderGeom(const mjvGeom* geom, int mode, const float* headpos,
|
||||
break;
|
||||
|
||||
case mjGEOM_MESH: // mesh
|
||||
if (geom->dataid>=0) {
|
||||
if (geom->dataid >= 0) {
|
||||
glCallList(con->baseMesh + geom->dataid);
|
||||
}
|
||||
break;
|
||||
@@ -443,8 +443,8 @@ static void renderGeom(const mjvGeom* geom, int mode, const float* headpos,
|
||||
glPopMatrix();
|
||||
|
||||
// disable texture if enabled
|
||||
if (geom->texid>=0 && con->ntexture>0 &&
|
||||
(mode==mjrRND_NORMAL || mode==mjrRND_SHADOWMAP)) {
|
||||
if (geom->texid >= 0 && con->ntexture > 0 &&
|
||||
(mode == mjrRND_NORMAL || mode == mjrRND_SHADOWMAP)) {
|
||||
settexture(mjtexREGULAR, 0, con, geom);
|
||||
}
|
||||
}
|
||||
@@ -456,7 +456,7 @@ void renderGeomReflection(int id, float reflectance, float headpos[3],
|
||||
float old_rgb[3];
|
||||
|
||||
// save rgb, modulate rgb by this->reflectance
|
||||
for (int k=0; k<3; k++) {
|
||||
for (int k=0; k < 3; k++) {
|
||||
old_rgb[k] = scn->geoms[id].rgba[k];
|
||||
scn->geoms[id].rgba[k] *= reflectance;
|
||||
}
|
||||
@@ -465,7 +465,7 @@ void renderGeomReflection(int id, float reflectance, float headpos[3],
|
||||
renderGeom(scn->geoms+id, mjrRND_NORMAL, headpos, scn, con);
|
||||
|
||||
// restore rgb
|
||||
for (int k=0; k<3; k++) {
|
||||
for (int k=0; k < 3; k++) {
|
||||
scn->geoms[id].rgba[k] = old_rgb[k];
|
||||
}
|
||||
}
|
||||
@@ -532,14 +532,14 @@ static void initLights(mjvScene* scn, const float* headpos, const float* gazedir
|
||||
|
||||
// headlight: set pos and dir
|
||||
if (scn->lights[0].headlight) {
|
||||
for (int i=0; i<3; i++) {
|
||||
for (int i=0; i < 3; i++) {
|
||||
scn->lights[0].pos[i] = headpos[i];
|
||||
scn->lights[0].dir[i] = gazedir[i];
|
||||
}
|
||||
}
|
||||
|
||||
// set light properties
|
||||
for (int i=0; i<scn->nlight; i++) {
|
||||
for (int i=0; i < scn->nlight; i++) {
|
||||
// colors
|
||||
glLightfv(GL_LIGHT0+i, GL_AMBIENT, scn->lights[i].ambient);
|
||||
glLightfv(GL_LIGHT0+i, GL_DIFFUSE, scn->lights[i].diffuse);
|
||||
@@ -565,7 +565,7 @@ static void initLights(mjvScene* scn, const float* headpos, const float* gazedir
|
||||
}
|
||||
|
||||
// disable all lights (enable selectively in render)
|
||||
for (int i=0; i<scn->nlight; i++) {
|
||||
for (int i=0; i < scn->nlight; i++) {
|
||||
glDisable(GL_LIGHT0+i);
|
||||
}
|
||||
}
|
||||
@@ -578,7 +578,7 @@ static void setView(int view, mjrRect viewport, const mjvScene* scn, const mjrCo
|
||||
mjvGLCamera cam;
|
||||
|
||||
// copy specified camera for stereo, average for mono (view = -1)
|
||||
if (view>=0) {
|
||||
if (view >= 0) {
|
||||
cam = scn->camera[view];
|
||||
} else {
|
||||
cam = mjv_averageCamera(scn->camera, scn->camera+1);
|
||||
@@ -674,7 +674,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
mjvLight *thislight;
|
||||
|
||||
// empty viewport: nothing to do
|
||||
if (viewport.width<=0 || viewport.height<=0) {
|
||||
if (viewport.width <= 0 || viewport.height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -682,7 +682,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
cam = mjv_averageCamera(scn->camera, scn->camera+1);
|
||||
|
||||
// check znear
|
||||
if (cam.frustum_near<mjMINVAL) {
|
||||
if (cam.frustum_near < mjMINVAL) {
|
||||
// geoms: error
|
||||
if (scn->ngeom) {
|
||||
mju_error("mjvScene frustum_near too small in mjr_render");
|
||||
@@ -695,7 +695,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
}
|
||||
|
||||
// upload dynamic skin data to GPU
|
||||
for (int i=0; i<scn->nskin; i++) {
|
||||
for (int i=0; i < scn->nskin; i++) {
|
||||
// upload positions to VBO
|
||||
glBindBuffer(GL_ARRAY_BUFFER, con->skinvertVBO[i]);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
@@ -712,7 +712,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
}
|
||||
|
||||
// determine drawbuffer; may be changed by stereo later
|
||||
if (con->currentBuffer==mjFB_WINDOW) {
|
||||
if (con->currentBuffer == mjFB_WINDOW) {
|
||||
drawbuffer = (con->windowDoublebuffer ? GL_BACK : GL_FRONT);
|
||||
} else {
|
||||
drawbuffer = GL_COLOR_ATTACHMENT0;
|
||||
@@ -728,12 +728,12 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
|
||||
// make list of transparent geoms
|
||||
nt = 0;
|
||||
for (int i=0; i<ngeom; i++) {
|
||||
for (int i=0; i < ngeom; i++) {
|
||||
// get geom pointer
|
||||
thisgeom = scn->geoms + i;
|
||||
|
||||
if (thisgeom->rgba[3]<0.995 || (thisgeom->type==mjGEOM_PLANE &&
|
||||
isBehind(headpos, thisgeom->pos, thisgeom->mat))) {
|
||||
if (thisgeom->rgba[3] < 0.995 || (thisgeom->type == mjGEOM_PLANE &&
|
||||
isBehind(headpos, thisgeom->pos, thisgeom->mat))) {
|
||||
// include index in list
|
||||
scn->geomorder[nt++] = i;
|
||||
thisgeom->transparent = 1;
|
||||
@@ -747,7 +747,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
thisgeom->camdist -= mjv_rbound(thisgeom);
|
||||
|
||||
// plane always far away
|
||||
if (thisgeom->type==mjGEOM_PLANE) {
|
||||
if (thisgeom->type == mjGEOM_PLANE) {
|
||||
thisgeom->camdist = 1E+10;
|
||||
}
|
||||
} else {
|
||||
@@ -760,7 +760,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
|
||||
// allow only one reflective geom
|
||||
int j = 0;
|
||||
for (int i=0; i<ngeom; i++) {
|
||||
for (int i=0; i < ngeom; i++) {
|
||||
if (j) {
|
||||
scn->geoms[i].reflectance = 0;
|
||||
} else if (isReflective(scn->geoms + i)) {
|
||||
@@ -782,19 +782,20 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
|
||||
// determine stereo; quadbuffered reverts to sidebyside if hardware not available
|
||||
stereo = scn->stereo;
|
||||
if (stereo==mjSTEREO_QUADBUFFERED && (con->currentBuffer!=mjFB_WINDOW || !con->windowStereo)) {
|
||||
if (stereo == mjSTEREO_QUADBUFFERED &&
|
||||
(con->currentBuffer != mjFB_WINDOW || !con->windowStereo)) {
|
||||
stereo = mjSTEREO_SIDEBYSIDE;
|
||||
}
|
||||
|
||||
// SIDEBYSIDE: reduce viewport
|
||||
if (stereo==mjSTEREO_SIDEBYSIDE) {
|
||||
if (stereo == mjSTEREO_SIDEBYSIDE) {
|
||||
viewport.width /= 2;
|
||||
}
|
||||
|
||||
// render with stereo
|
||||
for (int view=(stereo?0:-1); view<(stereo?2:0); view++) {
|
||||
for (int view=(stereo?0:-1); view < (stereo?2:0); view++) {
|
||||
// change drawbuffer for QUADBUFFERED stereo
|
||||
if (stereo==mjSTEREO_QUADBUFFERED) {
|
||||
if (stereo == mjSTEREO_QUADBUFFERED) {
|
||||
if (con->windowDoublebuffer) {
|
||||
drawbuffer = (view ? GL_BACK_RIGHT : GL_BACK_LEFT);
|
||||
} else {
|
||||
@@ -809,7 +810,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
}
|
||||
|
||||
// change viewport for SIDEBYSIDE stereo
|
||||
else if (stereo==mjSTEREO_SIDEBYSIDE) {
|
||||
else if (stereo == mjSTEREO_SIDEBYSIDE) {
|
||||
// move viewport to the right for view 1
|
||||
if (view) {
|
||||
viewport.left += viewport.width;
|
||||
@@ -834,8 +835,8 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
|
||||
// render all geoms
|
||||
for (int i=0; i<ngeom; i++) {
|
||||
if (scn->geoms[i].segid>=0) {
|
||||
for (int i=0; i < ngeom; i++) {
|
||||
if (scn->geoms[i].segid >= 0) {
|
||||
renderGeom(scn->geoms+i,
|
||||
scn->flags[mjRND_IDCOLOR] ? mjrRND_IDCOLOR : mjrRND_SEGMENT,
|
||||
headpos, scn, con);
|
||||
@@ -850,13 +851,13 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
|
||||
// plane and box reflection rendering
|
||||
if (scn->flags[mjRND_REFLECTION]) {
|
||||
for (int i=0; i<ngeom; i++) {
|
||||
for (int i=0; i < ngeom; i++) {
|
||||
// get geom pointer
|
||||
thisgeom = scn->geoms + i;
|
||||
|
||||
if (isReflective(thisgeom)) {
|
||||
// if box, replace with temporary plane matching Z+ box side
|
||||
if (thisgeom->type==mjGEOM_BOX) {
|
||||
if (thisgeom->type == mjGEOM_BOX) {
|
||||
// copy and convert to plane
|
||||
tempgeom = *thisgeom;
|
||||
tempgeom.type = mjGEOM_PLANE;
|
||||
@@ -911,14 +912,14 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
mjr_reflect(thisgeom->pos, thisgeom->mat);
|
||||
|
||||
// set light position and direction, enable
|
||||
for (int j=0; j<nlight; j++) {
|
||||
for (int j=0; j < nlight; j++) {
|
||||
adjustLight(scn->lights+j, j);
|
||||
glEnable(GL_LIGHT0+j);
|
||||
}
|
||||
|
||||
// render reflected non-transparent geoms, except for thisgeom
|
||||
for (int j=0; j<ngeom; j++) {
|
||||
if (!scn->geoms[j].transparent && i!=j) {
|
||||
for (int j=0; j < ngeom; j++) {
|
||||
if (!scn->geoms[j].transparent && i != j) {
|
||||
renderGeomReflection(j, thisgeom->reflectance, headpos, scn, con);
|
||||
}
|
||||
}
|
||||
@@ -931,14 +932,14 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
} else {
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
for (int j=0; j<nt; j++) {
|
||||
if (i!=scn->geomorder[j]) {
|
||||
for (int j=0; j < nt; j++) {
|
||||
if (i != scn->geomorder[j]) {
|
||||
renderGeomReflection(scn->geomorder[j], thisgeom->reflectance, headpos, scn, con);
|
||||
}
|
||||
}
|
||||
if (!scn->flags[mjRND_ADDITIVE]) {
|
||||
for (int j=nt-1; j>=0; j--) {
|
||||
if (i!=scn->geomorder[j]) {
|
||||
for (int j=nt-1; j >= 0; j--) {
|
||||
if (i != scn->geomorder[j]) {
|
||||
renderGeomReflection(scn->geomorder[j], thisgeom->reflectance, headpos, scn, con);
|
||||
}
|
||||
}
|
||||
@@ -947,7 +948,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
// disable lights
|
||||
for (int j=0; j<nlight; j++) {
|
||||
for (int j=0; j < nlight; j++) {
|
||||
glDisable(GL_LIGHT0+j);
|
||||
}
|
||||
|
||||
@@ -963,7 +964,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
//---------------------------------- regular rendering
|
||||
|
||||
// set light position and direction, enable non-shadow lights
|
||||
for (int i=0; i<nlight; i++) {
|
||||
for (int i=0; i < nlight; i++) {
|
||||
// set light
|
||||
thislight = scn->lights + i;
|
||||
adjustLight(thislight, i);
|
||||
@@ -978,21 +979,21 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
// (only one allowed, more would result in weird transparency)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for (int i=0; i<ngeom; i++)
|
||||
for (int i=0; i < ngeom; i++)
|
||||
if (isReflective(scn->geoms+i)) {
|
||||
renderGeom(scn->geoms+i, mjrRND_NORMAL, headpos, scn, con);
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
// render remaining opaque geoms
|
||||
for (int i=0; i<ngeom; i++) {
|
||||
for (int i=0; i < ngeom; i++) {
|
||||
if (!scn->geoms[i].transparent && !isReflective(scn->geoms+i)) {
|
||||
renderGeom(scn->geoms+i, mjrRND_NORMAL, headpos, scn, con);
|
||||
}
|
||||
}
|
||||
|
||||
// disable lights
|
||||
for (int i=0; i<nlight; i++) {
|
||||
for (int i=0; i < nlight; i++) {
|
||||
glDisable(GL_LIGHT0+i);
|
||||
}
|
||||
|
||||
@@ -1004,7 +1005,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
|
||||
// shadow map rendering
|
||||
if (scn->flags[mjRND_SHADOW] && con->shadowFBO) {
|
||||
for (int i=0; i<nlight; i++) {
|
||||
for (int i=0; i < nlight; i++) {
|
||||
// get pointer
|
||||
thislight = scn->lights + i;
|
||||
|
||||
@@ -1042,13 +1043,13 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
glColorMask(0, 0, 0, 0);
|
||||
|
||||
// render all geoms to depth texture
|
||||
for (int j=0; j<ngeom; j++) {
|
||||
for (int j=0; j < ngeom; j++) {
|
||||
renderGeom(scn->geoms+j, mjrRND_SHADOWCAST, headpos, scn, con);
|
||||
}
|
||||
|
||||
// restore OpenGL settings
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,
|
||||
con->currentBuffer==mjFB_WINDOW ? 0 : con->offFBO);
|
||||
con->currentBuffer == mjFB_WINDOW ? 0 : con->offFBO);
|
||||
glDrawBuffer(drawbuffer);
|
||||
glViewport(viewport.left, viewport.bottom, viewport.width, viewport.height);
|
||||
glCullFace(GL_BACK);
|
||||
@@ -1082,7 +1083,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
glEnable(GL_LIGHT0+i);
|
||||
|
||||
// only opaque geoms accept shadows
|
||||
for (int j=0; j<ngeom; j++) {
|
||||
for (int j=0; j < ngeom; j++) {
|
||||
if (!scn->geoms[j].transparent) {
|
||||
renderGeom(scn->geoms+j, mjrRND_SHADOWMAP, headpos, scn, con);
|
||||
}
|
||||
@@ -1108,8 +1109,8 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
// find skybox texture
|
||||
for (int i=0; i<con->ntexture; i++) {
|
||||
if (con->textureType[i]==mjTEXTURE_SKYBOX) {
|
||||
for (int i=0; i < con->ntexture; i++) {
|
||||
if (con->textureType[i] == mjTEXTURE_SKYBOX) {
|
||||
// save first skybox texture id in tempgeom
|
||||
memset(&tempgeom, 0, sizeof(mjvGeom));
|
||||
tempgeom.texid = i;
|
||||
@@ -1136,10 +1137,10 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
|
||||
// haze
|
||||
if (scn->flags[mjRND_HAZE]) {
|
||||
for (int j=0; j<ngeom; j++) {
|
||||
if (scn->geoms[j].type==mjGEOM_PLANE &&
|
||||
scn->geoms[j].size[0]==0 &&
|
||||
scn->geoms[j].size[1]==0) {
|
||||
for (int j=0; j < ngeom; j++) {
|
||||
if (scn->geoms[j].type == mjGEOM_PLANE &&
|
||||
scn->geoms[j].size[0] == 0 &&
|
||||
scn->geoms[j].size[1] == 0) {
|
||||
// compute headpos elevation above plane
|
||||
float* mat3 = scn->geoms[j].mat;
|
||||
float elevation = ((headpos[0]-scn->geoms[j].pos[0])*mat3[2] +
|
||||
@@ -1148,7 +1149,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
skyboxdst;
|
||||
|
||||
// below plane: no rendering
|
||||
if (elevation<0) {
|
||||
if (elevation < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1195,7 +1196,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
//------------------------------------ transparent regular rendering
|
||||
|
||||
// enable lights
|
||||
for (int i=0; i<nlight; i++) {
|
||||
for (int i=0; i < nlight; i++) {
|
||||
glEnable(GL_LIGHT0+i);
|
||||
}
|
||||
|
||||
@@ -1209,13 +1210,13 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
}
|
||||
|
||||
// render transparent geoms: front to back
|
||||
for (int i=0; i<nt; i++) {
|
||||
for (int i=0; i < nt; i++) {
|
||||
renderGeom(scn->geoms+scn->geomorder[i], mjrRND_NORMAL, headpos, scn, con);
|
||||
}
|
||||
|
||||
// render transparent geoms: back to front, if not additive
|
||||
if (!scn->flags[mjRND_ADDITIVE]) {
|
||||
for (int i=nt-1; i>=0; i--) {
|
||||
for (int i=nt-1; i >= 0; i--) {
|
||||
renderGeom(scn->geoms+scn->geomorder[i], mjrRND_NORMAL, headpos, scn, con);
|
||||
}
|
||||
}
|
||||
@@ -1225,7 +1226,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
// disable lights
|
||||
for (int i=0; i<nlight; i++) {
|
||||
for (int i=0; i < nlight; i++) {
|
||||
glDisable(GL_LIGHT0+i);
|
||||
}
|
||||
|
||||
@@ -1234,7 +1235,7 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
// render text labels if present
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
for (int i=0; i<ngeom; i++) {
|
||||
for (int i=0; i < ngeom; i++) {
|
||||
thisgeom = scn->geoms + i;
|
||||
|
||||
if (thisgeom->label[0]) {
|
||||
|
||||
Reference in New Issue
Block a user