39 vec3_t transformed,
int bit)
46 dist = PlaneDiffFast(transformed, node->plane);
47 if (
dist > light->intensity - DLIGHT_CUTOFF) {
48 node = node->children[0];
51 if (dist < -light->
intensity + DLIGHT_CUTOFF) {
52 node = node->children[1];
57 surf = node->firstface;
58 for (i = 0; i < node->numfaces; i++, surf++) {
63 surf->dlightbits |= bit;
67 node = node->children[1];
92 VectorCopy(light->origin, transformed);
111 byte *b1, *b2, *b3, *b4;
115 int smax, tmax, size;
118 lightpoint_t lightpoint;
122 end[2] = start[2] - 2048;
124 BSP_LightPoint(&lightpoint, start, end,
r_worldmodel->nodes);
126 surf = lightpoint.surf;
130 fracu = lightpoint.s & 15;
131 fracv = lightpoint.t & 15;
134 w1 = (16 - fracu) * (16 - fracv);
135 w2 = fracu * (16 - fracv);
137 w4 = (16 - fracu) * fracv;
139 s = lightpoint.s >> 4;
140 t = lightpoint.t >> 4;
147 lightmap = surf->lightmap;
148 for (maps = 0; maps < surf->numstyles; maps++) {
154 temp[0] = (w1 * b1[0] + w2 * b2[0] + w3 * b3[0] + w4 * b4[0]) >> 8;
155 temp[1] = (w1 * b1[1] + w2 * b2[1] + w3 * b3[1] + w4 * b4[1]) >> 8;
156 temp[2] = (w1 * b1[2] + w2 * b2[2] + w3 * b3[2] + w4 * b4[2]) >> 8;
158 scale =
r_newrefdef.lightstyles[surf->styles[maps]].white * (1.0f / 255);
159 color[0] += temp[0] * scale;
160 color[1] += temp[1] * scale;
161 color[2] += temp[2] * scale;
181 VectorSet(
color, 1, 1, 1);
188 VectorSet(
color, 1, 1, 1);
193 for (lnum = 0; lnum <
r_newrefdef.num_dlights; lnum++) {
195 add = dl->intensity - DLIGHT_CUTOFF - Distance(point, dl->origin);
219 vec3_t transformed, impact;
221 vec_t
dist, rad, minlight, scale, frac;
223 int i, smax, tmax, s, t, sd, td;
231 if (!(surf->dlightbits & (1 << i)))
244 VectorCopy(light->origin, transformed);
247 dist = PlaneDiffFast(transformed, surf->plane);
248 rad = light->intensity - fabs(
dist);
249 if (rad < DLIGHT_CUTOFF)
251 minlight = rad - DLIGHT_CUTOFF * 0.8f;
252 scale = rad / minlight;
254 VectorMA(transformed, -
dist, surf->plane->normal, impact);
256 local[0] = DotProduct(impact, tex->axis[0]) + tex->offset[0];
257 local[1] = DotProduct(impact, tex->axis[1]) + tex->offset[1];
259 local[0] -= surf->texturemins[0];
260 local[1] -= surf->texturemins[1];
263 for (t = 0; t < tmax; t++) {
264 td = abs(local[1] - (t << 4));
265 for (s = 0; s < smax; s++) {
266 sd = abs(local[0] - (s << 4));
268 dist = sd + (td >> 1);
270 dist = td + (sd >> 1);
271 if (
dist < minlight) {
273 block[0] += light->color[0] * frac;
274 block[1] += light->color[1] * frac;
275 block[2] += light->color[2] * frac;
292 int i, maps, smax, tmax, size;
307 for (i = 0; i < size; i++) {
308 block[0] = block[1] = block[2] = 0xffff;
318 lightmap = surf->lightmap;
319 for (maps = 0; maps < surf->numstyles; maps++) {
324 for (i = 0; i < size; i++) {
325 block[0] += lightmap[0] * scale;
326 block[1] += lightmap[1] * scale;
327 block[2] += lightmap[2] * scale;
340 for (i = 0; i < size; i++) {