git-svn-id: https://svn.eduke32.com/eduke32@1331 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2009-04-17 18:34:55 +00:00
parent 45897cf581
commit 779eda41da
2 changed files with 73 additions and 47 deletions

View file

@ -3,8 +3,8 @@
ENGINELIB=libengine.a
EDITORLIB=libbuild.a
SDLCONFIG = /usr/local/bin/sdl-config
# SDLCONFIG = sdl-config
# SDLCONFIG = /usr/local/bin/sdl-config
SDLCONFIG = sdl-config
ifeq ($(wildcard $(SDLCONFIG)),$(SDLCONFIG))
SDLROOT = /usr/local

View file

@ -665,6 +665,7 @@ void polymer_loadboard(void)
}
polymer_getsky();
polymer_resetlights();
if (pr_verbosity >= 1) OSD_Printf("PR : Board loaded.\n");
}
@ -695,7 +696,7 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
depth = 0;
if (pr_shadows)
if (pr_shadows && lightcount > 0 && pr_shadowcount > 0)
polymer_prepareshadows();
bglMatrixMode(GL_MODELVIEW);
@ -982,11 +983,12 @@ void polymer_drawsprite(int32_t snum)
bglPopMatrix();
i = 0;
while (i < 4)
do
{
polymer_transformpoint(&inbuffer[i * 5], &spriteplane.buffer[i * 5], spritemodelview);
i++;
}
while (i < 4);
polymer_buffertoplane(spriteplane.buffer, NULL, 4, spriteplane.plane, spriteplane.t, spriteplane.b, spriteplane.n);
@ -1071,7 +1073,7 @@ static void polymer_displayrooms(int16_t dacursectnum)
// depth-only occlusion testing pass
// overridematerial = 0;
while (front != back)
do
{
sec = &sector[sectorqueue[front]];
@ -1082,7 +1084,7 @@ static void polymer_displayrooms(int16_t dacursectnum)
doquery = 0;
i = 0;
while (i < sec->wallnum)
do
{
polymer_drawwall(sectorqueue[front], sec->wallptr + i);
@ -1093,9 +1095,10 @@ static void polymer_displayrooms(int16_t dacursectnum)
i++;
}
while (i < sec->wallnum);
i = 0;
while (i < sec->wallnum)
do
{
if ((wall[sec->wallptr + i].nextsector != -1) &&
(wallvisible(sec->wallptr + i)) &&
@ -1184,9 +1187,10 @@ static void polymer_displayrooms(int16_t dacursectnum)
i++;
}
while (i < sec->wallnum);
i = 0;
while (i < sec->wallnum)
do
{
if ((queryid[sec->wallptr + i]) &&
(!drawingstate[wall[sec->wallptr + i].nextsector]))
@ -1213,9 +1217,11 @@ static void polymer_displayrooms(int16_t dacursectnum)
i++;
}
while (i < sec->wallnum);
front++;
}
while (front != back);
// do the actual shaded drawing
// overridematerial = 0xFFFFFFFF;
@ -1318,9 +1324,9 @@ static void polymer_displayrooms(int16_t dacursectnum)
}
spritesortcnt = localspritesortcnt;
Bmemcpy(tsprite, localtsprite, sizeof(spritetype) * MAXSPRITESONSCREEN);
Bmemcpy(tsprite, localtsprite, sizeof(spritetype) * localspritesortcnt);
maskwallcnt = localmaskwallcnt;
Bmemcpy(maskwall, localmaskwall, sizeof(int16_t) * MAXWALLSB);
Bmemcpy(maskwall, localmaskwall, sizeof(int16_t) * localmaskwallcnt);
if (depth)
{
@ -1404,7 +1410,7 @@ static void polymer_drawplane(_prplane* plane)
curlight = 0;
while ((curlight == 0) || ((curlight < plane->lightcount) && (curlight < pr_maxlightpasses)))
do
{
materialbits = polymer_bindmaterial(plane->material, plane->lights, plane->lightcount);
@ -1428,6 +1434,7 @@ static void polymer_drawplane(_prplane* plane)
curlight++;
}
while ((curlight == 0) || ((curlight < plane->lightcount) && (curlight < pr_maxlightpasses)));
if (plane->vbo && (pr_vbos > 0))
{
@ -1555,7 +1562,7 @@ static int32_t polymer_updatesector(int16_t sectnum)
// geometry
wal = &wall[sec->wallptr];
i = 0;
while (i < sec->wallnum)
do
{
if ((-wal->x != s->verts[(i*3)+2]))
{
@ -1571,6 +1578,7 @@ static int32_t polymer_updatesector(int16_t sectnum)
i++;
wal = &wall[sec->wallptr + i];
}
while (i < sec->wallnum);
if ((s->controlstate == 2) ||
needfloor ||
@ -1583,7 +1591,7 @@ static int32_t polymer_updatesector(int16_t sectnum)
wal = &wall[sec->wallptr];
i = 0;
while (i < sec->wallnum)
do
{
getzsofslope(sectnum, wal->x, wal->y, &ceilz, &florz);
s->floor.buffer[(i*5)+1] = -(float)(florz) / 16.0f;
@ -1592,6 +1600,7 @@ static int32_t polymer_updatesector(int16_t sectnum)
i++;
wal = &wall[sec->wallptr + i];
}
while (i < sec->wallnum);
s->floorz = sec->floorz;
s->ceilingz = sec->ceilingz;
@ -1617,7 +1626,7 @@ static int32_t polymer_updatesector(int16_t sectnum)
wal = &wall[sec->wallptr];
i = 0;
while (i < sec->wallnum)
do
{
j = 2;
curstat = sec->floorstat;
@ -1626,7 +1635,7 @@ static int32_t polymer_updatesector(int16_t sectnum)
curxpanning = sec->floorxpanning;
curypanning = sec->floorypanning;
while (j)
do
{
if (j == 1)
{
@ -1687,9 +1696,11 @@ static int32_t polymer_updatesector(int16_t sectnum)
j--;
}
while (j);
i++;
wal = &wall[sec->wallptr + i];
}
while (i < sec->wallnum);
s->floorstat = sec->floorstat;
s->ceilingstat = sec->ceilingstat;
@ -2407,7 +2418,7 @@ static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, in
return; // corrupt sector (E3L4, I'm looking at you)
i = 0;
do
while (i < indicecount)
{
vec1[0] = buffer[(INDICE(1)) + 0] - buffer[(INDICE(0)) + 0]; //x1
vec1[1] = buffer[(INDICE(1)) + 1] - buffer[(INDICE(0)) + 1]; //y1
@ -2428,10 +2439,10 @@ static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, in
if (norm >= 15000) // hack to work around a precision issue with slopes
{
// normalize the normal/plane equation and calculate its plane norm
norm = -sqrt(norm);
plane[0] /= norm;
plane[1] /= norm;
plane[2] /= norm;
norm = 1.0f/(-sqrt(norm));
plane[0] *= norm;
plane[1] *= norm;
plane[2] *= norm;
plane[3] = -(plane[0] * buffer[0] + plane[1] * buffer[1] + plane[2] * buffer[2]);
// calculate T and B
@ -2471,28 +2482,27 @@ static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, in
// normalize T, B and N
norm = t[0] * t[0] + t[1] * t[1] + t[2] * t[2];
norm = sqrt(norm);
t[0] /= norm;
t[1] /= norm;
t[2] /= norm;
norm = 1.0f/sqrt(norm);
t[0] *= norm;
t[1] *= norm;
t[2] *= norm;
norm = b[0] * b[0] + b[1] * b[1] + b[2] * b[2];
norm = sqrt(norm);
b[0] /= norm;
b[1] /= norm;
b[2] /= norm;
norm = 1.0f/sqrt(norm);
b[0] *= norm;
b[1] *= norm;
b[2] *= norm;
norm = n[0] * n[0] + n[1] * n[1] + n[2] * n[2];
norm = sqrt(norm);
n[0] /= norm;
n[1] /= norm;
n[2] /= norm;
norm = 1.0f/sqrt(norm);
n[0] *= norm;
n[1] *= norm;
n[2] *= norm;
break;
}
i+= 3;
}
while (i < indicecount);
}
static inline void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLfloat* out)
@ -2670,7 +2680,7 @@ static void polymer_drawartsky(int16_t tilenum)
GLfloat height = 2.45f / 2.0f;
i = 0;
while (i < 5)
do
{
if (!waloff[tilenum + i])
loadtile(tilenum + i);
@ -2678,15 +2688,17 @@ static void polymer_drawartsky(int16_t tilenum)
glpics[i] = pth ? pth->glpic : 0;
i++;
}
while (i < 5);
i = 0;
j = (1<<pskybits);
while (i < j)
do
{
bglBindTexture(GL_TEXTURE_2D, glpics[pskyoff[i]]);
polymer_drawartskyquad(i, (i + 1) & (j - 1), height);
i++;
}
while (i < j);
}
static void polymer_drawartskyquad(int32_t p1, int32_t p2, GLfloat height)
@ -2726,7 +2738,7 @@ static void polymer_drawskybox(int16_t tilenum)
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, skyboxdatavbo);
i = 0;
while (i < 6)
do
{
drawingskybox = i + 1;
pth = gltexcache(tilenum, 0, 4);
@ -2744,6 +2756,7 @@ static void polymer_drawskybox(int16_t tilenum)
i++;
}
while (i < 6);
drawingskybox = 0;
if (pr_vbos > 0)
@ -2875,14 +2888,15 @@ static void polymer_drawmdsprite(spritetype *tspr)
else globalnoeffect=1; //mdloadskin reads this
}
color[3] = 1.0;
if (tspr->cstat & 2)
{
if (!(tspr->cstat&512))
color[3] = 0.66;
else
color[3] = 0.33;
} else
color[3] = 1.0;
}
if (pr_gpusmoothing)
mdspritematerial.frameprogress = m->interpol;
@ -3018,7 +3032,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m->indices[surfi]);
curlight = 0;
while ((curlight == 0) || ((curlight < modellightcount) && (curlight < pr_maxlightpasses)))
do
{
materialbits = polymer_bindmaterial(mdspritematerial, modellights, modellightcount);
bglDrawElements(GL_TRIANGLES, s->numtris * 3, GL_UNSIGNED_INT, 0);
@ -3026,6 +3040,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
curlight++;
}
while ((curlight == 0) || ((curlight < modellightcount) && (curlight < pr_maxlightpasses)));
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
@ -3043,7 +3058,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
}
curlight = 0;
while ((curlight == 0) || ((curlight < modellightcount) && (curlight < pr_maxlightpasses)))
do
{
materialbits = polymer_bindmaterial(mdspritematerial, modellights, modellightcount);
bglDrawElements(GL_TRIANGLES, s->numtris * 3, GL_UNSIGNED_INT, s->tris);
@ -3051,6 +3066,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
curlight++;
}
while ((curlight == 0) || ((curlight < modellightcount) && (curlight < pr_maxlightpasses)));
}
bglDisableClientState(GL_NORMAL_ARRAY);
@ -3752,7 +3768,7 @@ static void polymer_resetlights(void)
static void polymer_addlight(_prlight light)
{
if (light.sector == -1)
if (light.sector == -1 || light.sector >= numsectors)
return;
if (lightcount < PR_MAXLIGHTS)
@ -3815,28 +3831,33 @@ static int32_t polymer_planeinlight(_prplane* plane, _prlight* light)
if (light->radius)
return polymer_planeinfrustum(plane, light->frustum);
if (plane->vertcount < 1)
return 0;
lightpos[0] = light->y;
lightpos[1] = -light->z / 16.0f;
lightpos[2] = -light->x;
i = 0;
while (i < 3)
do
{
j = k = l = 0;
while (j < plane->vertcount)
do
{
if (plane->buffer[(j * 5) + i] > (lightpos[i] + light->range)) k++;
if (plane->buffer[(j * 5) + i] < (lightpos[i] - light->range)) l++;
j++;
}
while (j < plane->vertcount);
if ((k == plane->vertcount) || (l == plane->vertcount))
return 0;
i++;
}
while (i < 3);
return 1;
}
@ -3857,11 +3878,13 @@ static inline void polymer_culllight(char lightindex)
front = 0;
back = 1;
Bmemset(cullingstate, 0, sizeof(int16_t) * MAXSECTORS);
Bmemset(sectorqueue, 0, sizeof(int16_t) * MAXSECTORS);
cullingstate[light->sector] = 1;
sectorqueue[0] = light->sector;
while (front != back)
do
{
s = prsectors[sectorqueue[front]];
sec = &sector[sectorqueue[front]];
@ -3882,7 +3905,7 @@ static inline void polymer_culllight(char lightindex)
}
i = 0;
while (i < sec->wallnum)
do
{
w = prwalls[sec->wallptr + i];
@ -3922,8 +3945,10 @@ static inline void polymer_culllight(char lightindex)
i++;
}
while (i < sec->wallnum);
front++;
}
while (front != back);
}
static void polymer_prepareshadows(void)
@ -4027,7 +4052,7 @@ static void polymer_applylights(void)
float fade;
curpriority = 0;
while (curpriority < PR_MAXLIGHTPRIORITY)
do
{
i = 0;
while (i < staticlightcount)
@ -4091,6 +4116,7 @@ static void polymer_applylights(void)
}
curpriority++;
}
while (curpriority < PR_MAXLIGHTPRIORITY);
}
// RENDER TARGETS