move "points" instead of copying
pre-offset points remove double calculation for pos/dir in lightface (didn't seem to have any visual effect on the output)
This commit is contained in:
parent
022676fe63
commit
cc16b886a4
|
|
@ -430,7 +430,7 @@ public:
|
|||
setting_extra extra{
|
||||
this, {"extra", "extra4"}, 1, &performance_group, "supersampling; 2x2 (extra) or 4x4 (extra4) respectively"};
|
||||
setting_enum<visapprox_t> visapprox{
|
||||
this, "visapprox", visapprox_t::AUTO, { { "auto", visapprox_t::AUTO }, { "none", visapprox_t::NONE }, { "vis", visapprox_t::VIS }, { "rays", visapprox_t::RAYS } }, &debug_group, "change approximate visibility algorithm. auto = choose default based on format. vis = use BSP vis data. rays = use sphere culling with fired rays"};
|
||||
this, "visapprox", visapprox_t::AUTO, { { "auto", visapprox_t::AUTO }, { "none", visapprox_t::NONE }, { "vis", visapprox_t::VIS }, { "rays", visapprox_t::RAYS } }, &debug_group, "change approximate visibility algorithm. auto = choose default based on format. vis = use BSP vis data (slow but precise). rays = use sphere culling with fired rays (fast but may miss faces)"};
|
||||
setting_func lit{this, "lit", [&]() { write_litfile |= lightfile::external; }, &output_group, "write .lit file"};
|
||||
setting_func lit2{
|
||||
this, "lit2", [&]() { write_litfile = lightfile::lit2; }, &experimental_group, "write .lit2 file"};
|
||||
|
|
|
|||
|
|
@ -1209,11 +1209,7 @@ int light_main(int argc, const char **argv)
|
|||
|
||||
// check vis approx type
|
||||
if (options.visapprox.value() == visapprox_t::AUTO) {
|
||||
if (bspdata.loadversion->game->id == GAME_QUAKE_II) {
|
||||
options.visapprox.setValue(visapprox_t::VIS);
|
||||
} else {
|
||||
options.visapprox.setValue(visapprox_t::RAYS);
|
||||
}
|
||||
options.visapprox.setValue(visapprox_t::RAYS);
|
||||
}
|
||||
|
||||
load_textures(&bsp);
|
||||
|
|
|
|||
|
|
@ -2106,8 +2106,7 @@ LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t
|
|||
const qvec3d &lightsurf_pos = lightsurf->points[i];
|
||||
const qvec3d &lightsurf_normal = lightsurf->normals[i];
|
||||
|
||||
// Push 1 unit behind the surflight (fixes darkening near surflight face on neighbouring faces)
|
||||
qvec3f pos = vpl.points[c] - vpl.surfnormal;
|
||||
qvec3f pos = vpl.points[c];
|
||||
qvec3f dir = lightsurf_pos - pos;
|
||||
float dist = qv::length(dir);
|
||||
|
||||
|
|
@ -2120,16 +2119,6 @@ LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t
|
|||
if (LightSample_Brightness(indirect) < 0.01f) // Each point contributes very little to the final result
|
||||
continue;
|
||||
|
||||
// Push 1 unit in front of the surflight, so embree can properly process it ...
|
||||
pos = vpl.points[c] + vpl.surfnormal;
|
||||
dir = lightsurf_pos - pos;
|
||||
dist = qv::length(dir);
|
||||
|
||||
if (dist == 0.0f)
|
||||
dir = lightsurf_normal;
|
||||
else
|
||||
dir /= dist;
|
||||
|
||||
rs.pushRay(i, pos, dir, dist, &indirect);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys
|
|||
|
||||
// Dice winding...
|
||||
vector<qvec3f> points;
|
||||
winding.dice(cfg.surflightsubdivision.value(), [&points](winding_t &w) { points.push_back(w.center()); });
|
||||
winding.dice(cfg.surflightsubdivision.value(), [&points, &facenormal](winding_t &w) { points.push_back(w.center() + facenormal); });
|
||||
total_surflight_points += points.size();
|
||||
|
||||
// Calculate emit color and intensity...
|
||||
|
|
@ -107,7 +107,7 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys
|
|||
surfacelight_t l;
|
||||
l.surfnormal = facenormal;
|
||||
l.omnidirectional = !is_directional;
|
||||
l.points = points;
|
||||
l.points = std::move(points);
|
||||
l.style = style;
|
||||
|
||||
// Init bbox...
|
||||
|
|
@ -115,11 +115,11 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys
|
|||
l.bounds = EstimateVisibleBoundsAtPoint(facemidpoint);
|
||||
}
|
||||
|
||||
for (auto &pt : points) {
|
||||
for (auto &pt : l.points) {
|
||||
if (options.visapprox.value() == visapprox_t::VIS) {
|
||||
l.leaves.push_back(Light_PointInLeaf(bsp, pt + l.surfnormal));
|
||||
l.leaves.push_back(Light_PointInLeaf(bsp, pt));
|
||||
} else if (options.visapprox.value() == visapprox_t::RAYS) {
|
||||
l.bounds += EstimateVisibleBoundsAtPoint(pt + l.surfnormal);
|
||||
l.bounds += EstimateVisibleBoundsAtPoint(pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys
|
|||
|
||||
// Store surfacelight settings...
|
||||
l.totalintensity = intensity * facearea;
|
||||
l.intensity = l.totalintensity / points.size();
|
||||
l.intensity = l.totalintensity / l.points.size();
|
||||
l.color = texture_color.value();
|
||||
|
||||
// Store light...
|
||||
|
|
|
|||
Loading…
Reference in New Issue