X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=sv_light.c;h=41b4475f730824758e119638012c62aa67f449e0;hb=1f388bf636d1632373f47c04f08ddaf085c8b385;hp=cbad6db1709c91304a8c627748efd2f86821f824;hpb=6963b8df83a204aa0c6ce664376dc1766ab1fb1d;p=xonotic%2Fdarkplaces.git diff --git a/sv_light.c b/sv_light.c index cbad6db1..41b4475f 100644 --- a/sv_light.c +++ b/sv_light.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -17,11 +17,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// r_light.c #include "quakedef.h" -int RecursiveLightPoint (vec3_t color, mnode_t *node, float x, float y, float startz, float endz) +int SV_RecursiveLightPoint (vec3_t color, mnode_t *node, float x, float y, float startz, float endz) { int side, distz = endz - startz; float front, back; @@ -47,11 +46,6 @@ loc0: goto loc0; } // found an intersection -// mid = startz + (endz - startz) * (startz - node->plane->dist) / (startz - endz); -// mid = startz + distz * (startz - node->plane->dist) / (-distz); -// mid = startz + (-(startz - node->plane->dist)); -// mid = startz - (startz - node->plane->dist); -// mid = startz + node->plane->dist - startz; mid = node->plane->dist; break; default: @@ -65,14 +59,12 @@ loc0: goto loc0; } // found an intersection -// mid = startz + (endz - startz) * ((front - node->plane->dist) / ((front - node->plane->dist) - (back - node->plane->dist))); -// mid = startz + (endz - startz) * ((front - node->plane->dist) / (front - back)); mid = startz + distz * (front - node->plane->dist) / (front - back); break; } // go down front side - if (node->children[side]->contents >= 0 && RecursiveLightPoint (color, node->children[side], x, y, startz, mid)) + if (node->children[side]->contents >= 0 && SV_RecursiveLightPoint (color, node->children[side], x, y, startz, mid)) return true; // hit something else { @@ -81,16 +73,12 @@ loc0: { int i, ds, dt; msurface_t *surf; - lightspot[0] = x; - lightspot[1] = y; - lightspot[2] = mid; - lightplane = node->plane; surf = sv.worldmodel->surfaces + node->firstsurface; for (i = 0;i < node->numsurfaces;i++, surf++) { - if (surf->flags & SURF_DRAWTILED) - continue; // no lightmaps + if (!(surf->flags & SURF_LIGHTMAP)) + continue; ds = (int) (x * surf->texinfo->vecs[0][0] + y * surf->texinfo->vecs[0][1] + mid * surf->texinfo->vecs[0][2] + surf->texinfo->vecs[0][3]); dt = (int) (x * surf->texinfo->vecs[1][0] + y * surf->texinfo->vecs[1][1] + mid * surf->texinfo->vecs[1][2] + surf->texinfo->vecs[1][3]); @@ -106,7 +94,7 @@ loc0: if (surf->samples) { - byte *lightmap; + qbyte *lightmap; int maps, line3, size3, dsfrac = ds & 15, dtfrac = dt & 15, scale = 0, r00 = 0, g00 = 0, b00 = 0, r01 = 0, g01 = 0, b01 = 0, r10 = 0, g10 = 0, b10 = 0, r11 = 0, g11 = 0, b11 = 0; line3 = ((surf->extents[0]>>4)+1)*3; size3 = ((surf->extents[0]>>4)+1) * ((surf->extents[1]>>4)+1)*3; // LordHavoc: *3 for colored lighting @@ -115,7 +103,7 @@ loc0: for (maps = 0;maps < MAXLIGHTMAPS && surf->styles[maps] != 255;maps++) { - scale = d_lightstylevalue[surf->styles[maps]]; + scale = 256; // FIXME: server doesn't know what light styles are doing r00 += lightmap[ 0] * scale;g00 += lightmap[ 1] * scale;b00 += lightmap[ 2] * scale; r01 += lightmap[ 3] * scale;g01 += lightmap[ 4] * scale;b01 += lightmap[ 5] * scale; r10 += lightmap[line3+0] * scale;g10 += lightmap[line3+1] * scale;b10 += lightmap[line3+2] * scale; @@ -136,19 +124,20 @@ loc0: startz = mid; distz = endz - startz; goto loc0; -// return RecursiveLightPoint (color, node->children[side ^ 1], x, y, mid, endz); } } // LordHavoc: added light checking to the server void SV_LightPoint (vec3_t color, vec3_t p) { + Mod_CheckLoaded(sv.worldmodel); if (!sv.worldmodel->lightdata) { color[0] = color[1] = color[2] = 255; return; } - + color[0] = color[1] = color[2] = 0; - RecursiveLightPoint (color, sv.worldmodel->nodes, p[0], p[1], p[2], p[2] - 65536); + SV_RecursiveLightPoint (color, sv.worldmodel->nodes, p[0], p[1], p[2], p[2] - 65536); } +