diff --git a/src/r_plane.cpp b/src/r_plane.cpp index b936f5a04..36ba9d1b5 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -734,6 +734,8 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc)(drawcolumndata_t*), bo } INT32 angle = (pl->viewangle + xtoviewangle[viewssnum][x + i])>>ANGLETOSKYSHIFT; + angle -= (skytextureoffset >> FRACBITS); + dc.iscale = FixedMul(skyscale[viewssnum], FINECOSINE(xtoviewangle[viewssnum][x + i]>>ANGLETOFINESHIFT)); dc.x = x + i; dc.source = diff --git a/src/r_sky.c b/src/r_sky.c index 61e35fd74..a69ab4c46 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -37,10 +37,14 @@ INT32 skyflatnum; */ INT32 skytexture; -/** \brief the horizon line in a 256x128 sky texture +/** \brief the horizon line of the sky texture */ INT32 skytexturemid; +/** \brief the x offset of the sky texture +*/ +INT32 skytextureoffset; + /** \brief the scale of the sky */ fixed_t skyscale[MAXSPLITSCREENPLAYERS]; @@ -61,12 +65,19 @@ char globallevelskytexture[9]; */ void R_SetupSkyDraw(void) { - // the horizon line in a 256x128 sky texture - skytexturemid = (textures[skytexture]->height/2)<height / 2) << FRACBITS; + skytextureoffset = 0; - // Sal: Add arbritrary offset that makes it - // line up with the horizon line special - skytexturemid += (16 << FRACBITS); + if (textures[skytexture]->type == TEXTURETYPE_SINGLEPATCH) + { + // Sal: Allow for sky offsets + texpatch_t *const tex_patch = &textures[skytexture]->patches[0]; + patch_t *patch = W_CachePatchNumPwad(tex_patch->wad, tex_patch->lump, PU_CACHE); + + skytexturemid += (patch->topoffset << FRACBITS); + skytextureoffset += (patch->leftoffset << FRACBITS); + } R_SetSkyScale(); } diff --git a/src/r_sky.h b/src/r_sky.h index 5a4f5e9ee..d205c1279 100644 --- a/src/r_sky.h +++ b/src/r_sky.h @@ -26,7 +26,7 @@ extern "C" { /// \brief The sky map is 256*128*4 maps. #define ANGLETOSKYSHIFT 22 -extern INT32 skytexture, skytexturemid; +extern INT32 skytexture, skytexturemid, skytextureoffset; extern fixed_t skyscale[MAXSPLITSCREENPLAYERS]; extern INT32 skyflatnum;