Move headlight pos/dir computation from mjr_render to mjv_updateScene.
PiperOrigin-RevId: 586630110 Change-Id: Ia44ea944016ccfe081682375cdb975342695d826
This commit is contained in:
committed by
Copybara-Service
parent
822b03446c
commit
b39cca725a
+8
-17
@@ -613,7 +613,7 @@ static void initGL3(const mjvScene* scn, const mjrContext* con) {
|
||||
|
||||
|
||||
// init lights
|
||||
static void initLights(mjvScene* scn, const float* headpos, const float* gazedir) {
|
||||
static void initLights(mjvScene* scn) {
|
||||
// create some ambient light if no ligths are present
|
||||
float global = scn->nlight ? 0 : 0.3f;
|
||||
float rgba_global[4] = {global, global, global, 1};
|
||||
@@ -623,14 +623,6 @@ static void initLights(mjvScene* scn, const float* headpos, const float* gazedir
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
|
||||
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
|
||||
|
||||
// headlight: set pos and dir
|
||||
if (scn->lights[0].headlight) {
|
||||
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++) {
|
||||
// colors
|
||||
@@ -762,8 +754,8 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
int stereo, nt, ngeom = scn->ngeom, nlight = mjMIN(mjMAXLIGHT, scn->nlight);
|
||||
unsigned int drawbuffer;
|
||||
mjvGLCamera cam;
|
||||
mjtNum hpos[3], hfwd[3];
|
||||
float temp[4], headpos[3], forward[3], skyboxdst;
|
||||
mjtNum hpos[3];
|
||||
float temp[4], headpos[3], skyboxdst;
|
||||
float camProject[16], camView[16], lightProject[16], lightView[16];
|
||||
double clipplane[4];
|
||||
float biasMatrix[16] = {
|
||||
@@ -827,13 +819,12 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
||||
drawbuffer = GL_COLOR_ATTACHMENT0;
|
||||
}
|
||||
|
||||
// compute head position and gaze direction in model space
|
||||
mjv_cameraInModel(hpos, hfwd, NULL, scn);
|
||||
mju_n2f(headpos, hpos, 3);
|
||||
mju_n2f(forward, hfwd, 3);
|
||||
|
||||
// init lights
|
||||
initLights(scn, headpos, forward);
|
||||
initLights(scn);
|
||||
|
||||
// compute head position in model space
|
||||
mjv_cameraInModel(hpos, NULL, NULL, scn);
|
||||
mju_n2f(headpos, hpos, 3);
|
||||
|
||||
// make list of transparent geoms
|
||||
nt = 0;
|
||||
|
||||
Reference in New Issue
Block a user