MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / CheckLightGlowsForRoom

Function CheckLightGlowsForRoom

Descent3/render.cpp:2553–2598  ·  view source on GitHub ↗

Figures out if we can see the center of a light face and adds it to our globa list

Source from the content-addressed store, hash-verified

2551}
2552// Figures out if we can see the center of a light face and adds it to our globa list
2553void 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(&center, verts, fp->num_verts));
2563 size *= 2;
2564 center += (fp->normal / 4);
2565 if (vm_VectorDistanceQuick(&center, &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, &center, size, FastCoronas);
2574 continue;
2575 }
2576 vector subvec = Viewer_eye - center;
2577 vm_NormalizeVectorFast(&subvec);
2578 subvec *= size;
2579 subvec += center;
2580 fq.p0 = &center;
2581 fq.p1 = &subvec;
2582 fq.startroom = rp - Rooms;
2583 } else {
2584 fq.p0 = &Viewer_eye;
2585 fq.p1 = &center;
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, &center, size, FastCoronas);
2597 }
2598}
2599// Called before a frame starts to render - sets all of our light glows to decreasing
2600void PreUpdateAllLightGlows() {
2601 int i, count;

Callers 1

RenderRoomFunction · 0.85

Calls 5

SetGlowStatusFunction · 0.85
vm_NormalizeVectorFastFunction · 0.85
fvi_FindIntersectionFunction · 0.85
vm_GetCentroidFunction · 0.50
vm_VectorDistanceQuickFunction · 0.50

Tested by

no test coverage detected