1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 23:50:27 +00:00

fog for rug in spherical; fixed bugs with mouse in spherical rug

This commit is contained in:
Zeno Rogue 2017-12-27 14:12:27 +01:00
parent 59b51e8a05
commit b65e04eefd

43
rug.cpp
View File

@ -776,13 +776,15 @@ int eyemod;
void getco(rugpoint *m, hyperpoint& h, int &spherepoints) { void getco(rugpoint *m, hyperpoint& h, int &spherepoints) {
using namespace hyperpoint_vec; using namespace hyperpoint_vec;
h = m->getglue()->flat; h = m->getglue()->flat;
if(gwhere == gSphere && h[2] > 0) { if(rug_perspective && gwhere == gSphere) {
ld rad = hypot3(h); if(h[2] > 0) {
// turn M_PI to -M_PI ld rad = hypot3(h);
ld rad_to = M_PI + M_PI - rad; // turn M_PI to -M_PI
ld r = -rad_to / rad; ld rad_to = M_PI + M_PI - rad;
h *= r; ld r = -rad_to / rad;
spherepoints++; h *= r;
spherepoints++;
}
} }
if(eyemod) h[0] += eyemod * h[2] * vid.eye; if(eyemod) h[0] += eyemod * h[2] * vid.eye;
} }
@ -889,7 +891,7 @@ void prepareTexture() {
setGLProjection(); setGLProjection();
ptds.clear(); ptds.clear();
drawthemap(); drawthemap();
if(!renderonce) { if(mousing && !renderonce) {
for(int i=0; i<numplayers(); i++) if(multi::playerActive(i)) for(int i=0; i<numplayers(); i++) if(multi::playerActive(i))
queueline(tC0(shmup::ggmatrix(playerpos(i))), mouseh, 0xFF00FF, 8); queueline(tC0(shmup::ggmatrix(playerpos(i))), mouseh, 0xFF00FF, 8);
} }
@ -973,7 +975,12 @@ void drawRugScene() {
glOrtho(-xview, xview, -yview, yview, -1000, 1000); glOrtho(-xview, xview, -yview, yview, -1000, 1000);
} }
glColor4f(1,1,1,1); if(rug_perspective && gwhere == gSphere) {
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogf(GL_FOG_START, 0);
glFogf(GL_FOG_END, 10);
}
if(vid.eye > .001 || vid.eye < -.001) { if(vid.eye > .001 || vid.eye < -.001) {
selectEyeMask(1); selectEyeMask(1);
@ -1003,10 +1010,13 @@ void drawRugScene() {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glDisable(GL_FOG);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
selectEyeGL(0); selectEyeGL(0);
need_mouseh = true;
} }
// organization // organization
@ -1101,7 +1111,6 @@ void actDraw() {
if(keystate[SDLK_DOWN]) strafey += alpha; if(keystate[SDLK_DOWN]) strafey += alpha;
} }
if(qm)
for(int i=0; i<size(points); i++) { for(int i=0; i<size(points); i++) {
points[i]->flat = t * points[i]->flat; points[i]->flat = t * points[i]->flat;
} }
@ -1129,9 +1138,8 @@ void actDraw() {
int besti; int besti;
void getco_pers(rugpoint *r, hyperpoint& p, bool& error) { void getco_pers(rugpoint *r, hyperpoint& p, int& spherepoints, bool& error) {
int sp; getco(r, p, spherepoints);
getco(r, p, sp);
if(rug_perspective) { if(rug_perspective) {
if(p[2] >= 0) if(p[2] >= 0)
error = true; error = true;
@ -1157,10 +1165,11 @@ hyperpoint gethyper(ld x, ld y) {
auto r2 = triangles[i].m[2]; auto r2 = triangles[i].m[2];
hyperpoint p0, p1, p2; hyperpoint p0, p1, p2;
bool error = false; bool error = false;
getco_pers(r0, p0, error); int spherepoints = 0;
getco_pers(r1, p1, error); getco_pers(r0, p0, spherepoints, error);
getco_pers(r2, p2, error); getco_pers(r1, p1, spherepoints, error);
if(error) continue; getco_pers(r2, p2, spherepoints, error);
if(error || spherepoints == 1 || spherepoints == 2) continue;
double dx1 = p1[0] - p0[0]; double dx1 = p1[0] - p0[0];
double dy1 = p1[1] - p0[1]; double dy1 = p1[1] - p0[1];
double dx2 = p2[0] - p0[0]; double dx2 = p2[0] - p0[0];