Does lighting for the passed in external room
| 260 | |
| 261 | // Does lighting for the passed in external room |
| 262 | void ApplyLightingToExternalRoom(vector *pos, int roomnum, float light_dist, float red_scale, float green_scale, |
| 263 | float blue_scale, vector *light_direction, float dot_range) { |
| 264 | int i, lm_handle, t; |
| 265 | uint16_t *dest_data; |
| 266 | vector rad; |
| 267 | room *rp = &Rooms[roomnum]; |
| 268 | vector Light_min_xyz; |
| 269 | vector Light_max_xyz; |
| 270 | uint16_t lmilist[MAX_DYNAMIC_FACES]; |
| 271 | int num_spoken_for = 0; |
| 272 | |
| 273 | int red_limit = 31; |
| 274 | int green_limit = 31; |
| 275 | int blue_limit = 31; |
| 276 | |
| 277 | rad.x = light_dist; |
| 278 | rad.y = light_dist; |
| 279 | rad.z = light_dist; |
| 280 | |
| 281 | Light_min_xyz = *pos - rad; |
| 282 | Light_max_xyz = *pos + rad; |
| 283 | |
| 284 | // Now the Light_position is in the submodels frame of reference |
| 285 | for (i = 0; i < rp->num_faces; i++) { |
| 286 | face *fp = &rp->faces[i]; |
| 287 | |
| 288 | // check to see if this face is within reach |
| 289 | if (Light_max_xyz.y < fp->min_xyz.y || fp->max_xyz.y < Light_min_xyz.y || Light_max_xyz.x < fp->min_xyz.x || |
| 290 | fp->max_xyz.x < Light_min_xyz.x || Light_max_xyz.z < fp->min_xyz.z || fp->max_xyz.z < Light_min_xyz.z) |
| 291 | continue; |
| 292 | |
| 293 | // Make sure face was rendered |
| 294 | if (fp->renderframe != ((FrameCount - 1) % 256)) |
| 295 | continue; |
| 296 | |
| 297 | if (Num_dynamic_faces >= MAX_DYNAMIC_FACES) { |
| 298 | mprintf(0, "Too many dynamic faces!\n"); |
| 299 | return; |
| 300 | } |
| 301 | |
| 302 | // Make sure there already is a lightmap for this face |
| 303 | if (!(fp->flags & FF_LIGHTMAP)) |
| 304 | continue; |
| 305 | |
| 306 | if (Lmi_spoken_for[fp->lmi_handle / 8] & (1 << (fp->lmi_handle % 8))) |
| 307 | continue; |
| 308 | |
| 309 | int xres = lmi_w(fp->lmi_handle); |
| 310 | int yres = lmi_h(fp->lmi_handle); |
| 311 | |
| 312 | lightmap_info *lmi_ptr = &LightmapInfo[fp->lmi_handle]; |
| 313 | // Lightmap width and height |
| 314 | int lmw = lm_w(lmi_ptr->lm_handle); |
| 315 | |
| 316 | // Check for backfaces |
| 317 | vector subvec = *pos - lmi_ptr->upper_left; |
| 318 | float dist_from_plane = fabs(vm_DotProduct(&subvec, &lmi_ptr->normal)); |
| 319 |
no test coverage detected