fix visapprox rays crashing
fix visapprox rays to work with surface lights; it's slower than vis but it at least works now
This commit is contained in:
parent
e366898796
commit
51f2bc1ff0
|
|
@ -1537,9 +1537,6 @@ std::map<int, qvec3f> GetDirectLighting(
|
|||
|
||||
static bool VisCullEntity(const mbsp_t *bsp, const std::vector<uint8_t> &pvs, const mleaf_t *entleaf)
|
||||
{
|
||||
if (options.visapprox.value() != visapprox_t::VIS) {
|
||||
return false;
|
||||
}
|
||||
if (pvs.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1569,7 +1566,7 @@ static void LightFace_Entity(
|
|||
const qplane3d *plane = &lightsurf->plane;
|
||||
|
||||
/* vis cull */
|
||||
if (VisCullEntity(bsp, lightsurf->pvs, entity->leaf)) {
|
||||
if (options.visapprox.value() == visapprox_t::VIS && VisCullEntity(bsp, lightsurf->pvs, entity->leaf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2142,7 +2139,7 @@ static void LightFace_Bounce(
|
|||
|
||||
#if 1
|
||||
for (const bouncelight_t &vpl : BounceLights()) {
|
||||
if (VisCullEntity(bsp, lightsurf->pvs, vpl.leaf)) {
|
||||
if (options.visapprox.value() == visapprox_t::VIS && VisCullEntity(bsp, lightsurf->pvs, vpl.leaf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -2330,7 +2327,7 @@ LightFace_SurfaceLight(const mbsp_t *bsp, const lightsurf_t *lightsurf, lightmap
|
|||
raystream_occlusion_t *rs = lightsurf->occlusion_stream;
|
||||
|
||||
for (int c = 0; c < vpl.points.size(); c++) {
|
||||
if (VisCullEntity(bsp, lightsurf->pvs, vpl.leaves[c])) {
|
||||
if (options.visapprox.value() == visapprox_t::VIS && VisCullEntity(bsp, lightsurf->pvs, vpl.leaves[c])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,9 +119,14 @@ static void MakeSurfaceLightsThread(const mbsp_t *bsp, const settings::worldspaw
|
|||
l.omnidirectional = true;//(info->flags.native & Q2_SURF_SKY) ? true : false;
|
||||
l.points = points;
|
||||
|
||||
if (options.visapprox.value() == visapprox_t::VIS) {
|
||||
for (auto &pt : points) {
|
||||
// Init bbox...
|
||||
l.bounds = EstimateVisibleBoundsAtPoint(facemidpoint);
|
||||
|
||||
for (auto &pt : points) {
|
||||
if (options.visapprox.value() == visapprox_t::VIS) {
|
||||
l.leaves.push_back(Light_PointInLeaf(bsp, pt + l.surfnormal));
|
||||
} else if (options.visapprox.value() == visapprox_t::RAYS) {
|
||||
l.bounds += EstimateVisibleBoundsAtPoint(pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -132,13 +137,6 @@ static void MakeSurfaceLightsThread(const mbsp_t *bsp, const settings::worldspaw
|
|||
l.intensity = l.totalintensity / points.size();
|
||||
l.color = texturecolor;
|
||||
|
||||
// Init bbox...
|
||||
l.bounds = qvec3d(0);
|
||||
|
||||
if (options.visapprox.value() == visapprox_t::RAYS) {
|
||||
l.bounds = EstimateVisibleBoundsAtPoint(facemidpoint);
|
||||
}
|
||||
|
||||
// Store light...
|
||||
unique_lock<mutex> lck{surfacelights_lock};
|
||||
surfacelights.push_back(l);
|
||||
|
|
|
|||
Loading…
Reference in New Issue