Kills the lighting that a face casts and dampens all the faces that light influences
| 1993 | |
| 1994 | // Kills the lighting that a face casts and dampens all the faces that light influences |
| 1995 | void DestroyLight(int roomnum, int facenum) { |
| 1996 | vector vecs[MAX_VERTS_PER_FACE], center; |
| 1997 | room *destroy_rp = &Rooms[roomnum]; |
| 1998 | face *destroy_fp = &destroy_rp->faces[facenum]; |
| 1999 | float r, g, b; |
| 2000 | fvi_face_room_list facelist[MAX_DYNAMIC_FACES]; |
| 2001 | int num_faces, i; |
| 2002 | uint16_t lmilist[MAX_DYNAMIC_FACES]; |
| 2003 | int num_spoken_for = 0; |
| 2004 | |
| 2005 | if (Dedicated_server) |
| 2006 | return; |
| 2007 | |
| 2008 | float mul = ((float)destroy_fp->light_multiple) / 4.0; |
| 2009 | |
| 2010 | r = GameTextures[destroy_fp->tmap].r * mul; |
| 2011 | g = GameTextures[destroy_fp->tmap].g * mul; |
| 2012 | b = GameTextures[destroy_fp->tmap].b * mul; |
| 2013 | |
| 2014 | // Get highest component |
| 2015 | float rmax = std::max({r, g, b}); |
| 2016 | |
| 2017 | // Get the normalized color that this face emits |
| 2018 | float red_scale = r / rmax; |
| 2019 | float green_scale = g / rmax; |
| 2020 | float blue_scale = b / rmax; |
| 2021 | |
| 2022 | // red_scale/=30; |
| 2023 | // green_scale/=30; |
| 2024 | // blue_scale/=30; |
| 2025 | |
| 2026 | mprintf(0, "r=%f g=%f b=%f\n", red_scale, green_scale, blue_scale); |
| 2027 | |
| 2028 | // Get center and area of light face |
| 2029 | for (i = 0; i < destroy_fp->num_verts; i++) |
| 2030 | vecs[i] = destroy_rp->verts[destroy_fp->face_verts[i]]; |
| 2031 | |
| 2032 | float area = vm_GetCentroid(¢er, vecs, destroy_fp->num_verts); |
| 2033 | |
| 2034 | // Get the sphere of influence of this light |
| 2035 | float power = rmax * area; |
| 2036 | float temp_ignore = DESTROYABLE_IGNORE_LIMIT / power; |
| 2037 | float express = 1.0 / temp_ignore; |
| 2038 | express /= 3.14f; |
| 2039 | express -= area; |
| 2040 | float sphere_dist = sqrt(express); |
| 2041 | |
| 2042 | // ApplyLightingToObjects (pos,roomnum,light_dist,red_scale,green_scale,blue_scale,light_direction,dot_range); |
| 2043 | |
| 2044 | num_faces = fvi_QuickDistFaceList(roomnum, ¢er, sphere_dist, facelist, MAX_DYNAMIC_FACES); |
| 2045 | |
| 2046 | for (i = 0; i < num_faces; i++) { |
| 2047 | room *rp = &Rooms[facelist[i].room_index]; |
| 2048 | face *fp = &rp->faces[facelist[i].face_index]; |
| 2049 | |
| 2050 | ASSERT(Rooms[facelist[i].room_index].used); |
| 2051 | ASSERT(facelist[i].face_index < Rooms[facelist[i].room_index].num_faces); |
| 2052 |
no test coverage detected