Figures out if we can see the center of a light face and adds it to our globa list
| 2551 | } |
| 2552 | // Figures out if we can see the center of a light face and adds it to our globa list |
| 2553 | void CheckLightGlowsForRoom(room *rp) { |
| 2554 | int i; |
| 2555 | for (i = 0; i < Num_glows_this_frame; i++) { |
| 2556 | // For each light, see if we can cast a vector to it |
| 2557 | face *fp = &rp->faces[LightGlowsThisFrame[i].facenum]; |
| 2558 | vector verts[MAX_VERTS_PER_FACE]; |
| 2559 | vector center; |
| 2560 | for (int t = 0; t < fp->num_verts; t++) |
| 2561 | verts[t] = rp->verts[fp->face_verts[t]]; |
| 2562 | float size = sqrt(vm_GetCentroid(¢er, verts, fp->num_verts)); |
| 2563 | size *= 2; |
| 2564 | center += (fp->normal / 4); |
| 2565 | if (vm_VectorDistanceQuick(¢er, &Viewer_eye) < (size * CORONA_DIST_CUTOFF)) |
| 2566 | continue; |
| 2567 | // Check if we can see this light |
| 2568 | fvi_info hit_info; |
| 2569 | fvi_query fq; |
| 2570 | // shoot a ray from the light position to the current vertex |
| 2571 | if (FastCoronas) { |
| 2572 | if (rp->flags & RF_EXTERNAL) { |
| 2573 | SetGlowStatus(rp - Rooms, LightGlowsThisFrame[i].facenum, ¢er, size, FastCoronas); |
| 2574 | continue; |
| 2575 | } |
| 2576 | vector subvec = Viewer_eye - center; |
| 2577 | vm_NormalizeVectorFast(&subvec); |
| 2578 | subvec *= size; |
| 2579 | subvec += center; |
| 2580 | fq.p0 = ¢er; |
| 2581 | fq.p1 = &subvec; |
| 2582 | fq.startroom = rp - Rooms; |
| 2583 | } else { |
| 2584 | fq.p0 = &Viewer_eye; |
| 2585 | fq.p1 = ¢er; |
| 2586 | fq.startroom = Viewer_object->roomnum; |
| 2587 | } |
| 2588 | |
| 2589 | fq.rad = 0.0f; |
| 2590 | fq.flags = FQ_CHECK_OBJS | FQ_NO_RELINK | FQ_IGNORE_WEAPONS | FQ_ROBOTS_AS_SPHERE | FQ_PLAYERS_AS_SPHERE; |
| 2591 | fq.thisobjnum = -1; |
| 2592 | fq.ignore_obj_list = NULL; |
| 2593 | int fate = fvi_FindIntersection(&fq, &hit_info); |
| 2594 | if (fate != HIT_NONE) |
| 2595 | continue; |
| 2596 | SetGlowStatus(rp - Rooms, LightGlowsThisFrame[i].facenum, ¢er, size, FastCoronas); |
| 2597 | } |
| 2598 | } |
| 2599 | // Called before a frame starts to render - sets all of our light glows to decreasing |
| 2600 | void PreUpdateAllLightGlows() { |
| 2601 | int i, count; |
no test coverage detected