light: BounceLightsForFaceNum(): return indices so we have 1 main copy of the bounce lights
This commit is contained in:
parent
c2c3e915e6
commit
8a83e3d351
|
|
@ -46,7 +46,7 @@ typedef struct {
|
|||
// public functions
|
||||
|
||||
const std::vector<bouncelight_t> &BounceLights();
|
||||
const std::vector<bouncelight_t> &BounceLightsForFaceNum(int facenum);
|
||||
const std::vector<int> &BounceLightsForFaceNum(int facenum);
|
||||
void MakeTextureColors (const bsp2_t *bsp);
|
||||
void MakeBounceLights (const globalconfig_t &cfg, const bsp2_t *bsp);
|
||||
/** Returns color components in [0, 255] */
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ using namespace polylib;
|
|||
mutex radlights_lock;
|
||||
map<string, vec3> texturecolors;
|
||||
std::vector<bouncelight_t> radlights;
|
||||
std::map<int, std::vector<bouncelight_t>> radlightsByFacenum; // duplicate of `radlights` but indexed by face
|
||||
std::map<int, std::vector<int>> radlightsByFacenum;
|
||||
|
||||
class patch_t {
|
||||
public:
|
||||
|
|
@ -255,7 +255,9 @@ AddBounceLight(const vec3_t pos, const std::map<int, glm::vec3> &colorByStyle, c
|
|||
|
||||
unique_lock<mutex> lck { radlights_lock };
|
||||
radlights.push_back(l);
|
||||
radlightsByFacenum[Face_GetNum(bsp, face)].push_back(l);
|
||||
|
||||
const int lastBounceLightIndex = static_cast<int>(radlights.size()) - 1;
|
||||
radlightsByFacenum[Face_GetNum(bsp, face)].push_back(lastBounceLightIndex);
|
||||
}
|
||||
|
||||
const std::vector<bouncelight_t> &BounceLights()
|
||||
|
|
@ -263,14 +265,14 @@ const std::vector<bouncelight_t> &BounceLights()
|
|||
return radlights;
|
||||
}
|
||||
|
||||
const std::vector<bouncelight_t> &BounceLightsForFaceNum(int facenum)
|
||||
const std::vector<int> &BounceLightsForFaceNum(int facenum)
|
||||
{
|
||||
const auto &vec = radlightsByFacenum.find(facenum);
|
||||
if (vec != radlightsByFacenum.end()) {
|
||||
return vec->second;
|
||||
}
|
||||
|
||||
static std::vector<bouncelight_t> empty;
|
||||
static std::vector<int> empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1644,14 +1644,17 @@ LightFace_BounceLightsDebug(const lightsurf_t *lightsurf, lightmapdict_t *lightm
|
|||
// reset all lightmaps to black (lazily)
|
||||
Lightmap_ClearAll(lightmaps);
|
||||
|
||||
const std::vector<bouncelight_t> &vpls = BounceLightsForFaceNum(Face_GetNum(lightsurf->bsp, lightsurf->face));
|
||||
const std::vector<int> &vpls = BounceLightsForFaceNum(Face_GetNum(lightsurf->bsp, lightsurf->face));
|
||||
const std::vector<bouncelight_t> &all_vpls = BounceLights();
|
||||
|
||||
/* Overwrite each point with the emitted color... */
|
||||
for (int i = 0; i < lightsurf->numpoints; i++) {
|
||||
if (lightsurf->occluded[i])
|
||||
continue;
|
||||
|
||||
for (const auto &vpl : vpls) {
|
||||
for (const auto &vplnum : vpls) {
|
||||
const bouncelight_t &vpl = all_vpls[vplnum];
|
||||
|
||||
// check for point in polygon (note: could be on the edge of more than one)
|
||||
if (!GLM_EdgePlanes_PointInside(vpl.poly_edgeplanes, vec3_t_to_glm(lightsurf->points[i])))
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Reference in New Issue