2006-08-29 01:58:59 +00:00
|
|
|
// blah
|
2006-10-29 20:18:04 +00:00
|
|
|
#ifdef POLYMOST
|
2008-04-02 09:29:58 +00:00
|
|
|
|
|
|
|
#define POLYMER_C
|
2006-08-31 01:56:43 +00:00
|
|
|
#include "polymer.h"
|
2006-08-29 01:58:59 +00:00
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
// CVARS
|
2008-04-13 00:46:31 +00:00
|
|
|
int pr_occlusionculling = 50;
|
2006-10-15 18:51:41 +00:00
|
|
|
int pr_fov = 426; // appears to be the classic setting.
|
2008-04-06 23:35:48 +00:00
|
|
|
int pr_billboardingmode = 1;
|
2006-10-15 18:51:41 +00:00
|
|
|
int pr_verbosity = 1; // 0: silent, 1: errors and one-times, 2: multiple-times, 3: flood
|
|
|
|
int pr_wireframe = 0;
|
2008-05-24 09:37:09 +00:00
|
|
|
int pr_vbos = 0;
|
2008-04-06 03:00:39 +00:00
|
|
|
int pr_mirrordepth = 1;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-03-30 09:16:39 +00:00
|
|
|
int glerror;
|
|
|
|
|
2008-05-24 09:37:09 +00:00
|
|
|
GLenum mapvbousage = GL_STREAM_DRAW_ARB;
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
// DATA
|
|
|
|
_prsector *prsectors[MAXSECTORS];
|
|
|
|
_prwall *prwalls[MAXWALLS];
|
2006-08-29 01:58:59 +00:00
|
|
|
|
2006-10-18 03:59:28 +00:00
|
|
|
GLfloat skybox[16];
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
_prplane spriteplane;
|
|
|
|
|
2008-05-10 01:29:37 +00:00
|
|
|
GLfloat vertsprite[4 * 5] =
|
|
|
|
{
|
2008-04-02 06:01:12 +00:00
|
|
|
-0.5f, 0.0f, 0.0f,
|
2008-05-10 01:29:37 +00:00
|
|
|
0.0f, 1.0f,
|
|
|
|
0.5f, 0.0f, 0.0f,
|
|
|
|
1.0f, 1.0f,
|
|
|
|
0.5f, 1.0f, 0.0f,
|
|
|
|
1.0f, 0.0f,
|
2008-04-02 06:01:12 +00:00
|
|
|
-0.5f, 1.0f, 0.0f,
|
2008-05-10 01:29:37 +00:00
|
|
|
0.0f, 0.0f,
|
2008-04-02 06:01:12 +00:00
|
|
|
};
|
|
|
|
|
2008-05-10 01:29:37 +00:00
|
|
|
GLfloat horizsprite[4 * 5] =
|
|
|
|
{
|
2008-04-06 23:35:48 +00:00
|
|
|
-0.5f, 0.0f, -0.5f,
|
2008-05-10 01:29:37 +00:00
|
|
|
0.0f, 1.0f,
|
|
|
|
0.5f, 0.0f, -0.5f,
|
|
|
|
1.0f, 1.0f,
|
|
|
|
0.5f, 0.0f, 0.5f,
|
|
|
|
1.0f, 0.0f,
|
2008-04-06 23:35:48 +00:00
|
|
|
-0.5f, 0.0f, 0.5f,
|
2008-05-10 01:29:37 +00:00
|
|
|
0.0f, 0.0f,
|
2008-04-02 06:01:12 +00:00
|
|
|
};
|
|
|
|
|
2006-10-15 18:51:41 +00:00
|
|
|
// CONTROL
|
2008-04-02 06:01:12 +00:00
|
|
|
GLdouble spritemodelview[16];
|
2008-04-06 03:00:39 +00:00
|
|
|
GLdouble rootmodelviewmatrix[16];
|
|
|
|
GLdouble *curmodelviewmatrix;
|
2007-03-22 18:28:41 +00:00
|
|
|
GLdouble projectionmatrix[16];
|
2006-10-15 18:51:41 +00:00
|
|
|
|
|
|
|
int updatesectors = 1;
|
2008-04-09 07:27:17 +00:00
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
int depth;
|
2008-04-09 07:27:17 +00:00
|
|
|
int mirrorfrom[10]; // -3: no mirror; -2: floor; -1: ceiling; >=0: wallnum
|
2006-08-30 23:32:39 +00:00
|
|
|
|
|
|
|
GLUtesselator* prtess;
|
|
|
|
|
2007-07-01 06:32:03 +00:00
|
|
|
short cursky;
|
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
short viewangle;
|
|
|
|
|
|
|
|
int rootsectnum;
|
2008-04-04 08:07:11 +00:00
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
_pranimatespritesinfo asi;
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
// EXTERNAL FUNCTIONS
|
|
|
|
int polymer_init(void)
|
2006-08-29 01:58:59 +00:00
|
|
|
{
|
2008-04-02 06:01:12 +00:00
|
|
|
int i, j;
|
2006-08-29 01:58:59 +00:00
|
|
|
|
2006-08-30 23:32:39 +00:00
|
|
|
if (pr_verbosity >= 1) OSD_Printf("Initalizing Polymer subsystem...\n");
|
2006-08-29 01:58:59 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < MAXSECTORS)
|
|
|
|
{
|
|
|
|
prsectors[i] = NULL;
|
|
|
|
i++;
|
|
|
|
}
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
i = 0;
|
|
|
|
while (i < MAXWALLS)
|
|
|
|
{
|
|
|
|
prwalls[i] = NULL;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2007-01-16 03:19:04 +00:00
|
|
|
prtess = bgluNewTess();
|
2006-08-30 23:32:39 +00:00
|
|
|
if (prtess == 0)
|
|
|
|
{
|
|
|
|
if (pr_verbosity >= 1) OSD_Printf("PR : Tesselator initialization failed.\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
polymer_loadboard();
|
|
|
|
|
2006-10-18 03:59:28 +00:00
|
|
|
polymer_initskybox();
|
|
|
|
|
2008-04-02 06:01:12 +00:00
|
|
|
// init the face sprite modelview to identity
|
|
|
|
i = 0;
|
|
|
|
while (i < 4)
|
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
while (j < 4)
|
|
|
|
{
|
|
|
|
if (i == j)
|
|
|
|
spritemodelview[(i * 4) + j] = 1.0;
|
|
|
|
else
|
|
|
|
spritemodelview[(i * 4) + j] = 0.0;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2006-08-30 23:32:39 +00:00
|
|
|
if (pr_verbosity >= 1) OSD_Printf("PR : Initialization complete.\n");
|
|
|
|
return (1);
|
2006-08-29 01:58:59 +00:00
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
void polymer_glinit(void)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2006-10-18 03:59:28 +00:00
|
|
|
float a;
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
bglClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
2006-10-04 09:54:25 +00:00
|
|
|
bglClearStencil(0);
|
|
|
|
bglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
2006-10-14 23:33:10 +00:00
|
|
|
bglViewport(0, 0, xdim, ydim);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
|
|
|
// texturing
|
2006-09-27 17:55:49 +00:00
|
|
|
bglEnable(GL_TEXTURE_2D);
|
|
|
|
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
|
|
|
|
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
bglEnable(GL_DEPTH_TEST);
|
2006-10-19 23:51:44 +00:00
|
|
|
bglDepthFunc(GL_LEQUAL);
|
|
|
|
|
2006-08-30 23:32:39 +00:00
|
|
|
if (pr_wireframe)
|
|
|
|
bglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
|
|
|
else
|
|
|
|
bglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
bglMatrixMode(GL_PROJECTION);
|
|
|
|
bglLoadIdentity();
|
2008-03-30 12:22:50 +00:00
|
|
|
bgluPerspective((float)(pr_fov) / (2048.0f / 360.0f), (float)xdim / (float)ydim, 0.01f, 100.0f);
|
2006-10-14 23:33:10 +00:00
|
|
|
|
2007-03-22 18:28:41 +00:00
|
|
|
// get the new projection matrix
|
|
|
|
bglGetDoublev(GL_PROJECTION_MATRIX, projectionmatrix);
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglLoadIdentity();
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
bglEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
bglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
|
2006-10-18 03:59:28 +00:00
|
|
|
bglDisable(GL_FOG);
|
|
|
|
|
2007-02-16 17:44:59 +00:00
|
|
|
bglFogi(GL_FOG_MODE, GL_EXP2);
|
2006-11-13 23:12:47 +00:00
|
|
|
//glFogfv(GL_FOG_COLOR, fogColor);
|
2006-10-19 23:51:44 +00:00
|
|
|
bglEnable(GL_FOG);
|
2006-10-18 03:59:28 +00:00
|
|
|
|
|
|
|
a = (1 - ((float)(visibility) / 512.0f)) / 10.0f;
|
2006-11-13 23:12:47 +00:00
|
|
|
bglFogf(GL_FOG_DENSITY, 0.1f - a);
|
|
|
|
bglFogf(GL_FOG_START, 0.0f);
|
|
|
|
bglFogf(GL_FOG_END, 1000000.0f);
|
2006-10-18 03:59:28 +00:00
|
|
|
|
2006-10-04 09:54:25 +00:00
|
|
|
bglEnable(GL_CULL_FACE);
|
|
|
|
bglCullFace(GL_BACK);
|
2006-09-29 21:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void polymer_loadboard(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < numsectors)
|
|
|
|
{
|
|
|
|
polymer_initsector(i);
|
|
|
|
polymer_updatesector(i);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < numwalls)
|
|
|
|
{
|
|
|
|
polymer_initwall(i);
|
|
|
|
polymer_updatewall(i);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2006-10-19 23:51:44 +00:00
|
|
|
polymer_getsky();
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
if (pr_verbosity >= 1) OSD_Printf("PR : Board loaded.\n");
|
|
|
|
}
|
2008-03-26 09:24:25 +00:00
|
|
|
|
2008-03-25 09:21:18 +00:00
|
|
|
void polymer_drawrooms(int daposx, int daposy, int daposz, short daang, int dahoriz, short dacursectnum)
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
2008-03-30 09:16:39 +00:00
|
|
|
short cursectnum;
|
2008-04-06 03:00:39 +00:00
|
|
|
int i;
|
2006-10-14 23:33:10 +00:00
|
|
|
float ang, horizang, tiltang;
|
2008-04-06 03:00:39 +00:00
|
|
|
float pos[3];
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Drawing rooms...\n");
|
|
|
|
|
2006-10-14 23:33:10 +00:00
|
|
|
ang = (float)(daang) / (2048.0f / 360.0f);
|
|
|
|
horizang = (float)(100 - dahoriz) / (512.0f / 180.0f);
|
|
|
|
tiltang = (gtang * 90.0f);
|
|
|
|
|
2008-01-05 08:58:15 +00:00
|
|
|
pos[0] = daposy;
|
2008-04-06 23:35:48 +00:00
|
|
|
pos[1] = -(float)(daposz) / 16.0f;
|
2008-01-05 08:58:15 +00:00
|
|
|
pos[2] = -daposx;
|
2006-10-14 23:33:10 +00:00
|
|
|
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglLoadIdentity();
|
|
|
|
|
2006-10-15 18:51:41 +00:00
|
|
|
bglRotatef(tiltang, 0.0f, 0.0f, -1.0f);
|
2006-10-14 23:33:10 +00:00
|
|
|
bglRotatef(horizang, 1.0f, 0.0f, 0.0f);
|
|
|
|
bglRotatef(ang, 0.0f, 1.0f, 0.0f);
|
|
|
|
|
2006-10-18 03:59:28 +00:00
|
|
|
bglDisable(GL_DEPTH_TEST);
|
|
|
|
bglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
2006-10-19 23:51:44 +00:00
|
|
|
polymer_drawartsky(cursky);
|
2006-10-18 03:59:28 +00:00
|
|
|
bglEnable(GL_DEPTH_TEST);
|
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
bglScalef(1.0f / 1000.0f, 1.0f / 1000.0f, 1.0f / 1000.0f);
|
2008-01-05 08:58:15 +00:00
|
|
|
bglTranslatef(-pos[0], -pos[1], -pos[2]);
|
2006-10-14 23:33:10 +00:00
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
bglGetDoublev(GL_MODELVIEW_MATRIX, rootmodelviewmatrix);
|
2006-10-15 18:51:41 +00:00
|
|
|
|
2008-04-04 07:28:25 +00:00
|
|
|
cursectnum = dacursectnum;
|
|
|
|
updatesector(daposx, daposy, &cursectnum);
|
|
|
|
|
|
|
|
if ((cursectnum >= 0) && (cursectnum < numsectors))
|
|
|
|
dacursectnum = cursectnum;
|
|
|
|
|
2008-04-27 22:47:47 +00:00
|
|
|
// unflag all sectors
|
|
|
|
i = 0;
|
|
|
|
while (i < numsectors)
|
|
|
|
{
|
|
|
|
prsectors[i]->controlstate = 0;
|
|
|
|
prsectors[i]->wallsproffset = 0.0f;
|
|
|
|
prsectors[i]->floorsproffset = 0.0f;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
i = 0;
|
|
|
|
while (i < numwalls)
|
|
|
|
{
|
|
|
|
prwalls[i]->controlstate = 0;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2008-04-04 07:28:25 +00:00
|
|
|
// external view (editor)
|
2008-04-27 22:47:47 +00:00
|
|
|
if ((dacursectnum < 0) || (dacursectnum >= numsectors) ||
|
2008-05-10 01:29:37 +00:00
|
|
|
(daposz > sector[dacursectnum].floorz) ||
|
|
|
|
(daposz < sector[dacursectnum].ceilingz))
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
2006-10-15 18:51:41 +00:00
|
|
|
i = 0;
|
|
|
|
while (i < numsectors)
|
2006-10-14 23:33:10 +00:00
|
|
|
{
|
2006-10-15 18:51:41 +00:00
|
|
|
polymer_updatesector(i);
|
2006-10-19 23:51:44 +00:00
|
|
|
polymer_drawsector(i);
|
2008-04-06 23:35:48 +00:00
|
|
|
polymer_scansprites(i, tsprite, &spritesortcnt);
|
2006-10-19 23:51:44 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < numwalls)
|
|
|
|
{
|
2008-04-06 03:00:39 +00:00
|
|
|
polymer_updatewall(i);
|
2008-04-09 07:27:17 +00:00
|
|
|
polymer_drawwall(sectorofwall(i), i);
|
2006-10-19 23:51:44 +00:00
|
|
|
i++;
|
|
|
|
}
|
2008-04-06 03:00:39 +00:00
|
|
|
viewangle = daang;
|
2006-10-19 23:51:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
rootsectnum = dacursectnum;
|
|
|
|
|
|
|
|
// GO!
|
2008-04-09 07:27:17 +00:00
|
|
|
depth = 0;
|
|
|
|
mirrorfrom[0] = -3; // no mirror
|
2008-04-06 03:00:39 +00:00
|
|
|
polymer_displayrooms(dacursectnum);
|
2008-03-30 09:16:39 +00:00
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
viewangle = daang;
|
|
|
|
curmodelviewmatrix = rootmodelviewmatrix;
|
2008-04-10 08:24:06 +00:00
|
|
|
cosglobalang = sintable[(viewangle+512)&2047];
|
|
|
|
singlobalang = sintable[viewangle&2047];
|
|
|
|
cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange);
|
|
|
|
sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange);
|
2007-03-22 18:28:41 +00:00
|
|
|
|
2007-07-01 06:32:03 +00:00
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Rooms drawn.\n");
|
2007-03-22 18:28:41 +00:00
|
|
|
}
|
|
|
|
|
2008-03-30 09:16:39 +00:00
|
|
|
void polymer_drawmasks(void)
|
|
|
|
{
|
2008-03-30 14:22:03 +00:00
|
|
|
bglEnable(GL_ALPHA_TEST);
|
|
|
|
bglEnable(GL_BLEND);
|
|
|
|
bglEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
|
2008-03-30 09:16:39 +00:00
|
|
|
while (spritesortcnt)
|
|
|
|
{
|
2008-04-10 08:24:06 +00:00
|
|
|
spritesortcnt--;
|
|
|
|
tspriteptr[spritesortcnt] = &tsprite[spritesortcnt];
|
|
|
|
polymer_drawsprite(spritesortcnt);
|
2008-03-30 09:16:39 +00:00
|
|
|
}
|
2008-03-30 14:22:03 +00:00
|
|
|
|
|
|
|
bglDisable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
bglDisable(GL_BLEND);
|
|
|
|
bglDisable(GL_ALPHA_TEST);
|
2008-03-30 09:16:39 +00:00
|
|
|
}
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
void polymer_rotatesprite(int sx, int sy, int z, short a, short picnum, signed char dashade, char dapalnum, char dastat, int cx1, int cy1, int cx2, int cy2)
|
2006-10-14 23:33:10 +00:00
|
|
|
{
|
2008-03-25 09:21:18 +00:00
|
|
|
UNREFERENCED_PARAMETER(sx);
|
|
|
|
UNREFERENCED_PARAMETER(sy);
|
|
|
|
UNREFERENCED_PARAMETER(z);
|
|
|
|
UNREFERENCED_PARAMETER(a);
|
|
|
|
UNREFERENCED_PARAMETER(picnum);
|
|
|
|
UNREFERENCED_PARAMETER(dashade);
|
|
|
|
UNREFERENCED_PARAMETER(dapalnum);
|
|
|
|
UNREFERENCED_PARAMETER(dastat);
|
|
|
|
UNREFERENCED_PARAMETER(cx1);
|
|
|
|
UNREFERENCED_PARAMETER(cy1);
|
|
|
|
UNREFERENCED_PARAMETER(cx2);
|
|
|
|
UNREFERENCED_PARAMETER(cy2);
|
2006-10-14 23:33:10 +00:00
|
|
|
}
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
void polymer_drawmaskwall(int damaskwallcnt)
|
2006-10-14 23:33:10 +00:00
|
|
|
{
|
2008-04-03 06:58:36 +00:00
|
|
|
_prwall *w;
|
|
|
|
|
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Masked wall %i...\n", damaskwallcnt);
|
|
|
|
|
|
|
|
w = prwalls[maskwall[damaskwallcnt]];
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
polymer_drawplane(-1, -3, &w->mask, 0);
|
2006-10-14 23:33:10 +00:00
|
|
|
}
|
|
|
|
|
2008-05-05 09:05:07 +00:00
|
|
|
static void polymer_drawmdsprite(spritetype *tspr)
|
|
|
|
{
|
|
|
|
md3model* m;
|
|
|
|
float spos[3];
|
|
|
|
float ang;
|
2008-05-10 04:28:24 +00:00
|
|
|
float scale;
|
2008-05-05 09:05:07 +00:00
|
|
|
int surfi;
|
|
|
|
md3xyzn_t *v0;
|
|
|
|
md3surf_t *s;
|
|
|
|
GLuint i;
|
|
|
|
|
|
|
|
m = (md3model*)models[tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].modelid];
|
|
|
|
updateanimation((md2model *)m,tspr);
|
|
|
|
|
2008-05-10 04:28:24 +00:00
|
|
|
if (m->head.flags == 1337)
|
|
|
|
return;
|
|
|
|
|
2008-05-05 09:05:07 +00:00
|
|
|
spos[0] = tspr->y;
|
|
|
|
spos[1] = -(float)(tspr->z) / 16.0f;
|
|
|
|
spos[2] = -tspr->x;
|
|
|
|
ang = (float)((tspr->ang) & 2047) / (2048.0f / 360.0f);
|
|
|
|
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglPushMatrix();
|
2008-05-10 04:28:24 +00:00
|
|
|
scale = (m->head.flags == 1337) ? 1.0 : (1.0/64.0);
|
|
|
|
scale *= m->scale;
|
|
|
|
scale *= m->bscale;
|
|
|
|
scale *= 1024;
|
|
|
|
|
2008-05-05 09:05:07 +00:00
|
|
|
bglTranslatef(spos[0], spos[1], spos[2]);
|
|
|
|
bglRotatef(-ang, 0.0f, 1.0f, 0.0f);
|
|
|
|
bglRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
|
|
|
|
bglRotatef(90.0f, 0.0f, 0.0f, 1.0f);
|
2008-05-10 04:28:24 +00:00
|
|
|
bglScalef(scale * (float)(tspr->xrepeat) / 64.0, scale * (float)(tspr->xrepeat) / 64.0, scale * (float)(tspr->yrepeat) / 64.0);
|
2008-05-05 09:05:07 +00:00
|
|
|
for (surfi=0;surfi<m->head.numsurfs;surfi++)
|
|
|
|
{
|
|
|
|
s = &m->head.surfs[surfi];
|
|
|
|
v0 = &s->xyzn[m->cframe*s->numverts];
|
|
|
|
|
2008-05-10 04:28:24 +00:00
|
|
|
i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].skinnum,tspr->pal,surfi);
|
2008-05-05 09:05:07 +00:00
|
|
|
if (!i)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bglBindTexture(GL_TEXTURE_2D, i);
|
|
|
|
|
|
|
|
bglVertexPointer(3, GL_SHORT, sizeof(md3xyzn_t), v0);
|
|
|
|
bglTexCoordPointer(2, GL_FLOAT, 0, s->uv);
|
|
|
|
bglDrawElements(GL_TRIANGLES, s->numtris * 3, GL_UNSIGNED_INT, s->tris);
|
|
|
|
}
|
|
|
|
bglPopMatrix();
|
|
|
|
}
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
void polymer_drawsprite(int snum)
|
2006-10-14 23:33:10 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
int curpicnum, xsize, ysize, tilexoff, tileyoff, xoff, yoff;
|
2008-03-30 09:16:39 +00:00
|
|
|
spritetype *tspr;
|
|
|
|
pthtyp* pth;
|
2008-05-18 07:35:35 +00:00
|
|
|
float xratio, yratio, ang;
|
2008-04-06 03:00:39 +00:00
|
|
|
float spos[3];
|
2008-03-30 09:16:39 +00:00
|
|
|
|
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Sprite %i...\n", snum);
|
|
|
|
|
2008-03-30 16:08:18 +00:00
|
|
|
tspr = tspriteptr[snum];
|
2008-03-30 09:16:39 +00:00
|
|
|
|
2008-05-05 09:05:07 +00:00
|
|
|
if (usemodels && tile2model[Ptile2tile(tspr->picnum,tspr->pal)].modelid >= 0 && tile2model[Ptile2tile(tspr->picnum,tspr->pal)].framenum >= 0)
|
|
|
|
{
|
|
|
|
polymer_drawmdsprite(tspr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-30 09:16:39 +00:00
|
|
|
curpicnum = tspr->picnum;
|
|
|
|
if (picanm[curpicnum]&192) curpicnum += animateoffs(curpicnum,tspr->owner+32768);
|
|
|
|
|
2008-03-30 11:16:21 +00:00
|
|
|
if (!waloff[curpicnum])
|
|
|
|
loadtile(curpicnum);
|
|
|
|
|
2008-03-30 09:16:39 +00:00
|
|
|
pth = gltexcache(curpicnum, tspr->pal, 0);
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
spriteplane.color[0] =
|
|
|
|
spriteplane.color[1] =
|
|
|
|
spriteplane.color[2] = ((float)(numpalookups-min(max(tspr->shade,0),numpalookups)))/((float)numpalookups);
|
2008-03-30 09:16:39 +00:00
|
|
|
|
|
|
|
if (pth && (pth->flags & 2) && (pth->palnum != tspr->pal))
|
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
spriteplane.color[0] *= (float)hictinting[tspr->pal].r / 255.0;
|
|
|
|
spriteplane.color[1] *= (float)hictinting[tspr->pal].g / 255.0;
|
|
|
|
spriteplane.color[2] *= (float)hictinting[tspr->pal].b / 255.0;
|
2008-03-30 09:16:39 +00:00
|
|
|
}
|
|
|
|
|
2008-03-30 11:16:21 +00:00
|
|
|
if (tspr->cstat & 2)
|
|
|
|
{
|
|
|
|
if (tspr->cstat & 512)
|
2008-05-18 07:35:35 +00:00
|
|
|
spriteplane.color[3] = 0.33f;
|
2008-03-30 11:16:21 +00:00
|
|
|
else
|
2008-05-18 07:35:35 +00:00
|
|
|
spriteplane.color[3] = 0.66f;
|
2008-03-30 11:16:21 +00:00
|
|
|
}
|
|
|
|
else
|
2008-05-18 07:35:35 +00:00
|
|
|
spriteplane.color[3] = 1.0f;
|
2008-03-30 11:16:21 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
spriteplane.glpic = (pth) ? pth->glpic : 0;
|
2008-03-30 09:16:39 +00:00
|
|
|
|
|
|
|
if (((tspr->cstat>>4) & 3) == 0)
|
2008-04-12 05:44:16 +00:00
|
|
|
xratio = (float)(tspr->xrepeat) * 32.0f / 160.0f;
|
2008-03-30 09:16:39 +00:00
|
|
|
else
|
2008-04-12 05:44:16 +00:00
|
|
|
xratio = (float)(tspr->xrepeat) / 4.0f;
|
|
|
|
|
|
|
|
yratio = (float)(tspr->yrepeat) / 4.0f;
|
|
|
|
|
|
|
|
xsize = tilesizx[curpicnum] * xratio;
|
|
|
|
ysize = tilesizy[curpicnum] * yratio;
|
|
|
|
|
|
|
|
tilexoff = (int)tspr->xoffset;
|
|
|
|
tileyoff = (int)tspr->yoffset;
|
|
|
|
tilexoff += (signed char)((usehightile&&h_xsize[curpicnum])?(h_xoffs[curpicnum]):((picanm[curpicnum]>>8)&255));
|
|
|
|
tileyoff += (signed char)((usehightile&&h_xsize[curpicnum])?(h_yoffs[curpicnum]):((picanm[curpicnum]>>16)&255));
|
|
|
|
|
|
|
|
xoff = tilexoff * xratio;
|
|
|
|
yoff = tileyoff * yratio;
|
2008-03-30 09:16:39 +00:00
|
|
|
|
2008-04-12 05:44:16 +00:00
|
|
|
if (tspr->cstat & 128)
|
|
|
|
yoff -= ysize / 2;
|
2008-03-30 09:16:39 +00:00
|
|
|
|
|
|
|
spos[0] = tspr->y;
|
2008-04-06 23:35:48 +00:00
|
|
|
spos[1] = -(float)(tspr->z) / 16.0f;
|
2008-03-30 09:16:39 +00:00
|
|
|
spos[2] = -tspr->x;
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
spriteplane.buffer = vertsprite;
|
2008-04-02 06:01:12 +00:00
|
|
|
|
2008-04-04 08:07:11 +00:00
|
|
|
if (pr_billboardingmode && !((tspr->cstat>>4) & 3))
|
|
|
|
{
|
|
|
|
// do surgery on the face tspr to make it look like a wall sprite
|
|
|
|
tspr->cstat |= 16;
|
|
|
|
tspr->ang = (viewangle + 1024) & 2047;
|
|
|
|
}
|
|
|
|
|
2008-03-30 11:16:21 +00:00
|
|
|
switch ((tspr->cstat>>4) & 3)
|
|
|
|
{
|
2008-05-10 01:29:37 +00:00
|
|
|
case 0:
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglPushMatrix();
|
|
|
|
|
|
|
|
spritemodelview[12] = curmodelviewmatrix[0] * spos[0] +
|
|
|
|
curmodelviewmatrix[4] * spos[1] +
|
|
|
|
curmodelviewmatrix[8] * spos[2] +
|
|
|
|
curmodelviewmatrix[12];
|
|
|
|
spritemodelview[13] = curmodelviewmatrix[1] * spos[0] +
|
|
|
|
curmodelviewmatrix[5] * spos[1] +
|
|
|
|
curmodelviewmatrix[9] * spos[2] +
|
|
|
|
curmodelviewmatrix[13];
|
|
|
|
spritemodelview[14] = curmodelviewmatrix[2] * spos[0] +
|
|
|
|
curmodelviewmatrix[6] * spos[1] +
|
|
|
|
curmodelviewmatrix[10] * spos[2] +
|
|
|
|
curmodelviewmatrix[14];
|
|
|
|
|
|
|
|
bglLoadMatrixd(spritemodelview);
|
|
|
|
bglRotatef((gtang * 90.0f), 0.0f, 0.0f, -1.0f);
|
|
|
|
bglTranslatef((float)(-xoff)/1000.0f, (float)(yoff)/1000.0f, 0.0f);
|
|
|
|
bglScalef((float)(xsize) / 1000.0f, (float)(ysize) / 1000.0f, 1.0f / 1000.0f);
|
|
|
|
|
|
|
|
bglPolygonOffset(0.0f, 0.0f);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglPushMatrix();
|
|
|
|
|
|
|
|
ang = (float)((tspr->ang + 1024) & 2047) / (2048.0f / 360.0f);
|
|
|
|
|
|
|
|
bglTranslatef(spos[0], spos[1], spos[2]);
|
|
|
|
bglRotatef(-ang, 0.0f, 1.0f, 0.0f);
|
|
|
|
bglTranslatef((float)(-xoff), (float)(yoff), 0.0f);
|
|
|
|
bglScalef((float)(xsize), (float)(ysize), 1.0f);
|
|
|
|
|
|
|
|
prsectors[tspr->sectnum]->wallsproffset += 0.5f;
|
|
|
|
bglPolygonOffset(-prsectors[tspr->sectnum]->wallsproffset,
|
|
|
|
-prsectors[tspr->sectnum]->wallsproffset);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglPushMatrix();
|
|
|
|
|
|
|
|
ang = (float)((tspr->ang + 1024) & 2047) / (2048.0f / 360.0f);
|
|
|
|
|
|
|
|
bglTranslatef(spos[0], spos[1], spos[2]);
|
|
|
|
bglRotatef(-ang, 0.0f, 1.0f, 0.0f);
|
|
|
|
bglTranslatef((float)(-xoff), 1.0f, (float)(yoff));
|
|
|
|
bglScalef((float)(xsize), 1.0f, (float)(ysize));
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
spriteplane.buffer = horizsprite;
|
2008-05-10 01:29:37 +00:00
|
|
|
|
|
|
|
prsectors[tspr->sectnum]->floorsproffset += 0.5f;
|
|
|
|
bglPolygonOffset(-prsectors[tspr->sectnum]->floorsproffset,
|
|
|
|
-prsectors[tspr->sectnum]->floorsproffset);
|
|
|
|
break;
|
2008-03-30 09:16:39 +00:00
|
|
|
}
|
|
|
|
|
2008-04-02 06:01:12 +00:00
|
|
|
bglMatrixMode(GL_TEXTURE);
|
|
|
|
bglLoadIdentity();
|
|
|
|
|
2008-03-30 11:16:21 +00:00
|
|
|
if ((tspr->cstat & 4) || (((tspr->cstat>>4) & 3) == 2))
|
2008-04-02 06:01:12 +00:00
|
|
|
bglScalef(-1.0f, 1.0f, 1.0f);
|
2008-03-30 11:16:21 +00:00
|
|
|
|
|
|
|
if (tspr->cstat & 8)
|
2008-04-02 06:01:12 +00:00
|
|
|
bglScalef(1.0f, -1.0f, 1.0f);
|
2008-03-30 09:16:39 +00:00
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
if ((tspr->cstat & 64) && (((tspr->cstat>>4) & 3) == 1))
|
2008-04-04 07:40:15 +00:00
|
|
|
bglEnable(GL_CULL_FACE);
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
polymer_drawplane(-1, -3, &spriteplane, 0);
|
2008-03-30 09:16:39 +00:00
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
if ((tspr->cstat & 64) && (((tspr->cstat>>4) & 3) == 1))
|
2008-04-04 07:40:15 +00:00
|
|
|
bglDisable(GL_CULL_FACE);
|
|
|
|
|
2008-04-02 06:01:12 +00:00
|
|
|
bglLoadIdentity();
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
2008-03-30 09:16:39 +00:00
|
|
|
bglPopMatrix();
|
2006-10-14 23:33:10 +00:00
|
|
|
}
|
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
void polymer_setanimatesprites(animatespritesptr animatesprites, int x, int y, int a, int smoothratio)
|
|
|
|
{
|
|
|
|
asi.animatesprites = animatesprites;
|
|
|
|
asi.x = x;
|
|
|
|
asi.y = y;
|
|
|
|
asi.a = a;
|
|
|
|
asi.smoothratio = smoothratio;
|
|
|
|
}
|
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
// CORE
|
|
|
|
static void polymer_displayrooms(short dacursectnum)
|
|
|
|
{
|
|
|
|
sectortype *sec, *nextsec;
|
|
|
|
walltype *wal, *nextwal;
|
2008-04-12 08:16:01 +00:00
|
|
|
_prwall *w;
|
2008-04-06 03:00:39 +00:00
|
|
|
int i, j;
|
|
|
|
GLint result;
|
|
|
|
int front;
|
|
|
|
int back;
|
|
|
|
int firstback;
|
|
|
|
short sectorqueue[MAXSECTORS];
|
|
|
|
short querydelay[MAXSECTORS];
|
|
|
|
GLuint queryid[MAXSECTORS];
|
|
|
|
short drawingstate[MAXSECTORS];
|
|
|
|
GLdouble localmodelviewmatrix[16];
|
|
|
|
float frustum[5 * 4];
|
2008-04-06 23:35:48 +00:00
|
|
|
int localspritesortcnt;
|
|
|
|
spritetype localtsprite[MAXSPRITESONSCREEN];
|
|
|
|
short localmaskwall[MAXWALLSB], localmaskwallcnt;
|
2008-04-06 03:00:39 +00:00
|
|
|
|
|
|
|
if (depth)
|
|
|
|
{
|
|
|
|
curmodelviewmatrix = localmodelviewmatrix;
|
|
|
|
bglGetDoublev(GL_MODELVIEW_MATRIX, localmodelviewmatrix);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
curmodelviewmatrix = rootmodelviewmatrix;
|
|
|
|
|
|
|
|
polymer_extractfrustum(curmodelviewmatrix, projectionmatrix, frustum);
|
|
|
|
|
|
|
|
memset(querydelay, 0, sizeof(short) * MAXSECTORS);
|
|
|
|
memset(queryid, 0, sizeof(GLuint) * MAXSECTORS);
|
|
|
|
memset(drawingstate, 0, sizeof(short) * MAXSECTORS);
|
|
|
|
|
|
|
|
front = 0;
|
|
|
|
back = 0;
|
2008-04-06 23:35:48 +00:00
|
|
|
localspritesortcnt = localmaskwallcnt = 0;
|
2008-04-06 03:00:39 +00:00
|
|
|
|
|
|
|
polymer_pokesector(dacursectnum);
|
2008-04-09 07:27:17 +00:00
|
|
|
polymer_drawsector(dacursectnum);
|
2008-04-06 23:35:48 +00:00
|
|
|
polymer_scansprites(dacursectnum, localtsprite, &localspritesortcnt);
|
2008-04-06 03:00:39 +00:00
|
|
|
drawingstate[dacursectnum] = 1;
|
|
|
|
|
|
|
|
sec = §or[dacursectnum];
|
|
|
|
wal = &wall[sec->wallptr];
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < sec->wallnum)
|
|
|
|
{
|
2008-04-06 23:35:48 +00:00
|
|
|
if (((wallvisible(sec->wallptr + i))) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
2008-04-09 07:27:17 +00:00
|
|
|
if (mirrorfrom[depth] != (sec->wallptr + i))
|
|
|
|
polymer_drawwall(dacursectnum, sec->wallptr + i);
|
2008-04-06 03:00:39 +00:00
|
|
|
// mask
|
2008-04-06 23:35:48 +00:00
|
|
|
if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
|
2008-04-06 03:00:39 +00:00
|
|
|
|
|
|
|
if ((wal->nextsector != -1) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(drawingstate[wal->nextsector] == 0))
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
|
|
|
sectorqueue[back++] = wal->nextsector;
|
|
|
|
drawingstate[wal->nextsector] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
wal = &wall[sec->wallptr + i];
|
|
|
|
}
|
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
mirrorfrom[depth] = -3;
|
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
firstback = back;
|
|
|
|
|
|
|
|
while (front != back)
|
|
|
|
{
|
2008-04-13 00:29:13 +00:00
|
|
|
if ((front >= firstback) && (pr_occlusionculling))
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
2008-04-13 00:29:13 +00:00
|
|
|
if (querydelay[sectorqueue[front]] == 0)
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
2008-04-13 00:29:13 +00:00
|
|
|
bglGetQueryObjectivARB(queryid[sectorqueue[front]],
|
2008-05-10 01:29:37 +00:00
|
|
|
GL_QUERY_RESULT_ARB,
|
|
|
|
&result);
|
2008-04-13 00:29:13 +00:00
|
|
|
bglDeleteQueriesARB(1, &queryid[sectorqueue[front]]);
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
front++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
querydelay[sectorqueue[front]] = pr_occlusionculling-1;
|
2008-04-06 03:00:39 +00:00
|
|
|
}
|
2008-04-13 00:29:13 +00:00
|
|
|
else if (querydelay[sectorqueue[front]] == -1)
|
2008-04-06 03:00:39 +00:00
|
|
|
querydelay[sectorqueue[front]] = pr_occlusionculling-1;
|
2008-04-13 00:29:13 +00:00
|
|
|
else if (querydelay[sectorqueue[front]])
|
|
|
|
querydelay[sectorqueue[front]]--;
|
2008-04-06 03:00:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
polymer_pokesector(sectorqueue[front]);
|
|
|
|
polymer_drawsector(sectorqueue[front]);
|
2008-04-06 23:35:48 +00:00
|
|
|
polymer_scansprites(sectorqueue[front], localtsprite, &localspritesortcnt);
|
2008-04-06 03:00:39 +00:00
|
|
|
|
|
|
|
// scan sectors
|
|
|
|
sec = §or[sectorqueue[front]];
|
|
|
|
wal = &wall[sec->wallptr];
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < sec->wallnum)
|
|
|
|
{
|
|
|
|
if ((wallvisible(sec->wallptr + i)) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
2008-04-09 07:27:17 +00:00
|
|
|
polymer_drawwall(sectorqueue[front], sec->wallptr + i);
|
2008-04-06 03:00:39 +00:00
|
|
|
// mask
|
2008-04-06 23:35:48 +00:00
|
|
|
if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
|
2008-04-06 03:00:39 +00:00
|
|
|
|
|
|
|
if ((wal->nextsector != -1) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(drawingstate[wal->nextsector] == 0))
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
|
|
|
polymer_pokesector(wal->nextsector);
|
|
|
|
sectorqueue[back++] = wal->nextsector;
|
|
|
|
drawingstate[wal->nextsector] = 1;
|
|
|
|
|
|
|
|
if (pr_occlusionculling && !querydelay[wal->nextsector])
|
|
|
|
{
|
|
|
|
nextsec = §or[wal->nextsector];
|
|
|
|
nextwal = &wall[nextsec->wallptr];
|
|
|
|
|
2008-04-12 08:27:09 +00:00
|
|
|
if ((nextsec->ceilingstat & 1) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(nextsec->floorz == nextsec->ceilingz))
|
2008-04-12 08:16:01 +00:00
|
|
|
{
|
|
|
|
querydelay[wal->nextsector] = -1;
|
|
|
|
i++;
|
|
|
|
wal = &wall[sec->wallptr + i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
bglDisable(GL_TEXTURE_2D);
|
|
|
|
bglDisable(GL_FOG);
|
|
|
|
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
|
|
bglDepthMask(GL_FALSE);
|
|
|
|
|
|
|
|
bglGenQueriesARB(1, &queryid[wal->nextsector]);
|
|
|
|
bglBeginQueryARB(GL_SAMPLES_PASSED_ARB, queryid[wal->nextsector]);
|
|
|
|
|
|
|
|
j = 0;
|
|
|
|
while (j < nextsec->wallnum)
|
|
|
|
{
|
|
|
|
if ((nextwal->nextwall == (sec->wallptr + i)) ||
|
2008-05-10 01:29:37 +00:00
|
|
|
((nextwal->nextwall != -1) &&
|
|
|
|
(wallvisible(nextwal->nextwall)) &&
|
|
|
|
(polymer_portalinfrustum(nextwal->nextwall, frustum))))
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
2008-04-12 08:16:01 +00:00
|
|
|
w = prwalls[nextwal->nextwall];
|
2008-05-24 09:37:09 +00:00
|
|
|
|
|
|
|
if (pr_vbos > 0)
|
2008-04-12 08:16:01 +00:00
|
|
|
{
|
2008-05-24 09:37:09 +00:00
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo);
|
|
|
|
bglVertexPointer(3, GL_FLOAT, 0, NULL);
|
2008-04-12 08:16:01 +00:00
|
|
|
}
|
2008-05-24 09:37:09 +00:00
|
|
|
else
|
|
|
|
bglVertexPointer(3, GL_FLOAT, 0, w->bigportal);
|
|
|
|
|
|
|
|
bglDrawArrays(GL_QUADS, 0, 4);
|
|
|
|
|
|
|
|
if (pr_vbos > 0)
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
2008-04-06 03:00:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
j++;
|
|
|
|
nextwal = &wall[nextsec->wallptr + j];
|
|
|
|
}
|
|
|
|
bglEndQueryARB(GL_SAMPLES_PASSED_ARB);
|
|
|
|
|
|
|
|
bglDepthMask(GL_TRUE);
|
|
|
|
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
|
|
|
|
bglEnable(GL_FOG);
|
|
|
|
bglEnable(GL_TEXTURE_2D);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
wal = &wall[sec->wallptr + i];
|
|
|
|
}
|
|
|
|
front++;
|
|
|
|
}
|
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
spritesortcnt = localspritesortcnt;
|
|
|
|
memcpy(tsprite, localtsprite, sizeof(spritetype) * MAXSPRITESONSCREEN);
|
|
|
|
maskwallcnt = localmaskwallcnt;
|
|
|
|
memcpy(maskwall, localmaskwall, sizeof(short) * MAXWALLSB);
|
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
if (depth)
|
|
|
|
{
|
2008-04-10 08:24:06 +00:00
|
|
|
cosglobalang = sintable[(viewangle+512)&2047];
|
|
|
|
singlobalang = sintable[viewangle&2047];
|
|
|
|
cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange);
|
|
|
|
sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange);
|
|
|
|
|
|
|
|
display_mirror = 1;
|
2008-04-06 23:35:48 +00:00
|
|
|
polymer_animatesprites();
|
2008-04-10 08:24:06 +00:00
|
|
|
display_mirror = 0;
|
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
bglDisable(GL_CULL_FACE);
|
2008-04-06 03:00:39 +00:00
|
|
|
drawmasks();
|
2008-04-06 23:35:48 +00:00
|
|
|
bglEnable(GL_CULL_FACE);
|
|
|
|
bglEnable(GL_BLEND);
|
2008-04-06 03:00:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-24 09:37:09 +00:00
|
|
|
#define OMGDRAWSHITVBO \
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, plane->vbo); \
|
|
|
|
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), NULL); \
|
|
|
|
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), (GLfloat*)(3 * sizeof(GLfloat))); \
|
|
|
|
if (!plane->indices) \
|
|
|
|
bglDrawArrays(GL_QUADS, 0, 4); \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, plane->ivbo); \
|
|
|
|
bglDrawElements(GL_TRIANGLES, indicecount, GL_UNSIGNED_SHORT, NULL); \
|
|
|
|
} \
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); \
|
|
|
|
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0)
|
|
|
|
|
|
|
|
#define OMGDRAWSHIT \
|
|
|
|
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), plane->buffer); \
|
|
|
|
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &plane->buffer[3]); \
|
|
|
|
if (!plane->indices) \
|
|
|
|
bglDrawArrays(GL_QUADS, 0, 4); \
|
|
|
|
else \
|
2008-05-18 07:35:35 +00:00
|
|
|
bglDrawElements(GL_TRIANGLES, indicecount, GL_UNSIGNED_SHORT, plane->indices)
|
2008-04-09 07:27:17 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
static void polymer_drawplane(short sectnum, short wallnum, _prplane* plane, int indicecount)
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
|
|
|
|
2008-04-10 08:39:05 +00:00
|
|
|
if ((depth < 1) && (plane != NULL) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(wallnum >= 0) && (wall[wallnum].overpicnum == 560)) // insert mirror condition here
|
2008-04-09 07:27:17 +00:00
|
|
|
{
|
|
|
|
int gx, gy, gz, px, py, pz;
|
|
|
|
float coeff;
|
|
|
|
|
|
|
|
// set the stencil to 1 and clear the area to black where the sector floor is
|
|
|
|
bglDisable(GL_TEXTURE_2D);
|
|
|
|
bglDisable(GL_FOG);
|
|
|
|
bglColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
|
|
|
bglDepthMask(GL_FALSE);
|
|
|
|
|
|
|
|
bglEnable(GL_STENCIL_TEST);
|
|
|
|
bglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
|
|
|
bglStencilFunc(GL_EQUAL, 0, 0xffffffff);
|
|
|
|
|
2008-05-24 09:37:09 +00:00
|
|
|
if (plane->vbo && (pr_vbos > 0)) {
|
|
|
|
OMGDRAWSHITVBO;
|
|
|
|
} else {
|
|
|
|
OMGDRAWSHIT;
|
|
|
|
}
|
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
bglDepthMask(GL_TRUE);
|
|
|
|
|
|
|
|
// set the depth to 1 where we put the stencil by drawing a screen aligned quad
|
|
|
|
bglStencilFunc(GL_EQUAL, 1, 0xffffffff);
|
|
|
|
bglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
|
|
|
bglDepthFunc(GL_ALWAYS);
|
|
|
|
bglMatrixMode(GL_PROJECTION);
|
|
|
|
bglPushMatrix();
|
|
|
|
bglLoadIdentity();
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglPushMatrix();
|
|
|
|
bglLoadIdentity();
|
|
|
|
|
|
|
|
bglColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
bglBegin(GL_QUADS);
|
|
|
|
bglVertex3f(-1.0f, -1.0f, 1.0f);
|
|
|
|
bglVertex3f(1.0f, -1.0f, 1.0f);
|
|
|
|
bglVertex3f(1.0f, 1.0f, 1.0f);
|
|
|
|
bglVertex3f(-1.0f, 1.0f, 1.0f);
|
|
|
|
bglEnd();
|
|
|
|
|
|
|
|
bglMatrixMode(GL_PROJECTION);
|
|
|
|
bglPopMatrix();
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglPopMatrix();
|
|
|
|
bglDepthFunc(GL_LEQUAL);
|
|
|
|
bglEnable(GL_TEXTURE_2D);
|
|
|
|
bglEnable(GL_FOG);
|
|
|
|
// finally draw the shit
|
|
|
|
bglPushMatrix();
|
2008-05-18 07:35:35 +00:00
|
|
|
bglClipPlane(GL_CLIP_PLANE0, plane->plane);
|
|
|
|
polymer_inb4mirror(plane->buffer, plane->plane);
|
2008-04-09 07:27:17 +00:00
|
|
|
bglCullFace(GL_FRONT);
|
|
|
|
bglEnable(GL_CLIP_PLANE0);
|
|
|
|
|
2008-04-10 08:24:06 +00:00
|
|
|
if (wallnum >= 0)
|
|
|
|
preparemirror(globalposx, globalposy, 0, globalang,
|
|
|
|
0, wallnum, 0, &gx, &gy, &viewangle);
|
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
gx = globalposx;
|
|
|
|
gy = globalposy;
|
|
|
|
gz = globalposz;
|
|
|
|
|
|
|
|
// map the player pos from build to polymer
|
|
|
|
px = globalposy;
|
|
|
|
py = -globalposz / 16;
|
|
|
|
pz = -globalposx;
|
2008-04-06 23:35:48 +00:00
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
// calculate new player position on the other side of the mirror
|
|
|
|
// this way the basic build visibility shit can be used (wallvisible)
|
2008-05-18 07:35:35 +00:00
|
|
|
coeff = -plane->plane[0] * px +
|
|
|
|
-plane->plane[1] * py +
|
|
|
|
-plane->plane[2] * pz +
|
|
|
|
-plane->plane[3];
|
2008-04-06 03:00:39 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
coeff /= (float)(plane->plane[0] * plane->plane[0] +
|
|
|
|
plane->plane[1] * plane->plane[1] +
|
|
|
|
plane->plane[2] * plane->plane[2]);
|
2008-04-06 03:00:39 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
px = coeff*plane->plane[0]*2 + px;
|
|
|
|
py = coeff*plane->plane[1]*2 + py;
|
|
|
|
pz = coeff*plane->plane[2]*2 + pz;
|
2008-04-09 07:27:17 +00:00
|
|
|
|
|
|
|
// map back from polymer to build
|
|
|
|
globalposx = -pz;
|
|
|
|
globalposy = px;
|
|
|
|
globalposz = -py * 16;
|
|
|
|
|
|
|
|
depth++;
|
|
|
|
mirrorfrom[depth] = wallnum;
|
|
|
|
polymer_displayrooms(sectnum);
|
|
|
|
depth--;
|
|
|
|
|
|
|
|
globalposx = gx;
|
|
|
|
globalposy = gy;
|
|
|
|
globalposz = gz;
|
|
|
|
|
|
|
|
bglDisable(GL_CLIP_PLANE0);
|
|
|
|
bglCullFace(GL_BACK);
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglPopMatrix();
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
bglColor4f(plane->color[0], plane->color[1], plane->color[2], 0.0f);
|
2008-04-09 07:27:17 +00:00
|
|
|
}
|
|
|
|
else
|
2008-05-18 07:35:35 +00:00
|
|
|
bglColor4f(plane->color[0], plane->color[1], plane->color[2], plane->color[3]);
|
2008-04-09 07:27:17 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
bglBindTexture(GL_TEXTURE_2D, plane->glpic);
|
2008-05-24 09:37:09 +00:00
|
|
|
if (plane->vbo && (pr_vbos > 0)) {
|
|
|
|
OMGDRAWSHITVBO;
|
|
|
|
} else {
|
|
|
|
OMGDRAWSHIT;
|
|
|
|
}
|
2008-04-09 07:27:17 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if ((depth < 1) && (plane->plane != NULL) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(wallnum >= 0) && (wall[wallnum].overpicnum == 560)) // insert mirror condition here
|
2008-04-09 07:27:17 +00:00
|
|
|
{
|
|
|
|
bglDisable(GL_STENCIL_TEST);
|
|
|
|
bglClear(GL_STENCIL_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void polymer_inb4mirror(GLfloat* buffer, GLdouble* plane)
|
|
|
|
{
|
|
|
|
float pv;
|
|
|
|
float reflectionmatrix[16];
|
|
|
|
|
|
|
|
pv = buffer[0] * plane[0] +
|
|
|
|
buffer[1] * plane[1] +
|
|
|
|
buffer[2] * plane[2];
|
|
|
|
|
|
|
|
reflectionmatrix[0] = 1 - (2 * plane[0] * plane[0]);
|
|
|
|
reflectionmatrix[1] = -2 * plane[0] * plane[1];
|
|
|
|
reflectionmatrix[2] = -2 * plane[0] * plane[2];
|
2008-04-06 03:00:39 +00:00
|
|
|
reflectionmatrix[3] = 0;
|
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
reflectionmatrix[4] = -2 * plane[0] * plane[1];
|
|
|
|
reflectionmatrix[5] = 1 - (2 * plane[1] * plane[1]);
|
|
|
|
reflectionmatrix[6] = -2 * plane[1] * plane[2];
|
2008-04-06 03:00:39 +00:00
|
|
|
reflectionmatrix[7] = 0;
|
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
reflectionmatrix[8] = -2 * plane[0] * plane[2];
|
|
|
|
reflectionmatrix[9] = -2 * plane[1] * plane[2];
|
|
|
|
reflectionmatrix[10] = 1 - (2 * plane[2] * plane[2]);
|
2008-04-06 03:00:39 +00:00
|
|
|
reflectionmatrix[11] = 0;
|
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
reflectionmatrix[12] = 2 * pv * plane[0];
|
|
|
|
reflectionmatrix[13] = 2 * pv * plane[1];
|
|
|
|
reflectionmatrix[14] = 2 * pv * plane[2];
|
2008-04-06 03:00:39 +00:00
|
|
|
reflectionmatrix[15] = 1;
|
|
|
|
|
|
|
|
bglMultMatrixf(reflectionmatrix);
|
|
|
|
}
|
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
static void polymer_animatesprites(void)
|
|
|
|
{
|
2008-04-28 08:29:40 +00:00
|
|
|
if (asi.animatesprites)
|
|
|
|
asi.animatesprites(globalposx, globalposy, viewangle, asi.smoothratio);
|
2008-04-06 23:35:48 +00:00
|
|
|
}
|
|
|
|
|
2006-10-15 18:51:41 +00:00
|
|
|
// SECTORS
|
2008-04-02 09:29:58 +00:00
|
|
|
static int polymer_initsector(short sectnum)
|
2006-08-31 01:56:43 +00:00
|
|
|
{
|
2006-09-29 21:36:12 +00:00
|
|
|
sectortype *sec;
|
|
|
|
_prsector* s;
|
|
|
|
|
|
|
|
if (pr_verbosity >= 2) OSD_Printf("PR : Initalizing sector %i...\n", sectnum);
|
|
|
|
|
|
|
|
sec = §or[sectnum];
|
2008-04-02 06:58:26 +00:00
|
|
|
s = calloc(1, sizeof(_prsector));
|
2006-09-29 21:36:12 +00:00
|
|
|
if (s == NULL)
|
|
|
|
{
|
|
|
|
if (pr_verbosity >= 1) OSD_Printf("PR : Cannot initialize sector %i : malloc failed.\n", sectnum);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
s->verts = calloc(sec->wallnum, sizeof(GLdouble) * 3);
|
2008-05-18 07:35:35 +00:00
|
|
|
s->floor.buffer = calloc(sec->wallnum, sizeof(GLfloat) * 5);
|
|
|
|
s->ceil.buffer = calloc(sec->wallnum, sizeof(GLfloat) * 5);
|
|
|
|
if ((s->verts == NULL) || (s->floor.buffer == NULL) || (s->ceil.buffer == NULL))
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
|
|
|
if (pr_verbosity >= 1) OSD_Printf("PR : Cannot initialize geometry of sector %i : malloc failed.\n", sectnum);
|
|
|
|
return (0);
|
|
|
|
}
|
2008-05-18 07:35:35 +00:00
|
|
|
bglGenBuffersARB(1, &s->floor.vbo);
|
|
|
|
bglGenBuffersARB(1, &s->ceil.vbo);
|
|
|
|
bglGenBuffersARB(1, &s->floor.ivbo);
|
|
|
|
bglGenBuffersARB(1, &s->ceil.ivbo);
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
s->controlstate = 2; // let updatesector know that everything needs to go
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2006-10-15 18:51:41 +00:00
|
|
|
prsectors[sectnum] = s;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
if (pr_verbosity >= 2) OSD_Printf("PR : Initalized sector %i.\n", sectnum);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
static int polymer_updatesector(short sectnum)
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
|
|
|
_prsector* s;
|
|
|
|
sectortype *sec;
|
|
|
|
walltype *wal;
|
|
|
|
int i, j;
|
2007-12-12 17:42:14 +00:00
|
|
|
int ceilz, florz;
|
2008-04-28 08:29:40 +00:00
|
|
|
int tex, tey, heidiff;
|
|
|
|
float secangcos, secangsin, scalecoef, xpancoef, ypancoef;
|
2008-04-02 06:58:26 +00:00
|
|
|
int ang, needfloor, wallinvalidate;
|
|
|
|
short curstat, curpicnum, floorpicnum, ceilingpicnum;
|
2006-09-29 21:36:12 +00:00
|
|
|
char curxpanning, curypanning;
|
|
|
|
GLfloat* curbuffer;
|
2006-10-19 23:51:44 +00:00
|
|
|
GLuint *curglpic, *curfbglpic;
|
2006-09-29 21:36:12 +00:00
|
|
|
pthtyp* pth;
|
2006-08-31 01:56:43 +00:00
|
|
|
|
|
|
|
s = prsectors[sectnum];
|
|
|
|
sec = §or[sectnum];
|
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
secangcos = secangsin = 2;
|
2006-09-27 17:55:49 +00:00
|
|
|
|
2006-08-31 01:56:43 +00:00
|
|
|
if (s == NULL)
|
|
|
|
{
|
|
|
|
if (pr_verbosity >= 1) OSD_Printf("PR : Can't update uninitialized sector %i.\n", sectnum);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
needfloor = wallinvalidate = 0;
|
2006-09-27 17:55:49 +00:00
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
// geometry
|
2008-04-02 06:58:26 +00:00
|
|
|
wal = &wall[sec->wallptr];
|
2006-08-31 01:56:43 +00:00
|
|
|
i = 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
while (i < sec->wallnum)
|
2006-08-31 01:56:43 +00:00
|
|
|
{
|
2006-10-17 01:14:20 +00:00
|
|
|
if ((-wal->x != s->verts[(i*3)+2]))
|
2006-10-15 18:51:41 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
s->verts[(i*3)+2] = s->floor.buffer[(i*5)+2] = s->ceil.buffer[(i*5)+2] = -wal->x;
|
2008-04-02 06:58:26 +00:00
|
|
|
needfloor = wallinvalidate = 1;
|
2006-10-15 18:51:41 +00:00
|
|
|
}
|
2006-10-17 01:14:20 +00:00
|
|
|
if ((wal->y != s->verts[i*3]))
|
2006-10-15 18:51:41 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
s->verts[i*3] = s->floor.buffer[i*5] = s->ceil.buffer[i*5] = wal->y;
|
2008-04-02 06:58:26 +00:00
|
|
|
needfloor = wallinvalidate = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
wal = &wall[sec->wallptr + i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((s->controlstate == 2) ||
|
2008-05-10 01:29:37 +00:00
|
|
|
(sec->floorz != s->floorz) ||
|
|
|
|
(sec->ceilingz != s->ceilingz) ||
|
|
|
|
(sec->floorheinum != s->floorheinum) ||
|
|
|
|
(sec->ceilingheinum != s->ceilingheinum))
|
2008-04-02 06:58:26 +00:00
|
|
|
{
|
|
|
|
wallinvalidate = 1;
|
|
|
|
|
|
|
|
wal = &wall[sec->wallptr];
|
|
|
|
i = 0;
|
|
|
|
while (i < sec->wallnum)
|
|
|
|
{
|
|
|
|
getzsofslope(sectnum, wal->x, wal->y, &ceilz, &florz);
|
2008-05-18 07:35:35 +00:00
|
|
|
s->floor.buffer[(i*5)+1] = -(float)(florz) / 16.0f;
|
|
|
|
s->ceil.buffer[(i*5)+1] = -(float)(ceilz) / 16.0f;
|
2008-04-02 06:58:26 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
wal = &wall[sec->wallptr + i];
|
2006-10-15 18:51:41 +00:00
|
|
|
}
|
2006-08-31 01:56:43 +00:00
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
s->floorz = sec->floorz;
|
|
|
|
s->ceilingz = sec->ceilingz;
|
|
|
|
s->floorheinum = sec->floorheinum;
|
|
|
|
s->ceilingheinum = sec->ceilingheinum;
|
|
|
|
}
|
|
|
|
|
|
|
|
floorpicnum = sec->floorpicnum;
|
|
|
|
if (picanm[floorpicnum]&192) floorpicnum += animateoffs(floorpicnum,sectnum);
|
|
|
|
ceilingpicnum = sec->ceilingpicnum;
|
|
|
|
if (picanm[ceilingpicnum]&192) ceilingpicnum += animateoffs(ceilingpicnum,sectnum);
|
|
|
|
|
|
|
|
if ((s->controlstate != 2) && (!needfloor) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(sec->floorstat == s->floorstat) &&
|
|
|
|
(sec->ceilingstat == s->ceilingstat) &&
|
|
|
|
(floorpicnum == s->floorpicnum) &&
|
|
|
|
(ceilingpicnum == s->ceilingpicnum) &&
|
|
|
|
(sec->floorxpanning == s->floorxpanning) &&
|
|
|
|
(sec->ceilingxpanning == s->ceilingxpanning) &&
|
|
|
|
(sec->floorypanning == s->floorypanning) &&
|
|
|
|
(sec->ceilingypanning == s->ceilingypanning))
|
2008-04-02 06:58:26 +00:00
|
|
|
goto attributes;
|
|
|
|
|
|
|
|
wal = &wall[sec->wallptr];
|
|
|
|
i = 0;
|
|
|
|
while (i < sec->wallnum)
|
|
|
|
{
|
2006-09-27 17:55:49 +00:00
|
|
|
j = 2;
|
|
|
|
curstat = sec->floorstat;
|
2008-05-18 07:35:35 +00:00
|
|
|
curbuffer = s->floor.buffer;
|
2008-04-02 06:58:26 +00:00
|
|
|
curpicnum = floorpicnum;
|
2006-09-29 21:36:12 +00:00
|
|
|
curxpanning = sec->floorxpanning;
|
|
|
|
curypanning = sec->floorypanning;
|
2006-09-27 17:55:49 +00:00
|
|
|
|
|
|
|
while (j)
|
|
|
|
{
|
|
|
|
if (j == 1)
|
|
|
|
{
|
|
|
|
curstat = sec->ceilingstat;
|
2008-05-18 07:35:35 +00:00
|
|
|
curbuffer = s->ceil.buffer;
|
2008-04-02 06:58:26 +00:00
|
|
|
curpicnum = ceilingpicnum;
|
2006-09-29 21:36:12 +00:00
|
|
|
curxpanning = sec->ceilingxpanning;
|
|
|
|
curypanning = sec->ceilingypanning;
|
2006-09-27 17:55:49 +00:00
|
|
|
}
|
|
|
|
|
2006-10-16 22:07:15 +00:00
|
|
|
if (!waloff[curpicnum])
|
|
|
|
loadtile(curpicnum);
|
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
if (((sec->floorstat & 64) || (sec->ceilingstat & 64)) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
((secangcos == 2) && (secangsin == 2)))
|
2008-04-02 06:58:26 +00:00
|
|
|
{
|
|
|
|
ang = (getangle(wall[wal->point2].x - wal->x, wall[wal->point2].y - wal->y) + 512) & 2047;
|
|
|
|
secangcos = (float)(sintable[(ang+512)&2047]) / 16383.0f;
|
|
|
|
secangsin = (float)(sintable[ang&2047]) / 16383.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-27 17:55:49 +00:00
|
|
|
tex = (curstat & 64) ? ((wal->x - wall[sec->wallptr].x) * secangsin) + ((-wal->y - -wall[sec->wallptr].y) * secangcos) : wal->x;
|
2006-09-29 21:36:12 +00:00
|
|
|
tey = (curstat & 64) ? ((wal->x - wall[sec->wallptr].x) * secangcos) - ((wall[sec->wallptr].y - wal->y) * secangsin) : -wal->y;
|
2006-09-27 17:55:49 +00:00
|
|
|
|
2008-04-28 08:29:40 +00:00
|
|
|
if ((curstat & (2+64)) == (2+64))
|
|
|
|
{
|
|
|
|
heidiff = curbuffer[(i*5)+1] - curbuffer[1];
|
|
|
|
tey = sqrt((tey * tey) + (heidiff * heidiff));
|
|
|
|
}
|
|
|
|
|
2006-09-27 17:55:49 +00:00
|
|
|
if (curstat & 4)
|
|
|
|
swaplong(&tex, &tey);
|
|
|
|
|
|
|
|
if (curstat & 16) tex = -tex;
|
|
|
|
if (curstat & 32) tey = -tey;
|
|
|
|
|
|
|
|
scalecoef = (curstat & 8) ? 8.0f : 16.0f;
|
|
|
|
|
2008-04-28 08:29:40 +00:00
|
|
|
if (curxpanning)
|
|
|
|
{
|
|
|
|
xpancoef = (float)(pow2long[picsiz[curpicnum] & 15]);
|
|
|
|
xpancoef *= (float)(curxpanning) / (256.0f * (float)(tilesizx[curpicnum]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xpancoef = 0;
|
|
|
|
|
|
|
|
if (curypanning)
|
|
|
|
{
|
|
|
|
ypancoef = (float)(pow2long[picsiz[curpicnum] >> 4]);
|
|
|
|
ypancoef *= (float)(curypanning) / (256.0f * (float)(tilesizy[curpicnum]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ypancoef = 0;
|
|
|
|
|
|
|
|
curbuffer[(i*5)+3] = ((float)(tex) / (scalecoef * tilesizx[curpicnum])) + xpancoef;
|
|
|
|
curbuffer[(i*5)+4] = ((float)(tey) / (scalecoef * tilesizy[curpicnum])) + ypancoef;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
j--;
|
|
|
|
}
|
2008-04-02 06:58:26 +00:00
|
|
|
i++;
|
|
|
|
wal = &wall[sec->wallptr + i];
|
|
|
|
}
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
s->floorstat = sec->floorstat;
|
|
|
|
s->ceilingstat = sec->ceilingstat;
|
|
|
|
s->floorxpanning = sec->floorxpanning;
|
|
|
|
s->ceilingxpanning = sec->ceilingxpanning;
|
|
|
|
s->floorypanning = sec->floorypanning;
|
|
|
|
s->ceilingypanning = sec->ceilingypanning;
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
i = -1;
|
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
attributes:
|
2008-05-24 09:37:09 +00:00
|
|
|
if ((pr_vbos > 0) && ((i == -1) || (wallinvalidate)))
|
2008-05-18 07:35:35 +00:00
|
|
|
{
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->floor.vbo);
|
2008-05-24 09:37:09 +00:00
|
|
|
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, sec->wallnum * sizeof(GLfloat) * 5, s->floor.buffer, mapvbousage);
|
2008-05-18 07:35:35 +00:00
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->ceil.vbo);
|
2008-05-24 09:37:09 +00:00
|
|
|
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, sec->wallnum * sizeof(GLfloat) * 5, s->ceil.buffer, mapvbousage);
|
2008-05-18 07:35:35 +00:00
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
|
|
|
}
|
2008-04-02 06:58:26 +00:00
|
|
|
|
|
|
|
if ((s->controlstate != 2) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(sec->floorshade == s->floorshade) &&
|
|
|
|
(sec->floorpal == s->floorpal) &&
|
|
|
|
(floorpicnum == s->floorpicnum) &&
|
|
|
|
(ceilingpicnum == s->ceilingpicnum))
|
2008-04-02 06:58:26 +00:00
|
|
|
goto finish;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < sec->wallnum)
|
|
|
|
{
|
2006-09-29 21:36:12 +00:00
|
|
|
//attributes
|
|
|
|
j = 2;
|
2008-05-18 07:35:35 +00:00
|
|
|
curbuffer = s->floor.color;
|
2006-09-29 21:36:12 +00:00
|
|
|
curstat = sec->floorshade;
|
|
|
|
curxpanning = sec->floorpal;
|
2008-04-02 06:58:26 +00:00
|
|
|
curpicnum = floorpicnum;
|
2008-05-18 07:35:35 +00:00
|
|
|
curglpic = &s->floor.glpic;
|
|
|
|
curfbglpic = &s->floor.fbglpic;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
while (j > 0)
|
|
|
|
{
|
|
|
|
if (j == 1)
|
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
curbuffer = s->ceil.color;
|
2006-09-29 21:36:12 +00:00
|
|
|
curstat = sec->ceilingshade;
|
|
|
|
curxpanning = sec->ceilingpal;
|
2008-04-02 06:58:26 +00:00
|
|
|
curpicnum = ceilingpicnum;
|
2008-05-18 07:35:35 +00:00
|
|
|
curglpic = &s->ceil.glpic;
|
|
|
|
curfbglpic = &s->ceil.fbglpic;
|
2006-09-29 21:36:12 +00:00
|
|
|
}
|
2006-10-16 22:07:15 +00:00
|
|
|
|
|
|
|
if (!waloff[curpicnum])
|
|
|
|
loadtile(curpicnum);
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
curbuffer[0] = curbuffer[1] = curbuffer[2] = ((float)(numpalookups-min(max(curstat,0),numpalookups)))/((float)numpalookups);
|
|
|
|
curbuffer[3] = 1.0f;
|
|
|
|
|
|
|
|
pth = gltexcache(curpicnum,curxpanning,0);
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (pth && (pth->flags & 2) && (pth->palnum != curxpanning))
|
|
|
|
{
|
2006-09-29 21:36:12 +00:00
|
|
|
curbuffer[0] *= (float)hictinting[curxpanning].r / 255.0;
|
|
|
|
curbuffer[1] *= (float)hictinting[curxpanning].g / 255.0;
|
|
|
|
curbuffer[2] *= (float)hictinting[curxpanning].b / 255.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*curglpic = (pth) ? pth->glpic : 0;
|
2006-09-27 17:55:49 +00:00
|
|
|
|
2006-10-19 23:51:44 +00:00
|
|
|
if (pth && (pth->flags & 16))
|
|
|
|
*curfbglpic = pth->ofb->glpic;
|
|
|
|
else
|
|
|
|
*curfbglpic = 0;
|
|
|
|
|
2006-09-27 17:55:49 +00:00
|
|
|
j--;
|
|
|
|
}
|
|
|
|
|
2006-08-31 01:56:43 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
s->floorshade = sec->floorshade;
|
|
|
|
s->floorpal = sec->floorpal;
|
|
|
|
s->floorpicnum = floorpicnum;
|
|
|
|
s->ceilingpicnum = ceilingpicnum;
|
|
|
|
|
|
|
|
finish:
|
|
|
|
|
2008-03-30 19:13:24 +00:00
|
|
|
if (needfloor)
|
2008-05-18 07:35:35 +00:00
|
|
|
{
|
2006-10-15 18:51:41 +00:00
|
|
|
polymer_buildfloor(sectnum);
|
2008-05-24 09:37:09 +00:00
|
|
|
if ((pr_vbos > 0)) {
|
|
|
|
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->floor.ivbo);
|
|
|
|
bglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->indicescount * sizeof(GLushort), s->floor.indices, mapvbousage);
|
|
|
|
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->ceil.ivbo);
|
|
|
|
bglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->indicescount * sizeof(GLushort), s->ceil.indices, mapvbousage);
|
|
|
|
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
|
|
|
}
|
2008-05-18 07:35:35 +00:00
|
|
|
}
|
2008-03-30 19:13:24 +00:00
|
|
|
|
2008-04-02 06:58:26 +00:00
|
|
|
if (wallinvalidate)
|
2008-04-06 23:35:48 +00:00
|
|
|
{
|
2008-04-02 08:49:21 +00:00
|
|
|
s->invalidid++;
|
2008-05-18 07:35:35 +00:00
|
|
|
polymer_buffertoplane(s->floor.buffer, s->floor.indices, s->indicescount, s->floor.plane);
|
|
|
|
polymer_buffertoplane(s->ceil.buffer, s->ceil.indices, s->indicescount, s->ceil.plane);
|
2008-04-06 23:35:48 +00:00
|
|
|
}
|
2008-04-02 08:49:21 +00:00
|
|
|
|
|
|
|
s->controlstate = 1;
|
2006-10-15 18:51:41 +00:00
|
|
|
|
2006-08-31 01:56:43 +00:00
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Updated sector %i.\n", sectnum);
|
|
|
|
|
2006-09-27 17:55:49 +00:00
|
|
|
return (0);
|
2006-08-31 01:56:43 +00:00
|
|
|
}
|
|
|
|
|
2006-09-17 20:16:20 +00:00
|
|
|
void PR_CALLBACK polymer_tesserror(GLenum error)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
// This callback is called by the tesselator whenever it raises an error.
|
2007-01-16 03:19:04 +00:00
|
|
|
if (pr_verbosity >= 1) OSD_Printf("PR : Tesselation error number %i reported : %s.\n", error, bgluErrorString(errno));
|
2006-08-31 01:56:43 +00:00
|
|
|
}
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
void PR_CALLBACK polymer_tessedgeflag(GLenum error)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
// Passing an edgeflag callback forces the tesselator to output a triangle list
|
2008-03-25 09:21:18 +00:00
|
|
|
UNREFERENCED_PARAMETER(error);
|
2006-09-29 21:36:12 +00:00
|
|
|
return;
|
2006-09-27 17:55:49 +00:00
|
|
|
}
|
|
|
|
|
2006-09-27 02:23:27 +00:00
|
|
|
void PR_CALLBACK polymer_tessvertex(void* vertex, void* sector)
|
|
|
|
{
|
|
|
|
_prsector* s;
|
|
|
|
|
|
|
|
s = (_prsector*)sector;
|
|
|
|
|
2006-09-27 17:55:49 +00:00
|
|
|
if (s->curindice >= s->indicescount)
|
|
|
|
{
|
|
|
|
if (pr_verbosity >= 2) OSD_Printf("PR : Indice overflow, extending the indices list... !\n");
|
|
|
|
s->indicescount++;
|
2008-05-18 07:35:35 +00:00
|
|
|
s->floor.indices = realloc(s->floor.indices, s->indicescount * sizeof(GLushort));
|
|
|
|
s->ceil.indices = realloc(s->ceil.indices, s->indicescount * sizeof(GLushort));
|
2006-09-27 17:55:49 +00:00
|
|
|
}
|
2008-05-18 07:35:35 +00:00
|
|
|
s->ceil.indices[s->curindice] = (int)vertex;
|
2006-09-27 02:23:27 +00:00
|
|
|
s->curindice++;
|
|
|
|
}
|
2008-03-14 12:19:13 +00:00
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
static int polymer_buildfloor(short sectnum)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
|
|
|
// This function tesselates the floor/ceiling of a sector and stores the triangles in a display list.
|
2006-09-29 21:36:12 +00:00
|
|
|
_prsector* s;
|
|
|
|
sectortype *sec;
|
|
|
|
int i;
|
2006-08-31 01:56:43 +00:00
|
|
|
|
2008-04-12 08:16:01 +00:00
|
|
|
if (pr_verbosity >= 2) OSD_Printf("PR : Tesselating floor of sector %i...\n", sectnum);
|
2006-08-31 01:56:43 +00:00
|
|
|
|
|
|
|
s = prsectors[sectnum];
|
|
|
|
sec = §or[sectnum];
|
|
|
|
|
|
|
|
if (s == NULL)
|
|
|
|
return (-1);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (s->floor.indices == NULL)
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
|
|
|
s->indicescount = (sec->wallnum - 2) * 3;
|
2008-05-18 07:35:35 +00:00
|
|
|
s->floor.indices = calloc(s->indicescount, sizeof(GLushort));
|
|
|
|
s->ceil.indices = calloc(s->indicescount, sizeof(GLushort));
|
2006-09-29 21:36:12 +00:00
|
|
|
}
|
2006-09-27 02:23:27 +00:00
|
|
|
|
|
|
|
s->curindice = 0;
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2007-01-16 03:19:04 +00:00
|
|
|
bgluTessCallback(prtess, GLU_TESS_VERTEX_DATA, polymer_tessvertex);
|
|
|
|
bgluTessCallback(prtess, GLU_TESS_EDGE_FLAG, polymer_tessedgeflag);
|
|
|
|
bgluTessCallback(prtess, GLU_TESS_ERROR, polymer_tesserror);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2007-01-16 03:19:04 +00:00
|
|
|
bgluTessProperty(prtess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2007-01-16 03:19:04 +00:00
|
|
|
bgluTessBeginPolygon(prtess, s);
|
|
|
|
bgluTessBeginContour(prtess);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < sec->wallnum)
|
|
|
|
{
|
2007-01-16 03:19:04 +00:00
|
|
|
bgluTessVertex(prtess, s->verts + (3 * i), (void *)i);
|
2006-09-27 02:23:27 +00:00
|
|
|
if ((i != (sec->wallnum - 1)) && ((sec->wallptr + i) > wall[sec->wallptr + i].point2))
|
2006-08-30 23:32:39 +00:00
|
|
|
{
|
2007-01-16 03:19:04 +00:00
|
|
|
bgluTessEndContour(prtess);
|
|
|
|
bgluTessBeginContour(prtess);
|
2006-08-30 23:32:39 +00:00
|
|
|
}
|
2006-08-31 01:56:43 +00:00
|
|
|
i++;
|
2006-08-30 23:32:39 +00:00
|
|
|
}
|
2007-01-16 03:19:04 +00:00
|
|
|
bgluTessEndContour(prtess);
|
|
|
|
bgluTessEndPolygon(prtess);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2006-10-04 09:54:25 +00:00
|
|
|
i = 0;
|
|
|
|
while (i < s->indicescount)
|
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
s->floor.indices[s->indicescount - i - 1] = s->ceil.indices[i];
|
2006-10-04 09:54:25 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2006-08-31 01:56:43 +00:00
|
|
|
if (pr_verbosity >= 2) OSD_Printf("PR : Tesselated floor of sector %i.\n", sectnum);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
|
|
|
return (1);
|
2006-08-31 01:56:43 +00:00
|
|
|
}
|
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
static void polymer_drawsector(short sectnum)
|
2006-08-31 01:56:43 +00:00
|
|
|
{
|
2008-03-25 09:21:18 +00:00
|
|
|
sectortype *sec;
|
2006-09-29 21:36:12 +00:00
|
|
|
_prsector* s;
|
2006-08-31 01:56:43 +00:00
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Drawing sector %i...\n", sectnum);
|
2006-08-31 01:56:43 +00:00
|
|
|
|
|
|
|
sec = §or[sectnum];
|
2006-09-29 21:36:12 +00:00
|
|
|
s = prsectors[sectnum];
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
if (!(sec->floorstat & 1) && (mirrorfrom[depth] != -2))
|
2008-05-18 07:35:35 +00:00
|
|
|
polymer_drawplane(sectnum, -2, &s->floor, s->indicescount);
|
2008-04-09 07:27:17 +00:00
|
|
|
if (!(sec->ceilingstat & 1) && (mirrorfrom[depth] != -1))
|
2008-05-18 07:35:35 +00:00
|
|
|
polymer_drawplane(sectnum, -1, &s->ceil, s->indicescount);
|
2008-03-26 12:04:00 +00:00
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Finished drawing sector %i...\n", sectnum);
|
|
|
|
}
|
|
|
|
|
2006-10-15 18:51:41 +00:00
|
|
|
// WALLS
|
2008-04-02 09:29:58 +00:00
|
|
|
static int polymer_initwall(short wallnum)
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
|
|
|
_prwall *w;
|
|
|
|
|
|
|
|
if (pr_verbosity >= 2) OSD_Printf("PR : Initalizing wall %i...\n", wallnum);
|
|
|
|
|
2008-04-02 08:49:21 +00:00
|
|
|
w = calloc(1, sizeof(_prwall));
|
2006-09-29 21:36:12 +00:00
|
|
|
if (w == NULL)
|
|
|
|
{
|
|
|
|
if (pr_verbosity >= 1) OSD_Printf("PR : Cannot initialize wall %i : malloc failed.\n", wallnum);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (w->mask.buffer == NULL)
|
|
|
|
w->mask.buffer = calloc(4, sizeof(GLfloat) * 5);
|
2008-04-04 07:28:25 +00:00
|
|
|
if (w->bigportal == NULL)
|
|
|
|
w->bigportal = calloc(4, sizeof(GLfloat) * 3);
|
2008-04-12 08:16:01 +00:00
|
|
|
if (w->cap == NULL)
|
|
|
|
w->cap = calloc(4, sizeof(GLfloat) * 3);
|
2008-04-04 07:28:25 +00:00
|
|
|
|
2008-05-24 09:37:09 +00:00
|
|
|
bglGenBuffersARB(1, &w->wall.vbo);
|
|
|
|
bglGenBuffersARB(1, &w->over.vbo);
|
|
|
|
bglGenBuffersARB(1, &w->mask.vbo);
|
|
|
|
|
|
|
|
bglGenBuffersARB(1, &w->stuffvbo);
|
|
|
|
|
2008-04-02 08:49:21 +00:00
|
|
|
w->controlstate = 2;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
prwalls[wallnum] = w;
|
|
|
|
|
|
|
|
if (pr_verbosity >= 2) OSD_Printf("PR : Initalized wall %i.\n", wallnum);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
static void polymer_updatewall(short wallnum)
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
2008-04-02 08:49:21 +00:00
|
|
|
short nwallnum, nnwallnum, curpicnum, wallpicnum, walloverpicnum, nwallpicnum;
|
2008-04-29 04:46:06 +00:00
|
|
|
char curxpanning, curypanning, underwall, overwall, curpal;
|
|
|
|
signed char curshade;
|
2006-09-29 21:36:12 +00:00
|
|
|
walltype *wal;
|
|
|
|
sectortype *sec, *nsec;
|
|
|
|
_prwall *w;
|
|
|
|
_prsector *s, *ns;
|
|
|
|
pthtyp* pth;
|
2008-03-25 09:21:18 +00:00
|
|
|
int xref, yref;
|
2006-10-17 01:14:20 +00:00
|
|
|
float ypancoef, dist;
|
2006-09-29 21:36:12 +00:00
|
|
|
int i;
|
2008-04-02 08:49:21 +00:00
|
|
|
unsigned int invalid;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-04-04 07:28:25 +00:00
|
|
|
// yes, this function is messy and unefficient
|
|
|
|
// it also works, bitches
|
2006-09-29 21:36:12 +00:00
|
|
|
wal = &wall[wallnum];
|
2008-04-02 08:49:21 +00:00
|
|
|
nwallnum = wal->nextwall;
|
2006-09-29 21:36:12 +00:00
|
|
|
sec = §or[sectorofwall(wallnum)];
|
|
|
|
w = prwalls[wallnum];
|
|
|
|
s = prsectors[sectorofwall(wallnum)];
|
2008-04-02 08:49:21 +00:00
|
|
|
invalid = s->invalidid;
|
|
|
|
if (nwallnum != -1)
|
|
|
|
{
|
|
|
|
ns = prsectors[wal->nextsector];
|
|
|
|
invalid += ns->invalidid;
|
2008-04-03 06:58:36 +00:00
|
|
|
nsec = §or[wal->nextsector];
|
2008-04-02 08:49:21 +00:00
|
|
|
}
|
|
|
|
else
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
2008-04-02 08:49:21 +00:00
|
|
|
ns = NULL;
|
2008-04-06 03:00:39 +00:00
|
|
|
nsec = NULL;
|
|
|
|
}
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (w->wall.buffer == NULL)
|
|
|
|
w->wall.buffer = calloc(4, sizeof(GLfloat) * 5);
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-04-02 08:49:21 +00:00
|
|
|
wallpicnum = wal->picnum;
|
|
|
|
if (picanm[wallpicnum]&192) wallpicnum += animateoffs(wallpicnum,wallnum+16384);
|
|
|
|
walloverpicnum = wal->overpicnum;
|
|
|
|
if (picanm[walloverpicnum]&192) walloverpicnum += animateoffs(walloverpicnum,wallnum+16384);
|
|
|
|
if (nwallnum != -1)
|
|
|
|
{
|
|
|
|
nwallpicnum = wall[nwallnum].picnum;
|
|
|
|
if (picanm[nwallpicnum]&192) nwallpicnum += animateoffs(nwallpicnum,wallnum+16384);
|
|
|
|
}
|
2008-04-06 03:00:39 +00:00
|
|
|
else
|
|
|
|
nwallpicnum = 0;
|
2008-04-02 08:49:21 +00:00
|
|
|
|
|
|
|
if ((w->controlstate != 2) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(w->invalidid == invalid) &&
|
|
|
|
(wal->cstat == w->cstat) &&
|
|
|
|
(wallpicnum == w->picnum) &&
|
|
|
|
(wal->pal == w->pal) &&
|
|
|
|
(wal->xpanning == w->xpanning) &&
|
|
|
|
(wal->ypanning == w->ypanning) &&
|
|
|
|
(wal->xrepeat == w->xrepeat) &&
|
|
|
|
(wal->yrepeat == w->yrepeat) &&
|
|
|
|
(walloverpicnum == w->overpicnum) &&
|
|
|
|
(wal->shade == w->shade) &&
|
|
|
|
((nwallnum == -1) ||
|
|
|
|
((nwallpicnum == w->nwallpicnum) &&
|
|
|
|
(wall[nwallnum].xpanning == w->nwallxpanning) &&
|
|
|
|
(wall[nwallnum].ypanning == w->nwallypanning) &&
|
|
|
|
(wall[nwallnum].cstat == w->nwallcstat))))
|
2008-04-02 08:49:21 +00:00
|
|
|
{
|
|
|
|
w->controlstate = 1;
|
|
|
|
return; // screw you guys I'm going home
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w->invalidid = invalid;
|
|
|
|
w->cstat = wal->cstat;
|
|
|
|
w->picnum = wallpicnum;
|
|
|
|
w->pal = wal->pal;
|
|
|
|
w->xpanning = wal->xpanning;
|
|
|
|
w->ypanning = wal->ypanning;
|
|
|
|
w->xrepeat = wal->xrepeat;
|
|
|
|
w->yrepeat = wal->yrepeat;
|
|
|
|
w->overpicnum = walloverpicnum;
|
|
|
|
w->shade = wal->shade;
|
|
|
|
if (nwallnum != -1)
|
|
|
|
{
|
|
|
|
w->nwallpicnum = nwallpicnum;
|
|
|
|
w->nwallxpanning = wall[nwallnum].xpanning;
|
|
|
|
w->nwallypanning = wall[nwallnum].ypanning;
|
|
|
|
w->nwallcstat = wall[nwallnum].cstat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-03 06:58:36 +00:00
|
|
|
w->underover = underwall = overwall = 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
if (wal->cstat & 8)
|
2006-10-17 01:14:20 +00:00
|
|
|
xref = 1;
|
2006-09-29 21:36:12 +00:00
|
|
|
else
|
2006-10-17 01:14:20 +00:00
|
|
|
xref = 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-04-03 06:58:36 +00:00
|
|
|
if ((wal->nextsector == -1) || (wal->cstat & 32))
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(w->wall.buffer, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->wall.buffer[5], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->wall.buffer[10], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->wall.buffer[15], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-04-02 08:49:21 +00:00
|
|
|
curpicnum = wallpicnum;
|
2006-10-16 22:07:15 +00:00
|
|
|
|
|
|
|
if (!waloff[curpicnum])
|
|
|
|
loadtile(curpicnum);
|
|
|
|
|
|
|
|
pth = gltexcache(curpicnum, wal->pal, 0);
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.glpic = pth ? pth->glpic : 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2006-10-19 23:51:44 +00:00
|
|
|
if (pth && (pth->flags & 16))
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.fbglpic = pth->ofb->glpic;
|
2006-10-19 23:51:44 +00:00
|
|
|
else
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.fbglpic = 0;
|
2006-10-19 23:51:44 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.color[0] = w->wall.color[1] = w->wall.color[2] =
|
2008-05-10 01:29:37 +00:00
|
|
|
((float)(numpalookups-min(max(wal->shade,0),numpalookups)))/((float)numpalookups);
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.color[3] = 1.0f;
|
2008-04-29 04:46:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (pth && (pth->flags & 2) && (pth->palnum != wal->pal))
|
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.color[0] *= (float)hictinting[wal->pal].r / 255.0;
|
|
|
|
w->wall.color[1] *= (float)hictinting[wal->pal].g / 255.0;
|
|
|
|
w->wall.color[2] *= (float)hictinting[wal->pal].b / 255.0;
|
2006-08-31 01:56:43 +00:00
|
|
|
}
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
if (wal->cstat & 4)
|
2006-11-13 23:12:47 +00:00
|
|
|
yref = sec->floorz;
|
2006-08-31 01:56:43 +00:00
|
|
|
else
|
2006-09-29 21:36:12 +00:00
|
|
|
yref = sec->ceilingz;
|
|
|
|
|
2008-04-03 06:58:36 +00:00
|
|
|
if ((wal->cstat & 32) && (wal->nextsector != -1))
|
|
|
|
{
|
|
|
|
if ((!(wal->cstat & 2) && (wal->cstat & 4)) || ((wal->cstat & 2) && (wall[nwallnum].cstat & 4)))
|
|
|
|
yref = sec->ceilingz;
|
|
|
|
else
|
|
|
|
yref = nsec->floorz;
|
|
|
|
}
|
|
|
|
|
2006-10-16 22:07:15 +00:00
|
|
|
if (wal->ypanning)
|
|
|
|
{
|
|
|
|
ypancoef = (float)(pow2long[picsiz[curpicnum] >> 4]);
|
|
|
|
if (ypancoef < tilesizy[curpicnum])
|
|
|
|
ypancoef *= 2;
|
|
|
|
ypancoef *= (float)(wal->ypanning) / (256.0f * (float)(tilesizy[curpicnum]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ypancoef = 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < 4)
|
|
|
|
{
|
2006-10-17 01:14:20 +00:00
|
|
|
if ((i == 0) || (i == 3))
|
|
|
|
dist = xref;
|
|
|
|
else
|
|
|
|
dist = (xref == 0);
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]);
|
|
|
|
w->wall.buffer[(i * 5) + 4] = (-(float)(yref + (w->wall.buffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (wal->cstat & 256) w->wall.buffer[(i * 5) + 4] = -w->wall.buffer[(i * 5) + 4];
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
w->underover |= 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nnwallnum = wall[nwallnum].point2;
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (((s->floor.buffer[((wallnum - sec->wallptr) * 5) + 1] != ns->floor.buffer[((nnwallnum - nsec->wallptr) * 5) + 1]) ||
|
|
|
|
(s->floor.buffer[((wal->point2 - sec->wallptr) * 5) + 1] != ns->floor.buffer[((nwallnum - nsec->wallptr) * 5) + 1])) &&
|
|
|
|
((s->floor.buffer[((wallnum - sec->wallptr) * 5) + 1] <= ns->floor.buffer[((nnwallnum - nsec->wallptr) * 5) + 1]) ||
|
|
|
|
(s->floor.buffer[((wal->point2 - sec->wallptr) * 5) + 1] <= ns->floor.buffer[((nwallnum - nsec->wallptr) * 5) + 1])))
|
2008-04-03 06:58:36 +00:00
|
|
|
underwall = 1;
|
|
|
|
|
|
|
|
if ((underwall) || (wal->cstat & 16))
|
2006-08-31 01:56:43 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(w->wall.buffer, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->wall.buffer[5], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->wall.buffer[10], &ns->floor.buffer[(nwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->wall.buffer[15], &ns->floor.buffer[(nnwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2006-10-16 22:07:15 +00:00
|
|
|
if (wal->cstat & 2)
|
2006-10-17 01:14:20 +00:00
|
|
|
{
|
2008-04-02 08:49:21 +00:00
|
|
|
curpicnum = nwallpicnum;
|
2008-04-29 04:46:06 +00:00
|
|
|
curpal = wall[nwallnum].pal;
|
|
|
|
curshade = wall[nwallnum].shade;
|
2006-10-17 01:14:20 +00:00
|
|
|
curxpanning = wall[nwallnum].xpanning;
|
|
|
|
curypanning = wall[nwallnum].ypanning;
|
|
|
|
}
|
2006-10-16 22:07:15 +00:00
|
|
|
else
|
2006-10-17 01:14:20 +00:00
|
|
|
{
|
2008-04-02 08:49:21 +00:00
|
|
|
curpicnum = wallpicnum;
|
2008-04-29 04:46:06 +00:00
|
|
|
curpal = wal->pal;
|
|
|
|
curshade = wal->shade;
|
2006-10-17 01:14:20 +00:00
|
|
|
curxpanning = wal->xpanning;
|
|
|
|
curypanning = wal->ypanning;
|
|
|
|
}
|
2006-10-16 22:07:15 +00:00
|
|
|
|
|
|
|
if (!waloff[curpicnum])
|
|
|
|
loadtile(curpicnum);
|
|
|
|
|
2008-04-29 04:46:06 +00:00
|
|
|
pth = gltexcache(curpicnum, curpal, 0);
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.glpic = pth ? pth->glpic : 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2006-10-19 23:51:44 +00:00
|
|
|
if (pth && (pth->flags & 16))
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.fbglpic = pth->ofb->glpic;
|
2006-10-19 23:51:44 +00:00
|
|
|
else
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.fbglpic = 0;
|
2006-10-19 23:51:44 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.color[0] = w->wall.color[1] = w->wall.color[2] =
|
2008-05-10 01:29:37 +00:00
|
|
|
((float)(numpalookups-min(max(curshade,0),numpalookups)))/((float)numpalookups);
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.color[3] = 1.0f;
|
2008-04-29 04:46:06 +00:00
|
|
|
|
|
|
|
if (pth && (pth->flags & 2) && (pth->palnum != curpal))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.color[0] *= (float)hictinting[curpal].r / 255.0;
|
|
|
|
w->wall.color[1] *= (float)hictinting[curpal].g / 255.0;
|
|
|
|
w->wall.color[2] *= (float)hictinting[curpal].b / 255.0;
|
2006-08-31 01:56:43 +00:00
|
|
|
}
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2006-10-17 01:14:20 +00:00
|
|
|
if ((!(wal->cstat & 2) && (wal->cstat & 4)) || ((wal->cstat & 2) && (wall[nwallnum].cstat & 4)))
|
2006-11-13 23:12:47 +00:00
|
|
|
yref = sec->ceilingz;
|
2006-09-29 21:36:12 +00:00
|
|
|
else
|
|
|
|
yref = nsec->floorz;
|
|
|
|
|
2006-10-17 01:14:20 +00:00
|
|
|
if (curypanning)
|
2006-10-16 22:07:15 +00:00
|
|
|
{
|
|
|
|
ypancoef = (float)(pow2long[picsiz[curpicnum] >> 4]);
|
|
|
|
if (ypancoef < tilesizy[curpicnum])
|
|
|
|
ypancoef *= 2;
|
2006-10-17 01:14:20 +00:00
|
|
|
ypancoef *= (float)(curypanning) / (256.0f * (float)(tilesizy[curpicnum]));
|
2006-10-16 22:07:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ypancoef = 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < 4)
|
|
|
|
{
|
2006-10-17 01:14:20 +00:00
|
|
|
if ((i == 0) || (i == 3))
|
|
|
|
dist = xref;
|
|
|
|
else
|
|
|
|
dist = (xref == 0);
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
w->wall.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + curxpanning) / (float)(tilesizx[curpicnum]);
|
|
|
|
w->wall.buffer[(i * 5) + 4] = (-(float)(yref + (w->wall.buffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (wal->cstat & 256) w->wall.buffer[(i * 5) + 4] = -w->wall.buffer[(i * 5) + 4];
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
i++;
|
2006-08-31 01:56:43 +00:00
|
|
|
}
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-04-03 06:58:36 +00:00
|
|
|
if (underwall)
|
|
|
|
{
|
|
|
|
w->underover |= 1;
|
|
|
|
if ((sec->floorstat & 1) && (nsec->floorstat & 1))
|
|
|
|
w->underover |= 4;
|
|
|
|
}
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(w->mask.buffer, &w->wall.buffer[15], sizeof(GLfloat) * 5);
|
|
|
|
memcpy(&w->mask.buffer[5], &w->wall.buffer[10], sizeof(GLfloat) * 5);
|
2008-04-04 07:28:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(w->mask.buffer, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 5);
|
|
|
|
memcpy(&w->mask.buffer[5], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 5);
|
2006-08-31 01:56:43 +00:00
|
|
|
}
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (((s->ceil.buffer[((wallnum - sec->wallptr) * 5) + 1] != ns->ceil.buffer[((nnwallnum - nsec->wallptr) * 5) + 1]) ||
|
|
|
|
(s->ceil.buffer[((wal->point2 - sec->wallptr) * 5) + 1] != ns->ceil.buffer[((nwallnum - nsec->wallptr) * 5) + 1])) &&
|
|
|
|
((s->ceil.buffer[((wallnum - sec->wallptr) * 5) + 1] >= ns->ceil.buffer[((nnwallnum - nsec->wallptr) * 5) + 1]) ||
|
|
|
|
(s->ceil.buffer[((wal->point2 - sec->wallptr) * 5) + 1] >= ns->ceil.buffer[((nwallnum - nsec->wallptr) * 5) + 1])))
|
2008-04-03 06:58:36 +00:00
|
|
|
overwall = 1;
|
|
|
|
|
|
|
|
if ((overwall) || (wal->cstat & 16))
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
if (w->over.buffer == NULL)
|
|
|
|
w->over.buffer = calloc(4, sizeof(GLfloat) * 5);
|
2006-08-31 01:56:43 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(w->over.buffer, &ns->ceil.buffer[(nnwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->over.buffer[5], &ns->ceil.buffer[(nwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->over.buffer[10], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->over.buffer[15], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2006-10-16 22:07:15 +00:00
|
|
|
if ((wal->cstat & 16) || (wal->overpicnum == 0))
|
2008-04-02 08:49:21 +00:00
|
|
|
curpicnum = wallpicnum;
|
2006-10-16 22:07:15 +00:00
|
|
|
else
|
2008-04-02 08:49:21 +00:00
|
|
|
curpicnum = wallpicnum;
|
2006-10-16 22:07:15 +00:00
|
|
|
|
|
|
|
if (!waloff[curpicnum])
|
|
|
|
loadtile(curpicnum);
|
|
|
|
|
2008-04-03 06:58:36 +00:00
|
|
|
if (wal->cstat & 16)
|
|
|
|
{
|
2008-04-04 07:28:25 +00:00
|
|
|
// mask glpic and color
|
2008-04-03 06:58:36 +00:00
|
|
|
if (!waloff[wal->overpicnum])
|
|
|
|
loadtile(wal->overpicnum);
|
|
|
|
|
|
|
|
pth = gltexcache(wal->overpicnum, wal->pal, 0);
|
2008-05-18 07:35:35 +00:00
|
|
|
w->mask.glpic = pth ? pth->glpic : 0;
|
2008-04-03 06:58:36 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
w->mask.color[0] = w->mask.color[1] = w->mask.color[2] =
|
2008-05-10 01:29:37 +00:00
|
|
|
((float)(numpalookups-min(max(wal->shade,0),numpalookups)))/((float)numpalookups);
|
2008-05-18 07:35:35 +00:00
|
|
|
w->mask.color[3] = 1.0f;
|
2008-04-04 07:28:25 +00:00
|
|
|
|
|
|
|
if (pth && (pth->flags & 2) && (pth->palnum != wal->pal))
|
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
w->mask.color[0] *= (float)hictinting[wal->pal].r / 255.0;
|
|
|
|
w->mask.color[1] *= (float)hictinting[wal->pal].g / 255.0;
|
|
|
|
w->mask.color[2] *= (float)hictinting[wal->pal].b / 255.0;
|
2008-04-04 07:28:25 +00:00
|
|
|
}
|
|
|
|
if (wal->cstat & 128)
|
|
|
|
{
|
|
|
|
if (wal->cstat & 512)
|
2008-05-18 07:35:35 +00:00
|
|
|
w->mask.color[3] = 0.33f;
|
2008-04-04 07:28:25 +00:00
|
|
|
else
|
2008-05-18 07:35:35 +00:00
|
|
|
w->mask.color[3] = 0.66f;
|
2008-04-04 07:28:25 +00:00
|
|
|
}
|
|
|
|
else
|
2008-05-18 07:35:35 +00:00
|
|
|
w->mask.color[3] = 1.0f;
|
2008-04-03 06:58:36 +00:00
|
|
|
}
|
|
|
|
|
2006-10-16 22:07:15 +00:00
|
|
|
pth = gltexcache(curpicnum, wal->pal, 0);
|
2008-05-18 07:35:35 +00:00
|
|
|
w->over.glpic = pth ? pth->glpic : 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2006-10-19 23:51:44 +00:00
|
|
|
if (pth && (pth->flags & 16))
|
2008-05-18 07:35:35 +00:00
|
|
|
w->over.fbglpic = pth->ofb->glpic;
|
2006-10-19 23:51:44 +00:00
|
|
|
else
|
2008-05-18 07:35:35 +00:00
|
|
|
w->over.fbglpic = 0;
|
2006-10-19 23:51:44 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
w->over.color[0] = w->over.color[1] = w->over.color[2] =
|
2008-05-10 01:29:37 +00:00
|
|
|
((float)(numpalookups-min(max(wal->shade,0),numpalookups)))/((float)numpalookups);
|
2008-05-18 07:35:35 +00:00
|
|
|
w->over.color[3] = 1.0f;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (pth && (pth->flags & 2) && (pth->palnum != wal->pal))
|
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
w->over.color[0] *= (float)hictinting[wal->pal].r / 255.0;
|
|
|
|
w->over.color[1] *= (float)hictinting[wal->pal].g / 255.0;
|
|
|
|
w->over.color[2] *= (float)hictinting[wal->pal].b / 255.0;
|
2006-09-29 21:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (wal->cstat & 4)
|
2006-11-13 23:12:47 +00:00
|
|
|
yref = sec->ceilingz;
|
2006-09-29 21:36:12 +00:00
|
|
|
else
|
|
|
|
yref = nsec->ceilingz;
|
|
|
|
|
2006-10-16 22:07:15 +00:00
|
|
|
if (wal->ypanning)
|
|
|
|
{
|
|
|
|
ypancoef = (float)(pow2long[picsiz[curpicnum] >> 4]);
|
|
|
|
if (ypancoef < tilesizy[curpicnum])
|
|
|
|
ypancoef *= 2;
|
|
|
|
ypancoef *= (float)(wal->ypanning) / (256.0f * (float)(tilesizy[curpicnum]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ypancoef = 0;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < 4)
|
|
|
|
{
|
2006-10-17 01:14:20 +00:00
|
|
|
if ((i == 0) || (i == 3))
|
|
|
|
dist = xref;
|
|
|
|
else
|
|
|
|
dist = (xref == 0);
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
w->over.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]);
|
|
|
|
w->over.buffer[(i * 5) + 4] = (-(float)(yref + (w->over.buffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (wal->cstat & 256) w->over.buffer[(i * 5) + 4] = -w->over.buffer[(i * 5) + 4];
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2008-04-03 06:58:36 +00:00
|
|
|
if (overwall)
|
|
|
|
{
|
|
|
|
w->underover |= 2;
|
|
|
|
if ((sec->ceilingstat & 1) && (nsec->ceilingstat & 1))
|
|
|
|
w->underover |= 8;
|
|
|
|
}
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(&w->mask.buffer[10], &w->over.buffer[5], sizeof(GLfloat) * 5);
|
|
|
|
memcpy(&w->mask.buffer[15], &w->over.buffer[0], sizeof(GLfloat) * 5);
|
2008-04-04 07:28:25 +00:00
|
|
|
|
|
|
|
if (wal->cstat & 16)
|
|
|
|
{
|
|
|
|
// mask wall pass
|
|
|
|
if (wal->cstat & 4)
|
|
|
|
yref = min(sec->floorz, nsec->floorz);
|
|
|
|
else
|
|
|
|
yref = max(sec->ceilingz, nsec->ceilingz);
|
|
|
|
|
|
|
|
curpicnum = wal->overpicnum;
|
|
|
|
|
|
|
|
if (wal->ypanning)
|
|
|
|
{
|
|
|
|
ypancoef = (float)(pow2long[picsiz[curpicnum] >> 4]);
|
|
|
|
if (ypancoef < tilesizy[curpicnum])
|
|
|
|
ypancoef *= 2;
|
|
|
|
ypancoef *= (float)(wal->ypanning) / (256.0f * (float)(tilesizy[curpicnum]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ypancoef = 0;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < 4)
|
|
|
|
{
|
|
|
|
if ((i == 0) || (i == 3))
|
|
|
|
dist = xref;
|
|
|
|
else
|
|
|
|
dist = (xref == 0);
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
w->mask.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]);
|
|
|
|
w->mask.buffer[(i * 5) + 4] = (-(float)(yref + (w->mask.buffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
2008-04-04 07:28:25 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
if (wal->cstat & 256) w->mask.buffer[(i * 5) + 4] = -w->mask.buffer[(i * 5) + 4];
|
2008-04-04 07:28:25 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2008-04-03 06:58:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(&w->mask.buffer[10], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 5);
|
|
|
|
memcpy(&w->mask.buffer[15], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 5);
|
2008-04-03 06:58:36 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-15 18:51:41 +00:00
|
|
|
|
2008-04-04 07:28:25 +00:00
|
|
|
if ((wal->nextsector == -1) || (wal->cstat & 32))
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(w->mask.buffer, w->wall.buffer, sizeof(GLfloat) * 4 * 5);
|
2008-04-04 07:28:25 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(w->bigportal, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->bigportal[3], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->bigportal[6], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->bigportal[9], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
2006-10-15 18:51:41 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
memcpy(&w->cap[0], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->cap[3], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->cap[6], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
|
|
|
memcpy(&w->cap[9], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
2008-04-12 08:16:01 +00:00
|
|
|
w->cap[7] += 1048576; // this number is the result of 1048574 + 2
|
|
|
|
w->cap[10] += 1048576; // this one is arbitrary
|
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
polymer_buffertoplane(w->bigportal, NULL, 4, w->wall.plane);
|
|
|
|
memcpy(w->over.plane, w->wall.plane, sizeof(w->wall.plane));
|
|
|
|
memcpy(w->mask.plane, w->wall.plane, sizeof(w->wall.plane));
|
2008-04-09 07:59:37 +00:00
|
|
|
|
2008-05-24 09:37:09 +00:00
|
|
|
if ((pr_vbos > 0))
|
|
|
|
{
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->wall.vbo);
|
|
|
|
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, w->wall.buffer, mapvbousage);
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->over.vbo);
|
|
|
|
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, w->over.buffer, mapvbousage);
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->mask.vbo);
|
|
|
|
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, w->mask.buffer, mapvbousage);
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo);
|
|
|
|
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 8 * sizeof(GLfloat) * 3, NULL, mapvbousage);
|
|
|
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat) * 3, w->bigportal);
|
|
|
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 3, 4 * sizeof(GLfloat) * 3, w->cap);
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
|
|
|
}
|
|
|
|
|
2008-03-30 19:13:24 +00:00
|
|
|
w->controlstate = 1;
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Updated wall %i.\n", wallnum);
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
static void polymer_drawwall(short sectnum, short wallnum)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2006-09-29 21:36:12 +00:00
|
|
|
_prwall *w;
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Drawing wall %i...\n", wallnum);
|
2006-08-29 01:58:59 +00:00
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
w = prwalls[wallnum];
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
if ((w->underover & 1) && !(w->underover & 4))
|
2006-08-29 01:58:59 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
polymer_drawplane(sectnum, wallnum, &w->wall, 0);
|
2006-09-29 21:36:12 +00:00
|
|
|
}
|
2008-03-26 12:04:00 +00:00
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
if ((w->underover & 2) && !(w->underover & 8))
|
2006-09-29 21:36:12 +00:00
|
|
|
{
|
2008-05-18 07:35:35 +00:00
|
|
|
polymer_drawplane(sectnum, wallnum, &w->over, 0);
|
2006-08-29 01:58:59 +00:00
|
|
|
}
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2008-04-12 08:16:01 +00:00
|
|
|
if ((sector[sectnum].ceilingstat & 1) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
((wall[wallnum].nextsector == -1) ||
|
|
|
|
!(sector[wall[wallnum].nextsector].ceilingstat & 1)))
|
2008-04-12 08:16:01 +00:00
|
|
|
{
|
|
|
|
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
2008-05-24 09:37:09 +00:00
|
|
|
|
|
|
|
if (pr_vbos)
|
|
|
|
{
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo);
|
|
|
|
bglVertexPointer(3, GL_FLOAT, 0, (const GLvoid*)(4 * sizeof(GLfloat) * 3));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bglVertexPointer(3, GL_FLOAT, 0, w->cap);
|
|
|
|
|
2008-04-12 08:16:01 +00:00
|
|
|
bglDrawArrays(GL_QUADS, 0, 4);
|
2008-05-24 09:37:09 +00:00
|
|
|
|
|
|
|
if (pr_vbos)
|
|
|
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
|
|
|
|
2008-04-12 08:16:01 +00:00
|
|
|
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
}
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Finished drawing wall %i...\n", wallnum);
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
2006-10-14 23:33:10 +00:00
|
|
|
|
2008-04-10 08:24:06 +00:00
|
|
|
#define INDICE(n) ((indices) ? (indices[i+n]*5) : ((i+n)*3))
|
2008-04-09 07:59:37 +00:00
|
|
|
|
2006-10-14 23:33:10 +00:00
|
|
|
// HSR
|
2008-04-10 08:39:05 +00:00
|
|
|
static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, int indicecount, GLdouble* plane)
|
2008-04-06 23:35:48 +00:00
|
|
|
{
|
|
|
|
GLfloat vec1[3], vec2[3];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = 0;
|
2008-05-10 01:29:37 +00:00
|
|
|
do
|
|
|
|
{
|
2008-04-09 07:59:37 +00:00
|
|
|
vec1[0] = buffer[(INDICE(1)) + 0] - buffer[(INDICE(0)) + 0];
|
|
|
|
vec1[1] = buffer[(INDICE(1)) + 1] - buffer[(INDICE(0)) + 1];
|
|
|
|
vec1[2] = buffer[(INDICE(1)) + 2] - buffer[(INDICE(0)) + 2];
|
2008-04-06 23:35:48 +00:00
|
|
|
|
2008-04-09 07:59:37 +00:00
|
|
|
vec2[0] = buffer[(INDICE(2)) + 0] - buffer[(INDICE(1)) + 0];
|
|
|
|
vec2[1] = buffer[(INDICE(2)) + 1] - buffer[(INDICE(1)) + 1];
|
|
|
|
vec2[2] = buffer[(INDICE(2)) + 2] - buffer[(INDICE(1)) + 2];
|
2008-04-06 23:35:48 +00:00
|
|
|
|
2008-04-09 07:59:37 +00:00
|
|
|
polymer_crossproduct(vec2, vec1, plane);
|
2008-04-06 23:35:48 +00:00
|
|
|
|
2008-04-09 07:59:37 +00:00
|
|
|
// normalize
|
|
|
|
vec1[0] = plane[0] * plane[0] + plane[1] * plane[1] + plane[2] * plane[2];
|
|
|
|
i+= 3;
|
2008-04-06 23:35:48 +00:00
|
|
|
}
|
2008-04-10 08:39:05 +00:00
|
|
|
while ((i < indicecount) && (vec1[0] == 0));
|
2008-04-09 07:59:37 +00:00
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
vec1[0] = sqrt(vec1[0]);
|
|
|
|
plane[0] /= vec1[0];
|
|
|
|
plane[1] /= vec1[0];
|
|
|
|
plane[2] /= vec1[0];
|
|
|
|
|
|
|
|
plane[3] = -(plane[0] * buffer[0] + plane[1] * buffer[1] + plane[2] * buffer[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLdouble* out)
|
|
|
|
{
|
|
|
|
out[0] = in_a[1] * in_b[2] - in_a[2] * in_b[1];
|
|
|
|
out[1] = in_a[2] * in_b[0] - in_a[0] * in_b[2];
|
|
|
|
out[2] = in_a[0] * in_b[1] - in_a[1] * in_b[0];
|
|
|
|
}
|
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
static void polymer_pokesector(short sectnum)
|
|
|
|
{
|
|
|
|
sectortype *sec;
|
|
|
|
_prsector *s;
|
|
|
|
walltype *wal;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
sec = §or[sectnum];
|
|
|
|
s = prsectors[sectnum];
|
|
|
|
wal = &wall[sec->wallptr];
|
|
|
|
|
|
|
|
if (!s->controlstate)
|
|
|
|
polymer_updatesector(sectnum);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < sec->wallnum)
|
|
|
|
{
|
|
|
|
if ((wal->nextsector != -1) && (!prsectors[wal->nextsector]->controlstate))
|
|
|
|
polymer_updatesector(wal->nextsector);
|
|
|
|
if (!prwalls[sec->wallptr + i]->controlstate)
|
|
|
|
polymer_updatewall(sec->wallptr + i);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
wal = &wall[sec->wallptr + i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
static void polymer_extractfrustum(GLdouble* modelview, GLdouble* projection, float* frustum)
|
2006-10-15 18:51:41 +00:00
|
|
|
{
|
2007-03-22 18:28:41 +00:00
|
|
|
GLdouble matrix[16];
|
2006-10-15 18:51:41 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
bglMatrixMode(GL_TEXTURE);
|
2007-03-22 18:28:41 +00:00
|
|
|
bglLoadMatrixd(projection);
|
|
|
|
bglMultMatrixd(modelview);
|
|
|
|
bglGetDoublev(GL_TEXTURE_MATRIX, matrix);
|
2006-10-15 18:51:41 +00:00
|
|
|
bglLoadIdentity();
|
2008-03-30 09:16:39 +00:00
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
2006-10-15 18:51:41 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < 4)
|
|
|
|
{
|
2008-03-26 09:24:25 +00:00
|
|
|
frustum[i] = matrix[(4 * i) + 3] + matrix[4 * i]; // left
|
|
|
|
frustum[i + 4] = matrix[(4 * i) + 3] - matrix[4 * i]; // right
|
|
|
|
frustum[i + 8] = matrix[(4 * i) + 3] - matrix[(4 * i) + 1]; // top
|
|
|
|
frustum[i + 12] = matrix[(4 * i) + 3] + matrix[(4 * i) + 1]; // bottom
|
|
|
|
frustum[i + 16] = matrix[(4 * i) + 3] + matrix[(4 * i) + 2]; // near
|
2006-10-15 18:51:41 +00:00
|
|
|
i++;
|
|
|
|
}
|
2007-07-01 06:32:03 +00:00
|
|
|
i = 0;
|
|
|
|
|
|
|
|
if (pr_verbosity >= 3) OSD_Printf("PR : Frustum extracted.\n");
|
2006-10-15 18:51:41 +00:00
|
|
|
}
|
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
static int polymer_portalinfrustum(short wallnum, float* frustum)
|
2006-10-15 18:51:41 +00:00
|
|
|
{
|
2008-03-26 09:24:25 +00:00
|
|
|
int i, j, k;
|
|
|
|
float sqdist;
|
2006-10-15 18:51:41 +00:00
|
|
|
_prwall *w;
|
|
|
|
|
|
|
|
w = prwalls[wallnum];
|
|
|
|
|
2008-03-26 09:24:25 +00:00
|
|
|
i = 0;
|
2008-03-30 14:22:03 +00:00
|
|
|
while (i < 4)
|
2006-10-15 18:51:41 +00:00
|
|
|
{
|
|
|
|
j = k = 0;
|
|
|
|
while (j < 4)
|
|
|
|
{
|
2008-04-03 06:58:36 +00:00
|
|
|
sqdist = frustum[(i * 4) + 0] * w->bigportal[(j * 3) + 0] +
|
|
|
|
frustum[(i * 4) + 1] * w->bigportal[(j * 3) + 1] +
|
|
|
|
frustum[(i * 4) + 2] * w->bigportal[(j * 3) + 2] +
|
2006-10-15 18:51:41 +00:00
|
|
|
frustum[(i * 4) + 3];
|
2007-07-01 06:32:03 +00:00
|
|
|
if (sqdist < 0)
|
2006-10-15 18:51:41 +00:00
|
|
|
k++;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
if (k == 4)
|
|
|
|
return (0); // OUT !
|
2007-07-01 06:32:03 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2008-03-26 09:24:25 +00:00
|
|
|
return (1);
|
2006-10-14 23:33:10 +00:00
|
|
|
}
|
2006-10-18 03:59:28 +00:00
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
static void polymer_scansprites(short sectnum, spritetype* localtsprite, int* localspritesortcnt)
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
spritetype *spr;
|
|
|
|
|
|
|
|
for (i = headspritesect[sectnum];i >=0;i = nextspritesect[i])
|
|
|
|
{
|
|
|
|
spr = &sprite[i];
|
|
|
|
if ((((spr->cstat&0x8000) == 0) || (showinvisibility)) &&
|
2008-05-10 01:29:37 +00:00
|
|
|
(spr->xrepeat > 0) && (spr->yrepeat > 0) &&
|
|
|
|
(*localspritesortcnt < MAXSPRITESONSCREEN))
|
2008-04-06 03:00:39 +00:00
|
|
|
{
|
2008-04-06 23:35:48 +00:00
|
|
|
copybufbyte(spr,&localtsprite[*localspritesortcnt],sizeof(spritetype));
|
|
|
|
localtsprite[(*localspritesortcnt)++].owner = i;
|
2008-04-06 03:00:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-18 03:59:28 +00:00
|
|
|
// SKIES
|
2008-04-02 09:29:58 +00:00
|
|
|
static void polymer_initskybox(void)
|
2006-10-18 03:59:28 +00:00
|
|
|
{
|
|
|
|
GLfloat halfsqrt2 = 0.70710678f;
|
|
|
|
|
|
|
|
skybox[0] = -1.0f; skybox[1] = 0.0f; // 0
|
|
|
|
skybox[2] = -halfsqrt2; skybox[3] = halfsqrt2; // 1
|
|
|
|
skybox[4] = 0.0f; skybox[5] = 1.0f; // 2
|
|
|
|
skybox[6] = halfsqrt2; skybox[7] = halfsqrt2; // 3
|
|
|
|
skybox[8] = 1.0f; skybox[9] = 0.0f; // 4
|
|
|
|
skybox[10] = halfsqrt2; skybox[11] = -halfsqrt2; // 5
|
|
|
|
skybox[12] = 0.0f; skybox[13] = -1.0f; // 6
|
|
|
|
skybox[14] = -halfsqrt2; skybox[15] = -halfsqrt2; // 7
|
2006-10-19 23:51:44 +00:00
|
|
|
|
|
|
|
/*skybox[0] = -1.0f; skybox[1] = 0.0f; // 0
|
|
|
|
skybox[2] = -1.0f; skybox[3] = 1.0; // 1
|
|
|
|
skybox[4] = 0.0f; skybox[5] = 1.0f; // 2
|
|
|
|
skybox[6] = 1.0f; skybox[7] = 1.0f; // 3
|
|
|
|
skybox[8] = 1.0f; skybox[9] = 0.0f; // 4
|
|
|
|
skybox[10] = 1.0; skybox[11] = -1.0; // 5
|
|
|
|
skybox[12] = 0.0f; skybox[13] = -1.0f; // 6
|
|
|
|
skybox[14] = -1.0; skybox[15] = -1.0; // 7*/
|
|
|
|
}
|
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
static void polymer_getsky(void)
|
2006-10-19 23:51:44 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < numsectors)
|
|
|
|
{
|
|
|
|
if (sector[i].ceilingstat & 1)
|
|
|
|
{
|
|
|
|
cursky = sector[i].ceilingpicnum;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2006-10-18 03:59:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
static void polymer_drawskyquad(int p1, int p2, GLfloat height)
|
2006-10-18 03:59:28 +00:00
|
|
|
{
|
|
|
|
bglBegin(GL_QUADS);
|
|
|
|
bglTexCoord2f(0.0f, 0.0f);
|
|
|
|
//OSD_Printf("PR: drawing %f %f %f\n", skybox[(p1 * 2) + 1], height, skybox[p1 * 2]);
|
|
|
|
bglVertex3f(skybox[(p1 * 2) + 1], height, skybox[p1 * 2]);
|
|
|
|
bglTexCoord2f(0.0f, 1.0f);
|
|
|
|
//OSD_Printf("PR: drawing %f %f %f\n", skybox[(p1 * 2) + 1], -height, skybox[p1 * 2]);
|
|
|
|
bglVertex3f(skybox[(p1 * 2) + 1], -height, skybox[p1 * 2]);
|
|
|
|
bglTexCoord2f(1.0f, 1.0f);
|
|
|
|
//OSD_Printf("PR: drawing %f %f %f\n", skybox[(p2 * 2) + 1], -height, skybox[p2 * 2]);
|
|
|
|
bglVertex3f(skybox[(p2 * 2) + 1], -height, skybox[p2 * 2]);
|
|
|
|
bglTexCoord2f(1.0f, 0.0f);
|
|
|
|
//OSD_Printf("PR: drawing %f %f %f\n", skybox[(p2 * 2) + 1], height, skybox[p2 * 2]);
|
|
|
|
bglVertex3f(skybox[(p2 * 2) + 1], height, skybox[p2 * 2]);
|
|
|
|
bglEnd();
|
|
|
|
}
|
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
static void polymer_drawartsky(short tilenum)
|
2006-10-18 03:59:28 +00:00
|
|
|
{
|
|
|
|
pthtyp* pth;
|
|
|
|
GLuint glpics[5];
|
2006-10-19 23:51:44 +00:00
|
|
|
int i, j;
|
2006-10-18 03:59:28 +00:00
|
|
|
GLfloat height = 2.45f / 2.0f;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < 5)
|
|
|
|
{
|
|
|
|
if (!waloff[tilenum + i])
|
|
|
|
loadtile(tilenum + i);
|
|
|
|
pth = gltexcache(tilenum + i, 0, 0);
|
|
|
|
glpics[i] = pth ? pth->glpic : 0;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2006-10-19 23:51:44 +00:00
|
|
|
i = 0;
|
|
|
|
j = (1<<pskybits);
|
|
|
|
while (i < j)
|
|
|
|
{
|
|
|
|
bglBindTexture(GL_TEXTURE_2D, glpics[pskyoff[i]]);
|
|
|
|
polymer_drawskyquad(i, (i + 1) & (j - 1), height);
|
|
|
|
i++;
|
|
|
|
}
|
2006-10-18 03:59:28 +00:00
|
|
|
}
|
2006-10-29 20:18:04 +00:00
|
|
|
#endif
|