rewrite calculation of map geometry bounding box

and rename client-side struct "mapdims" to clmapdims (to avoid confusion
with server-side data)
This commit is contained in:
ac-stef
2016-08-26 14:08:55 +02:00
parent 48e2ce3863
commit e1ce0979d0
13 changed files with 223 additions and 105 deletions
+15 -15
View File
@@ -529,9 +529,9 @@ void recomputecamera()
case SM_OVERVIEW:
{
// TODO : fix water rendering
camera1->o.x = mapdims.xm;
camera1->o.y = mapdims.ym;
camera1->o.z = mapdims.maxceil + 1;
camera1->o.x = clmapdims.xm;
camera1->o.y = clmapdims.ym;
camera1->o.z = clmapdims.maxceil + 1;
camera1->pitch = -90;
camera1->yaw = 0;
@@ -824,14 +824,14 @@ void drawminimap(int w, int h)
physent minicam;
camera1 = &minicam;
camera1->type = ENT_CAMERA;
camera1->o.x = mapdims.xm;
camera1->o.y = mapdims.ym;
camera1->o.x = clmapdims.xm;
camera1->o.y = clmapdims.ym;
//float gdim = max(mapdims.xspan, mapdims.yspan)+2.0f; //make 1 cube smaller to give it a black edge
float gdim = max(mapdims.xspan, mapdims.yspan); //no border
float gdim = max(clmapdims.xspan, clmapdims.yspan); //no border
if(gdim < 1) gdim = ssize/2.0f;
camera1->o.z = mapdims.maxceil + 1;
camera1->o.z = clmapdims.maxceil + 1;
camera1->pitch = -90;
camera1->yaw = 0;
@@ -846,7 +846,7 @@ void drawminimap(int w, int h)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // stencil added 2010jul22
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-orthd, orthd, -orthd, orthd, 0, (mapdims.maxceil - mapdims.minfloor) + 2); // depth of map +2 covered
glOrtho(-orthd, orthd, -orthd, orthd, 0, (clmapdims.maxceil - clmapdims.minfloor) + 2); // depth of map +2 covered
glScalef(1, -1, 1);
glMatrixMode(GL_MODELVIEW);
glCullFace(GL_BACK);
@@ -862,7 +862,7 @@ void drawminimap(int w, int h)
renderstrips();
glDepthFunc(GL_LESS);
rendermapmodels();
renderzones(mapdims.maxceil);
renderzones(clmapdims.maxceil);
//renderentities();// IMHO better done by radar itself, if at all
resettmu(0);
float hf = waterlevel - 0.3f;
@@ -875,10 +875,10 @@ void drawminimap(int w, int h)
glColor3f(0, 0, 0);
glLineWidth(2.0f);
glBegin(GL_LINE_LOOP);
glVertex3f(mapdims.x1 + 0.02f, mapdims.y1 + 0.02f, mapdims.maxceil);
glVertex3f(mapdims.x1 + mapdims.xspan - 0.02f, mapdims.y1 + 0.02f, mapdims.maxceil);
glVertex3f(mapdims.x1 + mapdims.xspan - 0.02f, mapdims.y1 + mapdims.yspan - 0.02f, mapdims.maxceil);
glVertex3f(mapdims.x1 + 0.02f, mapdims.y1 + mapdims.yspan - 0.02f, mapdims.maxceil);
glVertex3f(clmapdims.x1 + 0.02f, clmapdims.y1 + 0.02f, clmapdims.maxceil);
glVertex3f(clmapdims.x1 + clmapdims.xspan - 0.02f, clmapdims.y1 + 0.02f, clmapdims.maxceil);
glVertex3f(clmapdims.x1 + clmapdims.xspan - 0.02f, clmapdims.y1 + clmapdims.yspan - 0.02f, clmapdims.maxceil);
glVertex3f(clmapdims.x1 + 0.02f, clmapdims.y1 + clmapdims.yspan - 0.02f, clmapdims.maxceil);
glEnd();
glLineWidth(prevLineWidth);
glEnable(GL_BLEND);
@@ -930,10 +930,10 @@ void setperspective(float fovy, float aspect, float nearplane, float farplane)
GLdouble ydist = nearplane * tan(fovy/2*RAD), xdist = ydist * aspect;
if(player1->isspectating() && player1->spectatemode == SM_OVERVIEW)
{
int gdim = max(mapdims.xspan, mapdims.yspan);
int gdim = max(clmapdims.xspan, clmapdims.yspan);
if(!gdim) gdim = ssize/2;
int orthd = 2 + gdim/2;
glOrtho(-orthd, orthd, -orthd, orthd, 0, (mapdims.maxceil - mapdims.minfloor) + 2); // depth of map +2 covered
glOrtho(-orthd, orthd, -orthd, orthd, 0, (clmapdims.maxceil - clmapdims.minfloor) + 2); // depth of map +2 covered
}
else
{