Bug #589 Tidy up of MirrorCam

I've made a couple of small improvements:
	Prevent static background render when dynamic enabled (and vice versa)
	Prevent extra qsort of cars
	Rolled in Re-589-fixed-board-rendering-bug.patch
	Rolled in Re-589-moved-mirror-position-calculation-to-cGrCarCa.patch
	Changed FoV to narrow view slightly (now 50)

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4980 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: f100a18a45f63dbaa7e50090a7e608ca157f1c43
Former-commit-id: 41dcb4c916979fc6a8e0f7d582779815a0b09990
This commit is contained in:
mungewell 2012-10-05 03:00:37 +00:00
parent cf38ca4e26
commit 4381c22b1f
4 changed files with 33 additions and 32 deletions

View file

@ -544,27 +544,24 @@ void cGrCarCamMirror::update(tCarElt *car, tSituation * /* s */)
speed[2] =car->pub.DynGCg.vel.z;
}
void cGrCarCamMirror::setViewport(int x, int y, int w, int h)
void cGrCarCamMirror::adaptScreenSize()
{
vpx = x;
vpy = y;
vpw = w;
vph = h;
vp_aspectratio = double(vph)/vpw;
}
vpx = screen->getScrX();
vpy = screen->getScrY();
vpw = screen->getScrW();
vph = screen->getScrH();
vp_aspectratio = double(vph)/vpw;
// mirror width adjusted to fit board size
int boardW = screen->getBoardWidth();
void cGrCarCamMirror::setScreenPos (int x, int y, int w, int h)
{
mx = x;
my = y;
mw = w;
mh = h;
mx = vpx + vpw / 2 - (vpw * boardW /400);
my = vpy + 5 * vph / 6 - vph / 10;
mw = vpw * boardW /200;
mh = vph / 6;
m_centery = my + mh/2;
}
void cGrCarCamMirror::beforeDraw (void)
{
glFrontFace( GL_CW );

View file

@ -266,6 +266,10 @@ class cGrCarCamMirror : public cGrPerspCamera
virtual void beforeDraw(void);
virtual void afterDraw(void);
/** Called by cGrScreen::activate() after the screen updated it's screen size.
* Cameras should use the cGrCamera::screen property to get the updated information. */
void adaptScreenSize();
};

View file

@ -131,12 +131,10 @@ void cGrScreen::activate(int x, int y, int w, int h, float v)
board->setWidth(fakeWidth);
if (mirrorCam) {
// mirror width adjusted to fit board size
mirrorCam->setViewport (scrx, scry, scrw, scrh);
mirrorCam->setScreenPos (scrx + scrw / 2 - (scrw * boardWidth /400),
scry + 5 * scrh / 6 - scrh / 10,
(scrw * boardWidth /200), scrh / 6);
// call this method after scr* values have been updated
mirrorCam->adaptScreenSize();
}
if (curCam) {
curCam->limitFov ();
curCam->setZoom (GR_ZOOM_DFLT);
@ -244,8 +242,8 @@ void cGrScreen::camDraw(tSituation *s)
GfProfStopProfile("dispCam->update*");
// Draw the static background.
// TODO: Exclude this when sky dome enabled, because it is then actually invisible.
if (dispCam->getDrawBackground()) {
// Exclude this when sky dome enabled, because it is then actually invisible.
if (dispCam->getDrawBackground() && (grSkyDomeDistance == 0 || grTrack->skyversion == 0)) {
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@ -269,7 +267,8 @@ void cGrScreen::camDraw(tSituation *s)
// Sort the cars by distance for transparent windows
TheDispCam = dispCam; // Needed by compareCars() ordering function
qsort(cars, s->_ncars, sizeof(tCarElt*), compareCars);
if (dispCam != mirrorCam)
qsort(cars, s->_ncars, sizeof(tCarElt*), compareCars);
for (int i = 0; i < s->_ncars; i++) {
grDrawCar(s, cars[i], curCar, dispCam->getDrawCurrent(), dispCam->getDrawDriver(), s->currentTime, dispCam);
@ -283,7 +282,7 @@ void cGrScreen::camDraw(tSituation *s)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Draw the sky dome if enabled (first part)
if (dispCam->getDrawBackground()) {
if (dispCam->getDrawBackground() && grSkyDomeDistance > 0 && grTrack->skyversion > 0) {
grPreDrawSky(s, dispCam->getFogStart(), dispCam->getFogEnd());
}
@ -291,7 +290,7 @@ void cGrScreen::camDraw(tSituation *s)
grDrawScene();
// Draw the sky dome if enabled (last part)
if (dispCam->getDrawBackground()) {
if (dispCam->getDrawBackground() && grSkyDomeDistance > 0 && grTrack->skyversion > 0) {
grPostDrawSky();
}
@ -355,6 +354,12 @@ void cGrScreen::update(tSituation *s, const cGrFrameInfo* frameInfo)
dispCam = curCam;
camDraw(s);
glDisable(GL_SCISSOR_TEST);
/* Mirror */
if (mirrorFlag && curCam->isMirrorAllowed ()) {
dispCam = mirrorCam;
camDraw (s);
}
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_CULL_FACE);
@ -365,12 +370,6 @@ void cGrScreen::update(tSituation *s, const cGrFrameInfo* frameInfo)
glDisable(GL_FOG);
glEnable(GL_TEXTURE_2D);
/* Mirror */
if (mirrorFlag && curCam->isMirrorAllowed ()) {
dispCam = mirrorCam;
camDraw (s);
}
GfProfStartProfile("boardCam*");
boardCam->action();
GfProfStopProfile("boardCam*");
@ -490,7 +489,7 @@ void cGrScreen::initCams(tSituation *s)
-1,
0, // drawCurr
1, // drawBG
90.0, // fovy
50.0, // fovy
0.0, // fovymin
360.0, // fovymax
0.3, // near

View file

@ -93,6 +93,7 @@ class cGrScreen {
inline int getScrY (void) { return scry; }
inline int getScrW (void) { return scrw; }
inline int getScrH (void) { return scrh; }
inline int getBoardWidth(void) { return boardWidth; }
};
#endif //_GRSCREEN_H_